lib Library API Documentation

kocommandhistory.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2000 Werner Trobin <trobin@kde.org>
00003    Copyright (C) 2000 David Faure <faure@kde.org>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018    Boston, MA 02111-1307, USA.
00019 */
00020 
00021 #ifndef kocommandhistory_h
00022 #define kocommandhistory_h
00023 
00024 #include <qptrlist.h>
00025 #include <qstring.h>
00026 #include <qobject.h>
00027 
00028 class KAction;
00029 class KActionCollection;
00030 class QPopupMenu;
00031 class KCommand;
00032 #include <qlistbox.h>
00033 
00034 class KoListBox : public QListBox {
00035     Q_OBJECT
00036 public:
00037     KoListBox( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
00038 protected:
00039     virtual void contentsMouseMoveEvent ( QMouseEvent * );
00040 signals:
00041     void changeNumberOfSelectedItem( int );
00042 };
00043 
00056 class KoCommandHistory : public QObject {
00057     Q_OBJECT
00058 public:
00064     KoCommandHistory();
00065 
00074     KoCommandHistory(KActionCollection *actionCollection, bool withMenus = true);
00075 
00079     virtual ~KoCommandHistory();
00080 
00086     void clear();
00087 
00096     void addCommand(KCommand *command, bool execute=true);
00097 
00101     int undoLimit() const { return m_undoLimit; }
00105     void setUndoLimit(int limit);
00109     int redoLimit() const { return m_redoLimit; }
00113     void setRedoLimit(int limit);
00114 
00121     void updateActions();
00122 
00123 public slots:
00128     virtual void undo();
00133     virtual void redo();
00142     virtual void documentSaved();
00143 
00144 protected slots:
00145     void slotUndoAboutToShow();
00146     void slotUndoActivated( int );
00147     void slotRedoAboutToShow();
00148     void slotRedoActivated( int );
00149     void slotUndoActivated( QListBoxItem *);
00150     void slotRedoActivated( QListBoxItem *);
00151     void slotChangeRedoNumberOfSelectedItem( int );
00152     void slotChangeUndoNumberOfSelectedItem( int );
00153 signals:
00159     void commandExecuted();
00164     void documentRestored();
00165 
00166 private:
00167     void clipCommands();  // ensures that the limits are kept
00168 
00169     QPtrList<KCommand> m_commands;
00170     KAction *m_undo, *m_redo;
00171     QPopupMenu *m_undoPopup, *m_redoPopup;
00172     int m_undoLimit, m_redoLimit;
00173     bool m_first;  // attention: it's the first command in the list!
00174 protected:
00175     virtual void virtual_hook( int id, void* data );
00176 private:
00177     class KoCommandHistoryPrivate;
00178     KoCommandHistoryPrivate *d;
00179 };
00180 
00181 #endif
KDE Logo
This file is part of the documentation for lib Library Version 1.3.5.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Mar 11 11:47:40 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003