]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fix Bug 304299 - Dolphin launches multiple instances of a program when multiple files...
authorEmmanuel Pescosta <emmanuelpescosta099@gmail.com>
Thu, 13 Dec 2012 21:54:09 +0000 (22:54 +0100)
committerEmmanuel Pescosta <emmanuelpescosta099@gmail.com>
Thu, 13 Dec 2012 21:54:09 +0000 (22:54 +0100)
BUG: 304299
REVIEW: 107305

src/dolphinpart.cpp
src/dolphinpart.h
src/dolphinviewcontainer.cpp
src/dolphinviewcontainer.h
src/views/dolphinview.cpp
src/views/dolphinview.h

index ccc91fd7ddac6aa2c11a196a376008efd9246968..627ba79c56570e87e01d61c40288761aa8610294 100644 (file)
@@ -90,6 +90,8 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL
             this, SLOT(slotErrorMessage(QString)));
     connect(m_view, SIGNAL(itemActivated(KFileItem)),
             this, SLOT(slotItemActivated(KFileItem)));
+    connect(m_view, SIGNAL(itemsActivated(KFileItemList)),
+            this, SLOT(slotItemsActivated(KFileItemList)));
     connect(m_view, SIGNAL(tabRequested(KUrl)),
             this, SLOT(createNewWindow(KUrl)));
     connect(m_view, SIGNAL(requestContextMenu(QPoint,KFileItem,KUrl,QList<QAction*>)),
@@ -367,6 +369,13 @@ void DolphinPart::slotItemActivated(const KFileItem& item)
     emit m_extension->openUrlRequest(item.targetUrl(), args, browserArgs);
 }
 
+void DolphinPart::slotItemsActivated(const KFileItemList& items)
+{
+    foreach (const KFileItem& item, items) {
+        slotItemActivated(item);
+    }
+}
+
 void DolphinPart::createNewWindow(const KUrl& url)
 {
     // TODO: Check issue N176832 for the missing QAIV signal; task 177399 - maybe this code
index e5693b363744a06937dc065a0d1165fafc30972b..7881ded43c15a1c1d9e4adeee11fe9427c81f272 100644 (file)
@@ -128,6 +128,10 @@ private Q_SLOTS:
      * Handles clicking on an item
      */
     void slotItemActivated(const KFileItem& item);
+    /**
+     * Handles activation of multiple items
+     */
+    void slotItemsActivated(const KFileItemList& items);
     /**
      * Creates a new window showing the content of \a url.
      */
index 6e99437d9aef61fd0fd72338e9d5c27c65b64a57..c27550ae10a7336434596faa9e2b5fbdad2d12b6 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <KDesktopFile>
 #include <KFileItemDelegate>
+#include <KFileItemActions>
 #include <KFilePlacesModel>
 #include <KLocale>
 #include <KIconEffect>
@@ -108,6 +109,7 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
     connect(m_view, SIGNAL(writeStateChanged(bool)),            this, SIGNAL(writeStateChanged(bool)));
     connect(m_view, SIGNAL(requestItemInfo(KFileItem)),         this, SLOT(showItemInfo(KFileItem)));
     connect(m_view, SIGNAL(itemActivated(KFileItem)),           this, SLOT(slotItemActivated(KFileItem)));
+    connect(m_view, SIGNAL(itemsActivated(KFileItemList)),      this, SLOT(slotItemsActivated(KFileItemList)));
     connect(m_view, SIGNAL(redirection(KUrl,KUrl)),             this, SLOT(redirect(KUrl,KUrl)));
     connect(m_view, SIGNAL(directoryLoadingStarted()),          this, SLOT(slotDirectoryLoadingStarted()));
     connect(m_view, SIGNAL(directoryLoadingCompleted()),        this, SLOT(slotDirectoryLoadingCompleted()));
@@ -509,6 +511,14 @@ void DolphinViewContainer::slotItemActivated(const KFileItem& item)
     item.run();
 }
 
+void DolphinViewContainer::slotItemsActivated(const KFileItemList& items)
+{
+    Q_ASSERT(items.count() >= 2);
+
+    KFileItemActions fileItemActions(this);
+    fileItemActions.runPreferredApplications(items, QString());
+}
+
 void DolphinViewContainer::showItemInfo(const KFileItem& item)
 {
     if (item.isNull()) {
index 0300273c1476ce8ea22908d8e50e50d1dd7edb5e..e2d1b18752ba36e318c3357d6d89da0c3d459309 100644 (file)
@@ -214,6 +214,12 @@ private slots:
      */
     void slotItemActivated(const KFileItem& item);
 
+    /**
+     * Handles activation of multiple files. The files get started by
+     * the corresponding applications.
+     */
+    void slotItemsActivated(const KFileItemList& items);
+
     /**
      * Shows the information for the item \a item inside the statusbar. If the
      * item is null, the default statusbar information is shown.
index 57c94a33befc59821bc37e912226d199dba5cfc5..941083fdeedd1c1a6f8e3867ff5317155174506a 100644 (file)
@@ -792,29 +792,34 @@ void DolphinView::slotItemsActivated(const QSet<int>& indexes)
 {
     Q_ASSERT(indexes.count() >= 2);
 
-    KFileItemList items;
-
-    QSetIterator<int> it(indexes);
-    while (it.hasNext()) {
-        const int index = it.next();
-        items.append(m_model->fileItem(index));
-    }
-
-    if (items.count() > 5) {
-        QString question = i18np("Are you sure you want to open 1 item?", "Are you sure you want to open %1 items?", items.count());
+    if (indexes.count() > 5) {
+        QString question = i18np("Are you sure you want to open 1 item?", "Are you sure you want to open %1 items?", indexes.count());
         const int answer = KMessageBox::warningYesNo(this, question);
         if (answer != KMessageBox::Yes) {
             return;
         }
     }
 
-    foreach (const KFileItem& item, items) {
-        if (item.isDir()) {
+    KFileItemList items;
+    items.reserve(indexes.count());
+
+    QSetIterator<int> it(indexes);
+    while (it.hasNext()) {
+        const int index = it.next();
+        KFileItem item = m_model->fileItem(index);
+
+        if (item.isDir()) { // Open folders in new tabs
             emit tabRequested(item.url());
         } else {
-            emit itemActivated(item);
+            items.append(item);
         }
     }
+
+    if (items.count() == 1) {
+        emit itemActivated(items.first());
+    } else if (items.count() > 1) {
+        emit itemsActivated(items);
+    }
 }
 
 void DolphinView::slotItemMiddleClicked(int index)
index 6d15ebf3239f7e84e2b90b992fdb67d0f01dba05..a2fe9f62a13fe8629b52cb8b24efa15b898a1011 100644 (file)
@@ -385,6 +385,12 @@ signals:
      */
     void itemActivated(const KFileItem& item);
 
+    /**
+     * Is emitted when multiple items have been activated by e. g.
+     * context menu open with.
+     */
+    void itemsActivated(const KFileItemList& items);
+
     /**
      * Is emitted if items have been added or deleted.
      */