Permalink
Browse files

Finish up the pc-pkgmanager search algorithm, now it will also search…

… the top level items, and expand them properly as necessary
  • Loading branch information...
1 parent 2e7bf77 commit a96d2c0f99c2576281ac470cd45d58cdd639c849 Ken Moore committed Aug 19, 2013
Showing with 12 additions and 4 deletions.
  1. +12 −4 src-qt4/pc-pkgmanager/mainWin.cpp
@@ -139,9 +139,17 @@ bool mainWin::performSearch(QString pkgSearch, QTreeWidget *TW, QTreeWidgetItem
//Start Iterating over the tree
bool found=false;
bool started = false;
-
+ //if(SI==0){ started = true; }
for(int p=0; (p<TW->topLevelItemCount()) && !found; p++){
- found = searchChildren(pkgSearch, TW, TW->topLevelItem(p), started, SI);
+ //Check the actual item itself
+ QTreeWidgetItem *CI = TW->topLevelItem(p);
+ if(started && CI->text(0).contains(pkgSearch, Qt::CaseInsensitive)){
+ TW->setCurrentItem(CI);
+ TW->scrollToItem(CI);
+ found=true;
+ }else{
+ found = searchChildren(pkgSearch, TW, CI, started, SI);
+ }
}
return found;
}
@@ -156,7 +164,7 @@ bool mainWin::searchChildren(QString srch, QTreeWidget *TW, QTreeWidgetItem *CI,
//qDebug() << "Search Children of:" << CI->text(0) << srch << started;
//Check for the start position
int start = -1;
- if(SI == 0){
+ if(SI == 0 || SI == CI){
//No search item to start at
start = 0;
started = true;
@@ -181,7 +189,7 @@ bool mainWin::searchChildren(QString srch, QTreeWidget *TW, QTreeWidgetItem *CI,
found=true;
break;
}
- }else if( SI == CI->child(i) || SI == CI ){
+ }else if( SI == CI->child(i) ){
started = true; //but don't look at this item, continue on to the next one (or children)
}
if(found){ break; }

0 comments on commit a96d2c0

Please sign in to comment.