# kdeui Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# kcommand.h

    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., 59 Temple Place - Suite 330,
    00018    Boston, MA 02111-1307, 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
    00028 class KAction;
    00029 class KActionCollection;
    00030 class QPopupMenu;
    00031
    00036 class KCommand
    00037 {
    00038 protected:
    00042     KCommand() {}
    00043
    00044 public:
    00045     virtual ~KCommand();
    00046
    00052     virtual void execute() = 0;
    00061     virtual void unexecute() = 0;
    00062
    00067     virtual QString name() const = 0;
    00068 protected:
    00069     virtual void virtual_hook( int id, void* data );
    00070 };
    00071
    00077 class KNamedCommand : public KCommand
    00078 {
    00079 protected:
    00085     KNamedCommand(const QString &name) : KCommand(), m_name(name) {}
    00086
    00087 public:
    00091     virtual QString name() const { return m_name; }
    00096     void setName(const QString &name) { m_name=name; }
    00097
    00098 private:
    00099     QString m_name;
    00100 protected:
    00101     virtual void virtual_hook( int id, void* data );
    00102 };
    00103
    00109 class KMacroCommand : public KNamedCommand
    00110 {
    00111 public:
    00118     KMacroCommand( const QString & name );
    00119     virtual ~KMacroCommand() {}
    00120
    00125     void addCommand(KCommand *command);
    00126
    00131     virtual void execute();
    00136     virtual void unexecute();
    00137
    00138 protected:
    00139     QPtrList<KCommand> m_commands;
    00140 protected:
    00141     virtual void virtual_hook( int id, void* data );
    00142 };
    00143
    00144
    00155 class KCommandHistory : public QObject {
    00156     Q_OBJECT
    00157 public:
    00163     KCommandHistory();
    00164
    00172     KCommandHistory(KActionCollection *actionCollection, bool withMenus = true);
    00173
    00177     virtual ~KCommandHistory();
    00178
    00184     void clear();
    00185
    00193     void addCommand(KCommand *command, bool execute=true);
    00194
    00198     int undoLimit() const { return m_undoLimit; }
    00202     void setUndoLimit(int limit);
    00206     int redoLimit() const { return m_redoLimit; }
    00210     void setRedoLimit(int limit);
    00211
    00218     void updateActions();
    00219
    00220 public slots:
    00225     virtual void undo();
    00230     virtual void redo();
    00239     virtual void documentSaved();
    00240
    00241 protected slots:
    00242     void slotUndoAboutToShow();
    00243     void slotUndoActivated( int );
    00244     void slotRedoAboutToShow();
    00245     void slotRedoActivated( int );
    00246
    00247 signals:
    00253     void commandExecuted();
    00258     void documentRestored();
    00259
    00260 private:
    00261     void clipCommands();  // ensures that the limits are kept
    00262
    00263     QPtrList<KCommand> m_commands;
    00264     KAction *m_undo, *m_redo;
    00265     QPopupMenu *m_undoPopup, *m_redoPopup;
    00266     int m_undoLimit, m_redoLimit;
    00267     bool m_first;  // attention: it's the first command in the list!
    00268 protected:
    00269     virtual void virtual_hook( int id, void* data );
    00270 private:
    00271     class KCommandHistoryPrivate;
    00272     KCommandHistoryPrivate *d;
    00273 };
    00274
    00275 #endif

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 12:56:23 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001