]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphincontroller.cpp
Fix compilation on OpenSolaris with Sun Studio
[dolphin.git] / src / dolphincontroller.cpp
index 408abd501ad72a86bf1ff6af745d90fdb595ec9c..b61c126b519452b473e9563cd5da6aae0f395c06 100644 (file)
@@ -75,13 +75,6 @@ void DolphinController::setItemView(QAbstractItemView* view)
     }
 }
 
-void DolphinController::triggerUrlChangeRequest(const KUrl& url)
-{
-    if (m_url != url) {
-        emit requestUrlChange(url);
-    }
-}
-
 void DolphinController::triggerContextMenuRequest(const QPoint& pos,
                                                   const QList<QAction*>& customActions)
 {
@@ -171,15 +164,34 @@ void DolphinController::handleKeyPressEvent(QKeyEvent* event)
     const QItemSelectionModel* selModel = m_itemView->selectionModel();
     const QModelIndex currentIndex = selModel->currentIndex();
     const bool trigger = currentIndex.isValid()
-                         && ((event->key() == Qt::Key_Return)
-                            || (event->key() == Qt::Key_Enter))
+                         && ((event->key() == Qt::Key_Return) || (event->key() == Qt::Key_Enter))
                          && !selModel->selectedIndexes().isEmpty();
-    if (trigger) {
-        const QModelIndexList indexList = selModel->selectedIndexes();
-        foreach (const QModelIndex& index, indexList) {
+    if (!trigger) {
+        return;
+    }
+
+    // Emit the signal itemTriggered() for all selected files.
+    // Several selected directories are opened in separate tabs,
+    // one selected directory will get opened in the view.
+    QModelIndexList dirQueue;
+    const QModelIndexList indexList = selModel->selectedIndexes();
+    foreach (const QModelIndex& index, indexList) {
+        if (itemForIndex(index).isDir()) {
+            dirQueue << index;
+        } else {
             emit itemTriggered(itemForIndex(index));
         }
     }
+
+    if (dirQueue.length() == 1) {
+        // open directory in the view
+        emit itemTriggered(itemForIndex(dirQueue[0]));
+    } else {
+        // open directories in separate tabs
+        foreach(const QModelIndex& dir, dirQueue) {
+            emit tabRequested(itemForIndex(dir).url());
+        }
+    }
 }
 
 void DolphinController::replaceUrlByClipboard()