• 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::documentSaved
virtual void documentSaved()
Remembers when you saved the document.
Definition k3command.cpp:248
K3CommandHistory::commandHistoryChanged
void commandHistoryChanged()
Emitted whenever the command history has changed, i.e.
K3CommandHistory::presentCommand
K3Command * presentCommand() const
Definition k3command.cpp:212
K3CommandHistory::documentRestored
void documentRestored()
Emitted every time we reach the index where you saved the document for the last time.
K3CommandHistory::redo
virtual void redo()
Redoes the last undone action.
Definition k3command.cpp:235
K3CommandHistory::clear
void clear()
Erases all the undo/redo history.
Definition k3command.cpp:180
K3CommandHistory::isUndoAvailable
bool isUndoAvailable() const
Definition k3command.cpp:302
K3CommandHistory::K3CommandHistory
K3CommandHistory()
Creates a command history, to store commands.
Definition k3command.cpp:149
K3CommandHistory::undo
virtual void undo()
Undoes the last action.
Definition k3command.cpp:219
K3CommandHistory::undoCommands
QList< K3Command * > undoCommands(int maxCommands=0) const
Definition k3command.cpp:312
K3CommandHistory::isRedoAvailable
bool isRedoAvailable() const
Definition k3command.cpp:307
K3CommandHistory::redoLimit
int redoLimit() const
Definition k3command.cpp:340
K3CommandHistory::updateActions
void updateActions()
Enable or disable the undo and redo actions.
Definition k3command.cpp:296
K3CommandHistory::undoLimit
int undoLimit() const
Definition k3command.cpp:335
K3CommandHistory::redoCommands
QList< K3Command * > redoCommands(int maxCommands=0) const
Definition k3command.cpp:323
K3CommandHistory::addCommand
void addCommand(K3Command *command, bool execute=true)
Adds a command to the history.
Definition k3command.cpp:188
K3CommandHistory::setRedoLimit
void setRedoLimit(int limit)
Sets the maximum number of items in the redo history.
Definition k3command.cpp:259
K3CommandHistory::commandExecuted
void commandExecuted(K3Command *command)
Emitted every time a command is executed (whether by addCommand, undo or redo).
K3CommandHistory::setUndoLimit
void setUndoLimit(int limit)
Sets the maximum number of items in the undo history.
Definition k3command.cpp:252
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::K3Command
K3Command()
Creates a command.
Definition k3command.cpp:33
K3Command::unexecute
virtual void unexecute()=0
Unexecutes (undo) this command.
K3Command::name
virtual QString name() const =0
K3Command::virtual_hook
virtual void virtual_hook(int id, void *data)
Definition k3command.cpp:436
K3MacroCommand::K3MacroCommand
K3MacroCommand(const QString &name)
Creates a macro command.
Definition k3command.cpp:76
K3MacroCommand::commands
const QList< K3Command * > commands() const
Definition k3command.cpp:110
K3MacroCommand::execute
virtual void execute()
Executes this command, i.e.
Definition k3command.cpp:93
K3MacroCommand::addCommand
void addCommand(K3Command *command)
Appends a command to this macro command.
Definition k3command.cpp:88
K3MacroCommand::virtual_hook
virtual void virtual_hook(int id, void *data)
Definition k3command.cpp:442
K3MacroCommand::unexecute
virtual void unexecute()
Undoes the execution of this command, i.e.
Definition k3command.cpp:101
K3NamedCommand::virtual_hook
virtual void virtual_hook(int id, void *data)
Definition k3command.cpp:439
K3NamedCommand::K3NamedCommand
K3NamedCommand(const QString &name)
Creates a command.
Definition k3command.cpp:48
K3NamedCommand::setName
void setName(const QString &name)
Updates the name of this command.
Definition k3command.cpp:65
K3NamedCommand::name
virtual QString name() const
Definition k3command.cpp:60
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::K3UndoRedoAction
K3UndoRedoAction(Type type, KActionCollection *actionCollection, K3CommandHistory *commandHistory)
Definition k3command.cpp:360
K3UndoRedoAction::Type
Type
Definition k3command.h:361
K3UndoRedoAction::Redo
@ Redo
Definition k3command.h:361
K3UndoRedoAction::Undo
@ Undo
Definition k3command.h:361
KActionCollection
KAction
KToolBarPopupAction::KToolBarPopupAction
KToolBarPopupAction(const KIcon &icon, const QString &text, QObject *parent)
QAction
QList
QObject
kde3support_export.h
ktoolbarpopupaction.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Tue Mar 25 2025 00:00:00 by doxygen 1.14.0 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