]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Details view related fixes: all columns except the name column should act as viewport.
authorPeter Penz <peter.penz19@gmail.com>
Mon, 16 Jun 2008 21:56:20 +0000 (21:56 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Mon, 16 Jun 2008 21:56:20 +0000 (21:56 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=821229

src/dolphincontroller.cpp
src/dolphindetailsview.cpp
src/infosidebarpage.cpp
src/tooltipmanager.cpp

index 8a5ba55187b1792bd8b62c7d5ef479caa7304c3d..091b73796b3a4bc1859cb31aacfdb2511ede4232 100644 (file)
@@ -169,7 +169,7 @@ void DolphinController::triggerItem(const QModelIndex& index)
     } else {
         m_itemView->clearSelection();
         if (!openTab) {
-            emit itemEntered(item);
+            emit itemEntered(KFileItem());
         }
     }
 }
index d452826026067b5aad1bc44d3c95ed336e33ee41..12513420d5a450cc8e5d574d6b4b61df18cf5b03 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();
@@ -444,12 +459,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();
     }
 }
index b384f24e6d99e61915889ab55ed78bca00e14324..4cb4e22c6c34e778abc7158f09cd40557a518b66 100644 (file)
@@ -94,6 +94,14 @@ void InfoSidebarPage::setSelection(const KFileItemList& selection)
         return;
     }
 
+    if ((selection.count() == 0) && (m_selection.count() == 0)) {
+        // The selection has not really changed, only the current index.
+        // QItemSelectionModel emits a signal in this case and it is less
+        // expensive doing the check this way instead of patching
+        // DolphinView::emitSelectionChanged().
+        return;
+    }
+
     m_selection = selection;
 
     const int count = selection.count();
index 2edd008fc85256b65e119e534bb1a39dd222fc44..5bb1e1a32f75e5ccc71300aa711a2dd5ff5a5ed9 100644 (file)
@@ -76,15 +76,19 @@ bool ToolTipManager::eventFilter(QObject* watched, QEvent* event)
 
 void ToolTipManager::requestToolTip(const QModelIndex& index)
 {
-    KToolTip::hideTip();
+    if (index.column() == DolphinModel::Name) {
+        KToolTip::hideTip();
 
-    const QRect rect = m_view->visualRect(index);
-    m_pos = m_view->viewport()->mapToGlobal(rect.bottomRight());
+        const QRect rect = m_view->visualRect(index);
+        m_pos = m_view->viewport()->mapToGlobal(rect.bottomRight());
 
-    const QModelIndex dirIndex = m_proxyModel->mapToSource(index);
-    m_item = m_dolphinModel->itemForIndex(dirIndex);
+        const QModelIndex dirIndex = m_proxyModel->mapToSource(index);
+        m_item = m_dolphinModel->itemForIndex(dirIndex);
 
-    m_timer->start(500);
+        m_timer->start(500);
+    } else {
+        hideToolTip();
+    }
 }
 
 void ToolTipManager::hideToolTip()