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

KDE3Support

Public Slots | Signals | Public Member Functions | List of all members
K3CommandHistory Class Reference

#include <k3command.h>

Inheritance diagram for K3CommandHistory:
Inheritance graph
[legend]

Public Slots

virtual void documentSaved ()
 
virtual void redo ()
 
virtual void undo ()
 

Signals

void commandExecuted (K3Command *command)
 
void commandHistoryChanged ()
 
void documentRestored ()
 

Public Member Functions

 K3CommandHistory ()
 
 K3CommandHistory (KActionCollection *actionCollection, bool withMenus=true)
 
virtual ~K3CommandHistory ()
 
void addCommand (K3Command *command, bool execute=true)
 
void clear ()
 
bool isRedoAvailable () const
 
bool isUndoAvailable () const
 
K3Command * presentCommand () const
 
QList< K3Command * > redoCommands (int maxCommands=0) const
 
int redoLimit () const
 
void setRedoLimit (int limit)
 
void setUndoLimit (int limit)
 
QList< K3Command * > undoCommands (int maxCommands=0) const
 
int undoLimit () const
 
void updateActions ()
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
 QObject (QObject *parent, const char *name)
 
virtual  ~QObject ()
 
bool blockSignals (bool block)
 
QObject * child (const char *objName, const char *inheritsClass, bool recursiveSearch) const
 
const QObjectList & children () const
 
const char * className () const
 
bool connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const QObject *receiver, const char *method)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method)
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QByteArray > dynamicPropertyNames () const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
T findChild (const QString &name) const
 
QList< T > findChildren (const QRegExp &regExp) const
 
QList< T > findChildren (const QString &name) const
 
bool inherits (const char *className) const
 
void insertChild (QObject *object)
 
void installEventFilter (QObject *filterObj)
 
bool isA (const char *className) const
 
bool isWidgetType () const
 
void killTimer (int id)
 
virtual const QMetaObject * metaObject () const
 
void moveToThread (QThread *targetThread)
 
const char * name () const
 
const char * name (const char *defaultName) const
 
QString objectName () const
 
QObject * parent () const
 
QVariant property (const char *name) const
 
void removeChild (QObject *object)
 
void removeEventFilter (QObject *obj)
 
void setName (const char *name)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval)
 
QThread * thread () const
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Protected Member Functions inherited from QObject
bool checkConnectArgs (const char *signal, const QObject *object, const char *method)
 
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const char *signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const char *signal)
 
int receivers (const char *signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 
- Static Protected Member Functions inherited from QObject
QByteArray normalizeSignalSlot (const char *signalSlot)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

The command history stores a (user) configurable amount of Commands.

It keeps track of its size and deletes commands if it gets too large. The user can set a maximum undo and a maximum redo limit (e.g. max. 50 undo / 30 redo commands). The K3CommandHistory keeps track of the "borders" and deletes commands, if appropriate. It also activates/deactivates the undo/redo actions in the menu and changes the text according to the name of the command.

Note: you might want to use the QUndo framework instead. It didn't exist when K3Command was written.

Definition at line 180 of file k3command.h.

Constructor & Destructor Documentation

K3CommandHistory::K3CommandHistory ( )

Creates a command history, to store commands.

This constructor doesn't create actions, so you need to call undo and redo yourself.

Definition at line 149 of file k3command.cpp.

K3CommandHistory::K3CommandHistory ( KActionCollection *  actionCollection,
bool  withMenus = true 
)

Creates a command history, to store commands.

This also creates an undo and a redo action, in the actionCollection, using the standard names ("edit_undo" and "edit_redo").

Parameters
withMenusif true, the actions will display a menu when plugged into a toolbar.
actionCollectionthe parent collection

Definition at line 155 of file k3command.cpp.

K3CommandHistory::~K3CommandHistory ( )
virtual

Destructs the command history object.

Definition at line 176 of file k3command.cpp.

Member Function Documentation

void K3CommandHistory::addCommand ( K3Command *  command,
bool  execute = true 
)

Adds a command to the history.

Call this for each command you create. Unless you set execute to false, this will also execute the command. This means, most of the application's code will look like MyCommand * cmd = new MyCommand( parameters ); m_historyCommand.addCommand( cmd );

Note that the command history takes ownership of the command, it will delete it when the undo limit is reached, or when deleting the command history itself.

Definition at line 188 of file k3command.cpp.

void K3CommandHistory::clear ( )

Erases all the undo/redo history.

Use this when reloading the data, for instance, since this invalidates all the commands.

Definition at line 180 of file k3command.cpp.

void K3CommandHistory::commandExecuted ( K3Command *  command)
signal

Emitted every time a command is executed (whether by addCommand, undo or redo).

You can use this to update the GUI, for instance.

Parameters
commandwas executed
void K3CommandHistory::commandHistoryChanged ( )
signal

Emitted whenever the command history has changed, i.e.

after addCommand, undo or redo. This is used by the actions to update themselves.

void K3CommandHistory::documentRestored ( )
signal

Emitted every time we reach the index where you saved the document for the last time.

See documentSaved

void K3CommandHistory::documentSaved ( )
virtualslot

Remembers when you saved the document.

Call this right after saving the document. As soon as the history reaches the current index again (via some undo/redo operations) it will emit documentRestored If you implemented undo/redo properly the document is the same you saved before.

Definition at line 248 of file k3command.cpp.

bool K3CommandHistory::isRedoAvailable ( ) const
Returns
true if redo is available i.e. there is at least one command that can be redone right now

Definition at line 307 of file k3command.cpp.

bool K3CommandHistory::isUndoAvailable ( ) const
Returns
true if undo is available, i.e. there is at least one command that can be undone right now

Definition at line 302 of file k3command.cpp.

K3Command * K3CommandHistory::presentCommand ( ) const
Returns
the present command, i.e. the one that undo() would unexecute. This can be used to e.g. show selection.

Definition at line 212 of file k3command.cpp.

void K3CommandHistory::redo ( )
virtualslot

Redoes the last undone action.

Call this if you don't use the builtin KActions.

Definition at line 235 of file k3command.cpp.

QList< K3Command * > K3CommandHistory::redoCommands ( int  maxCommands = 0) const
Returns
the list of next maxCommands actions that will be redone by redo() The returned list is empty if !isRedoAvailable(). Otherwise the list starts with the next command to redo.
Parameters
maxCommandsmaximum number of commands requested. 0 means no maximum, all stored redo commands (within redoLimit()) are returned.

Definition at line 323 of file k3command.cpp.

int K3CommandHistory::redoLimit ( ) const
Returns
the maximum number of items in the redo history

Definition at line 340 of file k3command.cpp.

void K3CommandHistory::setRedoLimit ( int  limit)

Sets the maximum number of items in the redo history.

Definition at line 259 of file k3command.cpp.

void K3CommandHistory::setUndoLimit ( int  limit)

Sets the maximum number of items in the undo history.

Definition at line 252 of file k3command.cpp.

void K3CommandHistory::undo ( )
virtualslot

Undoes the last action.

Call this if you don't use the builtin KActions.

Definition at line 219 of file k3command.cpp.

QList< K3Command * > K3CommandHistory::undoCommands ( int  maxCommands = 0) const
Returns
the list of next maxCommands actions that will be undone by undo() The returned list is empty if !isUndoAvailable(). Otherwise the list starts with the next command to undo, i.e. the order of the commands in the list is the reverse of the chronological order of the commands.
Parameters
maxCommandsmaximum number of commands requested. 0 means no maximum, all stored undo commands (within undoLimit()) are returned.

Definition at line 312 of file k3command.cpp.

int K3CommandHistory::undoLimit ( ) const
Returns
the maximum number of items in the undo history

Definition at line 335 of file k3command.cpp.

void K3CommandHistory::updateActions ( )

Enable or disable the undo and redo actions.

This isn't usually necessary, but this method can be useful if you disable all actions (to go to a "readonly" state), and then want to come back to a readwrite mode.

Definition at line 296 of file k3command.cpp.


The documentation for this class was generated from the following files:
  • k3command.h
  • k3command.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:26:48 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