#include <kmessagebox.h>\r
#include <knewmenu.h>\r
#include <konqmimedata.h>\r
-#include <konq_undo.h>\r
#include <kpropertiesdialog.h>\r
#include <kprotocolinfo.h>\r
#include <ktoggleaction.h>\r
\r
KonqUndoManager::incRef();\r
\r
- connect(KonqUndoManager::self(), SIGNAL(undoAvailable(bool)),\r
+ KonqUndoManager* undoManager = KonqUndoManager::self();\r
+ undoManager->setUiInterface(new UndoUiInterface(this));\r
+\r
+ connect(undoManager, SIGNAL(undoAvailable(bool)),\r
this, SLOT(slotUndoAvailable(bool)));\r
- connect(KonqUndoManager::self(), SIGNAL(undoTextChanged(const QString&)),\r
+ connect(undoManager, SIGNAL(undoTextChanged(const QString&)),\r
this, SLOT(slotUndoTextChanged(const QString&)));\r
}\r
\r
break;\r
\r
case Qt::LinkAction:\r
- KonqOperations::copy(this, KonqOperations::LINK, urls, destination);\r
- m_undoOperations.append(KonqOperations::LINK);\r
+ linkUrls(urls, destination);\r
break;\r
\r
default:\r
m_undoOperations.append(KonqOperations::MOVE);\r
}\r
\r
+void DolphinMainWindow::linkUrls(const KUrl::List& source, const KUrl& dest)\r
+{\r
+ KonqOperations::copy(this, KonqOperations::LINK, source, dest);\r
+ m_undoOperations.append(KonqOperations::LINK);\r
+}\r
+\r
void DolphinMainWindow::clearStatusBar()\r
{\r
m_activeView->statusBar()->clear();\r
\r
}\r
\r
+DolphinMainWindow::UndoUiInterface::UndoUiInterface(DolphinMainWindow* mainWin) :\r
+ m_mainWin(mainWin)\r
+{\r
+ assert(m_mainWin != 0);\r
+}\r
+\r
+DolphinMainWindow::UndoUiInterface::~UndoUiInterface()\r
+{\r
+}\r
+\r
+void DolphinMainWindow::UndoUiInterface::jobError(KIO::Job* job)\r
+{\r
+ DolphinStatusBar* statusBar = m_mainWin->activeView()->statusBar();\r
+ statusBar->setMessage(job->errorString(), DolphinStatusBar::Error);\r
+}\r
+\r
+bool DolphinMainWindow::UndoUiInterface::copiedFileWasModified(const KUrl& src,\r
+ const KUrl& dest,\r
+ time_t /*srcTime*/,\r
+ time_t destTime)\r
+{\r
+ // The following code has been taken from libkonq/konq_undo.cc\r
+ // Copyright (C) 2000 Simon Hausmann <hausmann@kde.org>\r
+ // Copyright (C) 2006 David Faure <faure@kde.org>\r
+ const QDateTime destDt = QDateTime::fromTime_t(destTime);\r
+ const QString timeStr = KGlobal::locale()->formatDateTime(destDt, true /* short */);\r
+ return KMessageBox::warningContinueCancel(\r
+ m_mainWin,\r
+ i18n( "The file %1 was copied from %2, but since then it has apparently been modified at %3.\n"\r
+ "Undoing the copy will delete the file, and all modifications will be lost.\n"\r
+ "Are you sure you want to delete %4?", dest.pathOrUrl(), src.pathOrUrl(), timeStr, dest.pathOrUrl()),\r
+ i18n( "Undo File Copy Confirmation" ),\r
+ KStandardGuiItem::cont(),\r
+ QString(),\r
+ KMessageBox::Notify | KMessageBox::Dangerous ) == KMessageBox::Continue;\r
+}\r
+\r
#include "dolphinmainwindow.moc"\r
#include <kmainwindow.h>
#include <ksortablelist.h>
#include <konq_operations.h>
+#include <konq_undo.h>
#include <QList>
void updateGoActions();
void copyUrls(const KUrl::List& source, const KUrl& dest);
void moveUrls(const KUrl::List& source, const KUrl& dest);
+ void linkUrls(const KUrl::List& source, const KUrl& dest);
void clearStatusBar();
/**
/// remember pending undo operations until they are finished
QList<KonqOperations::Operation> m_undoOperations;
- /** Contains meta information for creating files. */
- struct CreateFileEntry
- {
- QString name;
- QString filePath;
- QString templatePath;
- QString icon;
- QString comment;
+ /**
+ * Implements a custom error handling for the undo manager. This
+ * assures that all errors are shown in the status bar of Dolphin
+ * instead as modal error dialog with an OK button.
+ */
+ class UndoUiInterface : public KonqUndoManager::UiInterface {
+ public:
+ UndoUiInterface(DolphinMainWindow* mainWin);
+ virtual ~UndoUiInterface();
+ virtual void jobError(KIO::Job* job);
+ virtual bool copiedFileWasModified(const KUrl& src,
+ const KUrl& dest,
+ time_t srcTime,
+ time_t destTime);
+ private:
+ DolphinMainWindow* m_mainWin;
};
};