KoCommandHistory.h
1/* This file is part of the KDE project
2 Copyright (C) 2000 Werner Trobin <trobin@kde.org>
3 Copyright (C) 2000 David Faure <faure@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#ifndef kocommandhistory_h
22#define kocommandhistory_h
23
24#include <tqptrlist.h>
25#include <tqstring.h>
26#include <tqobject.h>
27#include <koffice_export.h>
28
29class TDEAction;
31class TQPopupMenu;
32class KCommand;
33#include <tqlistbox.h>
34
35class KoListBox : public TQListBox {
36 TQ_OBJECT
37
38public:
39 KoListBox( TQWidget *parent = 0, const char *name = 0, WFlags f = 0 );
40protected:
41 virtual void contentsMouseMoveEvent ( TQMouseEvent * );
42 virtual TQSize sizeHint() const;
43signals:
44 void changeNumberOfSelectedItem( int );
45};
46
59class KOFFICEUI_EXPORT KoCommandHistory : public TQObject {
60 TQ_OBJECT
61
62public:
69
79 KoCommandHistory(TDEActionCollection *actionCollection, bool withMenus = true);
80
84 virtual ~KoCommandHistory();
85
91 void clear();
92
101 void addCommand(KCommand *command, bool execute=true);
102
106 int undoLimit() const { return m_undoLimit; }
110 void setUndoLimit(int limit);
114 int redoLimit() const { return m_redoLimit; }
118 void setRedoLimit(int limit);
119
126 void updateActions();
127
131 KCommand * presentCommand();
132
133public slots:
138 virtual void undo();
143 virtual void redo();
152 virtual void documentSaved();
153
154protected slots:
155 void slotUndoAboutToShow();
156 void slotUndoActivated( int );
157 void slotRedoAboutToShow();
158 void slotRedoActivated( int );
159 void slotUndoActivated( TQListBoxItem *);
160 void slotRedoActivated( TQListBoxItem *);
161 void slotChangeRedoNumberOfSelectedItem( int );
162 void slotChangeUndoNumberOfSelectedItem( int );
163signals:
170
178
184
185private:
186 void clipCommands(); // ensures that the limits are kept
187
188 TQPtrList<KCommand> m_commands;
189 TDEAction *m_undo, *m_redo;
190 TQPopupMenu *m_undoPopup, *m_redoPopup;
191 int m_undoLimit, m_redoLimit;
192 bool m_first; // attention: it's the first command in the list!
193protected:
194 virtual void virtual_hook( int id, void* data );
195private:
196 class KoCommandHistoryPrivate;
197 KoCommandHistoryPrivate *d;
198};
199
200#endif
The command history stores a (user) configurable amount of Commands.
void commandExecuted()
Emitted every time a command is executed (whether by addCommand, undo or redo).
void documentRestored()
Emitted every time we reach the index where you saved the document for the last time.
void commandExecuted(KCommand *cmd)
Emitted every time a command is executed (whether by addCommand, undo or redo).