[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/apps/dolphin/src
From:       Peter Penz <peter.penz19 () gmail ! com>
Date:       2011-01-09 15:03:30
Message-ID: 20110109150330.CCDF5AC8B3 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1213199 by ppenz:

Fix implementation of DolphinView::invertSelection() which assures that \
DolphinView::hasSelection() provides a valid return-value. This looks like an issue \
in Qt, but I did not have the time yet to provide a Qt-only example for a bug-report \
:-(


 M  +5 -15     tests/dolphinviewtest_allviewmodes.cpp  
 M  +16 -8     views/dolphinview.cpp  


--- trunk/KDE/kdebase/apps/dolphin/src/tests/dolphinviewtest_allviewmodes.cpp \
#1213198:1213199 @@ -83,14 +83,12 @@
     m_view->selectAll();
     verifySelectedItemsCount(totalItems);
 
-    // TODO: DolphinView::invertSelection() does not work in combination with \
                DolphinView::hasSelection(). Might
-    // be a Qt-issue - further investigations are needed.
-    //m_view->invertSelection();
-    //verifySelectedItemsCount(0);
-    //
-    //m_view->invertSelection();
-    //verifySelectedItemsCount(totalItems);
+    m_view->invertSelection();
+    verifySelectedItemsCount(0);
 
+    m_view->invertSelection();
+    verifySelectedItemsCount(totalItems);
+
     m_view->clearSelection();
     verifySelectedItemsCount(0);
 
@@ -149,14 +147,6 @@
         QVERIFY(m_view->hasSelection());
     }
     else {
-        if (mode() == DolphinView::ColumnView &&
-            itemView()->selectionModel()->selectedIndexes().count() == 0 &&
-            itemView()->selectionModel()->hasSelection()) {
-            QEXPECT_FAIL("",
-                         "The selection model's hasSelection() method returns true, \
                but there are no selected indexes. Needs to be investigated.",
-                         Continue);
-        }
-
         QVERIFY(!m_view->hasSelection());
     }
 }
--- trunk/KDE/kdebase/apps/dolphin/src/views/dolphinview.cpp #1213198:1213199
@@ -566,15 +566,23 @@
 
 void DolphinView::invertSelection()
 {
-    QItemSelectionModel* selectionModel = \
                m_viewAccessor.itemView()->selectionModel();
-    const QAbstractItemModel* itemModel = selectionModel->model();
+    // Implementation note: Using selectionModel->select(selection, \
QItemSelectionModel::Toggle) does not +    // work, as \
QItemSelectionModel::hasSelection() provides invalid values in this case. This might \
be a Qt-issue - +    // when changing the implementation with an updated Qt-version \
don't forget to run the Dolphin-unit-tests that +    // verify this usecase.
+    const KFileItemList selItems = selectedItems();
+    clearSelection();
 
-    const QModelIndex topLeft = itemModel->index(0, 0);
-    const QModelIndex bottomRight = itemModel->index(itemModel->rowCount() - 1,
-                                                     itemModel->columnCount() - 1);
+    QItemSelection invertedSelection;
+    foreach (const KFileItem& item, items()) {
+        if (!selItems.contains(item)) {
+            const QModelIndex index = \
m_viewAccessor.proxyModel()->mapFromSource(m_viewAccessor.dirModel()->indexForItem(item));
 +            invertedSelection.select(index, index);
+        }
+    }
 
-    const QItemSelection selection(topLeft, bottomRight);
-    selectionModel->select(selection, QItemSelectionModel::Toggle);
+    QItemSelectionModel* selectionModel = \
m_viewAccessor.itemView()->selectionModel(); +    \
selectionModel->select(invertedSelection, QItemSelectionModel::ClearAndSelect | \
QItemSelectionModel::Current);  }
 
 void DolphinView::clearSelection()
@@ -1100,7 +1108,7 @@
         foreach(const KFileItem& item, m_selectedItems) {
             url = item.url().upUrl();
             if (baseUrl.equals(url, KUrl::CompareWithoutTrailingSlash)) {
-                QModelIndex index = \
m_viewAccessor.proxyModel()->mapFromSource(m_viewAccessor.dirModel()->indexForItem(item));
 +                const QModelIndex index = \
m_viewAccessor.proxyModel()->mapFromSource(m_viewAccessor.dirModel()->indexForItem(item));
  newSelection.select(index, index);
             }
         }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic