1.1 --- a/vymmodel.cpp Wed Feb 04 16:33:16 2009 +0000
1.2 +++ b/vymmodel.cpp Fri Mar 06 15:02:58 2009 +0000
1.3 @@ -125,7 +125,8 @@
1.4 selModel=NULL;
1.5
1.6 // find routine
1.7 - itFind=NULL;
1.8 + findCurrent=NULL;
1.9 + findPrevious=NULL;
1.10 EOFind=false;
1.11
1.12 // animations
1.13 @@ -1490,33 +1491,38 @@
1.14 }
1.15 }
1.16
1.17 -BranchObj* VymModel::findText (QString s, bool cs) // FIXME needs to converted to first() next() next (ti)
1.18 +BranchObj* VymModel::findText (QString s, bool cs)
1.19 {
1.20 - /*
1.21 + int d=0;
1.22 QTextDocument::FindFlags flags=0;
1.23 if (cs) flags=QTextDocument::FindCaseSensitively;
1.24
1.25 - if (!itFind)
1.26 + if (!findCurrent)
1.27 { // Nothing found or new find process
1.28 if (EOFind)
1.29 // nothing found, start again
1.30 EOFind=false;
1.31 - itFind=first();
1.32 + findCurrent=NULL;
1.33 + findPrevious=NULL;
1.34 + next (findCurrent,findPrevious,d);
1.35 }
1.36 bool searching=true;
1.37 bool foundNote=false;
1.38 while (searching && !EOFind)
1.39 {
1.40 - if (itFind)
1.41 + if (findCurrent)
1.42 {
1.43 // Searching in Note
1.44 - if (itFind->getNote().contains(s,cs))
1.45 + if (findCurrent->getNote().contains(s,cs))
1.46 {
1.47 + select (findCurrent);
1.48 + /*
1.49 if (getSelectedBranch()!=itFind)
1.50 {
1.51 select(itFind);
1.52 ensureSelectionVisible();
1.53 }
1.54 + */
1.55 if (textEditor->findText(s,flags))
1.56 {
1.57 searching=false;
1.58 @@ -1524,17 +1530,16 @@
1.59 }
1.60 }
1.61 // Searching in Heading
1.62 - if (searching && itFind->getHeading().contains (s,cs) )
1.63 + if (searching && findCurrent->getHeading().contains (s,cs) )
1.64 {
1.65 - select(itFind);
1.66 - ensureSelectionVisible();
1.67 + select(findCurrent);
1.68 searching=false;
1.69 }
1.70 }
1.71 if (!foundNote)
1.72 {
1.73 - itFind=next(itFind);
1.74 - if (!itFind) EOFind=true;
1.75 + if (!next(findCurrent,findPrevious,d) )
1.76 + EOFind=true;
1.77 }
1.78 //cout <<"still searching... "<<qPrintable( itFind->getHeading())<<endl;
1.79 }
1.80 @@ -1542,12 +1547,12 @@
1.81 return getSelectedBranch();
1.82 else
1.83 return NULL;
1.84 - */
1.85 }
1.86
1.87 void VymModel::findReset()
1.88 { // Necessary if text to find changes during a find process
1.89 - itFind=NULL;
1.90 + findCurrent=NULL;
1.91 + findPrevious=NULL;
1.92 EOFind=false;
1.93 }
1.94
1.95 @@ -1979,7 +1984,7 @@
1.96 {
1.97 MapCenterObj *mco=addMapCenter (contextPos);
1.98 cout <<"VM::addMCO () mapScene="<<mapScene<<endl;
1.99 - selection.select (mco);
1.100 + //FIXME selection.select (mco);
1.101 updateActions();
1.102 ensureSelectionVisible();
1.103 saveState (
1.104 @@ -3897,13 +3902,16 @@
1.105 else
1.106 linkstyle=LinkableMapObj::UndefinedStyle;
1.107
1.108 - TreeItem *ti=first();
1.109 + TreeItem *cur=NULL;
1.110 + TreeItem *prev=NULL;
1.111 + int d=0;
1.112 BranchObj *bo;
1.113 - while (ti)
1.114 + next (cur,prev,d);
1.115 + while (cur)
1.116 {
1.117 - bo=(BranchObj*)(ti->getLMO() );
1.118 + bo=(BranchObj*)(cur->getLMO() );
1.119 bo->setLinkStyle(bo->getDefLinkStyle());
1.120 - ti=next();
1.121 + cur=next(cur,prev,d);
1.122 }
1.123 reposition();
1.124 }
1.125 @@ -3923,14 +3931,16 @@
1.126 );
1.127
1.128 defLinkColor=col;
1.129 - TreeItem *ti;
1.130 + TreeItem *cur=NULL;
1.131 + TreeItem *prev=NULL;
1.132 + int d=0;
1.133 BranchObj *bo;
1.134 - ti=first();
1.135 - while (ti)
1.136 + cur=next(cur,prev,d);
1.137 + while (cur)
1.138 {
1.139 - bo=(BranchObj*)(ti->getLMO() );
1.140 + bo=(BranchObj*)(cur->getLMO() );
1.141 bo->setLinkColor();
1.142 - ti=next();
1.143 + next(cur,prev,d);
1.144 }
1.145 updateActions();
1.146 }
1.147 @@ -3938,14 +3948,16 @@
1.148 void VymModel::setMapLinkColorHintInt()
1.149 {
1.150 // called from setMapLinkColorHint(lch) or at end of parse
1.151 - TreeItem *ti;
1.152 + TreeItem *cur=NULL;
1.153 + TreeItem *prev=NULL;
1.154 + int d=0;
1.155 BranchObj *bo;
1.156 - ti=first();
1.157 - while (ti)
1.158 + cur=next(cur,prev,d);
1.159 + while (cur)
1.160 {
1.161 - bo=(BranchObj*)(ti->getLMO() );
1.162 + bo=(BranchObj*)(cur->getLMO() );
1.163 bo->setLinkColor();
1.164 - ti=next();
1.165 + cur=next(cur,prev,d);
1.166 }
1.167 }
1.168
1.169 @@ -3961,14 +3973,16 @@
1.170 linkcolorhint=LinkableMapObj::DefaultColor;
1.171 else
1.172 linkcolorhint=LinkableMapObj::HeadingColor;
1.173 - TreeItem *ti;
1.174 + TreeItem *cur=NULL;
1.175 + TreeItem *prev=NULL;
1.176 + int d=0;
1.177 BranchObj *bo;
1.178 - ti=first();
1.179 - while (bo)
1.180 + cur=next(cur,prev,d);
1.181 + while (cur)
1.182 {
1.183 - bo=(BranchObj*)(ti->getLMO() );
1.184 + bo=(BranchObj*)(cur->getLMO() );
1.185 bo->setLinkColor();
1.186 - ti=next();
1.187 + next(cur,prev,d);
1.188 }
1.189 }
1.190