Ok, I got it to filter like I want it to ( the Problem was - as Wysota pointed out - casting the children ):
void QMyClass::refilterBrowseTree()
{
bool hide = true;
*cc = 0;
browseTree->setUpdatesEnabled(false);
for (int i = 0; i < browseTree->invisibleRootItem()->childCount(); ++i)
{
c = browseTree->invisibleRootItem()->child(i);
for (int ii = 0; ii < c->childCount(); ++ii)
{
cc = c->child(ii);
hide = false;
if (cc->type()==1000)
{
if ( !cc->text(0).contains(eBrowseFilter->text()) ) )
hide = true;
}
cc->setHidden(hide);
}
}
browseTree->setUpdatesEnabled(true);
browseTree->update();
}
void QMyClass::refilterBrowseTree()
{
bool hide = true;
QTreeWidgetItem *c = 0,
*cc = 0;
browseTree->setUpdatesEnabled(false);
for (int i = 0; i < browseTree->invisibleRootItem()->childCount(); ++i)
{
c = browseTree->invisibleRootItem()->child(i);
for (int ii = 0; ii < c->childCount(); ++ii)
{
cc = c->child(ii);
hide = false;
if (cc->type()==1000)
{
if ( !cc->text(0).contains(eBrowseFilter->text()) ) )
hide = true;
}
cc->setHidden(hide);
}
}
browseTree->setUpdatesEnabled(true);
browseTree->update();
}
To copy to clipboard, switch view to plain text mode
The only problem is that it takes about 20seconds to do it (the UI hangs during that time). ![Frown](images/smilies/frown.png)
There are about 17K items in the list, but filtering a treewidget in kde3/qt3 with klistviewsearchline didnt take any time (and klistviewsearchline iterates through the items as well if I understood it correctly)...
I had a closer look at Model/View-Programming and think it is really confusing. If you think there is no way around it I'll open a new thread and try to solve my problems with a new Model/View Thing, but if you have an idea how to to filter faster doing what I do right now, I would be happy!
Thanks!
Bookmarks