From fc1503986032918ad84d420209c948b45c8bb375 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Sat, 29 Mar 2008 07:44:03 +0000 Subject: The paste operation should ignore the current selection to behave similar as Konqueror and other file managers. Only if a context menu for a folder is opened, a pasting should be done into this folder. Some internal cleanups are still required (see TODO comments), so that after finishing the operation an indication can be given to the user in the statusbar (must go for breakfast now, otherwise I'll eat my keyboard...). BUG: 159862 svn path=/trunk/KDE/kdebase/apps/; revision=791354 --- src/dolphincontextmenu.cpp | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) (limited to 'src/dolphincontextmenu.cpp') diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp index 008212bea..e17987fdd 100644 --- a/src/dolphincontextmenu.cpp +++ b/src/dolphincontextmenu.cpp @@ -95,6 +95,24 @@ void DolphinContextMenu::open() } } +void DolphinContextMenu::pasteIntoFolder() +{ + // TODO: this method should go into DolphinView (see DolphinContextMenu::createPasteAction()) + Q_ASSERT(m_selectedItems.count() == 1); + Q_ASSERT(m_fileInfo.isDir()); + + QClipboard* clipboard = QApplication::clipboard(); + const QMimeData* mimeData = clipboard->mimeData(); + + const KUrl::List source = KUrl::List::fromMimeData(mimeData); + const KUrl& dest = m_fileInfo.url(); + if (KonqMimeData::decodeIsCutSelection(mimeData)) { + KonqOperations::copy(m_mainWindow, KonqOperations::MOVE, source, dest); + clipboard->clear(); + } else { + KonqOperations::copy(m_mainWindow, KonqOperations::COPY, source, dest); + } +} void DolphinContextMenu::openTrashContextMenu() { @@ -230,7 +248,7 @@ void DolphinContextMenu::openViewportContextMenu() popup->addMenu(newMenu->menu()); popup->addSeparator(); - QAction* pasteAction = m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::Paste)); + QAction* pasteAction = createPasteAction(); popup->addAction(pasteAction); // setup 'View Mode' menu @@ -281,7 +299,7 @@ void DolphinContextMenu::insertDefaultItemActions(KMenu* popup) // insert 'Cut', 'Copy' and 'Paste' QAction* cutAction = collection->action(KStandardAction::name(KStandardAction::Cut)); QAction* copyAction = collection->action(KStandardAction::name(KStandardAction::Copy)); - QAction* pasteAction = collection->action(KStandardAction::name(KStandardAction::Paste)); + QAction* pasteAction = createPasteAction(); popup->addAction(cutAction); popup->addAction(copyAction); @@ -415,4 +433,21 @@ QString DolphinContextMenu::placesName(const KUrl& url) const return name; } +QAction* DolphinContextMenu::createPasteAction() +{ + // TODO: move this method as QAction* action pasteAction() into DolphinMainWindow + QAction* action = 0; + if ((m_selectedItems.count() == 1) && m_fileInfo.isDir()) { + action = new QAction(KIcon("edit-paste"), i18nc("@action:inmenu", "Paste Into Folder"), this); + const QMimeData* mimeData = QApplication::clipboard()->mimeData(); + const KUrl::List pasteData = KUrl::List::fromMimeData(mimeData); + action->setEnabled(!pasteData.isEmpty()); + connect(action, SIGNAL(triggered()), this, SLOT(pasteIntoFolder())); + } else { + action = m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::Paste)); + } + + return action; +} + #include "dolphincontextmenu.moc" -- cgit v1.3