]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Rename Dolphin View's nameColumnRect member to visualRect.
authorFrank Reininghaus <frank78ac@googlemail.com>
Wed, 9 Dec 2009 18:38:54 +0000 (18:38 +0000)
committerFrank Reininghaus <frank78ac@googlemail.com>
Wed, 9 Dec 2009 18:38:54 +0000 (18:38 +0000)
This overrides QTreeView::visualRect, such that the "visual rect"
matches the area used in indexAt. Fixes the problem that the selection
loses items in the Details View when selecting new items with
Shift+Keyboard.

BUG: 217447

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

src/dolphindetailsview.cpp
src/dolphindetailsview.h

index bc15985415dfc03093ff83f83a491e67efab3b5e..1bf5f75e0062cd51a0007ae2c28462221db48f64 100644 (file)
@@ -445,10 +445,22 @@ QModelIndex DolphinDetailsView::indexAt(const QPoint& point) const
     // the blank portion of the name column counts as empty space
     const QModelIndex index = QTreeView::indexAt(point);
     const bool isAboveEmptySpace  = !m_useDefaultIndexAt &&
-                                    (index.column() == KDirModel::Name) && !nameColumnRect(index).contains(point);
+                                    (index.column() == KDirModel::Name) && !visualRect(index).contains(point);
     return isAboveEmptySpace ? QModelIndex() : index;
 }
 
+QRect DolphinDetailsView::visualRect(const QModelIndex& index) const
+{
+    QRect rect = QTreeView::visualRect(index);
+    const KFileItem item = m_controller->itemForIndex(index);
+    if (!item.isNull()) {
+        const int width = DolphinFileItemDelegate::nameColumnWidth(item.text(), viewOptions());
+        rect.setWidth(width);
+    }
+
+    return rect;
+}
+
 void DolphinDetailsView::setSelection(const QRect& rect, QItemSelectionModel::SelectionFlags command)
 {
     // We must override setSelection() as Qt calls it internally and when this happens
@@ -791,7 +803,7 @@ void DolphinDetailsView::updateElasticBandSelection()
    QModelIndex toggleIndexRangeBegin = QModelIndex();
 
    do {
-       QRect currIndexRect = nameColumnRect(currIndex);
+       QRect currIndexRect = visualRect(currIndex);
 
         // Update some optimization info as we go.
        const int cr = currIndexRect.right();
@@ -994,18 +1006,6 @@ void DolphinDetailsView::resizeColumns()
     headerView->resizeSection(KDirModel::Name, columnWidth[KDirModel::Name]);
 }
 
-QRect DolphinDetailsView::nameColumnRect(const QModelIndex& index) const
-{
-    QRect rect = visualRect(index);
-    const KFileItem item = m_controller->itemForIndex(index);
-    if (!item.isNull()) {
-        const int width = DolphinFileItemDelegate::nameColumnWidth(item.text(), viewOptions());
-        rect.setWidth(width);
-    }
-
-    return rect;
-}
-
 bool DolphinDetailsView::isAboveExpandingToggle(const QPoint& pos) const
 {
     // QTreeView offers no public API to get the information whether an index has an
@@ -1014,7 +1014,7 @@ bool DolphinDetailsView::isAboveExpandingToggle(const QPoint& pos) const
     if (itemsExpandable()) {
         const QModelIndex index = QTreeView::indexAt(pos);
         if (index.isValid() && (index.column() == KDirModel::Name)) {
-            QRect rect = nameColumnRect(index);
+            QRect rect = visualRect(index);
             const int toggleSize = rect.height();
             if (isRightToLeft()) {
                 rect.moveRight(rect.right());
index f9a795560ce5ef27d2cc619ec6c604705eae2a2e..30e126cd4f60c3582ce9fef4936b5e826635b2e5 100644 (file)
@@ -72,6 +72,7 @@ protected:
     virtual void currentChanged(const QModelIndex& current, const QModelIndex& previous);
     virtual bool eventFilter(QObject* watched, QEvent* event);
     virtual QModelIndex indexAt (const QPoint& point) const;
+    virtual QRect visualRect(const QModelIndex& index) const;
     virtual void setSelection(const QRect& rect, QItemSelectionModel::SelectionFlags command);
     virtual void scrollTo(const QModelIndex& index, ScrollHint hint = EnsureVisible);
 
@@ -206,8 +207,6 @@ private:
      */
     void resizeColumns();
 
-    QRect nameColumnRect(const QModelIndex& index) const;
-
     /**
      * Returns true, if \a pos is within the expanding toggle of a tree.
      */