• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDE3Support

  • kde3support
  • kdeui
k3command.h
Go to the documentation of this file.
1/* This file is part of the KDE project
2 Copyright (C) 2000 Werner Trobin <trobin@kde.org>
3 Copyright (C) 2000,2006 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 <kde3support_export.h>
25
26#include <QtCore/QList>
27#include <QtCore/QString>
28#include <QtCore/QObject>
29
30class KAction;
31class KActionCollection;
32class QAction;
33
41class KDE3SUPPORT_EXPORT K3Command
42{
43protected:
47 K3Command();
48
49public:
50 virtual ~K3Command();
51
57 virtual void execute() = 0;
66 virtual void unexecute() = 0;
67
72 virtual QString name() const = 0;
73protected:
74 virtual void virtual_hook( int id, void* data );
75private:
76 class Private;
77 Private* const d;
78 Q_DISABLE_COPY( K3Command )
79};
80
89class KDE3SUPPORT_EXPORT K3NamedCommand : public K3Command
90{
91protected:
97 K3NamedCommand( const QString &name );
98
99public:
103 virtual QString name() const;
108 void setName( const QString &name );
109
110 virtual ~K3NamedCommand();
111
112protected:
113 virtual void virtual_hook( int id, void* data );
114
115private:
116 class Private;
117 Private* const d;
118 Q_DISABLE_COPY( K3NamedCommand )
119};
120
126class KDE3SUPPORT_EXPORT K3MacroCommand : public K3NamedCommand
127{
128public:
135 K3MacroCommand( const QString & name );
136 virtual ~K3MacroCommand();
137
142 void addCommand(K3Command *command);
143
148 virtual void execute();
153 virtual void unexecute();
154
155protected:
156 const QList<K3Command *> commands() const;
157
158 virtual void virtual_hook( int id, void* data );
159
160private:
161 class Private;
162 Private* const d;
163 Q_DISABLE_COPY( K3MacroCommand )
164};
165
166
180class KDE3SUPPORT_EXPORT K3CommandHistory : public QObject {
181 Q_OBJECT
182public:
188 K3CommandHistory();
189
198 K3CommandHistory(KActionCollection *actionCollection, bool withMenus = true);
199
203 virtual ~K3CommandHistory();
204
210 void clear();
211
222 void addCommand(K3Command *command, bool execute=true);
223
227 int undoLimit() const;
231 void setUndoLimit(int limit);
235 int redoLimit() const;
239 void setRedoLimit(int limit);
240
247 void updateActions();
248
253 K3Command * presentCommand() const;
254
259 bool isUndoAvailable() const;
260
265 bool isRedoAvailable() const;
266
276 QList<K3Command *> undoCommands( int maxCommands = 0 ) const;
277
285 QList<K3Command *> redoCommands( int maxCommands = 0 ) const;
286
287public Q_SLOTS:
292 virtual void undo();
297 virtual void redo();
306 virtual void documentSaved();
307
308Q_SIGNALS:
315 void commandExecuted(K3Command *command);
316
321 void documentRestored();
322
328 void commandHistoryChanged();
329
330private:
331 void clipCommands(); // ensures that the limits are kept
332
333private:
334 class K3CommandHistoryPrivate;
335 K3CommandHistoryPrivate * const d;
336 Q_DISABLE_COPY( K3CommandHistory )
337};
338
339#include <ktoolbarpopupaction.h>
340
357class K3UndoRedoAction : public KToolBarPopupAction
358{
359 Q_OBJECT
360public:
361 enum Type { Undo, Redo };
362 K3UndoRedoAction( Type type, KActionCollection* actionCollection, K3CommandHistory* commandHistory );
363
364private Q_SLOTS:
365 void slotAboutToShow();
366 void slotActionTriggered( QAction *action );
367 void slotCommandHistoryChanged();
368
369private:
370 class Private;
371 Private* const d;
372 Q_DISABLE_COPY( K3UndoRedoAction )
373};
374
375#endif
K3CommandHistory
The command history stores a (user) configurable amount of Commands.
Definition: k3command.h:180
K3CommandHistory::commandHistoryChanged
void commandHistoryChanged()
Emitted whenever the command history has changed, i.e.
K3CommandHistory::documentRestored
void documentRestored()
Emitted every time we reach the index where you saved the document for the last time.
K3CommandHistory::commandExecuted
void commandExecuted(K3Command *command)
Emitted every time a command is executed (whether by addCommand, undo or redo).
K3Command
The abstract base class for all Commands.
Definition: k3command.h:42
K3Command::execute
virtual void execute()=0
The main method: executes this command.
K3Command::unexecute
virtual void unexecute()=0
Unexecutes (undo) this command.
K3Command::name
virtual QString name() const =0
K3MacroCommand
A Macro Command is a command that holds several sub-commands.
Definition: k3command.h:127
K3NamedCommand
A command which stores its name.
Definition: k3command.h:90
K3UndoRedoAction
This type of action is used to show undo or redo actions in the menu or in the toolbars.
Definition: k3command.h:358
K3UndoRedoAction::Type
Type
Definition: k3command.h:361
K3UndoRedoAction::Redo
@ Redo
Definition: k3command.h:361
K3UndoRedoAction::Undo
@ Undo
Definition: k3command.h:361
KActionCollection
KAction
KToolBarPopupAction
QAction
QList
QObject
kde3support_export.h
ktoolbarpopupaction.h
Type
Type
undo
KAction * undo(const QObject *recvr, const char *slot, QObject *parent)
name
const char * name(StandardAction id)
clear
KAction * clear(const QObject *recvr, const char *slot, QObject *parent)
redo
KAction * redo(const QObject *recvr, const char *slot, QObject *parent)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDE3Support

Skip menu "KDE3Support"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal