branchobj.cpp
changeset 746 ee6b0f3a4c2f
parent 745 2d4cc445a86a
child 748 edb78a44240b
     1.1 --- a/branchobj.cpp	Mon Mar 23 09:06:51 2009 +0000
     1.2 +++ b/branchobj.cpp	Thu Mar 26 07:49:17 2009 +0000
     1.3 @@ -17,11 +17,7 @@
     1.4  // BranchObj
     1.5  /////////////////////////////////////////////////////////////////
     1.6  
     1.7 -BranchObj* BranchObj::itLast=NULL;
     1.8 -BranchObj* BranchObj::itFirst=NULL;
     1.9 -
    1.10 -
    1.11 -BranchObj::BranchObj () :OrnamentedObj()	// FIXME needed at all?
    1.12 +BranchObj::BranchObj () :OrnamentedObj()	// FIXME-3 needed at all?
    1.13  {
    1.14  //    cout << "Const BranchObj ()\n";
    1.15      setParObj (this);	
    1.16 @@ -392,155 +388,6 @@
    1.17  		branch.at(i)->setColorSubtree(col);
    1.18  }
    1.19  
    1.20 -BranchObj* BranchObj::first()
    1.21 -{
    1.22 -	itLast=NULL;	
    1.23 -	itFirst=this;
    1.24 -	return this; 
    1.25 -}
    1.26 -	
    1.27 -BranchObj* BranchObj::next()
    1.28 -{
    1.29 -	BranchObj *bo;
    1.30 -	BranchObj *lmo;
    1.31 -	BranchObj *po=(BranchObj*)parObj;
    1.32 -
    1.33 -	if (branch.isEmpty())
    1.34 -		bo=NULL;
    1.35 -	else
    1.36 -		bo=branch.first();
    1.37 -
    1.38 -	if (!itLast)
    1.39 -	{
    1.40 -		// no itLast, we are just beginning
    1.41 -		if (bo) 
    1.42 -		{
    1.43 -			// we have children, return first one
    1.44 -			itLast=this;
    1.45 -			return bo;
    1.46 -		}	
    1.47 -		else
    1.48 -		{
    1.49 -			// No children, so there is no next
    1.50 -			itLast=this;
    1.51 -			return NULL;
    1.52 -		}	
    1.53 -	}
    1.54 -
    1.55 -	// We have an itLast
    1.56 -	if (itLast==po)
    1.57 -	{	// We come from parent
    1.58 -		if (bo)
    1.59 -		{
    1.60 -			// there are children, go there
    1.61 -			itLast=this;
    1.62 -			return bo;
    1.63 -		}	
    1.64 -		else
    1.65 -		{	// no children, try to go up again
    1.66 -			if (po)
    1.67 -			{
    1.68 -				// go back to parent and try to find next there
    1.69 -				itLast=this;
    1.70 -				lmo=po->next();
    1.71 -				itLast=this;
    1.72 -				return lmo;
    1.73 -
    1.74 -			}	
    1.75 -			else
    1.76 -			{
    1.77 -				// can't go up, I am mapCenter, no next
    1.78 -				itLast=NULL;
    1.79 -				return NULL;
    1.80 -			}	
    1.81 -		}
    1.82 -	}
    1.83 -
    1.84 -	// We don't come from parent, but from brother or children
    1.85 -
    1.86 -	// Try to find last child, where we came from, in my own children
    1.87 -	bool searching=true;
    1.88 -	int i=0;
    1.89 -	while (i<branch.size())
    1.90 -	{
    1.91 -		// Try to find itLast in my own children
    1.92 -		if (itLast==branch.at(i))
    1.93 -		{
    1.94 -			// ok, we come from my own children
    1.95 -			if (i<branch.size()-1)
    1.96 -				bo=branch.at(i+1);
    1.97 -			 else
    1.98 -				bo=NULL;
    1.99 -			searching=false;
   1.100 -			i=branch.size();
   1.101 -		} 	
   1.102 -		++i;	
   1.103 -	}
   1.104 -	if (!searching)
   1.105 -	{	// found itLast in my children
   1.106 -		if (bo)
   1.107 -		{
   1.108 -			// found a brother of lastLMO 
   1.109 -			itLast=this;
   1.110 -			return bo;
   1.111 -		}	
   1.112 -		else
   1.113 -		{
   1.114 -			if (po)
   1.115 -			{
   1.116 -				if (this==itFirst) return NULL;	// Stop at starting point
   1.117 -				// go up
   1.118 -				itLast=this;
   1.119 -				lmo=po->next();
   1.120 -				itLast=this;
   1.121 -				return lmo;
   1.122 -			}
   1.123 -			else
   1.124 -			{
   1.125 -				// can't go up, I am mapCenter
   1.126 -				itLast=NULL;
   1.127 -				return NULL;
   1.128 -			}	
   1.129 -		}
   1.130 -	}
   1.131 -
   1.132 -	// couldn't find last child, it must be a nephew of mine
   1.133 -	if (branch.size()>0)
   1.134 -	{
   1.135 -		// proceed with my first child
   1.136 -		itLast=this;	
   1.137 -		return branch.first();
   1.138 -	}	
   1.139 -	else
   1.140 -	{
   1.141 -		// or go back to my parents
   1.142 -		if (po)
   1.143 -		{
   1.144 -			// go up
   1.145 -			itLast=this;
   1.146 -			lmo=po->next();
   1.147 -			itLast=this;
   1.148 -			return lmo;
   1.149 -		}	
   1.150 -		else
   1.151 -		{
   1.152 -			// can't go up, I am mapCenter
   1.153 -			itLast=NULL;
   1.154 -			return NULL;
   1.155 -		}	
   1.156 -	}	
   1.157 -}
   1.158 -
   1.159 -BranchObj* BranchObj::getLastIterator()
   1.160 -{
   1.161 -	return itLast;
   1.162 -}
   1.163 -
   1.164 -void BranchObj::setLastIterator(BranchObj* it)
   1.165 -{
   1.166 -	itLast=it;
   1.167 -}
   1.168 -
   1.169  void BranchObj::positionContents()
   1.170  {
   1.171      for (int i=0; i<floatimage.size(); ++i )
   1.172 @@ -787,7 +634,7 @@
   1.173  	if (hidden) return "";
   1.174  
   1.175  	// Update of note is usually done while unselecting a branch
   1.176 -	if (isNoteInEditor) getNoteFromTextEditor();
   1.177 +	// if (isNoteInEditor) getNoteFromTextEditor();		//FIXME-2 moved to TreeItem
   1.178  	
   1.179      QString s,a;
   1.180  	QString scrolledAttr;
   1.181 @@ -840,8 +687,8 @@
   1.182  		s+=floatimage.at(i)->saveToDir (tmpdir,prefix);
   1.183  
   1.184  	// save note
   1.185 -	if (!note.isEmpty() )
   1.186 -		s+=note.saveToDir();
   1.187 +	if (!treeItem->getNoteObj().isEmpty() )
   1.188 +		s+=treeItem->getNoteObj().saveToDir();
   1.189  	
   1.190  	// Save branches
   1.191  	for (int i=0; i<branch.size(); ++i)
   1.192 @@ -1078,7 +925,7 @@
   1.193  	bo->depth=depth+1;
   1.194  	bo->setDefAttr(MovedBranch);
   1.195  	if (scrolled) tmpUnscroll();
   1.196 -	//setLastSelectedBranch (bo);	//FIXME needed?
   1.197 +	//setLastSelectedBranch (bo);	//FIXME-3 needed?
   1.198  	return bo;
   1.199  }
   1.200  
   1.201 @@ -1112,7 +959,7 @@
   1.202  	bo->depth=depth+1;
   1.203  	bo->setDefAttr (MovedBranch);
   1.204  	if (scrolled) tmpUnscroll();
   1.205 -	//setLastSelectedBranch (bo); //FIXME needed?
   1.206 +	//setLastSelectedBranch (bo); //FIXME-3 needed?
   1.207  	qSort (branch.begin(),branch.end(), isAbove);
   1.208  	return bo;
   1.209  }
   1.210 @@ -1535,28 +1382,27 @@
   1.211  	bboxTotal.setHeight(max (r.height(),  bbox.height()));
   1.212  }
   1.213  
   1.214 -void BranchObj::select()	// FIXME try to get rid of this in BO completely
   1.215 +void BranchObj::select()	// FIXME-2 try to get rid of this in BO completely
   1.216  {
   1.217  	cout << "BO::select()\n";
   1.218 -	// update NoteEditor   FIXME do this via VymView::changeSelection
   1.219 -	textEditor->setText(note.getNote() );
   1.220 -	QString fnh=note.getFilenameHint();
   1.221 +	textEditor->setText(treeItem->getNoteObj().getNote() );
   1.222 +	QString fnh=treeItem->getNoteObj().getFilenameHint();
   1.223  	if (fnh!="")
   1.224 -		textEditor->setFilenameHint(note.getFilenameHint() );
   1.225 +		textEditor->setFilenameHint(treeItem->getNoteObj().getFilenameHint() );
   1.226  	else	
   1.227  		textEditor->setFilenameHint(getHeading() );
   1.228 -	textEditor->setFontHint (note.getFontHint() );
   1.229 -	isNoteInEditor=true;
   1.230 +	textEditor->setFontHint (treeItem->getNoteObj().getFontHint() );
   1.231 +	//isNoteInEditor=true;
   1.232  
   1.233  	// set selected and visible
   1.234      LinkableMapObj::select();
   1.235  
   1.236 -    //if (po)	po->setLastSelectedBranch(this);  FIXME needed?
   1.237 +    //if (po)	po->setLastSelectedBranch(this);  needed?
   1.238  		
   1.239  	// temporary unscroll, if we have scrolled parents somewhere
   1.240  	if (parObj) ((BranchObj*)(parObj))->tmpUnscroll();
   1.241  
   1.242 -	/* FIXME moved to vymmodel or vymview...
   1.243 +	/* moved to vymmodel or vymview...
   1.244  	// Show URL and link in statusbar
   1.245  	QString status;
   1.246  	if (!url.isEmpty()) status+="URL: "+url+"  ";
   1.247 @@ -1571,15 +1417,17 @@
   1.248  	*/
   1.249  }
   1.250  
   1.251 -void BranchObj::unselect()
   1.252 +void BranchObj::unselect()	//FIXME-3 should not be needed
   1.253  {
   1.254  	LinkableMapObj::unselect();
   1.255  	// Delete any messages like vymLink in StatusBar
   1.256 -	mainWindow->statusMessage ("");		//FIXME this causes segfault, when MainWindow is already gone in global destructor on quitting vym
   1.257 +	mainWindow->statusMessage ("");		//this causes segfault, when MainWindow is already gone in global destructor on quitting vym
   1.258  
   1.259 +/*
   1.260  	// Save current note
   1.261  	if (isNoteInEditor) getNoteFromTextEditor();
   1.262  	isNoteInEditor=false;
   1.263 +*/	
   1.264  
   1.265  	// reset temporary unscroll, if we have scrolled parents somewhere
   1.266  	if (parObj) ((BranchObj*)(parObj))->resetTmpUnscroll();