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
00079 class KDE_DEPRECATED
KNamedCommand : public
KCommand
00080 {
00081
protected:
00087 KNamedCommand(
const QString &name) : KCommand(), m_name(name) {}
00088
00089
public:
00093 virtual QString name()
const {
return m_name; }
00098 void setName(
const QString &name) { m_name=name; }
00099
00100
private:
00101
QString m_name;
00102
protected:
00103
virtual void virtual_hook(
int id,
void* data );
00104 };
00105
00111 class KMacroCommand :
public KNamedCommand
00112 {
00113
public:
00120
KMacroCommand(
const QString & name );
00121
virtual ~
KMacroCommand() {}
00122
00127
void addCommand(
KCommand *command);
00128
00133
virtual void execute();
00138
virtual void unexecute();
00139
00140
protected:
00141
QPtrList<KCommand> m_commands;
00142
protected:
00143
virtual void virtual_hook(
int id,
void* data );
00144 };
00145
00146
00157 class KCommandHistory :
public QObject {
00158 Q_OBJECT
00159
public:
00165
KCommandHistory();
00166
00175
KCommandHistory(
KActionCollection *actionCollection,
bool withMenus =
true);
00176
00180
virtual ~
KCommandHistory();
00181
00187
void clear();
00188
00196
void addCommand(
KCommand *command,
bool execute=
true);
00197
00201 int undoLimit()
const {
return m_undoLimit; }
00205
void setUndoLimit(
int limit);
00209 int redoLimit()
const {
return m_redoLimit; }
00213
void setRedoLimit(
int limit);
00214
00221
void updateActions();
00222
00223
public slots:
00228
virtual void undo();
00233
virtual void redo();
00242
virtual void documentSaved();
00243
00244
protected slots:
00245
void slotUndoAboutToShow();
00246
void slotUndoActivated(
int );
00247
void slotRedoAboutToShow();
00248
void slotRedoActivated(
int );
00249
00250 signals:
00256
void commandExecuted();
00261
void documentRestored();
00262
00263
private:
00264
void clipCommands();
00265
00266
QPtrList<KCommand> m_commands;
00267
KAction *m_undo, *m_redo;
00268
QPopupMenu *m_undoPopup, *m_redoPopup;
00269
int m_undoLimit, m_redoLimit;
00270
bool m_first;
00271
protected:
00272
virtual void virtual_hook(
int id,
void* data );
00273
private:
00274
class KCommandHistoryPrivate;
00275 KCommandHistoryPrivate *d;
00276 };
00277
00278
#endif
This file is part of the documentation for kdeui Library Version 3.2.3.