lib Library API Documentation

kocommandhistory.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 kocommandhistory_h
00022 #define kocommandhistory_h
00023 
00024 #include <qptrlist.h>
00025 #include <qstring.h>
00026 #include <qobject.h>
00027 #include <koffice_export.h>
00028 
00029 class KAction;
00030 class KActionCollection;
00031 class QPopupMenu;
00032 class KCommand;
00033 #include <qlistbox.h>
00034 
00035 class KoListBox : public QListBox {
00036     Q_OBJECT
00037 public:
00038     KoListBox( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
00039 protected:
00040     virtual void contentsMouseMoveEvent ( QMouseEvent * );
00041 signals:
00042     void changeNumberOfSelectedItem( int );
00043 };
00044 
00057 class KOFFICEUI_EXPORT KoCommandHistory : public QObject {
00058     Q_OBJECT
00059 public:
00065     KoCommandHistory();
00066 
00075     KoCommandHistory(KActionCollection *actionCollection, bool withMenus = true);
00076 
00080     virtual ~KoCommandHistory();
00081 
00087     void clear();
00088 
00097     void addCommand(KCommand *command, bool execute=true);
00098 
00102     int undoLimit() const { return m_undoLimit; }
00106     void setUndoLimit(int limit);
00110     int redoLimit() const { return m_redoLimit; }
00114     void setRedoLimit(int limit);
00115 
00122     void updateActions();
00123 
00124 public slots:
00129     virtual void undo();
00134     virtual void redo();
00143     virtual void documentSaved();
00144 
00145 protected slots:
00146     void slotUndoAboutToShow();
00147     void slotUndoActivated( int );
00148     void slotRedoAboutToShow();
00149     void slotRedoActivated( int );
00150     void slotUndoActivated( QListBoxItem *);
00151     void slotRedoActivated( QListBoxItem *);
00152     void slotChangeRedoNumberOfSelectedItem( int );
00153     void slotChangeUndoNumberOfSelectedItem( int );
00154 signals:
00160     void commandExecuted();
00165     void documentRestored();
00166 
00167 private:
00168     void clipCommands();  // ensures that the limits are kept
00169 
00170     QPtrList<KCommand> m_commands;
00171     KAction *m_undo, *m_redo;
00172     QPopupMenu *m_undoPopup, *m_redoPopup;
00173     int m_undoLimit, m_redoLimit;
00174     bool m_first;  // attention: it's the first command in the list!
00175 protected:
00176     virtual void virtual_hook( int id, void* data );
00177 private:
00178     class KoCommandHistoryPrivate;
00179     KoCommandHistoryPrivate *d;
00180 };
00181 
00182 #endif
KDE Logo
This file is part of the documentation for lib Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:39:59 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003