Skip to content
Skip to link menu
Trinity API Reference
Trinity API Reference
tdeui
tdeui
tdeui
kcommand.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 kcommand_h
22
#define kcommand_h
23
24
#include <tqptrlist.h>
25
#include <tqstring.h>
26
#include <tqobject.h>
27
#include <tdelibs_export.h>
28
29
class
TDEAction
;
30
class
TDEActionCollection
;
31
class
TQPopupMenu;
32
37
class
TDEUI_EXPORT
KCommand
38
{
39
protected
:
43
KCommand
() {}
44
45
public
:
46
virtual
~
KCommand
();
47
53
virtual
void
execute() = 0;
62
virtual
void
unexecute() = 0;
63
68
virtual
TQString name()
const
= 0;
69
protected
:
70
virtual
void
virtual_hook(
int
id
,
void
* data );
71
};
72
78
class
TDEUI_EXPORT
KNamedCommand
:
public
KCommand
79
{
80
protected
:
86
KNamedCommand
(
const
TQString &name) :
KCommand
(), m_name(name) {}
87
88
public
:
92
virtual
TQString
name
()
const
{
return
m_name; }
97
void
setName
(
const
TQString &name) { m_name=
name
; }
98
99
private
:
100
TQString m_name;
101
protected
:
102
virtual
void
virtual_hook(
int
id
,
void
* data );
103
};
104
110
class
TDEUI_EXPORT
KMacroCommand
:
public
KNamedCommand
111
{
112
public
:
119
KMacroCommand
(
const
TQString & name );
120
virtual
~
KMacroCommand
() {}
121
126
void
addCommand(
KCommand
*command);
127
132
virtual
void
execute
();
137
virtual
void
unexecute
();
138
139
protected
:
140
TQPtrList<KCommand> m_commands;
141
protected
:
142
virtual
void
virtual_hook(
int
id
,
void
* data );
143
};
144
145
156
class
TDEUI_EXPORT
KCommandHistory
:
public
TQObject {
157
Q_OBJECT
158
public
:
164
KCommandHistory
();
165
174
KCommandHistory
(
TDEActionCollection
*actionCollection,
bool
withMenus =
true
);
175
179
virtual
~
KCommandHistory
();
180
186
void
clear();
187
195
void
addCommand(
KCommand
*command,
bool
execute=
true
);
196
200
int
undoLimit
()
const
{
return
m_undoLimit; }
204
void
setUndoLimit(
int
limit);
208
int
redoLimit
()
const
{
return
m_redoLimit; }
212
void
setRedoLimit(
int
limit);
213
220
void
updateActions();
221
222
public
slots:
227
virtual
void
undo();
232
virtual
void
redo();
241
virtual
void
documentSaved();
242
243
protected
slots:
244
void
slotUndoAboutToShow();
245
void
slotUndoActivated(
int
);
246
void
slotRedoAboutToShow();
247
void
slotRedoActivated(
int
);
248
249
signals:
257
void
commandExecuted();
258
266
void
commandExecuted(
KCommand
*command);
267
272
void
documentRestored();
273
274
private
:
275
void
clipCommands();
// ensures that the limits are kept
276
277
TQPtrList<KCommand> m_commands;
278
TDEAction
*m_undo, *m_redo;
279
TQPopupMenu *m_undoPopup, *m_redoPopup;
280
int
m_undoLimit, m_redoLimit;
281
bool
m_first;
// attention: it's the first command in the list!
282
protected
:
283
virtual
void
virtual_hook(
int
id
,
void
* data );
284
private
:
285
class
KCommandHistoryPrivate;
286
KCommandHistoryPrivate *d;
287
};
288
289
#endif
KCommand::execute
virtual void execute()=0
The main method: executes this command.
KCommand::name
virtual TQString name() const =0
KNamedCommand::name
virtual TQString name() const
Definition:
kcommand.h:92
TDEActionCollection
A managed set of TDEAction objects.
Definition:
tdeactioncollection.h:78
TDEAction
Class to encapsulate user-driven action or event.
Definition:
tdeaction.h:202
KNamedCommand::setName
void setName(const TQString &name)
Updates the name of this command.
Definition:
kcommand.h:97
KCommand::unexecute
virtual void unexecute()=0
Unexecutes (undo) this command.
KCommandHistory::undoLimit
int undoLimit() const
Definition:
kcommand.h:200
KCommand
The abstract base class for all Commands.
Definition:
kcommand.h:37
KCommandHistory
The command history stores a (user) configurable amount of Commands.
Definition:
kcommand.h:156
KCommand::KCommand
KCommand()
Creates a command.
Definition:
kcommand.h:43
KCommandHistory::redoLimit
int redoLimit() const
Definition:
kcommand.h:208
KNamedCommand
A command which stores its name.
Definition:
kcommand.h:78
KNamedCommand::KNamedCommand
KNamedCommand(const TQString &name)
Creates a command.
Definition:
kcommand.h:86
KMacroCommand
A Macro Command is a command that holds several sub-commands.
Definition:
kcommand.h:110
tdeui
Skip menu "tdeui"
Main Page
Namespace List
Class Hierarchy
Alphabetical List
Class List
File List
Namespace Members
Class Members
Related Pages
tdeui
Skip menu "tdeui"
arts
dcop
dnssd
interfaces
kspeech
interface
library
tdetexteditor
kate
kded
kdoctools
kimgio
kjs
libtdemid
libtdescreensaver
tdecore
tdeabc
tdecmshell
tdecore
tdefx
tdehtml
tdeinit
tdeio
bookmarks
httpfilter
kpasswdserver
kssl
tdeioslave
http
tdefile
tdeio
tdeioexec
tdemdi
tdemdi
tdenewstuff
tdeparts
tdeprint
tderandr
tderesources
tdespell2
tdesu
tdeui
tdeunittest
tdeutils
tdewallet