emit selectionChanged();
}
+void DolphinMainWindow::slotRedo()
+{
+ UndoManager::instance().redo(this);
+}
+
+void DolphinMainWindow::slotUndo()
+{
+ UndoManager::instance().undo(this);
+}
+
void DolphinMainWindow::closeEvent(QCloseEvent* event)
{
// KDE4-TODO
statusBar->setMessage(i18n("Created folder %1.",url.path()),
DolphinStatusBar::OperationCompleted);
- DolphinCommand command(DolphinCommand::CreateFolder, KUrl::List(), url, this);
+ DolphinCommand command(DolphinCommand::CreateFolder, KUrl::List(), url);
UndoManager::instance().addCommand(command);
}
else {
KUrl::List list;
list.append(sourceUrl);
- DolphinCommand command(DolphinCommand::CreateFile, list, destUrl, this);
+ DolphinCommand command(DolphinCommand::CreateFile, list, destUrl);
UndoManager::instance().addCommand(command);
}
// setup 'Edit' menu
UndoManager& undoManager = UndoManager::instance();
- KStdAction::undo(&undoManager,
- SLOT(undo()),
+ KStdAction::undo(this,
+ SLOT(slotUndo()),
actionCollection());
connect(&undoManager, SIGNAL(undoAvailable(bool)),
this, SLOT(slotUndoAvailable(bool)));
connect(&undoManager, SIGNAL(undoTextChanged(const QString&)),
this, SLOT(slotUndoTextChanged(const QString&)));
- KStdAction::redo(&undoManager,
- SLOT(redo()),
+ KStdAction::redo(this,
+ SLOT(slotRedo()),
actionCollection());
connect(&undoManager, SIGNAL(redoAvailable(bool)),
this, SLOT(slotRedoAvailable(bool)));
UndoInfo undoInfo;
undoInfo.id = job->progressId();
- undoInfo.command = DolphinCommand(commandType, source, dest, this);
+ undoInfo.command = DolphinCommand(commandType, source, dest);
m_pendingUndoJobs.append(undoInfo);
}
/** Updates the state of the 'Edit' menu actions. */
void slotSelectionChanged();
+ /** Executes Redo operation */
+ void slotRedo();
+
+ /** @see slotUndo() */
+ void slotUndo();
+
protected:
/** @see QMainWindow::closeEvent */
virtual void closeEvent(QCloseEvent* event);
else if (KIO::NetAccess::file_move(source, dest)) {
// TODO: From the users point of view he executed one 'rename n files' operation,
// but internally we store it as n 'rename 1 file' operations for the undo mechanism.
- DolphinCommand command(DolphinCommand::Rename, source, dest, mainWindow());
+ DolphinCommand command(DolphinCommand::Rename, source, dest);
undoMan.addCommand(command);
}
}
m_statusBar->setMessage(i18n("Renamed file '%1' to '%2'.",source.fileName(), dest.fileName()),
DolphinStatusBar::OperationCompleted);
- DolphinCommand command(DolphinCommand::Rename, source, dest, mainWindow());
+ DolphinCommand command(DolphinCommand::Rename, source, dest);
UndoManager::instance().addCommand(command);
}
else {
DolphinCommand::DolphinCommand() :
m_type(Copy),
- m_macroIndex(-1),
- m_mainWindow(0)
+ m_macroIndex(-1)
{
// Implementation note: DolphinCommands are stored in a QValueList, whereas
// QValueList requires a default constructor of the added class.
DolphinCommand::DolphinCommand(Type type,
const KUrl::List& source,
- const KUrl& dest,
- DolphinMainWindow* mainWindow) :
+ const KUrl& dest) :
m_type(type),
m_macroIndex(-1),
m_source(source),
- m_dest(dest),
- m_mainWindow(mainWindow)
+ m_dest(dest)
{
}
m_type = command.m_type;
m_source = command.m_source;
m_dest = command.m_dest;
- m_mainWindow = command.m_mainWindow;
return *this;
}
// KDE4 TODO: consider switching to KCommandHistory (kdeui) for the command history, and to
// KonqCommandRecorder etc. from libkonq/konq_undo.*
-void UndoManager::undo()
+void UndoManager::undo(DolphinMainWindow* mainWindow)
{
if (m_recordMacro) {
endMacro();
int macroCount = 1;
calcStepsCount(macroCount, progressCount);
+ /*
+ * KDE4, ### TODO Only here to avoid possible crash
+ */
+ ProgressIndicator progressIndicator(mainWindow, i18n("Executing undo operation..."),
+ i18n("Executed undo operation."),
+ progressCount);
for (int i = 0; i < macroCount; ++i) {
const DolphinCommand command = m_history[m_historyIndex];
- /*
- * KDE4, ### TODO Only here to avoid possible crash
- */
- ProgressIndicator progressIndicator(command.mainWindow(), i18n("Executing undo operation..."),
- i18n("Executed undo operation."),
- progressCount);
--m_historyIndex;
if (m_historyIndex < 0) {
emit undoAvailable(false);
case DolphinCommand::CreateFolder:
case DolphinCommand::CreateFile: {
- KIO::NetAccess::del(command.destination(), command.mainWindow() );
+ KIO::NetAccess::del(command.destination(), mainWindow);
break;
}
}
// information to the Dolphin statusbar.
connect(job, SIGNAL(percent(KIO::Job*, unsigned long)),
this, SLOT(slotPercent(KIO::Job*, unsigned long)));
- KIO::NetAccess::synchronousRun(job, command.mainWindow() );
+ KIO::NetAccess::synchronousRun(job, mainWindow);
}
progressIndicator.execOperation();
}
}
-void UndoManager::redo()
+void UndoManager::redo(DolphinMainWindow *mainWindow)
{
if (m_recordMacro) {
endMacro();
int macroCount = 1;
calcStepsCount(macroCount, progressCount);
+ ProgressIndicator progressIndicator(mainWindow, i18n("Executing redo operation..."),
+ i18n("Executed redo operation."),
+ progressCount);
for (int i = 0; i < macroCount; ++i) {
const DolphinCommand command = m_history[m_historyIndex];
-#warning "TOUGH"
- ProgressIndicator progressIndicator(0, i18n("Executing redo operation..."),
- i18n("Executed redo operation."),
- progressCount);
if (m_historyIndex >= maxHistoryIndex) {
emit redoAvailable(false);
emit redoTextChanged(i18n("Redo"));
const QString originalFileName((*it).fileName().section('-', 1));
KUrl originalSourceUrl(destUrl + "/" + originalFileName);
KIO::Job* moveToTrashJob = KIO::trash(originalSourceUrl);
- KIO::NetAccess::synchronousRun(moveToTrashJob, command.mainWindow() );
+ KIO::NetAccess::synchronousRun(moveToTrashJob, mainWindow);
++it;
progressIndicator.execOperation();
}
case DolphinCommand::CreateFolder: {
- KIO::NetAccess::mkdir(command.destination(), command.mainWindow());
+ KIO::NetAccess::mkdir(command.destination(), mainWindow);
break;
}
// information to the Dolphin statusbar.
connect(job, SIGNAL(percent(KJob*, unsigned long)),
this, SLOT(slotPercent(KJob*, unsigned long)));
- KIO::NetAccess::synchronousRun(job, command.mainWindow());
+ KIO::NetAccess::synchronousRun(job, mainWindow);
}
++m_historyIndex;
};
DolphinCommand();
- DolphinCommand(Type type, const KUrl::List& source, const KUrl& dest, DolphinMainWindow* mainWindow);
+ DolphinCommand(Type type, const KUrl::List& source, const KUrl& dest);
~DolphinCommand(); // non-virtual
DolphinCommand& operator = (const DolphinCommand& command);
void setSource(const KUrl::List source) { m_source = source; }
const KUrl::List& source() const { return m_source; }
const KUrl& destination() const { return m_dest; }
- DolphinMainWindow* mainWindow() const { return m_mainWindow; }
private:
Type m_type;
int m_macroIndex;
KUrl::List m_source;
KUrl m_dest;
- QPointer<DolphinMainWindow> m_mainWindow;
friend class UndoManager; // allow to modify m_macroIndex
};
/**
* 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();
+ 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();
+ void redo(DolphinMainWindow* mainwindow);
signals:
/**