]> cloud.milkyroute.net Git - dolphin.git/commitdiff
* open folders always on single click
authorPeter Penz <peter.penz19@gmail.com>
Sun, 8 Feb 2009 18:32:44 +0000 (18:32 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Sun, 8 Feb 2009 18:32:44 +0000 (18:32 +0000)
* open files/select files dependent from the global single click/double click setting
* open a new column when pressing the Key_Right

Thanks to Shaun Michael Reich for the original patches!

CCMAIL: predator106@gmail.com

svn path=/trunk/KDE/kdebase/apps/; revision=923423

src/dolphincolumnwidget.cpp
src/dolphincolumnwidget.h

index 4a6527c1bed6ea3b896e32a7b5d87193504082e7..d2701bdec1f8bde576761d7e451c33831f807279 100644 (file)
@@ -390,7 +390,19 @@ void DolphinColumnWidget::keyPressEvent(QKeyEvent* event)
 {
     QListView::keyPressEvent(event);
     requestActivation();
-    m_view->m_controller->handleKeyPressEvent(event);
+
+    DolphinController* controller = m_view->m_controller;
+    controller->handleKeyPressEvent(event);
+    if (event->key() == Qt::Key_Right) {
+        // Special key handling for the column: A Key_Right should
+        // open a new column for the currently selected folder.
+        const QModelIndex index = currentIndex();
+        const KFileItem item = controller->itemForIndex(index);
+        if (!item.isNull() && item.isDir()) {
+            controller->emitItemTriggered(item);
+        }
+    }
+
     if (m_toolTipManager != 0) {
         m_toolTipManager->hideTip();
     }
@@ -468,6 +480,28 @@ void DolphinColumnWidget::slotEntered(const QModelIndex& index)
     m_view->m_controller->emitItemEntered(index);
 }
 
+void DolphinColumnWidget::slotClicked(const QModelIndex& index)
+{
+    DolphinController* controller = m_view->m_controller;
+    if (KGlobalSettings::singleClick()) {
+        controller->triggerItem(index);
+    } else {
+        // even when using double click, a directory should be opened
+        // after the first click
+        const KFileItem item = controller->itemForIndex(index);
+        if (!item.isNull() && item.isDir()) {
+            controller->triggerItem(index);
+        }
+    }
+}
+
+void DolphinColumnWidget::slotDoubleClicked(const QModelIndex& index)
+{
+    if (!KGlobalSettings::singleClick()) {
+        m_view->m_controller->triggerItem(index);
+    }
+}
+
 void DolphinColumnWidget::requestActivation()
 {
     m_view->m_controller->setItemView(this);
@@ -496,10 +530,13 @@ void DolphinColumnWidget::activate()
     connect(this, SIGNAL(clicked(const QModelIndex&)),
             m_view->m_controller, SLOT(requestTab(const QModelIndex&)));
     connect(this, SIGNAL(clicked(const QModelIndex&)),
-            m_view->m_controller, SLOT(triggerItem(const QModelIndex&)));
+            this, SLOT(slotClicked(const QModelIndex&)));
+    connect(this, SIGNAL(doubleClicked(const QModelIndex&)),
+            this, SLOT(slotDoubleClicked(const QModelIndex&)));
 
-    if (selectionModel() && selectionModel()->currentIndex().isValid())
+    if (selectionModel() && selectionModel()->currentIndex().isValid()) {
         selectionModel()->setCurrentIndex(selectionModel()->currentIndex(), QItemSelectionModel::SelectCurrent);
+    }
 
     updateBackground();
 }
@@ -509,7 +546,9 @@ void DolphinColumnWidget::deactivate()
     clearFocus();
 
     disconnect(this, SIGNAL(clicked(const QModelIndex&)),
-               m_view->m_controller, SLOT(triggerItem(const QModelIndex&)));
+               this, SLOT(slotClicked(const QModelIndex&)));
+    disconnect(this, SIGNAL(doubleClicked(const QModelIndex&)),
+               this, SLOT(slotDoubleClicked(const QModelIndex&)));
 
     const QModelIndex current = selectionModel()->currentIndex();
     selectionModel()->clear();
index 38649ca9dca2fe038e152446d5f5246c5f1351bf..916bfac2ed1a7c8e6b383a7322db5ba4396ee899 100644 (file)
@@ -137,6 +137,8 @@ protected:
 
 private slots:
     void slotEntered(const QModelIndex& index);
+    void slotClicked(const QModelIndex& index);
+    void slotDoubleClicked(const QModelIndex& index);
     void requestActivation();
     void updateFont();