]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Use KonqMimeData for the cut- and copy-operation instead of using bool property insid...
authorPeter Penz <peter.penz19@gmail.com>
Sun, 17 Dec 2006 13:47:45 +0000 (13:47 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Sun, 17 Dec 2006 13:47:45 +0000 (13:47 +0000)
svn path=/trunk/playground/utils/dolphin/; revision=614351

src/CMakeLists.txt
src/dolphinmainwindow.cpp
src/dolphinmainwindow.h

index 7c50ce550e4d7ead72d8fdb66eb9fe3a0e997a0c..569e178c19896e54556549294a4517e33cac71d8 100644 (file)
@@ -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})
 
index dd985fc1d1c939dfb75b5c704ebcee00e6cce6c3..3ed4a5403ad706ef63c2878ddc6a262c5a41cc14 100644 (file)
@@ -51,6 +51,7 @@
 #include <kstandarddirs.h>
 #include <krun.h>
 #include <klocale.h>
+#include <konqmimedata.h>
 
 #include <qclipboard.h>
 #include <q3dragobject.h>
 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 {
index e61e1775e8a6b899ce1642e58a52934aba22711c..b9a9db3d84e37c0e673cdba73c57992216a87533 100644 (file)
@@ -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<QAction*> fileGroupActions() const { return m_fileGroupActions; }
-    //QLinkedList<QAction*>& linkGroupActions() const { return m_linkGroupActions; }
-    //QLinkedList<QAction*>& 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<QAction*> m_fileGroupActions;
     KSortableList<CreateFileEntry,QString> m_createFileTemplates;
-
-    // TODO: not used yet. See documentation of DolphinMainWindow::linkGroupActions()
-    // and DolphinMainWindow::linkToDeviceActions() in for details.
-    //QLinkedList<QAction*> m_linkGroupActions;
-    //QLinkedList<QAction*> m_linkToDeviceActions;
 };
 
 #endif // _DOLPHIN_H_