From: Peter Penz Date: Thu, 3 May 2012 20:26:10 +0000 (+0200) Subject: Places Panel: Implement PlacesItemModel::setHiddenItemsShown(false) X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/067642a23cfd759442a541335e42cef0e8c09e7f Places Panel: Implement PlacesItemModel::setHiddenItemsShown(false) --- diff --git a/src/panels/places/placesitemmodel.cpp b/src/panels/places/placesitemmodel.cpp index 4fb85dea0..2e8cb67b1 100644 --- a/src/panels/places/placesitemmodel.cpp +++ b/src/panels/places/placesitemmodel.cpp @@ -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";