]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphindetailsview.cpp
fixed issue that CTRL + mouseclick did not work anymore in the details view
[dolphin.git] / src / dolphindetailsview.cpp
index d452826026067b5aad1bc44d3c95ed336e33ee41..e33b575009962676f3785c694037143eae6c59ff 100644 (file)
@@ -187,6 +187,7 @@ void DolphinDetailsView::mousePressEvent(QMouseEvent* event)
 {
     m_controller->requestActivation();
 
+    const QModelIndex current = currentIndex();
     QTreeView::mousePressEvent(event);
 
     m_expandingTogglePressed = false;
@@ -214,6 +215,9 @@ void DolphinDetailsView::mousePressEvent(QMouseEvent* event)
         if (!(modifier & Qt::ShiftModifier) && !(modifier & Qt::ControlModifier)) {
             clearSelection();
         }
+
+        // restore the current index, other columns are handled as viewport area
+        selectionModel()->setCurrentIndex(current, QItemSelectionModel::Current);
     }
 
     if ((event->button() == Qt::LeftButton) && !m_expandingTogglePressed) {
@@ -269,7 +273,18 @@ void DolphinDetailsView::mouseMoveEvent(QMouseEvent* event)
 
 void DolphinDetailsView::mouseReleaseEvent(QMouseEvent* event)
 {
-    QTreeView::mouseReleaseEvent(event);
+    const QModelIndex index = indexAt(event->pos());
+    if (index.isValid() && (index.column() == DolphinModel::Name)) {
+        QTreeView::mouseReleaseEvent(event);
+    } else {
+        // don't change the current index if the cursor is released
+        // above any other column than the name column, as the other
+        // columns act as viewport
+        const QModelIndex current = currentIndex();
+        QTreeView::mouseReleaseEvent(event);
+        selectionModel()->setCurrentIndex(current, QItemSelectionModel::Current);
+    }
+
     m_expandingTogglePressed = false;
     if (m_showElasticBand) {
         updateElasticBand();
@@ -363,7 +378,11 @@ void DolphinDetailsView::paintEvent(QPaintEvent* event)
 
 void DolphinDetailsView::keyPressEvent(QKeyEvent* event)
 {
-    m_keyPressed = true;
+    // If the Control modifier is pressed, a multiple selection
+    // is done and DolphinDetailsView::currentChanged() may not
+    // not change the selection in a custom way.
+    m_keyPressed = !(event->modifiers() & Qt::ControlModifier);
+
     QTreeView::keyPressEvent(event);
     m_controller->handleKeyPressEvent(event);
 }
@@ -444,12 +463,9 @@ void DolphinDetailsView::synchronizeSortingState(int column)
 
 void DolphinDetailsView::slotEntered(const QModelIndex& index)
 {
-    const QPoint pos = viewport()->mapFromGlobal(QCursor::pos());
-    const int nameColumnWidth = header()->sectionSize(DolphinModel::Name);
-    if (pos.x() < nameColumnWidth) {
+    if (index.column() == DolphinModel::Name) {
         m_controller->emitItemEntered(index);
-    }
-    else {
+    } else {
         m_controller->emitViewportEntered();
     }
 }