diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/dolphincolumnwidget.cpp | 16 | ||||
| -rw-r--r-- | src/dolphincontroller.cpp | 6 | ||||
| -rw-r--r-- | src/dolphincontroller.h | 14 | ||||
| -rw-r--r-- | src/dolphindetailsview.cpp | 16 | ||||
| -rw-r--r-- | src/dolphindropcontroller.cpp | 100 | ||||
| -rw-r--r-- | src/dolphindropcontroller.h | 18 | ||||
| -rw-r--r-- | src/dolphinfileplacesview.cpp | 5 | ||||
| -rw-r--r-- | src/dolphiniconsview.cpp | 14 | ||||
| -rw-r--r-- | src/dolphinmainwindow.cpp | 14 | ||||
| -rw-r--r-- | src/dolphinmainwindow.h | 6 | ||||
| -rw-r--r-- | src/dolphinview.cpp | 26 | ||||
| -rw-r--r-- | src/dolphinview.h | 6 | ||||
| -rw-r--r-- | src/sidebartreeview.cpp | 13 | ||||
| -rw-r--r-- | src/sidebartreeview.h | 5 | ||||
| -rw-r--r-- | src/treeviewsidebarpage.cpp | 9 | ||||
| -rw-r--r-- | src/treeviewsidebarpage.h | 10 |
16 files changed, 91 insertions, 187 deletions
diff --git a/src/dolphincolumnwidget.cpp b/src/dolphincolumnwidget.cpp index 176431b65..f5d3ca435 100644 --- a/src/dolphincolumnwidget.cpp +++ b/src/dolphincolumnwidget.cpp @@ -29,13 +29,13 @@ #include "dolphin_generalsettings.h" #include "draganddrophelper.h" #include "folderexpander.h" -#include "kfilepreviewgenerator.h" #include "selectionmanager.h" #include "tooltipmanager.h" #include <kcolorscheme.h> #include <kdirlister.h> #include <kfileitem.h> +#include <kfilepreviewgenerator.h> #include <kio/previewjob.h> #include <kiconeffect.h> #include <kjob.h> @@ -331,16 +331,10 @@ void DolphinColumnWidget::dragMoveEvent(QDragMoveEvent* event) void DolphinColumnWidget::dropEvent(QDropEvent* event) { - const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData()); - if (!urls.isEmpty()) { - const QModelIndex index = indexAt(event->pos()); - m_view->m_controller->setItemView(this); - const KFileItem item = m_view->m_controller->itemForIndex(index); - m_view->m_controller->indicateDroppedUrls(urls, - url(), - item); - event->acceptProposedAction(); - } + const QModelIndex index = indexAt(event->pos()); + m_view->m_controller->setItemView(this); + const KFileItem item = m_view->m_controller->itemForIndex(index); + m_view->m_controller->indicateDroppedUrls(item, url(), event); QListView::dropEvent(event); } diff --git a/src/dolphincontroller.cpp b/src/dolphincontroller.cpp index abbae6ec7..973231687 100644 --- a/src/dolphincontroller.cpp +++ b/src/dolphincontroller.cpp @@ -84,11 +84,11 @@ void DolphinController::requestActivation() emit activated(); } -void DolphinController::indicateDroppedUrls(const KUrl::List& urls, +void DolphinController::indicateDroppedUrls(const KFileItem& destItem, const KUrl& destPath, - const KFileItem& destItem) + QDropEvent* event) { - emit urlsDropped(urls, destPath, destItem); + emit urlsDropped(destItem, destPath, event); } diff --git a/src/dolphincontroller.h b/src/dolphincontroller.h index 9196a157d..312cea3cc 100644 --- a/src/dolphincontroller.h +++ b/src/dolphincontroller.h @@ -136,13 +136,13 @@ public: * Indicates that URLs are dropped above a destination. This method * should be invoked by the view implementation. The abstract Dolphin view * will start the corresponding action (copy, move, link). - * @param urls URLs that are dropped above a destination. + * @param destItem Item of the destination (can be null, see KFileItem::isNull()). * @param destPath Path of the destination. - * @param destItem Destination item (can be null, see KFileItem::isNull()). + * @param event Drop event */ - void indicateDroppedUrls(const KUrl::List& urls, + void indicateDroppedUrls(const KFileItem& destItem, const KUrl& destPath, - const KFileItem& destItem); + QDropEvent* event); /** * Informs the abstract Dolphin view about a sorting change done inside @@ -262,14 +262,14 @@ signals: void activated(); /** - * Is emitted if the URLs \a urls have been dropped to the destination + * Is emitted if URLs have been dropped to the destination * path \a destPath. If the URLs have been dropped above an item of * the destination path, the item is indicated by \a destItem * (can be null, see KFileItem::isNull()). */ - void urlsDropped(const KUrl::List& urls, + void urlsDropped(const KFileItem& destItem, const KUrl& destPath, - const KFileItem& destItem); + QDropEvent* event); /** * Is emitted if the sorting has been changed to \a sorting by diff --git a/src/dolphindetailsview.cpp b/src/dolphindetailsview.cpp index 61cb0df76..79a1a106d 100644 --- a/src/dolphindetailsview.cpp +++ b/src/dolphindetailsview.cpp @@ -349,18 +349,12 @@ void DolphinDetailsView::dragMoveEvent(QDragMoveEvent* event) void DolphinDetailsView::dropEvent(QDropEvent* event) { - const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData()); - if (!urls.isEmpty()) { - event->acceptProposedAction(); - const QModelIndex index = indexAt(event->pos()); - KFileItem item; - if (index.isValid() && (index.column() == DolphinModel::Name)) { - item = m_controller->itemForIndex(index); - } - m_controller->indicateDroppedUrls(urls, - m_controller->url(), - item); + const QModelIndex index = indexAt(event->pos()); + KFileItem item; + if (index.isValid() && (index.column() == DolphinModel::Name)) { + item = m_controller->itemForIndex(index); } + m_controller->indicateDroppedUrls(item, m_controller->url(), event); QTreeView::dropEvent(event); } diff --git a/src/dolphindropcontroller.cpp b/src/dolphindropcontroller.cpp index 4fecbe626..6d1261d1a 100644 --- a/src/dolphindropcontroller.cpp +++ b/src/dolphindropcontroller.cpp @@ -19,6 +19,7 @@ ***************************************************************************/ #include "dolphindropcontroller.h" +#include <kfileitem.h> #include <klocale.h> #include <kicon.h> #include <QApplication> @@ -26,11 +27,6 @@ #include <kmenu.h> #include <konq_operations.h> -// TODO replace with KonqOperations::doDrop [or move doDrop code into this class] -// Note that this means changing the DolphinDropController controller usage -// to "create with new and let it autodelete" instead of on stack, since doDrop is async. -// NOTE: let's wait for KDirModel::dropEvent first. - DolphinDropController::DolphinDropController(QWidget* parentWidget) : QObject(parentWidget), m_parentWidget(parentWidget) { @@ -40,90 +36,24 @@ DolphinDropController::~DolphinDropController() { } -void DolphinDropController::dropUrls(const KUrl::List& urls, - const KUrl& destination) +void DolphinDropController::dropUrls(const KFileItem& destItem, + const KUrl& destPath, + QDropEvent* event) { - kDebug() << "Source" << urls; - kDebug() << "Destination:" << destination; - - if (destination.protocol() == "trash") { - KonqOperations::del(m_parentWidget, KonqOperations::TRASH, urls); - return; - } - - Qt::DropAction action = Qt::CopyAction; - - Qt::KeyboardModifiers modifier = QApplication::keyboardModifiers(); - const bool shiftPressed = modifier & Qt::ShiftModifier; - const bool controlPressed = modifier & Qt::ControlModifier; - const bool altPressed = modifier & Qt::AltModifier; - if ((shiftPressed && controlPressed) || altPressed) { - action = Qt::LinkAction; - } else if (controlPressed) { - action = Qt::CopyAction; - } else if (shiftPressed) { - action = Qt::MoveAction; - } else { - // open a context menu which offers the following actions: - // - Move Here - // - Copy Here - // - Link Here - // - Cancel - - KMenu popup(m_parentWidget); - - QString seq = QKeySequence(Qt::ShiftModifier).toString(); - seq.chop(1); // chop superfluous '+' - QAction* moveAction = popup.addAction(KIcon("go-jump"), - i18nc("@action:inmenu", - "&Move Here\t<shortcut>%1</shortcut>", seq)); - - seq = QKeySequence(Qt::ControlModifier).toString(); - seq.chop(1); - QAction* copyAction = popup.addAction(KIcon("edit-copy"), - i18nc("@action:inmenu", - "&Copy Here\t<shortcut>%1</shortcut>", seq)); - - seq = QKeySequence(Qt::ControlModifier + Qt::ShiftModifier).toString(); - seq.chop(1); - QAction* linkAction = popup.addAction(KIcon("edit-link"), - i18nc("@action:inmenu", - "&Link Here\t<shortcut>%1</shortcut>", seq)); - - popup.addSeparator(); - popup.addAction(KIcon("process-stop"), i18nc("@action:inmenu", "Cancel")); - - QAction* activatedAction = popup.exec(QCursor::pos()); - if (activatedAction == moveAction) { - action = Qt::MoveAction; - } else if (activatedAction == copyAction) { - action = Qt::CopyAction; - } else if (activatedAction == linkAction) { - action = Qt::LinkAction; + const bool dropToItem = !destItem.isNull() && (destItem.isDir() || destItem.isDesktopFile()); + const KUrl destination = dropToItem ? destItem.url() : destPath; + + const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData()); + const KUrl sourceDir = KUrl(urls.first().directory()); + if (sourceDir != destination) { + if (dropToItem) { + KonqOperations::doDrop(destItem, destination, event, m_parentWidget); } else { - return; + KonqOperations::doDrop(KFileItem(), destination, event, m_parentWidget); } } - - switch (action) { - case Qt::MoveAction: - KonqOperations::copy(m_parentWidget, KonqOperations::MOVE, urls, destination); - emit doingOperation(KIO::FileUndoManager::Move); - break; - - case Qt::CopyAction: - KonqOperations::copy(m_parentWidget, KonqOperations::COPY, urls, destination); - emit doingOperation(KIO::FileUndoManager::Copy); - break; - - case Qt::LinkAction: - KonqOperations::copy(m_parentWidget, KonqOperations::LINK, urls, destination); - emit doingOperation(KIO::FileUndoManager::Link); - break; - - default: - break; - } + // TODO: emit doingOperation, so that the main window gets informed about + // about the finished operations } #include "dolphindropcontroller.moc" diff --git a/src/dolphindropcontroller.h b/src/dolphindropcontroller.h index 955d1614c..647955802 100644 --- a/src/dolphindropcontroller.h +++ b/src/dolphindropcontroller.h @@ -21,11 +21,14 @@ #define DOLPHINDROPCONTROLLER_H #include <QObject> -#include <kurl.h> #include <kio/fileundomanager.h> #include "libdolphin_export.h" +class QDropEvent; +class KUrl; +class KFileItem; + /** * @brief Handler for drop events, shared between DolphinView and TreeViewSidebarPage */ @@ -41,14 +44,13 @@ public: * destination. A context menu with the options * 'Move Here', 'Copy Here', 'Link Here' and * 'Cancel' is offered to the user. - * @param urls List of URLs which have been - * dropped. - * @param destination Destination URL, where the - * list or URLs should be moved, - * copied or linked to. + * @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 KUrl::List& urls, - const KUrl& destination); + void dropUrls(const KFileItem& destItem, + const KUrl& destPath, + QDropEvent* event); signals: /** diff --git a/src/dolphinfileplacesview.cpp b/src/dolphinfileplacesview.cpp index 4165b9049..a2291275d 100644 --- a/src/dolphinfileplacesview.cpp +++ b/src/dolphinfileplacesview.cpp @@ -19,6 +19,7 @@ #include "dolphinfileplacesview.h" #include "dolphindropcontroller.h" +#include <kfileitem.h> #include <konq_operations.h> DolphinFilePlacesView::DolphinFilePlacesView(QWidget* parent) : @@ -44,13 +45,11 @@ void DolphinFilePlacesView::mousePressEvent(QMouseEvent* event) void DolphinFilePlacesView::slotUrlsDropped(const KUrl& dest, QDropEvent* event, QWidget* parent) { - const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData()); - 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(urls, dest); + dropController.dropUrls(KFileItem(), dest, event); } void DolphinFilePlacesView::emitExtendedUrlChangedSignal(const KUrl& url) diff --git a/src/dolphiniconsview.cpp b/src/dolphiniconsview.cpp index 9947a2755..14a8b9fca 100644 --- a/src/dolphiniconsview.cpp +++ b/src/dolphiniconsview.cpp @@ -252,17 +252,9 @@ void DolphinIconsView::dragMoveEvent(QDragMoveEvent* event) void DolphinIconsView::dropEvent(QDropEvent* event) { - if (!selectionModel()->isSelected(indexAt(event->pos()))) { - const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData()); - if (!urls.isEmpty()) { - const QModelIndex index = indexAt(event->pos()); - const KFileItem item = m_controller->itemForIndex(index); - m_controller->indicateDroppedUrls(urls, - m_controller->url(), - item); - event->acceptProposedAction(); - } - } + const QModelIndex index = indexAt(event->pos()); + const KFileItem item = m_controller->itemForIndex(index); + m_controller->indicateDroppedUrls(item, m_controller->url(), event); KCategorizedView::dropEvent(event); } diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index da7f8e170..2ab725367 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -82,6 +82,8 @@ #include <QSplitter> #include <QDockWidget> +#include <kdebug.h> + DolphinMainWindow::DolphinMainWindow(int id) : KXmlGuiWindow(0), m_newMenu(0), @@ -155,13 +157,14 @@ void DolphinMainWindow::refreshViews() setActiveViewContainer(activeViewContainer); } -void DolphinMainWindow::dropUrls(const KUrl::List& urls, - const KUrl& destination) +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(urls, destination); + dropController.dropUrls(destItem, destPath, event); } void DolphinMainWindow::pasteIntoFolder() @@ -1056,8 +1059,9 @@ void DolphinMainWindow::setupDockWidgets() this, SLOT(handlePlacesClick(KUrl, Qt::MouseButtons))); connect(treeWidget, SIGNAL(changeSelection(KFileItemList)), this, SLOT(changeSelection(KFileItemList))); - connect(treeWidget, SIGNAL(urlsDropped(KUrl::List, KUrl)), - this, SLOT(dropUrls(KUrl::List, KUrl))); + // TODO: connecting to urlsDropped() fails! + connect(treeWidget, SIGNAL(urlsDropped(KFileItem&, KUrl&, QDropEvent*)), + this, SLOT(dropUrls(KFileItem&, KUrl&, QDropEvent*))); // setup "Terminal" #ifndef Q_OS_WIN diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index 48a829e39..2b7b247b5 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -41,6 +41,7 @@ class DolphinViewContainer; class KNewMenu; class KTabBar; class KUrl; +class QDropEvent; class QSplitter; /** @@ -107,8 +108,9 @@ public slots: * Handles the dropping of URLs to the given * destination. This is only called by the TreeViewSidebarPage. */ - void dropUrls(const KUrl::List& urls, - const KUrl& destination); + void dropUrls(const KFileItem& destItem, + const KUrl& destPath, + QDropEvent* event); /** * Pastes the clipboard data into the currently selected folder diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index c5e637c16..64aa10fd4 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -32,6 +32,7 @@ #include <kcolorscheme.h> #include <kdirlister.h> #include <kfileitemdelegate.h> +#include <kfilepreviewgenerator.h> #include <kiconeffect.h> #include <klocale.h> #include <kio/deletejob.h> @@ -58,7 +59,6 @@ #include "dolphinsettings.h" #include "dolphin_generalsettings.h" #include "folderexpander.h" -#include "kfilepreviewgenerator.h" #include "renamedialog.h" #include "tooltipmanager.h" #include "viewproperties.h" @@ -106,8 +106,8 @@ DolphinView::DolphinView(QWidget* parent, connect(m_controller, SIGNAL(requestContextMenu(const QPoint&)), this, SLOT(openContextMenu(const QPoint&))); - connect(m_controller, SIGNAL(urlsDropped(const KUrl::List&, const KUrl&, const KFileItem&)), - this, SLOT(dropUrls(const KUrl::List&, const KUrl&, const KFileItem&))); + connect(m_controller, SIGNAL(urlsDropped(const KFileItem&, const KUrl&, QDropEvent*)), + this, SLOT(dropUrls(const KFileItem&, const KUrl&, QDropEvent*))); connect(m_controller, SIGNAL(sortingChanged(DolphinView::Sorting)), this, SLOT(updateSorting(DolphinView::Sorting))); connect(m_controller, SIGNAL(sortOrderChanged(Qt::SortOrder)), @@ -816,21 +816,15 @@ void DolphinView::openContextMenu(const QPoint& pos) m_isContextMenuOpen = false; } -void DolphinView::dropUrls(const KUrl::List& urls, +void DolphinView::dropUrls(const KFileItem& destItem, const KUrl& destPath, - const KFileItem& destItem) + QDropEvent* event) { - Q_ASSERT(!urls.isEmpty()); - const KUrl destination = !destItem.isNull() && destItem.isDir() ? - destItem.url() : destPath; - const KUrl sourceDir = KUrl(urls.first().directory()); - if (sourceDir != destination) { - 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(urls, destination); - } + 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); } void DolphinView::updateSorting(DolphinView::Sorting sorting) diff --git a/src/dolphinview.h b/src/dolphinview.h index f0bacb989..661ef73d5 100644 --- a/src/dolphinview.h +++ b/src/dolphinview.h @@ -549,13 +549,13 @@ private slots: void openContextMenu(const QPoint& pos); /** - * Drops the URLs \a urls to the destination path \a destPath. If + * Drops dragged URLs to the destination path \a destPath. If * the URLs are dropped above an item inside the destination path, * the item is indicated by \a destItem. */ - void dropUrls(const KUrl::List& urls, + void dropUrls(const KFileItem& destItem, const KUrl& destPath, - const KFileItem& destItem); + QDropEvent* event); /** * Updates the view properties of the current URL to the diff --git a/src/sidebartreeview.cpp b/src/sidebartreeview.cpp index 0b18c260a..00c98f6e7 100644 --- a/src/sidebartreeview.cpp +++ b/src/sidebartreeview.cpp @@ -125,16 +125,11 @@ void SidebarTreeView::dragMoveEvent(QDragMoveEvent* event) void SidebarTreeView::dropEvent(QDropEvent* event) { - const KUrl::List urls = KUrl::List::fromMimeData(event->mimeData()); - if (urls.isEmpty()) { - KTreeView::dropEvent(event); - } else { - event->acceptProposedAction(); - const QModelIndex index = indexAt(event->pos()); - if (index.isValid()) { - emit urlsDropped(urls, index); - } + const QModelIndex index = indexAt(event->pos()); + if (index.isValid()) { + emit urlsDropped(index, event); } + KTreeView::dropEvent(event); } #include "sidebartreeview.moc" diff --git a/src/sidebartreeview.h b/src/sidebartreeview.h index f692be3a2..93bcbae2e 100644 --- a/src/sidebartreeview.h +++ b/src/sidebartreeview.h @@ -38,11 +38,10 @@ public: signals: /** - * Is emitted if the URLs \a urls have been dropped to + * Is emitted if the URL have been dropped to * the index \a index. */ - void urlsDropped(const KUrl::List& urls, - const QModelIndex& index); + void urlsDropped(const QModelIndex& index, QDropEvent* event); protected: virtual bool event(QEvent* event); diff --git a/src/treeviewsidebarpage.cpp b/src/treeviewsidebarpage.cpp index cbb6ecf8a..d349f7b0b 100644 --- a/src/treeviewsidebarpage.cpp +++ b/src/treeviewsidebarpage.cpp @@ -164,8 +164,8 @@ void TreeViewSidebarPage::showEvent(QShowEvent* event) connect(m_treeView, SIGNAL(clicked(const QModelIndex&)), this, SLOT(updateActiveView(const QModelIndex&))); - connect(m_treeView, SIGNAL(urlsDropped(const KUrl::List&, const QModelIndex&)), - this, SLOT(dropUrls(const KUrl::List&, const QModelIndex&))); + connect(m_treeView, SIGNAL(urlsDropped(const QModelIndex&, QDropEvent*)), + this, SLOT(dropUrls(const QModelIndex&, QDropEvent*))); connect(m_treeView, SIGNAL(pressed(const QModelIndex&)), this, SLOT(updateMouseButtons())); @@ -203,15 +203,14 @@ void TreeViewSidebarPage::updateActiveView(const QModelIndex& index) } } -void TreeViewSidebarPage::dropUrls(const KUrl::List& urls, - const QModelIndex& index) +void TreeViewSidebarPage::dropUrls(const QModelIndex& index, QDropEvent* event) { if (index.isValid()) { const QModelIndex dirIndex = m_proxyModel->mapToSource(index); KFileItem item = m_dolphinModel->itemForIndex(dirIndex); Q_ASSERT(!item.isNull()); if (item.isDir()) { - emit urlsDropped(urls, item.url()); + emit urlsDropped(item, item.url(), event); } } } diff --git a/src/treeviewsidebarpage.h b/src/treeviewsidebarpage.h index 6bc0ae6c3..80db7840b 100644 --- a/src/treeviewsidebarpage.h +++ b/src/treeviewsidebarpage.h @@ -72,7 +72,7 @@ signals: * This signal is emitted whenever a drop action on this widget needs the * MainWindow's attention. */ - void urlsDropped(const KUrl::List& urls, const KUrl& destination); + void urlsDropped(const KFileItem& destItem, const KUrl& destPath, QDropEvent* event); public slots: /** @@ -95,10 +95,10 @@ private slots: void updateActiveView(const QModelIndex& index); /** - * Is emitted if the URLs \a urls have been dropped - * to the index \a index. */ - void dropUrls(const KUrl::List& urls, - const QModelIndex& index); + * Is emitted if URLs have been dropped + * to the index \a index. + */ + void dropUrls(const QModelIndex& index, QDropEvent* event); /** * Invokes expandToLeafDir() asynchronously (the expanding |
