]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Opening a tab with the middle mouse button should always be done with one click,...
authorPeter Penz <peter.penz19@gmail.com>
Sun, 23 Nov 2008 12:28:10 +0000 (12:28 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Sun, 23 Nov 2008 12:28:10 +0000 (12:28 +0000)
BUG: 162986

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

src/dolphincolumnwidget.cpp
src/dolphincontroller.cpp
src/dolphincontroller.h
src/dolphindetailsview.cpp
src/dolphiniconsview.cpp

index ab0c3783cb71dc06092941891cf3d4eb96c22074..31f5c61935663652cb004e081bc99e3f6e44a021 100644 (file)
@@ -464,9 +464,8 @@ void DolphinColumnWidget::activate()
 {
     setFocus(Qt::OtherFocusReason);
 
-    // TODO: Connecting to the signal 'activated()' is not possible, as kstyle
-    // does not forward the single vs. doubleclick to it yet (KDE 4.1?). Hence it is
-    // necessary connecting the signal 'singleClick()' or 'doubleClick'.
+    connect(this, SIGNAL(clicked(const QModelIndex&)),
+            m_view->m_controller, SLOT(requestTab(const QModelIndex&)));
     if (KGlobalSettings::singleClick()) {
         connect(this, SIGNAL(clicked(const QModelIndex&)),
                 m_view->m_controller, SLOT(triggerItem(const QModelIndex&)));
index f6ee66634267940f58ae98edc17581e6bd069918..fe8c426f33acb544173441406ac883f46fa3196b 100644 (file)
@@ -170,26 +170,33 @@ KFileItem DolphinController::itemForIndex(const QModelIndex& index) const
 
 void DolphinController::triggerItem(const QModelIndex& index)
 {
-    if (m_mouseButtons & Qt::RightButton) {
-        // a context menu is opened - assure that no triggering is done
-        return;
+    if (m_mouseButtons & Qt::LeftButton) {
+        const KFileItem item = itemForIndex(index);
+        if (index.isValid() && (index.column() == KDirModel::Name)) {
+            emit itemTriggered(item);
+        } else {
+            m_itemView->clearSelection();
+            emit itemEntered(KFileItem());
+        }
+        m_mouseButtons = Qt::NoButton;
+    } else if (m_mouseButtons & Qt::RightButton) {
+        m_mouseButtons = Qt::NoButton;
     }
-    
-    const bool openTab = m_mouseButtons & Qt::MidButton;
-    m_mouseButtons = Qt::NoButton;
+}
 
-    const KFileItem item = itemForIndex(index);
-    if (index.isValid() && (index.column() == KDirModel::Name)) {
-        if (openTab && (item.isDir() || m_dolphinView->isTabsForFilesEnabled())) {
+void DolphinController::requestTab(const QModelIndex& index)
+{
+    if (m_mouseButtons & Qt::MidButton) {
+        const KFileItem item = itemForIndex(index);
+        const bool validRequest = index.isValid() &&
+                                  (index.column() == KDirModel::Name) &&
+                                  (item.isDir() || m_dolphinView->isTabsForFilesEnabled());
+        if (validRequest) {
             emit tabRequested(item.url());
-        } else {
-            emit itemTriggered(item);
-        }
-    } else {
-        m_itemView->clearSelection();
-        if (!openTab) {
-            emit itemEntered(KFileItem());
         }
+        m_mouseButtons = Qt::NoButton;
+    } else if (m_mouseButtons & Qt::RightButton) {
+        m_mouseButtons = Qt::NoButton;
     }
 }
 
index 13a840a3806f848c5af9c2dba68f06bf1a5efb82..77e965afe4acc08ff74c6064e481194981670f22 100644 (file)
@@ -60,6 +60,7 @@ class QWidget;
  * - indicateSortingChange()
  * - indicateSortOrderChanged()
  * - triggerItem()
+ * - openTab()
  * - handleKeyPressEvent()
  * - emitItemEntered()
  * - emitViewportEntered()
@@ -217,10 +218,19 @@ public:
 public slots:
     /**
      * Emits the signal itemTriggered() if the file item for the index \a index
-     * is not null. The method should be invoked by the
-     * controller parent whenever the user has triggered an item.
+     * is not null and the left mouse button has been pressed. If the item is
+     * null, the signal itemEntered() is emitted.
+     * The method should be invoked by the controller parent whenever the
+     * user has triggered an item.
      */
     void triggerItem(const QModelIndex& index);
+    
+    /**
+     * Emits the signal tabRequested(), if the file item for the index \a index
+     * represents a directory and when the middle mouse button has been pressed.
+     * The method should be invoked by the controller parent.
+     */
+    void requestTab(const QModelIndex& index);
 
     /**
      * Emits the signal itemEntered() if the file item for the index \a index
index 86a2865b8f9f179f144266762b105b1e7a793412..c4f54cec4da13e9af8bc9c41ae5efd6dfd136b0f 100644 (file)
@@ -96,10 +96,8 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr
     connect(parent, SIGNAL(sortOrderChanged(Qt::SortOrder)),
             this, SLOT(setSortIndicatorOrder(Qt::SortOrder)));
 
-    // TODO: Connecting to the signal 'activated()' is not possible, as kstyle
-    // does not forward the single vs. doubleclick to it yet (KDE 4.1?). Hence it is
-    // necessary connecting the signal 'singleClick()' or 'doubleClick' and to handle the
-    // RETURN-key in keyPressEvent().
+    connect(this, SIGNAL(clicked(const QModelIndex&)),
+            controller, SLOT(requestTab(const QModelIndex&)));
     if (KGlobalSettings::singleClick()) {
         connect(this, SIGNAL(clicked(const QModelIndex&)),
                 controller, SLOT(triggerItem(const QModelIndex&)));
index 0dd7dd7190ebb85fd697180770d8220d38679b6d..52be40b0230ceaa76ef8504b61213013200e7573 100644 (file)
@@ -62,10 +62,8 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
 
     setMouseTracking(true);
 
-    // TODO: Connecting to the signal 'activated()' is not possible, as kstyle
-    // does not forward the single vs. doubleclick to it yet (KDE 4.1?). Hence it is
-    // necessary connecting the signal 'singleClick()' or 'doubleClick' and to handle the
-    // RETURN-key in keyPressEvent().
+    connect(this, SIGNAL(clicked(const QModelIndex&)),
+            controller, SLOT(requestTab(const QModelIndex&)));
     if (KGlobalSettings::singleClick()) {
         connect(this, SIGNAL(clicked(const QModelIndex&)),
                 controller, SLOT(triggerItem(const QModelIndex&)));