• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kdeui

kcommand.h

Go to the documentation of this file.
00001 /* This file is part of the KDE project
00002    Copyright (C) 2000 Werner Trobin <trobin@kde.org>
00003    Copyright (C) 2000 David Faure <faure@kde.org>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018    Boston, MA 02110-1301, USA.
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 <kdelibs_export.h>
00028 
00029 class KAction;
00030 class KActionCollection;
00031 class QPopupMenu;
00032 
00037 class KDEUI_EXPORT 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 
00078 class KDEUI_EXPORT KNamedCommand : public KCommand
00079 {
00080 protected:
00086     KNamedCommand(const QString &name) : KCommand(), m_name(name) {}
00087 
00088 public:
00092     virtual QString name() const { return m_name; }
00097     void setName(const QString &name) { m_name=name; }
00098 
00099 private:
00100     QString m_name;
00101 protected:
00102     virtual void virtual_hook( int id, void* data );
00103 };
00104 
00110 class KDEUI_EXPORT KMacroCommand : public KNamedCommand
00111 {
00112 public:
00119     KMacroCommand( const QString & name );
00120     virtual ~KMacroCommand() {}
00121 
00126     void addCommand(KCommand *command);
00127 
00132     virtual void execute();
00137     virtual void unexecute();
00138 
00139 protected:
00140     QPtrList<KCommand> m_commands;
00141 protected:
00142     virtual void virtual_hook( int id, void* data );
00143 };
00144 
00145 
00156 class KDEUI_EXPORT KCommandHistory : public QObject {
00157     Q_OBJECT
00158 public:
00164     KCommandHistory();
00165 
00174     KCommandHistory(KActionCollection *actionCollection, bool withMenus = true);
00175 
00179     virtual ~KCommandHistory();
00180 
00186     void clear();
00187 
00195     void addCommand(KCommand *command, bool execute=true);
00196 
00200     int undoLimit() const { return m_undoLimit; }
00204     void setUndoLimit(int limit);
00208     int redoLimit() const { return m_redoLimit; }
00212     void setRedoLimit(int limit);
00213 
00220     void updateActions();
00221 
00222 public slots:
00227     virtual void undo();
00232     virtual void redo();
00241     virtual void documentSaved();
00242 
00243 protected slots:
00244     void slotUndoAboutToShow();
00245     void slotUndoActivated( int );
00246     void slotRedoAboutToShow();
00247     void slotRedoActivated( int );
00248 
00249 signals:
00257     void commandExecuted();
00258 
00266     void commandExecuted(KCommand *command);
00267 
00272     void documentRestored();
00273 
00274 private:
00275     void clipCommands();  // ensures that the limits are kept
00276 
00277     QPtrList<KCommand> m_commands;
00278     KAction *m_undo, *m_redo;
00279     QPopupMenu *m_undoPopup, *m_redoPopup;
00280     int m_undoLimit, m_redoLimit;
00281     bool m_first;  // attention: it's the first command in the list!
00282 protected:
00283     virtual void virtual_hook( int id, void* data );
00284 private:
00285     class KCommandHistoryPrivate;
00286     KCommandHistoryPrivate *d;
00287 };
00288 
00289 #endif

kdeui

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

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal