[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/apps/dolphin/src
From:       Peter Penz <peter.penz () gmx ! at>
Date:       2008-03-29 7:44:04
Message-ID: 1206776644.172268.16608.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 791354 by ppenz:

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

 M  +37 -2     dolphincontextmenu.cpp  
 M  +5 -0      dolphincontextmenu.h  
 M  +2 -44     dolphinview.cpp  


--- trunk/KDE/kdebase/apps/dolphin/src/dolphincontextmenu.cpp #791353:791354
@@ -95,7 +95,25 @@
     }
 }
 
+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);
@@ -230,7 +248,7 @@
     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 @@
     // 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 @@
     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"
--- trunk/KDE/kdebase/apps/dolphin/src/dolphincontextmenu.h #791353:791354
@@ -69,6 +69,9 @@
     /** Opens the context menu model. */
     void open();
 
+private slots:
+    void pasteIntoFolder();
+
 private:
     void openTrashContextMenu();
     void openTrashItemContextMenu();
@@ -108,6 +111,8 @@
      */
     QString placesName(const KUrl& url) const;
 
+    QAction* createPasteAction();
+
 private:
     struct Entry
     {
--- trunk/KDE/kdebase/apps/dolphin/src/dolphinview.cpp #791353:791354
@@ -1102,41 +1102,12 @@
     const QMimeData* mimeData = clipboard->mimeData();
 
     const KUrl::List sourceUrls = KUrl::List::fromMimeData(mimeData);
-
-    // per default the pasting is done into the current URL of the view
-    KUrl destUrl = url();
-
-    // check whether the pasting should be done into a selected directory
-    const KUrl::List selectedUrls = this->selectedUrls();
-    if (selectedUrls.count() == 1) {
-        const KFileItem fileItem(S_IFDIR,
-                                 KFileItem::Unknown,
-                                 selectedUrls.first(),
-                                 true);
-        if (fileItem.isDir()) {
-            // only one item is selected which is a directory, hence paste
-            // into this directory
-            destUrl = selectedUrls.first();
-            if (sourceUrls.contains(destUrl)) {
-                const QString text = i18nc("@info", "The folder \
                <filename>%1</filename> is pasted into itself. Is this intended?", \
                fileItem.name());
-                int result = KMessageBox::questionYesNo(window(),
-                                                        text,
-                                                        i18nc("@title:window", \
                "Paste into Folder"),
-                                                        \
                KGuiItem(i18nc("@action:button", "Paste"), "dialog-ok"),
-                                                        \
                KGuiItem(i18nc("@action:button", "Cancel"), "dialog-cancel"));
-                if (result == KMessageBox::No) {
-                    return;
-                }
-            }
-        }
-    }
-
     if (KonqMimeData::decodeIsCutSelection(mimeData)) {
-        KonqOperations::copy(this, KonqOperations::MOVE, sourceUrls, destUrl);
+        KonqOperations::copy(this, KonqOperations::MOVE, sourceUrls, url());
         emit doingOperation(KonqFileUndoManager::MOVE);
         clipboard->clear();
     } else {
-        KonqOperations::copy(this, KonqOperations::COPY, sourceUrls, destUrl);
+        KonqOperations::copy(this, KonqOperations::COPY, sourceUrls, url());
         emit doingOperation(KonqFileUndoManager::COPY);
     }
 }
@@ -1163,19 +1134,6 @@
         ret.second = i18nc("@action:inmenu", "Paste");
     }
 
-    if (ret.first) {
-        const KFileItemList items = selectedItems();
-        const uint count = items.count();
-        if (count > 1) {
-            // pasting should not be allowed when more than one file
-            // is selected
-            ret.first = false;
-        } else if (count == 1) {
-            // Only one file is selected. Pasting is only allowed if this
-            // file is a directory.
-            ret.first = items.first().isDir();
-        }
-    }
     return ret;
 }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic