kcommand.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#ifndef kcommand_h
00022
#define kcommand_h
00023
00024
#include <qptrlist.h>
00025
#include <qstring.h>
00026
#include <qobject.h>
00027
#include <kdemacros.h>
00028
00029
class KAction;
00030
class KActionCollection;
00031
class QPopupMenu;
00032
00037 class KCommand
00038 {
00039
protected:
00043 KCommand() {}
00044
00045
public:
00046
virtual ~
KCommand();
00047
00053
virtual void execute() = 0;
00062
virtual void unexecute() = 0;
00063
00068
virtual QString name() const = 0;
00069 protected:
00070 virtual
void virtual_hook(
int id,
void* data );
00071 };
00072
00078 class
KNamedCommand : public
KCommand
00079 {
00080
protected:
00086 KNamedCommand(
const QString &name) : KCommand(), m_name(name) {}
00087
00088
public:
00092 virtual QString name()
const {
return m_name; }
00097 void setName(
const QString &name) { m_name=name; }
00098
00099
private:
00100
QString m_name;
00101
protected:
00102
virtual void virtual_hook(
int id,
void* data );
00103 };
00104
00110 class KMacroCommand :
public KNamedCommand
00111 {
00112
public:
00119
KMacroCommand(
const QString & name );
00120
virtual ~
KMacroCommand() {}
00121
00126
void addCommand(
KCommand *command);
00127
00132
virtual void execute();
00137
virtual void unexecute();
00138
00139
protected:
00140
QPtrList<KCommand> m_commands;
00141
protected:
00142
virtual void virtual_hook(
int id,
void* data );
00143 };
00144
00145
00156 class KCommandHistory :
public QObject {
00157 Q_OBJECT
00158
public:
00164
KCommandHistory();
00165
00174
KCommandHistory(
KActionCollection *actionCollection,
bool withMenus =
true);
00175
00179
virtual ~
KCommandHistory();
00180
00186
void clear();
00187
00195
void addCommand(
KCommand *command,
bool execute=
true);
00196
00200 int undoLimit()
const {
return m_undoLimit; }
00204
void setUndoLimit(
int limit);
00208 int redoLimit()
const {
return m_redoLimit; }
00212
void setRedoLimit(
int limit);
00213
00220
void updateActions();
00221
00222
public slots:
00227
virtual void undo();
00232
virtual void redo();
00241
virtual void documentSaved();
00242
00243
protected slots:
00244
void slotUndoAboutToShow();
00245
void slotUndoActivated(
int );
00246
void slotRedoAboutToShow();
00247
void slotRedoActivated(
int );
00248
00249 signals:
00255
void commandExecuted();
00260
void documentRestored();
00261
00262
private:
00263
void clipCommands();
00264
00265
QPtrList<KCommand> m_commands;
00266
KAction *m_undo, *m_redo;
00267
QPopupMenu *m_undoPopup, *m_redoPopup;
00268
int m_undoLimit, m_redoLimit;
00269
bool m_first;
00270
protected:
00271
virtual void virtual_hook(
int id,
void* data );
00272
private:
00273
class KCommandHistoryPrivate;
00274 KCommandHistoryPrivate *d;
00275 };
00276
00277
#endif
This file is part of the documentation for kdeui Library Version 3.3.1.