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

KDE3Support

  • sources
  • kde-4.14
  • kdelibs
  • 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 
30 class KAction;
31 class KActionCollection;
32 class QAction;
33 
41 class KDE3SUPPORT_EXPORT K3Command
42 {
43 protected:
47  K3Command();
48 
49 public:
50  virtual ~K3Command();
51 
57  virtual void execute() = 0;
66  virtual void unexecute() = 0;
67 
72  virtual QString name() const = 0;
73 protected:
74  virtual void virtual_hook( int id, void* data );
75 private:
76  class Private;
77  Private* const d;
78  Q_DISABLE_COPY( K3Command )
79 };
80 
89 class KDE3SUPPORT_EXPORT K3NamedCommand : public K3Command
90 {
91 protected:
97  K3NamedCommand( const QString &name );
98 
99 public:
103  virtual QString name() const;
108  void setName( const QString &name );
109 
110  virtual ~K3NamedCommand();
111 
112 protected:
113  virtual void virtual_hook( int id, void* data );
114 
115 private:
116  class Private;
117  Private* const d;
118  Q_DISABLE_COPY( K3NamedCommand )
119 };
120 
126 class KDE3SUPPORT_EXPORT K3MacroCommand : public K3NamedCommand
127 {
128 public:
135  K3MacroCommand( const QString & name );
136  virtual ~K3MacroCommand();
137 
142  void addCommand(K3Command *command);
143 
148  virtual void execute();
153  virtual void unexecute();
154 
155 protected:
156  const QList<K3Command *> commands() const;
157 
158  virtual void virtual_hook( int id, void* data );
159 
160 private:
161  class Private;
162  Private* const d;
163  Q_DISABLE_COPY( K3MacroCommand )
164 };
165 
166 
180 class KDE3SUPPORT_EXPORT K3CommandHistory : public QObject {
181  Q_OBJECT
182 public:
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 
287 public Q_SLOTS:
292  virtual void undo();
297  virtual void redo();
306  virtual void documentSaved();
307 
308 Q_SIGNALS:
315  void commandExecuted(K3Command *command);
316 
321  void documentRestored();
322 
328  void commandHistoryChanged();
329 
330 private:
331  void clipCommands(); // ensures that the limits are kept
332 
333 private:
334  class K3CommandHistoryPrivate;
335  K3CommandHistoryPrivate * const d;
336  Q_DISABLE_COPY( K3CommandHistory )
337 };
338 
339 #include <ktoolbarpopupaction.h>
340 
357 class K3UndoRedoAction : public KToolBarPopupAction
358 {
359  Q_OBJECT
360 public:
361  enum Type { Undo, Redo };
362  K3UndoRedoAction( Type type, KActionCollection* actionCollection, K3CommandHistory* commandHistory );
363 
364 private Q_SLOTS:
365  void slotAboutToShow();
366  void slotActionTriggered( QAction *action );
367  void slotCommandHistoryChanged();
368 
369 private:
370  class Private;
371  Private* const d;
372  Q_DISABLE_COPY( K3UndoRedoAction )
373 };
374 
375 #endif
KActionCollection
K3NamedCommand::virtual_hook
virtual void virtual_hook(int id, void *data)
Definition: k3command.cpp:439
K3Command::virtual_hook
virtual void virtual_hook(int id, void *data)
Definition: k3command.cpp:436
K3UndoRedoAction
This type of action is used to show undo or redo actions in the menu or in the toolbars.
Definition: k3command.h:357
Type
Type
undo
KAction * undo(const QObject *recvr, const char *slot, QObject *parent)
K3Command
The abstract base class for all Commands.
Definition: k3command.h:41
K3UndoRedoAction::K3UndoRedoAction
K3UndoRedoAction(Type type, KActionCollection *actionCollection, K3CommandHistory *commandHistory)
Definition: k3command.cpp:360
name
const char * name(StandardAction id)
kde3support_export.h
QObject
K3Command::name
virtual QString name() const =0
clear
KAction * clear(const QObject *recvr, const char *slot, QObject *parent)
K3Command::unexecute
virtual void unexecute()=0
Unexecutes (undo) this command.
redo
KAction * redo(const QObject *recvr, const char *slot, QObject *parent)
QString
QList< K3Command * >
K3NamedCommand
A command which stores its name.
Definition: k3command.h:89
K3Command::execute
virtual void execute()=0
The main method: executes this command.
QAction
KAction
K3UndoRedoAction::Redo
Definition: k3command.h:361
K3UndoRedoAction::Type
Type
Definition: k3command.h:361
KToolBarPopupAction
ktoolbarpopupaction.h
K3MacroCommand
A Macro Command is a command that holds several sub-commands.
Definition: k3command.h:126
K3UndoRedoAction::Undo
Definition: k3command.h:361
K3CommandHistory
The command history stores a (user) configurable amount of Commands.
Definition: k3command.h:180
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:26:47 by doxygen 1.8.7 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 API Reference

Skip menu "kdelibs 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

Search



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