┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/undomanager.h
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2007-01-18 06:32:21 +0000
committerPeter Penz <[email protected]>2007-01-18 06:32:21 +0000
commit76866f783cfd5e84a85b6e9024aa554f3969ecec (patch)
tree826ebfa5500bc17c023386a72914118e0cc87430 /src/undomanager.h
parent4db903c6709b8c0dd47df54f84070d6adf0e4a25 (diff)
Replaced Dolphins UndoManager and DolphinCommand by KonqUndoManager and KonqOperations. There are still some minor open issues left (renaming of multiple selected files, no undo support for KonqOperations::mkdir(), redo, ...), but all in all it absolutely makes sense to use a shared code for those operations.
svn path=/trunk/playground/utils/dolphin/; revision=624760
Diffstat (limited to 'src/undomanager.h')
-rw-r--r--src/undomanager.h201
1 files changed, 0 insertions, 201 deletions
diff --git a/src/undomanager.h b/src/undomanager.h
deleted file mode 100644
index 4f0b6682d..000000000
--- a/src/undomanager.h
+++ /dev/null
@@ -1,201 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2006 by Peter Penz *
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License *
- * along with this program; if not, write to the *
- * Free Software Foundation, Inc., *
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
- ***************************************************************************/
-
-#ifndef UNDOMANAGER_H
-#define UNDOMANAGER_H
-
-#include <QObject>
-#include <QPointer>
-#include <QList>
-
-#include <kurl.h>
-#include <kio/jobclasses.h>
-
-class DolphinMainWindow;
-
-/**
- * @short Represents a file manager command which can be undone and redone.
- *
- * A command is specified by a type, a list of source Urls and a
- * destination Url.
- *
- * Due to the fixed set of commands a file manager offers this class is
- * a very simplified version of the classic command pattern.
- *
- * @see UndoManager
- * @author Peter Penz <[email protected]>
- */
-class DolphinCommand
-{
-public:
- enum Type {
- Copy,
- Move,
- Link,
- Rename,
- Trash,
- CreateFolder,
- CreateFile
- };
-
- DolphinCommand();
- DolphinCommand(Type type, const KUrl::List& source, const KUrl& dest);
- ~DolphinCommand(); // non-virtual
-
- DolphinCommand& operator = (const DolphinCommand& command);
- Type type() const { return m_type; }
- void setSource(const KUrl::List source) { m_source = source; }
- const KUrl::List& source() const { return m_source; }
- const KUrl& destination() const { return m_dest; }
-
-private:
- Type m_type;
- int m_macroIndex;
- KUrl::List m_source;
- KUrl m_dest;
-
- friend class UndoManager; // allow to modify m_macroIndex
-};
-
-/**
- * @short Stores all file manager commands which can be undone and redone.
- *
- * During the undo and redo operations a progress information is
- * shown in the status bar.
- *
- * @author Peter Penz <[email protected]>
- */
-class UndoManager : public QObject // TODO switch to KonqUndoManager (multi-process, async, more robust on complex operations, no redo though)
-{
- Q_OBJECT
-
-public:
- static UndoManager& instance();
-
- /**
- * Adds the command \a command to the undo list. The command
- * can be undone by invoking UndoManager::undo().
- */
- void addCommand(const DolphinCommand& command);
-
- /**
- * Allows to summarize several commands into one macro, which
- * can be undo in one stop by UndoManager::undo(). Example
- * \code
- * UndoManager& undoMan = UndoManager.instance();
- * undoMan.beginMacro();
- * undoMan.addCommand(...);
- * undoMan.addCommand(...);
- * undoMan.addCommand(...);
- * undoMan.endMacro();
- * \endcode
- * It is not allowed to do nested macro recordings.
- */
- void beginMacro();
-
- /**
- * Marks the end of a macro command. See UndoManager::beginMacro()
- * for sample code.
- */
- void endMacro();
-
-public slots:
- /**
- * Performs an undo operation on the last command which has
- * been added by UndoManager::addCommand().
- *
- * @param mainwindow The mainwindow where to show progress
- */
- void undo(DolphinMainWindow* mainwindow);
-
- /**
- * Performs a redo operation on the last command where an undo
- * operation has been applied.
- *
- * @param mainwindow The mainwindow where to show progress
- */
- void redo(DolphinMainWindow* mainwindow);
-
-signals:
- /**
- * Is emitted if whenever the availability state
- * of the current undo operation changes.
- */
- void undoAvailable(bool available);
-
- /**
- * Is emitted whenever the text of the current
- * undo operation changes
- * (e. g. from 'Undo: Delete' to 'Undo: Copy')
- */
- void undoTextChanged(const QString& text);
-
- /**
- * Is emitted if whenever the availability state
- * of the current redo operation changes.
- */
- void redoAvailable(bool available);
-
- /**
- * Is emitted whenever the text of the current
- * redo operation changes
- * (e. g. from 'Redo: Delete' to 'Redo: Copy')
- */
- void redoTextChanged(const QString& text);
-
-protected:
- UndoManager();
- virtual ~UndoManager();
- QString commandText(const DolphinCommand& command) const;
-
-private slots:
- /**
- * Slot for the percent information of the I/O slaves.
- * Delegates the updating of the progress information
- * to UndoManager::updateProgress().
- */
- void slotPercent(KJob* job, unsigned long percent);
-
- /**
- * Updates the progress information of the statusbar
- * by accessing the progress indicator information.
- */
- void updateProgress();
-
-private:
- bool m_recordMacro;
- int m_historyIndex;
- int m_macroCounter;
- QList<DolphinCommand> m_history;
-
- /**
- * Dependent from the current history index \a m_historyIndex
- * the number of macro commands is written to the output
- * parameter \a macroCount. The number of steps for all macro
- * commands is written to the output parameter \a progressCount.
- *
- * Per default \a macroCount is 1 and \a progressCount represents
- * the number of operations for one command.
- */
- void calcStepsCount(int& macroCount,
- int& progressCount);
-};
-
-#endif