[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kdeui
From: Daniel Teske <teske () squorn ! de>
Date: 2005-07-11 23:04:54
Message-ID: 1121123094.075581.14491.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 433828 by teske:
KListViewSearchLine didn't unhide the right items.
Fix that with a new algorithm.
Thanks to Richard Smith for his help. He reviewed a earlier patch and
ensured that the algorithm is alot more readable.
BUG: 91476
M +38 -5 klistviewsearchline.cpp
M +1 -1 klistviewsearchline.h
--- trunk/KDE/kdelibs/kdeui/klistviewsearchline.cpp #433827:433828
@@ -353,15 +353,48 @@
}
}
-bool KListViewSearchLine::checkItemParentsVisible(QListViewItem *item)
+#include <kdebug.h>
+
+/** Check whether \p item, its siblings and their descendents should be shown. Show \
or hide the items as necessary. + *
+ * \p item The list view item to start showing / hiding items at. Typically, this \
is the first child of another item, or the + * the first child of the \
list view. + * \p highestHiddenParent The highest (closest to root) ancestor of \p \
item which is hidden. If 0, all parents of + * \p item must \
be visible. + * \return \c true if an item which should be visible is found, \c \
false if all items found should be hidden. If this function + * returns \
true and \p highestHiddenParent was not 0, highestHiddenParent will have been shown. \
+ */ +bool KListViewSearchLine::checkItemParentsVisible(QListViewItem *item, \
QListViewItem *highestHiddenParent) {
bool visible = false;
- for(; item; item = item->nextSibling()) {
- if((item->firstChild() && checkItemParentsVisible(item->firstChild())) ||
- itemMatches(item, d->search))
+ QListViewItem * first = item;
+ for(; item; item = item->nextSibling())
+ {
+ //What we pass to our children as highestHiddenParent:
+ QListViewItem * hhp = highestHiddenParent ? highestHiddenParent : \
item->isVisible() ? 0L : item; + bool childMatch = false;
+ if(item->firstChild() && checkItemParentsVisible(item->firstChild(), hhp))
+ childMatch = true;
+ // Should this item be shown? It should if any children should be, or if it \
matches. + if(childMatch || itemMatches(item, d->search))
{
- item->setVisible( true );
visible = true;
+ if (highestHiddenParent)
+ {
+ highestHiddenParent->setVisible(true);
+ // Calling setVisible on our ancestor will unhide all its \
descendents. Hide the ones + // before us that should not be shown.
+ for(QListViewItem *hide = first; hide != item; hide = \
hide->nextSibling()) + hide->setVisible(false);
+ highestHiddenParent = 0;
+ // If we matched, than none of our children matched, yet the \
setVisible() call on our + // ancestor unhid them, undo the damage:
+ if(!childMatch)
+ for(QListViewItem *hide = item->firstChild(); hide; hide = \
hide->nextSibling()) + hide->setVisible(false);
+ }
+ else
+ item->setVisible(true);
}
else
item->setVisible(false);
--- trunk/KDE/kdelibs/kdeui/klistviewsearchline.h #433827:433828
@@ -190,7 +190,7 @@
* It makes a recursive call to all children. It returns true if at least
* one item in the subtree with the given root item is visible.
*/
- bool checkItemParentsVisible(QListViewItem *item);
+ bool checkItemParentsVisible(QListViewItem *item, QListViewItem \
*highestHiddenParent = 0);
private slots:
void itemAdded(QListViewItem *item) const;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic