]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Places Panel: Implement PlacesItemModel::setHiddenItemsShown(false)
authorPeter Penz <peter.penz19@gmail.com>
Thu, 3 May 2012 20:26:10 +0000 (22:26 +0200)
committerPeter Penz <peter.penz19@gmail.com>
Thu, 3 May 2012 20:27:11 +0000 (22:27 +0200)
src/panels/places/placesitemmodel.cpp

index 4fb85dea095daa5bc9209f558a9e029d78c79f67..2e8cb67b1db11d56e7c26c8a7ae65acea69db5bd 100644 (file)
@@ -121,6 +121,7 @@ void PlacesItemModel::setHiddenItemsShown(bool show)
     m_hiddenItemsShown = show;
 
     if (show) {
+        // Move all items that are part of m_hiddenItems to the model.
         int modelIndex = 0;
         for (int hiddenIndex = 0; hiddenIndex < m_hiddenItems.count(); ++hiddenIndex) {
             if (m_hiddenItems[hiddenIndex]) {
@@ -133,7 +134,17 @@ void PlacesItemModel::setHiddenItemsShown(bool show)
             ++modelIndex;
         }
     } else {
-
+        // Move all items of the model, where the "isHidden" property is true, to
+        // m_hiddenItems.
+        Q_ASSERT(m_hiddenItems.count() == count());
+        for (int i = count() - 1; i >= 0; --i) {
+            KStandardItem* visibleItem = item(i);
+            if (visibleItem->dataValue("isHidden").toBool()) {
+                KStandardItem* hiddenItem = new KStandardItem(*visibleItem);
+                removeItem(i);
+                m_hiddenItems.insert(i, hiddenItem);
+            }
+        }
     }
 #ifdef PLACESITEMMODEL_DEBUG
         kDebug() << "Changed visibility of hidden items";