diff -r 46553c106c52 -r bec082472471 vymmodel.cpp --- a/vymmodel.cpp Mon Mar 22 15:37:23 2010 +0000 +++ b/vymmodel.cpp Tue Mar 30 17:30:39 2010 +0000 @@ -503,6 +503,9 @@ updateActions(); if (mapEditor) mapEditor->setZoomFactorTarget (zoomFactor); + + //Update view (scene()->update() is not enough) + qApp->processEvents(); // Update view (scene()->update() is not enough) return err; } @@ -1650,22 +1653,41 @@ void VymModel::findAll (FindResultModel *rmodel, QString s, Qt::CaseSensitivity cs) { rmodel->clear(); + rmodel->setSearchString (s); + rmodel->setSearchFlags (0); //FIXME-2 translate cs to QTextDocument::FindFlag BranchItem *cur=NULL; BranchItem *prev=NULL; nextBranch(cur,prev); + + FindResultItem *lastParent=NULL; while (cur) { + lastParent=NULL; if (cur->getHeading().contains (s,cs)) + lastParent=rmodel->addItem (cur); + QString n=cur->getNoteASCII(); + int i=0; + int j=0; + while ( i>=0) { - rmodel->addItem (cur); - } - int i=0; - while (i>=0) - { - i=cur->getNote().indexOf (s,i,cs); //FIXME-2 add subitems to rmodel + i=n.indexOf (s,i,cs); //FIXME-2 add subitems to rmodel if (i>=0) { - rmodel->addSubItem (cur,"Note",cur,i); + // If not there yet, add "parent" item + if (!lastParent) + { + lastParent=rmodel->addItem (cur); + if (!lastParent) + qWarning()<<"VymModel::findAll still no lastParent?!"; + /* + else + lastParent->setSelectable (false); + */ + } + + // save index of occurence + rmodel->addSubItem (lastParent,QString(tr("Note","FindAll in VymModel")+" "+s),cur,j); + j++; i++; } } @@ -1673,7 +1695,7 @@ } } -BranchItem* VymModel::findText (QString s,Qt::CaseSensitivity cs,QTextCursor &cursor) +BranchItem* VymModel::findText (QString s,Qt::CaseSensitivity cs) { if (!s.isEmpty() && s!=findString) { @@ -1703,7 +1725,7 @@ if (findCurrent->getNote().contains(findString,cs)) { select (findCurrent); - if (textEditor->findText(findString,flags,cursor)) + if (textEditor->findText(findString,flags)) { searching=false; foundNote=true; @@ -5064,6 +5086,20 @@ return false; } +bool VymModel::select (TreeItem *ti, int i) +{ + if (!ti || i<0) return false; + if (select (index(ti))) + { + qDebug ()<<"VM::select with index: "<getTextCursor(); + c.setPosition (i-1,QTextCursor::MoveAnchor); + textEditor->setTextCursor (c); + } else + qDebug ()<<"VM::select with index: "<