From: Peter Penz Date: Sun, 17 Dec 2006 13:47:45 +0000 (+0000) Subject: Use KonqMimeData for the cut- and copy-operation instead of using bool property insid... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/8b240249dbc3ea965cbcb4d311aeba5c30e85127 Use KonqMimeData for the cut- and copy-operation instead of using bool property inside DolphinMainWindow. This assures that cut- and copy-operations also work within multiple Dolphin main windows. svn path=/trunk/playground/utils/dolphin/; revision=614351 --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7c50ce550..569e178c1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -57,7 +57,7 @@ kde4_add_kcfg_files(dolphin_SRCS kde4_add_executable(dolphin ${dolphin_SRCS}) -target_link_libraries(dolphin ${KDE4_KDECORE_LIBS} ${KDE4_KDEPRINT_LIBS} ) +target_link_libraries(dolphin ${KDE4_KDECORE_LIBS} ${KDE4_KDEPRINT_LIBS} konq ) install(TARGETS dolphin DESTINATION ${BIN_INSTALL_DIR}) diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index dd985fc1d..3ed4a5403 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -79,31 +80,19 @@ DolphinMainWindow::DolphinMainWindow() : KMainWindow(0), m_splitter(0), - m_activeView(0), - m_clipboardContainsCutData(false) + m_activeView(0) { setObjectName("Dolphin"); m_view[PrimaryIdx] = 0; m_view[SecondaryIdx] = 0; - - // TODO: the following members are not used yet. See documentation - // of DolphinMainWindow::linkGroupActions() and DolphinMainWindow::linkToDeviceActions() - // in the header file for details. } DolphinMainWindow::~DolphinMainWindow() { qDeleteAll(m_fileGroupActions); - //qDeleteAll(m_linkToDeviceActions); - //qDeleteAll(m_linkGroupActions); m_fileGroupActions.clear(); - //m_linkGroupActions.clear(); - //m_linkToDeviceActions.clear(); - /* - * bye, bye managed window - */ - DolphinApplication::app()->removeMainWindow( this ); + DolphinApplication::app()->removeMainWindow(this); } void DolphinMainWindow::setActiveView(DolphinView* view) @@ -653,25 +642,19 @@ void DolphinMainWindow::slotRedoTextChanged(const QString& text) void DolphinMainWindow::cut() { - // TODO: this boolean doesn't work between instances of dolphin or with konqueror or with other - // apps. The "application/x-kde-cutselection" mimetype should be used instead, see KonqMimeData - // in libkonq - m_clipboardContainsCutData = true; - QMimeData* mimeData = new QMimeData(); - const KUrl::List selectedUrls = m_activeView->selectedUrls(); - selectedUrls.populateMimeData(mimeData); - + const KUrl::List kdeUrls = m_activeView->selectedUrls(); + const KUrl::List mostLocalUrls; + KonqMimeData::populateMimeData(mimeData, kdeUrls, mostLocalUrls, true); QApplication::clipboard()->setMimeData(mimeData); } void DolphinMainWindow::copy() { - m_clipboardContainsCutData = false; - QMimeData* mimeData = new QMimeData(); - const KUrl::List selectedUrls = m_activeView->selectedUrls(); - selectedUrls.populateMimeData(mimeData); + const KUrl::List kdeUrls = m_activeView->selectedUrls(); + const KUrl::List mostLocalUrls; + KonqMimeData::populateMimeData(mimeData, kdeUrls, mostLocalUrls, false); QApplication::clipboard()->setMimeData(mimeData); } @@ -702,15 +685,8 @@ void DolphinMainWindow::paste() } } - // TODO #1: use libkonq commands (see doPaste() implementation - // KIO::Job* job = KIO::pasteClipboard(destUrl, this, false); - // ... - // TODO #2: this boolean doesn't work between instances of dolphin or with konqueror or with other - // apps. The "application/x-kde-cutselection" mimetype should be used instead, see KonqMimeData - // in libkonq - if (m_clipboardContainsCutData) { + if (KonqMimeData::decodeIsCutSelection(mimeData)) { moveUrls(sourceUrls, destUrl); - m_clipboardContainsCutData = false; clipboard->clear(); } else { diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index e61e1775e..b9a9db3d8 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -93,20 +93,12 @@ public: void dropUrls(const KUrl::List& urls, const KUrl& destination); - /** - * Returns 'true', if the clipboard contains data - * which has been cutted by the Cut action (Ctrl + X). - */ - bool clipboardContainsCutData() const { return m_clipboardContainsCutData; } - /** * Returns the list of actions which are part of the file group * of the 'Create New...' sub menu. Usually the list contains actions * for creating folders, text files, HTML files etc. */ QLinkedList fileGroupActions() const { return m_fileGroupActions; } - //QLinkedList& linkGroupActions() const { return m_linkGroupActions; } - //QLinkedList& linkToDeviceActions() const { return m_linkToDeviceActions; } /** * Refreshs the views of the main window by recreating them dependent from @@ -411,9 +403,6 @@ private: }; DolphinView* m_view[SecondaryIdx + 1]; - /// If set to true, the clipboard contains data which should be cutted after pasting. - bool m_clipboardContainsCutData; - /** * Asynchronous operations like 'Move' and 'Copy' may only be added as undo * operation after they have been finished successfully. When an asynchronous @@ -442,11 +431,6 @@ private: QLinkedList m_fileGroupActions; KSortableList m_createFileTemplates; - - // TODO: not used yet. See documentation of DolphinMainWindow::linkGroupActions() - // and DolphinMainWindow::linkToDeviceActions() in for details. - //QLinkedList m_linkGroupActions; - //QLinkedList m_linkToDeviceActions; }; #endif // _DOLPHIN_H_