branchobj.cpp
changeset 767 6d2b32f305f9
parent 766 7a71a914afdb
child 771 01f2f6d6789d
     1.1 --- a/branchobj.cpp	Thu May 07 08:48:53 2009 +0000
     1.2 +++ b/branchobj.cpp	Wed May 13 08:26:27 2009 +0000
     1.3 @@ -6,12 +6,8 @@
     1.4  #include "mainwindow.h"
     1.5  #include "misc.h"
     1.6  
     1.7 -//class TextEditor; //FIXME-3
     1.8 -
     1.9 -//extern TextEditor *textEditor;
    1.10 -//extern Main *mainWindow;
    1.11 -//extern FlagRowObj *standardFlagsDefault;
    1.12 -
    1.13 +extern FlagRow *standardFlagsMaster;
    1.14 +extern FlagRow *systemFlagsMaster;
    1.15  
    1.16  /////////////////////////////////////////////////////////////////
    1.17  // BranchObj
    1.18 @@ -325,12 +321,12 @@
    1.19      QSizeF heading_r=heading->getSize();
    1.20      qreal heading_w=(qreal) heading_r.width() ;
    1.21      qreal heading_h=(qreal) heading_r.height() ;
    1.22 -    QSizeF sysflags_r; //FIXME-1 =systemFlags->getSize();
    1.23 -	qreal sysflags_h=0;//sysflags_r.height();
    1.24 -	qreal sysflags_w=0;//sysflags_r.width();
    1.25 -    QSizeF stanflags_r; //FIXME-1 =standardFlags->getSize();
    1.26 -	qreal stanflags_h=0; //stanflags_r.height();
    1.27 -	qreal stanflags_w=0; //stanflags_r.width();
    1.28 +    QSizeF sysflags_r=systemFlags->getSize();
    1.29 +	qreal sysflags_h=sysflags_r.height();
    1.30 +	qreal sysflags_w=sysflags_r.width();
    1.31 +    QSizeF stanflags_r=standardFlags->getSize();
    1.32 +	qreal stanflags_h=stanflags_r.height();
    1.33 +	qreal stanflags_w=stanflags_r.width();
    1.34      qreal w;
    1.35      qreal h;
    1.36  
    1.37 @@ -416,105 +412,67 @@
    1.38      }
    1.39  }
    1.40  
    1.41 -void BranchObj::updateHeading()
    1.42 +void BranchObj::updateData()
    1.43  {
    1.44 +	bool changed=false;
    1.45  	if (!treeItem)
    1.46  	{
    1.47  		qWarning ("BranchObj::udpateHeading treeItem==NULL");
    1.48  		return;
    1.49  	}
    1.50 -	heading->setText (treeItem->getHeading() );
    1.51 -	updateContentSize();
    1.52 +	QString s=treeItem->getHeading();
    1.53 +	if (s!=heading->text())
    1.54 +	{
    1.55 +		heading->setText (s);
    1.56 +		changed=true;
    1.57 +	}
    1.58 +	QStringList TIactiveFlags=treeItem->activeStandardFlagNames();
    1.59 +
    1.60 +	// Add missing standard flags active in TreeItem
    1.61 +	for (int i=0;i<=TIactiveFlags.size()-1;i++)
    1.62 +	{	
    1.63 +		if (!standardFlags->isActive (TIactiveFlags.at(i) ))
    1.64 +		{
    1.65 +			Flag *f=standardFlagsMaster->getFlag(TIactiveFlags.at(i));
    1.66 +			if (f) standardFlags->activate (f);
    1.67 +			changed=true;
    1.68 +		}
    1.69 +	}
    1.70 +	// Remove standard flags no longer active in TreeItem
    1.71 +	QStringList BOactiveFlags=standardFlags->activeFlagNames();
    1.72 +	for (int i=0;i<BOactiveFlags.size();++i)
    1.73 +		if (!TIactiveFlags.contains (BOactiveFlags.at(i)))
    1.74 +		{
    1.75 +			standardFlags->deactivate (BOactiveFlags.at(i));
    1.76 +			changed=true;
    1.77 +		}	
    1.78 +
    1.79 +	// Add missing system flags active in TreeItem
    1.80 +	TIactiveFlags=treeItem->activeSystemFlagNames();
    1.81 +	for (int i=0;i<TIactiveFlags.size();++i)
    1.82 +	{	
    1.83 +		if (!systemFlags->isActive (TIactiveFlags.at(i) ))
    1.84 +		{
    1.85 +			Flag *f=systemFlagsMaster->getFlag(TIactiveFlags.at(i));
    1.86 +			if (f) systemFlags->activate (f);
    1.87 +			changed=true;
    1.88 +		}
    1.89 +	}
    1.90 +	// Remove system flags no longer active in TreeItem
    1.91 +	BOactiveFlags=systemFlags->activeFlagNames();
    1.92 +	for (int i=0;i<BOactiveFlags.size();++i)
    1.93 +	{
    1.94 +		if (!TIactiveFlags.contains (BOactiveFlags.at(i)))
    1.95 +		{
    1.96 +			systemFlags->deactivate (BOactiveFlags.at(i));
    1.97 +			changed=true;
    1.98 +		}	
    1.99 +	}
   1.100 +
   1.101 +	if (changed)
   1.102 +		updateContentSize();
   1.103  }
   1.104  
   1.105 -QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset)
   1.106 -{
   1.107 -	// Cloudy stuff can be hidden during exports
   1.108 -	// FIXME-1 if (hidden) return "";
   1.109 -
   1.110 -	// Update of note is usually done while unselecting a branch
   1.111 -	// if (isNoteInEditor) getNoteFromTextEditor();		//FIXME-2 moved to TreeItem
   1.112 -	
   1.113 -    QString s,a;
   1.114 -	/*
   1.115 -	QString scrolledAttr;
   1.116 -	if ( ((BranchItem*)treeItem)->isScrolled() ) 
   1.117 -		scrolledAttr=attribut ("scrolled","yes");
   1.118 -	else
   1.119 -		scrolledAttr="";
   1.120 -
   1.121 -	// save area, if not scrolled
   1.122 -	QString areaAttr;
   1.123 -	if (!((BranchItem*) (treeItem->parent()) )->isScrolled() )
   1.124 -	{
   1.125 -		areaAttr=
   1.126 -			attribut("x1",QString().setNum(absPos.x()-offset.x())) +
   1.127 -			attribut("y1",QString().setNum(absPos.y()-offset.y())) +
   1.128 -			attribut("x2",QString().setNum(absPos.x()+width()-offset.x())) +
   1.129 -			attribut("y2",QString().setNum(absPos.y()+height()-offset.y()));
   1.130 -
   1.131 -	} else
   1.132 -		areaAttr="";
   1.133 -	
   1.134 -	// Providing an ID for a branch makes export to XHTML easier
   1.135 -	QString idAttr;
   1.136 -	if (treeItem->xlinkCount()>0)
   1.137 -		idAttr=attribut ("id",model->getSelectString(this)); //TODO directly access model
   1.138 -	else
   1.139 -		idAttr="";
   1.140 -
   1.141 -    s=beginElement ("branch" 
   1.142 -		+getOrnXMLAttr() 
   1.143 -		+scrolledAttr 
   1.144 -		+areaAttr 
   1.145 -		+idAttr 
   1.146 -		+getIncludeImageAttr() );
   1.147 -    incIndent();
   1.148 -
   1.149 -	// save heading
   1.150 -    s+=valueElement("heading", treeItem->getHeading(),
   1.151 -		attribut ("textColor",QColor(heading->getColor()).name()));
   1.152 -
   1.153 -	// Save frame
   1.154 -	if (frame->getFrameType()!=FrameObj::NoFrame) 
   1.155 -		s+=frame->saveToDir ();
   1.156 -
   1.157 -	// save names of flags set
   1.158 -	s+=standardFlags->saveToDir(tmpdir,prefix,0);
   1.159 -	
   1.160 -	// Save FloatImages
   1.161 -	for (int i=0; i<floatimage.size(); ++i)
   1.162 -		s+=floatimage.at(i)->saveToDir (tmpdir,prefix);
   1.163 -
   1.164 -	// save note
   1.165 -	if (!treeItem->getNoteObj().isEmpty() )
   1.166 -		s+=treeItem->getNoteObj().saveToDir();
   1.167 -	
   1.168 -	// Save branches
   1.169 -	for (int i=0; i<treeItem->branchCount(); ++i)
   1.170 -		s+=treeItem->getBranchObjNum(i)->saveToDir(tmpdir,prefix,offset);
   1.171 -
   1.172 -	// Save XLinks
   1.173 -	QString ol;	// old link
   1.174 -	QString cl;	// current link
   1.175 -	for (int i=0; i<xlink.size(); ++i)
   1.176 -	{
   1.177 -		cl=xlink.at(i)->saveToDir();
   1.178 -		if (cl!=ol)
   1.179 -		{
   1.180 -			s+=cl;
   1.181 -			ol=cl;
   1.182 -		} else
   1.183 -		{
   1.184 -			qWarning (QString("Ignoring of duplicate xLink in %1").arg(treeItem->getHeading()));
   1.185 -		}
   1.186 -	}	
   1.187 -
   1.188 -    decIndent();
   1.189 -    s+=endElement   ("branch");
   1.190 -    return s;
   1.191 -*/	
   1.192 -}
   1.193  
   1.194  void BranchObj::addXLink (XLinkObj *xlo)
   1.195  {
   1.196 @@ -732,66 +690,6 @@
   1.197  */	
   1.198  }
   1.199  
   1.200 -bool BranchObj::canMoveBranchUp() // FIXME-1 move to BranchItem
   1.201 -{
   1.202 -/*
   1.203 -	if (!parObj || depth==1) return false;
   1.204 -	BranchObj* par=(BranchObj*)parObj;
   1.205 -	if (this==par->getTreeItem()->getFirstBranch())
   1.206 -		return false;
   1.207 -	else
   1.208 -		return true;
   1.209 -		*/
   1.210 -return false;
   1.211 -}
   1.212 -
   1.213 -BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // FIXME-1
   1.214 -{
   1.215 -/*
   1.216 -	savePosInAngle();
   1.217 -    int i=branch.indexOf(bo1);
   1.218 -    if (i>0) 
   1.219 -	{	// -1 if bo1 not found 
   1.220 -		treeItem->getBranchObjNum(i)->angle--;
   1.221 -		treeItem->getBranchObjNum(i-1)->angle++;
   1.222 -		qSort (branch.begin(),branch.end(), isAbove);
   1.223 -		return treeItem->getBranchObjNum(i);
   1.224 -	} else
   1.225 -*/	
   1.226 -		return NULL;
   1.227 -}
   1.228 -
   1.229 -bool BranchObj::canMoveBranchDown() //FIXME-1 move to BranchItem
   1.230 -{
   1.231 -	/* 
   1.232 -	if (!parObj|| depth==1) return false;
   1.233 -	BranchObj* par=(BranchObj*)parObj;
   1.234 -	if (this==par->getTreeItem()->getLastBranch())
   1.235 -		return false;
   1.236 -	else
   1.237 -		return true;
   1.238 -	*/
   1.239 -return false;	
   1.240 -}
   1.241 -
   1.242 -BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)// FIXME-1
   1.243 -{
   1.244 -/*
   1.245 -	savePosInAngle();
   1.246 -    int i=branch.indexOf(bo1);
   1.247 -	int j;
   1.248 -	if (i <treeItem->branchCount())
   1.249 -	{
   1.250 -		j = i+1;
   1.251 -		treeItem->getBranchObjNum(i)->angle++;
   1.252 -		treeItem->getBranchObjNum(j)->angle--;
   1.253 -		qSort (branch.begin(),branch.end(), isAbove);
   1.254 -		return treeItem->getBranchObjNum(i);
   1.255 -	} else
   1.256 -*/	
   1.257 -		return NULL;
   1.258 -}
   1.259 -
   1.260  void BranchObj::sortChildren() //FIXME-2  
   1.261  {
   1.262  /*
   1.263 @@ -1070,65 +968,6 @@
   1.264  	bboxTotal.setHeight(max (r.height(),  bbox.height()));
   1.265  }
   1.266  
   1.267 -/*
   1.268 -void BranchObj::select()	// FIXME-4 try to get rid of this in BO completely
   1.269 -{
   1.270 -	cout << "BO::select()\n";
   1.271 -	textEditor->setText(treeItem->getNoteObj().getNote() );
   1.272 -	QString fnh=treeItem->getNoteObj().getFilenameHint();
   1.273 -	if (fnh!="")
   1.274 -		textEditor->setFilenameHint(treeItem->getNoteObj().getFilenameHint() );
   1.275 -	else	
   1.276 -		textEditor->setFilenameHint(getHeading() );
   1.277 -	textEditor->setFontHint (treeItem->getNoteObj().getFontHint() );
   1.278 -	//isNoteInEditor=true;
   1.279 -
   1.280 -	// set selected and visible
   1.281 -    LinkableMapObj::select();
   1.282 -
   1.283 -    //if (po)	po->setLastSelectedBranch(this);  needed?
   1.284 -		
   1.285 -	// temporary unscroll, if we have scrolled parents somewhere
   1.286 -	if (parObj) ((BranchObj*)(parObj))->tmpUnscroll();
   1.287 -
   1.288 -	//moved to vymmodel or vymview...
   1.289 -	// Show URL and link in statusbar
   1.290 -	QString status;
   1.291 -	if (!url.isEmpty()) status+="URL: "+url+"  ";
   1.292 -	if (!vymLink.isEmpty()) status+="Link: "+vymLink;
   1.293 -	if (!status.isEmpty()) mainWindow->statusMessage (status);
   1.294 -
   1.295 -	// Update Toolbar
   1.296 -	updateFlagsToolbar();
   1.297 -
   1.298 -	// Update actions
   1.299 -	model->updateActions();
   1.300 -}
   1.301 -	*/
   1.302 -
   1.303 -/*
   1.304 -void BranchObj::unselect()	//FIXME-4 should not be needed
   1.305 -{
   1.306 -	cout << "BO::unselect()\n";
   1.307 -	LinkableMapObj::unselect();
   1.308 -	// Delete any messages like vymLink in StatusBar
   1.309 -	mainWindow->statusMessage ("");		//this causes segfault, when MainWindow is already gone in global destructor on quitting vym
   1.310 -
   1.311 -	// Save current note
   1.312 -	if (isNoteInEditor) getNoteFromTextEditor();
   1.313 -	isNoteInEditor=false;
   1.314 -
   1.315 -	// reset temporary unscroll, if we have scrolled parents somewhere
   1.316 -	if (parObj) ((BranchObj*)(parObj))->resetTmpUnscroll();
   1.317 -
   1.318 -	// Erase content of editor 
   1.319 -	textEditor->setInactive();
   1.320 -
   1.321 -	// unselect all buttons in toolbar
   1.322 -	standardFlagsDefault->updateToolbar();
   1.323 -}
   1.324 -*/	
   1.325 -
   1.326  QString BranchObj::getSelectString()
   1.327  {
   1.328  	return model->getSelectString (this);