]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Reimplement visualRegionForSelection in DolpinDetailsView.
authorFrank Reininghaus <frank78ac@googlemail.com>
Sun, 13 Dec 2009 18:18:08 +0000 (18:18 +0000)
committerFrank Reininghaus <frank78ac@googlemail.com>
Sun, 13 Dec 2009 18:18:08 +0000 (18:18 +0000)
Fixes the problem that not the entire area affected by changing the
selection gets updated. QTreeView::visualRegionForSelection assumes
implicitly that the visualRects of all items have the same width,
which is not the case here.

Fix will be in KDE 4.4 Beta 2.

BUG: 218114

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

src/dolphindetailsview.cpp
src/dolphindetailsview.h

index 1bf5f75e0062cd51a0007ae2c28462221db48f64..53d7fb95148ecca96930a5c465668c825c4047ed 100644 (file)
@@ -1,4 +1,4 @@
-/***************************************************************************
+    /***************************************************************************
  *   Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at)                  *
  *   Copyright (C) 2008 by Simon St. James (kdedevel@etotheipiplusone.com) *
  *                                                                         *
@@ -171,6 +171,21 @@ QSet<KUrl> DolphinDetailsView::expandedUrls() const
     return m_expandedUrls;
 }
 
+QRegion DolphinDetailsView::visualRegionForSelection(const QItemSelection &selection) const
+{
+    // We have to make sure that the visualRect of each model index is inside the region.
+    // QTreeView::visualRegionForSelection does not do it right because it assumes implicitly
+    // that all visualRects have the same width, which is in general not the case here.
+    QRegion selectionRegion;
+    const QModelIndexList indexes = selection.indexes();
+
+    foreach(const QModelIndex& index, indexes) {
+        selectionRegion += visualRect(index);
+    }
+
+    return selectionRegion;
+}
+
 bool DolphinDetailsView::event(QEvent* event)
 {
     if (event->type() == QEvent::Polish) {
index 30e126cd4f60c3582ce9fef4936b5e826635b2e5..3bd62d33fc7f9f077a671a92029f502ebd9450ee 100644 (file)
@@ -52,6 +52,8 @@ public:
      */
     QSet<KUrl> expandedUrls() const;
 
+    virtual QRegion visualRegionForSelection(const QItemSelection & selection) const;
+
 protected:
     virtual bool event(QEvent* event);
     virtual QStyleOptionViewItem viewOptions() const;