diff options
| author | Peter Penz <[email protected]> | 2008-03-29 07:44:03 +0000 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2008-03-29 07:44:03 +0000 |
| commit | fc1503986032918ad84d420209c948b45c8bb375 (patch) | |
| tree | 06250b28b25778c0cc0c29f30a7855625cdf5ce1 /src/dolphincontextmenu.cpp | |
| parent | 2fdeb4f5bbbbb10ed98d43616740a52ed2fc14f7 (diff) | |
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
Diffstat (limited to 'src/dolphincontextmenu.cpp')
| -rw-r--r-- | src/dolphincontextmenu.cpp | 39 |
1 files changed, 37 insertions, 2 deletions
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" |
