]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphincontroller.cpp
BUG:222186
[dolphin.git] / src / dolphincontroller.cpp
index 47c661e83ee623d8ed65d391ee20beb0da780130..0bbf0557a178d04f3bb7065524400cb74f66ddbc 100644 (file)
@@ -34,7 +34,8 @@ DolphinController::DolphinController(DolphinView* dolphinView) :
     m_nameFilter(),
     m_url(),
     m_dolphinView(dolphinView),
-    m_itemView(0)
+    m_itemView(0),
+    m_versionControlActions()
 {
 }
 
@@ -46,10 +47,16 @@ void DolphinController::setUrl(const KUrl& url)
 {
     if (m_url != url) {
         m_url = url;
+        emit cancelPreviews();
         emit urlChanged(url);
     }
 }
 
+void DolphinController::redirectToUrl(const KUrl& url)
+{
+    m_url = url;
+}
+
 void DolphinController::setItemView(QAbstractItemView* view)
 {
     if (m_itemView != 0) {
@@ -143,6 +150,20 @@ void DolphinController::setZoomLevel(int level)
     }
 }
 
+void DolphinController::setVersionControlActions(QList<QAction*> actions)
+{
+    m_versionControlActions = actions;
+}
+
+QList<QAction*> DolphinController::versionControlActions(const KFileItemList& items)
+{
+    emit requestVersionControlActions(items);
+    // All view implementations are connected with the signal requestVersionControlActions()
+    // (see ViewExtensionFactory) and will invoke DolphinController::setVersionControlActions(),
+    // so that the context dependent actions can be returned.
+    return m_versionControlActions;
+}
+
 void DolphinController::handleKeyPressEvent(QKeyEvent* event)
 {
     Q_ASSERT(m_itemView != 0);
@@ -154,9 +175,28 @@ void DolphinController::handleKeyPressEvent(QKeyEvent* event)
                             || (event->key() == Qt::Key_Enter))
                          && !selModel->selectedIndexes().isEmpty();
     if (trigger) {
+        QModelIndexList dirQueue;
         const QModelIndexList indexList = selModel->selectedIndexes();
         foreach (const QModelIndex& index, indexList) {
-            emit itemTriggered(itemForIndex(index));
+            // Trigger non-directories immediately.
+            if (!itemForIndex(index).isDir()) {
+                emit itemTriggered(itemForIndex(index));
+            } else {
+                // Keep storing the directory indexes for trigger later.
+                dirQueue << index;
+            }
+        }
+        // Trigger directories - Tabs if multiple, else normal.
+        if (!dirQueue.isEmpty()) {
+            if (dirQueue.length() == 1) {
+                // For single directory selection, open normally.
+                emit itemTriggered(itemForIndex(dirQueue[0]));
+            } else {
+                foreach(const QModelIndex& dir, dirQueue) {
+                    // Since its a valid directory - open a tab.
+                    emit tabRequested(itemForIndex(dir).url());
+                }
+            }
         }
     }
 }