]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphincontroller.cpp
Added right arrow key usage when in the Column View mode. When a directory is selecte...
[dolphin.git] / src / dolphincontroller.cpp
index 81cec286889b4f9231ecac65838424d10ba9982d..820d34a064cde1a84e006280241fc3b92a68dcc6 100644 (file)
 #include <QClipboard>
 #include <QDir>
 
+Qt::MouseButtons DolphinController::m_mouseButtons = Qt::NoButton;
+
 DolphinController::DolphinController(DolphinView* dolphinView) :
     QObject(dolphinView),
     m_zoomLevel(0),
-    m_mouseButtons(Qt::NoButton),
     m_url(),
     m_dolphinView(dolphinView),
     m_itemView(0)
@@ -128,14 +129,36 @@ 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) {
-            emit itemTriggered(itemForIndex(index));
+
+    if (currentIndex.isValid() && selModel->selectedIndexes().count() > 0) {
+        const int key = event->key();
+
+        if ((key == Qt::Key_Return) || (key == Qt::Key_Enter) || (key == Qt::Key_Right)) {
+
+            const QModelIndexList indexList = selModel->selectedIndexes();
+            const bool isColumnView = m_dolphinView->mode() == m_dolphinView->ColumnView;
+
+            if (key == Qt::Key_Right) {
+                if (isColumnView) {
+                    // If it is the right arrow key and in the column view-only.
+                    KFileItem curFileItem;
+                    foreach(const QModelIndex& index, indexList) {
+                        curFileItem = itemForIndex(index);
+                        if (!curFileItem.isFile()) {
+                            /* We want
+                            *  to make sure that the selected item
+                            *  is only a folder. If we did not have this check, it would be possible to use
+                            *  the right arrow to open a file when in the column view */
+                            emit itemTriggered(curFileItem);
+                        }
+                    }
+                }
+            } else {
+                //Else it is Return or Enter keypress, so it is okay to perform the action of triggering, on files also.
+                foreach(const QModelIndex& index, indexList) {
+                    emit itemTriggered(itemForIndex(index));
+                }
+            }
         }
     }
 }