Move the pasteIntoFolder() method from the contextmenu into DolphinView. This allows to show the information inside the statusbar, that the paste operation has been completed (also some code duplication can be prevented by the way).

svn path=/trunk/KDE/kdebase/apps/; revision=791436
This commit is contained in:
Peter Penz 2008-03-29 14:54:56 +00:00
parent 6816615900
commit c33b01efb2
6 changed files with 52 additions and 35 deletions

View file

@ -95,25 +95,6 @@ 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()
{
Q_ASSERT(m_context & TrashContext);
@ -435,14 +416,13 @@ QString DolphinContextMenu::placesName(const KUrl& url) const
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()));
connect(action, SIGNAL(triggered()), m_mainWindow, SLOT(pasteIntoFolder()));
} else {
action = m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::Paste));
}

View file

@ -69,9 +69,6 @@ public:
/** Opens the context menu model. */
void open();
private slots:
void pasteIntoFolder();
private:
void openTrashContextMenu();
void openTrashItemContextMenu();

View file

@ -87,7 +87,9 @@ DolphinMainWindow::DolphinMainWindow(int id) :
m_showMenuBar(0),
m_splitter(0),
m_activeViewContainer(0),
m_id(id)
m_id(id),
m_viewContainer(),
m_actionHandler(0)
{
setObjectName("Dolphin#");
m_viewContainer[PrimaryView] = 0;
@ -162,6 +164,11 @@ void DolphinMainWindow::dropUrls(const KUrl::List& urls,
dropController.dropUrls(urls, destination);
}
void DolphinMainWindow::pasteIntoFolder()
{
m_activeViewContainer->view()->pasteIntoFolder();
}
void DolphinMainWindow::changeUrl(const KUrl& url)
{
DolphinViewContainer* view = activeViewContainer();

View file

@ -109,6 +109,13 @@ public slots:
void dropUrls(const KUrl::List& urls,
const KUrl& destination);
/**
* Pastes the clipboard data into the currently selected folder
* of the active view. If not exactly one folder is selected,
* no pasting is done at all.
*/
void pasteIntoFolder();
/**
* Returns the main window ID used through DBus.
*/

View file

@ -607,17 +607,14 @@ void DolphinView::copySelectedItems()
void DolphinView::paste()
{
QClipboard* clipboard = QApplication::clipboard();
const QMimeData* mimeData = clipboard->mimeData();
pasteToUrl(url());
}
const KUrl::List sourceUrls = KUrl::List::fromMimeData(mimeData);
if (KonqMimeData::decodeIsCutSelection(mimeData)) {
KonqOperations::copy(this, KonqOperations::MOVE, sourceUrls, url());
emit doingOperation(KonqFileUndoManager::MOVE);
clipboard->clear();
} else {
KonqOperations::copy(this, KonqOperations::COPY, sourceUrls, url());
emit doingOperation(KonqFileUndoManager::COPY);
void DolphinView::pasteIntoFolder()
{
const KFileItemList items = selectedItems();
if ((items.count() == 1) && items.first().isDir()) {
pasteToUrl(items.first().url());
}
}
@ -1138,4 +1135,20 @@ bool DolphinView::isCutItem(const KFileItem& item) const
return false;
}
void DolphinView::pasteToUrl(const KUrl& url)
{
QClipboard* clipboard = QApplication::clipboard();
const QMimeData* mimeData = clipboard->mimeData();
const KUrl::List sourceUrls = KUrl::List::fromMimeData(mimeData);
if (KonqMimeData::decodeIsCutSelection(mimeData)) {
KonqOperations::copy(this, KonqOperations::MOVE, sourceUrls, url);
emit doingOperation(KonqFileUndoManager::MOVE);
clipboard->clear();
} else {
KonqOperations::copy(this, KonqOperations::COPY, sourceUrls, url);
emit doingOperation(KonqFileUndoManager::COPY);
}
}
#include "dolphinview.moc"

View file

@ -358,6 +358,13 @@ public slots:
/** Pastes the clipboard data to this view. */
void paste();
/**
* Pastes the clipboard data into the currently selected
* folder. If the current selection is not exactly one folder, no
* paste operation is done.
*/
void pasteIntoFolder();
/**
* Turns on the file preview for the all files of the current directory,
* if \a show is true.
@ -611,6 +618,12 @@ private:
*/
bool isCutItem(const KFileItem& item) const;
/**
* Helper method for DolphinView::paste() and DolphinView::pasteIntoFolder().
* Pastes the clipboard data into the URL \a url.
*/
void pasteToUrl(const KUrl& url);
/**
* Returns true, if the ColumnView is activated. As the column view
* requires some special handling for iterating through directories,