]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphincontroller.cpp
Use KFileItem::text() instead of name() for pretty printed filenames
[dolphin.git] / src / dolphincontroller.cpp
index b128c90335e2c89804458b7a0ac88f1b86f9b47d..caa0aa74faec9ca6b43eac62eb9f4349725b41db 100644 (file)
@@ -31,9 +31,11 @@ Qt::MouseButtons DolphinController::m_mouseButtons = Qt::NoButton;
 DolphinController::DolphinController(DolphinView* dolphinView) :
     QObject(dolphinView),
     m_zoomLevel(0),
+    m_nameFilter(),
     m_url(),
     m_dolphinView(dolphinView),
-    m_itemView(0)
+    m_itemView(0),
+    m_versionControlActions()
 {
 }
 
@@ -45,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) {
@@ -104,6 +112,11 @@ void DolphinController::indicateSortOrderChange(Qt::SortOrder order)
     emit sortOrderChanged(order);
 }
 
+void DolphinController::indicateSortFoldersFirstChange(bool foldersFirst)
+{
+    emit sortFoldersFirstChanged(foldersFirst);
+}
+
 void DolphinController::indicateAdditionalInfoChange(const KFileItemDelegate::InformationList& info)
 {
     emit additionalInfoChanged(info);
@@ -114,6 +127,19 @@ void DolphinController::indicateActivationChange(bool active)
     emit activationChanged(active);
 }
 
+void DolphinController::setNameFilter(const QString& nameFilter)
+{
+    if (nameFilter != m_nameFilter) {
+        m_nameFilter = nameFilter;
+        emit nameFilterChanged(nameFilter);
+    }
+}
+
+QString DolphinController::nameFilter() const
+{
+    return m_nameFilter;
+}
+
 void DolphinController::setZoomLevel(int level)
 {
     Q_ASSERT(level >= ZoomLevelInfo::minimumLevel());
@@ -124,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);
@@ -131,15 +171,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))
-                         && (selModel->selectedIndexes().count() > 0);
-    if (trigger) {
-        const QModelIndexList indexList = selModel->selectedIndexes();
-        foreach (const QModelIndex& index, indexList) {
+                         && ((event->key() == Qt::Key_Return) || (event->key() == Qt::Key_Enter))
+                         && !selModel->selectedIndexes().isEmpty();
+    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()