lib

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., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, 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 #include <koffice_export.h>
00028 
00029 class KAction;
00030 class KActionCollection;
00031 class QPopupMenu;
00032 class KCommand;
00033 #include <qlistbox.h>
00034 
00035 class KoListBox : public QListBox {
00036     Q_OBJECT
00037 public:
00038     KoListBox( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
00039 protected:
00040     virtual void contentsMouseMoveEvent ( QMouseEvent * );
00041     virtual QSize sizeHint() const;
00042 signals:
00043     void changeNumberOfSelectedItem( int );
00044 };
00045 
00058 class KOFFICEUI_EXPORT KoCommandHistory : public QObject {
00059     Q_OBJECT
00060 public:
00066     KoCommandHistory();
00067 
00077     KoCommandHistory(KActionCollection *actionCollection, bool withMenus = true);
00078 
00082     virtual ~KoCommandHistory();
00083 
00089     void clear();
00090 
00099     void addCommand(KCommand *command, bool execute=true);
00100 
00104     int undoLimit() const { return m_undoLimit; }
00108     void setUndoLimit(int limit);
00112     int redoLimit() const { return m_redoLimit; }
00116     void setRedoLimit(int limit);
00117 
00124     void updateActions();
00125 
00129     KCommand * presentCommand();
00130 
00131 public slots:
00136     virtual void undo();
00141     virtual void redo();
00150     virtual void documentSaved();
00151 
00152 protected slots:
00153     void slotUndoAboutToShow();
00154     void slotUndoActivated( int );
00155     void slotRedoAboutToShow();
00156     void slotRedoActivated( int );
00157     void slotUndoActivated( QListBoxItem *);
00158     void slotRedoActivated( QListBoxItem *);
00159     void slotChangeRedoNumberOfSelectedItem( int );
00160     void slotChangeUndoNumberOfSelectedItem( int );
00161 signals:
00167     void commandExecuted();
00168 
00175     void commandExecuted(KCommand *cmd);
00176 
00181     void documentRestored();
00182 
00183 private:
00184     void clipCommands();  // ensures that the limits are kept
00185 
00186     QPtrList<KCommand> m_commands;
00187     KAction *m_undo, *m_redo;
00188     QPopupMenu *m_undoPopup, *m_redoPopup;
00189     int m_undoLimit, m_redoLimit;
00190     bool m_first;  // attention: it's the first command in the list!
00191 protected:
00192     virtual void virtual_hook( int id, void* data );
00193 private:
00194     class KoCommandHistoryPrivate;
00195     KoCommandHistoryPrivate *d;
00196 };
00197 
00198 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys