1.1 --- a/vymmodel.cpp Mon Mar 22 15:37:23 2010 +0000
1.2 +++ b/vymmodel.cpp Tue Mar 30 17:30:39 2010 +0000
1.3 @@ -503,6 +503,9 @@
1.4 updateActions();
1.5
1.6 if (mapEditor) mapEditor->setZoomFactorTarget (zoomFactor);
1.7 +
1.8 + //Update view (scene()->update() is not enough)
1.9 + qApp->processEvents(); // Update view (scene()->update() is not enough)
1.10 return err;
1.11 }
1.12
1.13 @@ -1650,22 +1653,41 @@
1.14 void VymModel::findAll (FindResultModel *rmodel, QString s, Qt::CaseSensitivity cs)
1.15 {
1.16 rmodel->clear();
1.17 + rmodel->setSearchString (s);
1.18 + rmodel->setSearchFlags (0); //FIXME-2 translate cs to QTextDocument::FindFlag
1.19 BranchItem *cur=NULL;
1.20 BranchItem *prev=NULL;
1.21 nextBranch(cur,prev);
1.22 +
1.23 + FindResultItem *lastParent=NULL;
1.24 while (cur)
1.25 {
1.26 + lastParent=NULL;
1.27 if (cur->getHeading().contains (s,cs))
1.28 + lastParent=rmodel->addItem (cur);
1.29 + QString n=cur->getNoteASCII();
1.30 + int i=0;
1.31 + int j=0;
1.32 + while ( i>=0)
1.33 {
1.34 - rmodel->addItem (cur);
1.35 - }
1.36 - int i=0;
1.37 - while (i>=0)
1.38 - {
1.39 - i=cur->getNote().indexOf (s,i,cs); //FIXME-2 add subitems to rmodel
1.40 + i=n.indexOf (s,i,cs); //FIXME-2 add subitems to rmodel
1.41 if (i>=0)
1.42 {
1.43 - rmodel->addSubItem (cur,"Note",cur,i);
1.44 + // If not there yet, add "parent" item
1.45 + if (!lastParent)
1.46 + {
1.47 + lastParent=rmodel->addItem (cur);
1.48 + if (!lastParent)
1.49 + qWarning()<<"VymModel::findAll still no lastParent?!";
1.50 + /*
1.51 + else
1.52 + lastParent->setSelectable (false);
1.53 + */
1.54 + }
1.55 +
1.56 + // save index of occurence
1.57 + rmodel->addSubItem (lastParent,QString(tr("Note","FindAll in VymModel")+" "+s),cur,j);
1.58 + j++;
1.59 i++;
1.60 }
1.61 }
1.62 @@ -1673,7 +1695,7 @@
1.63 }
1.64 }
1.65
1.66 -BranchItem* VymModel::findText (QString s,Qt::CaseSensitivity cs,QTextCursor &cursor)
1.67 +BranchItem* VymModel::findText (QString s,Qt::CaseSensitivity cs)
1.68 {
1.69 if (!s.isEmpty() && s!=findString)
1.70 {
1.71 @@ -1703,7 +1725,7 @@
1.72 if (findCurrent->getNote().contains(findString,cs))
1.73 {
1.74 select (findCurrent);
1.75 - if (textEditor->findText(findString,flags,cursor))
1.76 + if (textEditor->findText(findString,flags))
1.77 {
1.78 searching=false;
1.79 foundNote=true;
1.80 @@ -5064,6 +5086,20 @@
1.81 return false;
1.82 }
1.83
1.84 +bool VymModel::select (TreeItem *ti, int i)
1.85 +{
1.86 + if (!ti || i<0) return false;
1.87 + if (select (index(ti)))
1.88 + {
1.89 + qDebug ()<<"VM::select with index: "<<i<<" Trying to find text in note ";
1.90 + QTextCursor c=textEditor->getTextCursor();
1.91 + c.setPosition (i-1,QTextCursor::MoveAnchor);
1.92 + textEditor->setTextCursor (c);
1.93 + } else
1.94 + qDebug ()<<"VM::select with index: "<<i<<" Giving up to find text in note ";
1.95 + return true;
1.96 +}
1.97 +
1.98 bool VymModel::select (const QModelIndex &index)
1.99 {
1.100 if (index.isValid() )