From aa0b09dac43ec2a58bd32a1e08d59acd35bd86aa Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Wed, 1 Oct 2008 21:39:35 +0000 Subject: [PATCH] * adjusted Dolphin to use KonqOperations::doDrop() instead of using a custom implementation * used new signals jobRecordingStarted() and jobRecordingFinished from FileUndoManager to inform the user in the statusbar when a recorded command has been finished svn path=/trunk/KDE/kdebase/apps/; revision=866777 --- src/dolphindropcontroller.cpp | 27 ++--------- src/dolphindropcontroller.h | 30 ++++-------- src/dolphinfileplacesview.cpp | 6 +-- src/dolphinmainwindow.cpp | 89 ++++++++++++++--------------------- src/dolphinmainwindow.h | 20 +++----- src/dolphinview.cpp | 11 +---- src/dolphinview.h | 6 --- src/dolphinviewcontainer.cpp | 10 +++- src/dolphinviewcontainer.h | 6 +++ src/treeviewsidebarpage.cpp | 3 +- src/treeviewsidebarpage.h | 6 --- 11 files changed, 74 insertions(+), 140 deletions(-) diff --git a/src/dolphindropcontroller.cpp b/src/dolphindropcontroller.cpp index 6d1261d1a..40fccf0d2 100644 --- a/src/dolphindropcontroller.cpp +++ b/src/dolphindropcontroller.cpp @@ -20,25 +20,12 @@ #include "dolphindropcontroller.h" #include -#include -#include -#include -#include -#include #include -DolphinDropController::DolphinDropController(QWidget* parentWidget) - : QObject(parentWidget), m_parentWidget(parentWidget) -{ -} - -DolphinDropController::~DolphinDropController() -{ -} - void DolphinDropController::dropUrls(const KFileItem& destItem, const KUrl& destPath, - QDropEvent* event) + QDropEvent* event, + QWidget* widget) { const bool dropToItem = !destItem.isNull() && (destItem.isDir() || destItem.isDesktopFile()); const KUrl destination = dropToItem ? destItem.url() : destPath; @@ -47,13 +34,9 @@ void DolphinDropController::dropUrls(const KFileItem& destItem, const KUrl sourceDir = KUrl(urls.first().directory()); if (sourceDir != destination) { if (dropToItem) { - KonqOperations::doDrop(destItem, destination, event, m_parentWidget); + KonqOperations::doDrop(destItem, destination, event, widget); } else { - KonqOperations::doDrop(KFileItem(), destination, event, m_parentWidget); + KonqOperations::doDrop(KFileItem(), destination, event, widget); } } - // TODO: emit doingOperation, so that the main window gets informed about - // about the finished operations -} - -#include "dolphindropcontroller.moc" +} \ No newline at end of file diff --git a/src/dolphindropcontroller.h b/src/dolphindropcontroller.h index 647955802..f4e7c84c2 100644 --- a/src/dolphindropcontroller.h +++ b/src/dolphindropcontroller.h @@ -20,25 +20,19 @@ #ifndef DOLPHINDROPCONTROLLER_H #define DOLPHINDROPCONTROLLER_H -#include -#include - #include "libdolphin_export.h" class QDropEvent; +class QWidget; class KUrl; class KFileItem; /** * @brief Handler for drop events, shared between DolphinView and TreeViewSidebarPage */ -class LIBDOLPHINPRIVATE_EXPORT DolphinDropController : public QObject +class LIBDOLPHINPRIVATE_EXPORT DolphinDropController { - Q_OBJECT public: - explicit DolphinDropController(QWidget* parentWidget); - virtual ~DolphinDropController(); - /** * Handles the dropping of URLs to the given * destination. A context menu with the options @@ -46,21 +40,13 @@ public: * 'Cancel' is offered to the user. * @param destItem Item of the destination (can be null, see KFileItem::isNull()). * @param destPath Path of the destination. - * @param event Drop event - */ - void dropUrls(const KFileItem& destItem, - const KUrl& destPath, - QDropEvent* event); - -signals: - /** - * Is emitted when renaming, copying, moving, linking etc. - * Used for feedback in the mainwindow. + * @param event Drop event. + * @param widget Source widget where the dragging has been started. */ - void doingOperation(KIO::FileUndoManager::CommandType type); - -private: - QWidget* m_parentWidget; + static void dropUrls(const KFileItem& destItem, + const KUrl& destPath, + QDropEvent* event, + QWidget* widget); }; #endif // DOLPHINDROPCONTROLLER_H diff --git a/src/dolphinfileplacesview.cpp b/src/dolphinfileplacesview.cpp index a2291275d..c6626e010 100644 --- a/src/dolphinfileplacesview.cpp +++ b/src/dolphinfileplacesview.cpp @@ -45,11 +45,7 @@ void DolphinFilePlacesView::mousePressEvent(QMouseEvent* event) void DolphinFilePlacesView::slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent) { - DolphinDropController dropController(parent); - // forward doingOperation signal up to the mainwindow - connect(&dropController, SIGNAL(doingOperation(KIO::FileUndoManager::CommandType)), - this, SIGNAL(doingOperation(KIO::FileUndoManager::CommandType))); - dropController.dropUrls(KFileItem(), dest, event); + DolphinDropController::dropUrls(KFileItem(), dest, event, parent); } void DolphinFilePlacesView::emitExtendedUrlChangedSignal(const KUrl& url) diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 588404aaa..48f085e33 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -110,6 +110,10 @@ DolphinMainWindow::DolphinMainWindow(int id) : this, SLOT(slotUndoAvailable(bool))); connect(undoManager, SIGNAL(undoTextChanged(const QString&)), this, SLOT(slotUndoTextChanged(const QString&))); + connect(undoManager, SIGNAL(jobRecordingStarted(CommandType)), + this, SLOT(clearStatusBar())); + connect(undoManager, SIGNAL(jobRecordingFinished(CommandType)), + this, SLOT(showCommand(CommandType))); connect(DolphinSettings::instance().placesModel(), SIGNAL(errorMessage(const QString&)), this, SLOT(slotHandlePlacesError(const QString&))); } @@ -134,10 +138,39 @@ void DolphinMainWindow::toggleViews() m_viewTab[m_tabIndex].secondaryView = container; } -void DolphinMainWindow::slotDoingOperation(KIO::FileUndoManager::CommandType commandType) +void DolphinMainWindow::showCommand(CommandType command) { - clearStatusBar(); - m_undoCommandTypes.append(commandType); + DolphinStatusBar* statusBar = m_activeViewContainer->statusBar(); + switch (command) { + case KIO::FileUndoManager::Copy: + statusBar->setMessage(i18nc("@info:status", "Copy operation completed."), + DolphinStatusBar::OperationCompleted); + break; + case KIO::FileUndoManager::Move: + statusBar->setMessage(i18nc("@info:status", "Move operation completed."), + DolphinStatusBar::OperationCompleted); + break; + case KIO::FileUndoManager::Link: + statusBar->setMessage(i18nc("@info:status", "Link operation completed."), + DolphinStatusBar::OperationCompleted); + break; + case KIO::FileUndoManager::Trash: + statusBar->setMessage(i18nc("@info:status", "Move to trash operation completed."), + DolphinStatusBar::OperationCompleted); + break; + case KIO::FileUndoManager::Rename: + statusBar->setMessage(i18nc("@info:status", "Renaming operation completed."), + DolphinStatusBar::OperationCompleted); + break; + + case KIO::FileUndoManager::Mkdir: + statusBar->setMessage(i18nc("@info:status", "Created folder."), + DolphinStatusBar::OperationCompleted); + break; + + default: + break; + } } void DolphinMainWindow::refreshViews() @@ -157,16 +190,6 @@ void DolphinMainWindow::refreshViews() setActiveViewContainer(activeViewContainer); } -void DolphinMainWindow::dropUrls(const KFileItem& destItem, - const KUrl& destPath, - QDropEvent* event) -{ - DolphinDropController dropController(this); - connect(&dropController, SIGNAL(doingOperation(KIO::FileUndoManager::CommandType)), - this, SLOT(slotDoingOperation(KIO::FileUndoManager::CommandType))); - dropController.dropUrls(destItem, destPath, event); -} - void DolphinMainWindow::pasteIntoFolder() { m_activeViewContainer->view()->pasteIntoFolder(); @@ -380,42 +403,6 @@ void DolphinMainWindow::slotUndoAvailable(bool available) if (undoAction != 0) { undoAction->setEnabled(available); } - - if (available && (m_undoCommandTypes.count() > 0)) { - const KIO::FileUndoManager::CommandType command = m_undoCommandTypes.takeFirst(); - DolphinStatusBar* statusBar = m_activeViewContainer->statusBar(); - switch (command) { - case KIO::FileUndoManager::Copy: - statusBar->setMessage(i18nc("@info:status", "Copy operation completed."), - DolphinStatusBar::OperationCompleted); - break; - case KIO::FileUndoManager::Move: - statusBar->setMessage(i18nc("@info:status", "Move operation completed."), - DolphinStatusBar::OperationCompleted); - break; - case KIO::FileUndoManager::Link: - statusBar->setMessage(i18nc("@info:status", "Link operation completed."), - DolphinStatusBar::OperationCompleted); - break; - case KIO::FileUndoManager::Trash: - statusBar->setMessage(i18nc("@info:status", "Move to trash operation completed."), - DolphinStatusBar::OperationCompleted); - break; - case KIO::FileUndoManager::Rename: - statusBar->setMessage(i18nc("@info:status", "Renaming operation completed."), - DolphinStatusBar::OperationCompleted); - break; - - case KIO::FileUndoManager::Mkdir: - statusBar->setMessage(i18nc("@info:status", "Created folder."), - DolphinStatusBar::OperationCompleted); - break; - - default: - break; - } - - } } void DolphinMainWindow::slotUndoTextChanged(const QString& text) @@ -1059,8 +1046,6 @@ void DolphinMainWindow::setupDockWidgets() this, SLOT(handlePlacesClick(KUrl, Qt::MouseButtons))); connect(treeWidget, SIGNAL(changeSelection(KFileItemList)), this, SLOT(changeSelection(KFileItemList))); - connect(treeWidget, SIGNAL(urlsDropped(KFileItem, KUrl, QDropEvent*)), - this, SLOT(dropUrls(KFileItem, KUrl, QDropEvent*))); // setup "Terminal" #ifndef Q_OS_WIN @@ -1174,8 +1159,6 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container) this, SLOT(slotRequestItemInfo(KFileItem))); connect(view, SIGNAL(activated()), this, SLOT(toggleActiveView())); - connect(view, SIGNAL(doingOperation(KIO::FileUndoManager::CommandType)), - this, SLOT(slotDoingOperation(KIO::FileUndoManager::CommandType))); connect(view, SIGNAL(tabRequested(const KUrl&)), this, SLOT(openNewTab(const KUrl&))); diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index 2b7b247b5..a9db9a3e2 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -34,6 +34,8 @@ #include +typedef KIO::FileUndoManager::CommandType CommandType; + class KAction; class DolphinViewActionHandler; class DolphinApplication; @@ -104,14 +106,6 @@ public: KAction* showMenuBarAction() const; public slots: - /** - * Handles the dropping of URLs to the given - * destination. This is only called by the TreeViewSidebarPage. - */ - void dropUrls(const KFileItem& destItem, - const KUrl& destPath, - QDropEvent* event); - /** * Pastes the clipboard data into the currently selected folder * of the active view. If not exactly one folder is selected, @@ -314,8 +308,11 @@ private slots: /** Toggles the active view if two views are shown within the main window. */ void toggleActiveView(); - /** Called when the view is doing a file operation, like renaming, copying, moving etc. */ - void slotDoingOperation(KIO::FileUndoManager::CommandType type); + /** + * Indicates in the statusbar that the execution of the command \a command + * has been finished. + */ + void showCommand(CommandType command); /** * Activates the tab with the index \a index, which means that the current view @@ -423,9 +420,6 @@ private: QList m_viewTab; DolphinViewActionHandler* m_actionHandler; - - /// remember pending undo operations until they are finished - QList m_undoCommandTypes; }; inline DolphinViewContainer* DolphinMainWindow::activeViewContainer() const diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 64aa10fd4..b3be62252 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -558,7 +558,6 @@ void DolphinView::renameSelectedItems() KUrl newUrl = oldUrl; newUrl.setFileName(name); KonqOperations::rename(this, oldUrl, newUrl); - emit doingOperation(KIO::FileUndoManager::Rename); } } } @@ -588,14 +587,12 @@ void DolphinView::renameSelectedItems() KUrl newUrl = oldUrl; newUrl.setFileName(newName); KonqOperations::rename(this, oldUrl, newUrl); - emit doingOperation(KIO::FileUndoManager::Rename); } } } void DolphinView::trashSelectedItems() { - emit doingOperation(KIO::FileUndoManager::Trash); const KUrl::List list = simplifiedSelectedUrls(); KonqOperations::del(this, KonqOperations::TRASH, list); } @@ -820,11 +817,7 @@ void DolphinView::dropUrls(const KFileItem& destItem, const KUrl& destPath, QDropEvent* event) { - DolphinDropController dropController(this); - // forward doingOperation signal up to the mainwindow - connect(&dropController, SIGNAL(doingOperation(KIO::FileUndoManager::CommandType)), - this, SIGNAL(doingOperation(KIO::FileUndoManager::CommandType))); - dropController.dropUrls(destItem, destPath, event); + DolphinDropController::dropUrls(destItem, destPath, event, this); } void DolphinView::updateSorting(DolphinView::Sorting sorting) @@ -1252,11 +1245,9 @@ void DolphinView::pasteToUrl(const KUrl& url) const KUrl::List sourceUrls = KUrl::List::fromMimeData(mimeData); if (KonqMimeData::decodeIsCutSelection(mimeData)) { KonqOperations::copy(this, KonqOperations::MOVE, sourceUrls, url); - emit doingOperation(KIO::FileUndoManager::Move); clipboard->clear(); } else { KonqOperations::copy(this, KonqOperations::COPY, sourceUrls, url); - emit doingOperation(KIO::FileUndoManager::Copy); } } diff --git a/src/dolphinview.h b/src/dolphinview.h index 661ef73d5..6546c457e 100644 --- a/src/dolphinview.h +++ b/src/dolphinview.h @@ -513,12 +513,6 @@ signals: */ void startedPathLoading(const KUrl& url); - /** - * Is emitted when renaming, copying, moving, linking etc. - * Used for feedback in the mainwindow. - */ - void doingOperation(KIO::FileUndoManager::CommandType type); - protected: /** @see QWidget::mouseReleaseEvent */ virtual void mouseReleaseEvent(QMouseEvent* event); diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index cccce3fad..c5ec69959 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -46,6 +46,7 @@ #include "dolphinmodel.h" #include "dolphincolumnview.h" #include "dolphincontroller.h" +#include "dolphindropcontroller.h" #include "dolphinstatusbar.h" #include "dolphinmainwindow.h" #include "dolphindirlister.h" @@ -80,8 +81,8 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow, m_topLayout->setMargin(0); m_urlNavigator = new KUrlNavigator(DolphinSettings::instance().placesModel(), url, this); - connect(m_urlNavigator, SIGNAL(urlsDropped(const KUrl::List&, const KUrl&)), - m_mainWindow, SLOT(dropUrls(const KUrl::List&, const KUrl&))); + connect(m_urlNavigator, SIGNAL(urlsDropped(const KUrl&, QDropEvent*)), + this, SLOT(dropUrls(const KUrl&, QDropEvent*))); connect(m_urlNavigator, SIGNAL(activated()), this, SLOT(activate())); @@ -406,6 +407,11 @@ void DolphinViewContainer::saveRootUrl(const KUrl& url) m_urlNavigator->saveRootUrl(m_view->rootUrl()); } +void DolphinViewContainer::dropUrls(const KUrl& destination, QDropEvent* event) +{ + DolphinDropController::dropUrls(KFileItem(), destination, event, this); +} + void DolphinViewContainer::slotItemTriggered(const KFileItem& item) { KUrl url = item.targetUrl(); diff --git a/src/dolphinviewcontainer.h b/src/dolphinviewcontainer.h index b4f799cb1..7c81384d2 100644 --- a/src/dolphinviewcontainer.h +++ b/src/dolphinviewcontainer.h @@ -201,6 +201,12 @@ private slots: * into the URL navigator. */ void saveRootUrl(const KUrl& url); + + /** + * Is connected with the URL navigator and drops the URLs + * above the destination \a destination. + */ + void dropUrls(const KUrl& destination, QDropEvent* event); private: /** diff --git a/src/treeviewsidebarpage.cpp b/src/treeviewsidebarpage.cpp index d349f7b0b..6cf2ede18 100644 --- a/src/treeviewsidebarpage.cpp +++ b/src/treeviewsidebarpage.cpp @@ -19,6 +19,7 @@ #include "treeviewsidebarpage.h" +#include "dolphindropcontroller.h" #include "dolphinmodel.h" #include "dolphinsortfilterproxymodel.h" #include "dolphinview.h" @@ -210,7 +211,7 @@ void TreeViewSidebarPage::dropUrls(const QModelIndex& index, QDropEvent* event) KFileItem item = m_dolphinModel->itemForIndex(dirIndex); Q_ASSERT(!item.isNull()); if (item.isDir()) { - emit urlsDropped(item, item.url(), event); + DolphinDropController::dropUrls(item, item.url(), event, this); } } } diff --git a/src/treeviewsidebarpage.h b/src/treeviewsidebarpage.h index 80db7840b..b9f1fba6d 100644 --- a/src/treeviewsidebarpage.h +++ b/src/treeviewsidebarpage.h @@ -68,12 +68,6 @@ signals: */ void changeSelection(const KFileItemList& selection); - /** - * This signal is emitted whenever a drop action on this widget needs the - * MainWindow's attention. - */ - void urlsDropped(const KFileItem& destItem, const KUrl& destPath, QDropEvent* event); - public slots: /** * Changes the current selection inside the tree to \a url. -- 2.47.3