more changes for multiple mapCenters
authorinsilmaril
Tue, 15 Jan 2008 13:06:59 +0000
changeset 652700553af9ca5
parent 651 1e51ba080947
child 653 8be6ac05960b
more changes for multiple mapCenters
demos/vym-projectplan.vym
mapeditor.cpp
version.h
vymmodel.cpp
vymmodel.h
xml-freemind.cpp
xml-vym.cpp
     1.1 Binary file demos/vym-projectplan.vym has changed
     2.1 --- a/mapeditor.cpp	Tue Jan 15 13:06:59 2008 +0000
     2.2 +++ b/mapeditor.cpp	Tue Jan 15 13:06:59 2008 +0000
     2.3 @@ -2685,18 +2685,13 @@
     2.4  
     2.5  bool MapEditor::select (const QString &s)
     2.6  {
     2.7 -	LinkableMapObj *lmo=model->findObjBySelect(s);
     2.8 -
     2.9 -	// Finally select the found object
    2.10 -	if (lmo)
    2.11 +	if (xelection.select(s))
    2.12  	{
    2.13 -		xelection.unselect();
    2.14 -		xelection.select(lmo);
    2.15  		xelection.update();
    2.16  		ensureSelectionVisible();
    2.17  		sendSelection ();
    2.18  		return true;
    2.19 -	} 
    2.20 +	}
    2.21  	return false;
    2.22  }
    2.23  
    2.24 @@ -4258,9 +4253,8 @@
    2.25  void MapEditor::testFunction2()
    2.26  {
    2.27  
    2.28 -	cout << "Selection   (org): "<<xelection.getSelectString().ascii()<<endl;
    2.29 -	cout << "Selection (model): "<<model->getSelectString(xelection.getBranch()).ascii()<<endl;
    2.30 -//	model->addMapCenter();
    2.31 +	xelection.select (model->addMapCenter());
    2.32 +	ensureSelectionVisible();
    2.33  
    2.34  /*
    2.35  	// Toggle hidemode
    2.36 @@ -4269,14 +4263,6 @@
    2.37  	else	
    2.38  		setHideTmpMode (HideExport);
    2.39  */		
    2.40 -/*
    2.41 -	LinkableMapObj *lmo=xelection.getBranch();
    2.42 -	if (lmo) 
    2.43 -	{
    2.44 -		cout << "LMO::id="<<lmo->getID().ascii()<<endl;
    2.45 -		cout << " BO::id="<<((BranchObj*)lmo)->getID().ascii()<<endl;
    2.46 -	}	
    2.47 -*/	
    2.48  }
    2.49  
    2.50  void MapEditor::contextMenuEvent ( QContextMenuEvent * e )
     3.1 --- a/version.h	Tue Jan 15 13:06:59 2008 +0000
     3.2 +++ b/version.h	Tue Jan 15 13:06:59 2008 +0000
     3.3 @@ -7,7 +7,7 @@
     3.4  #define __VYM_VERSION "1.11.5"
     3.5  //#define __VYM_CODENAME "Codename: 1.10.0-RC-3"
     3.6  #define __VYM_CODENAME "Codename: development version"
     3.7 -#define __VYM_BUILD_DATE "2008-01-14"
     3.8 +#define __VYM_BUILD_DATE "2008-01-15"
     3.9  
    3.10  
    3.11  bool checkVersion(const QString &);
     4.1 --- a/vymmodel.cpp	Tue Jan 15 13:06:59 2008 +0000
     4.2 +++ b/vymmodel.cpp	Tue Jan 15 13:06:59 2008 +0000
     4.3 @@ -101,89 +101,6 @@
     4.4  	return NULL;
     4.5  }
     4.6  
     4.7 -// Only as long as we dont have Model/View yet
     4.8 -LinkableMapObj* VymModel::getSelection()
     4.9 -{
    4.10 -	return mapEditor->getSelection();
    4.11 -}
    4.12 -BranchObj* VymModel::getSelectedBranch()
    4.13 -{
    4.14 -	return mapEditor->getSelectedBranch();
    4.15 -}
    4.16 -
    4.17 -bool VymModel::select (const QString &s)
    4.18 -{
    4.19 -	LinkableMapObj *lmo=model->findObjBySelect(s);
    4.20 -
    4.21 -/*
    4.22 -	// Finally select the found object
    4.23 -	if (lmo)
    4.24 -	{
    4.25 -		xelection.unselect();
    4.26 -		xelection.select(lmo);
    4.27 -		xelection.update();
    4.28 -		ensureSelectionVisible();
    4.29 -		sendSelection ();
    4.30 -		return true;
    4.31 -	} 
    4.32 -	return false;
    4.33 -*/
    4.34 -}
    4.35 -
    4.36 -QString VymModel::getSelectString (LinkableMapObj *lmo)
    4.37 -{
    4.38 -	QString s;
    4.39 -	if (!lmo) return s;
    4.40 -	if (typeid(*lmo)==typeid(BranchObj) ||
    4.41 -		typeid(*lmo)==typeid(MapCenterObj) )
    4.42 -	{	
    4.43 -		LinkableMapObj *par=lmo->getParObj();
    4.44 -		if (par)
    4.45 -		{
    4.46 -			if (lmo->getDepth() ==1)
    4.47 -				// Mainbranch, return 
    4.48 -				s= "bo:" + QString("%1").arg(((BranchObj*)lmo)->getNum());
    4.49 -			else	
    4.50 -				// Branch, call myself recursively
    4.51 -				s= getSelectString(par) + ",bo:" + QString("%1").arg(((BranchObj*)lmo)->getNum());
    4.52 -		} else
    4.53 -		{
    4.54 -			// MapCenter
    4.55 -			int i=mapCenters.indexOf ((MapCenterObj*)lmo);
    4.56 -			if (i>=0) s=QString("mc:%1").arg(i);
    4.57 -		}	
    4.58 -	}	
    4.59 -	return s;
    4.60 -
    4.61 -}
    4.62 -
    4.63 -/* FIXME copied from MCO, still needed?
    4.64 -void VymModel::move (double x, double y)
    4.65 -{
    4.66 -	BranchObj::move(x,y);
    4.67 -}
    4.68 -
    4.69 -void VymModel::moveBy (double x, double y)
    4.70 -{
    4.71 -	BranchObj::moveBy(x,y);
    4.72 -}
    4.73 -
    4.74 -void VymModel::moveAll (double x, double y)
    4.75 -{
    4.76 -	// Get rel. position
    4.77 -	double dx=x-absPos.x();
    4.78 -	double dy=y-absPos.y();
    4.79 -
    4.80 -	// Move myself and branches
    4.81 -	moveAllBy (dx,dy);
    4.82 -}
    4.83 -
    4.84 -void VymModel::moveAllBy (double dx, double dy)
    4.85 -{
    4.86 -	// Move myself and childs
    4.87 -	BranchObj::moveBy(dx,dy);
    4.88 -}
    4.89 -*/
    4.90  BranchObj* VymModel::first()
    4.91  {
    4.92  	if (mapCenters.count()>0) 
    4.93 @@ -212,45 +129,6 @@
    4.94  			return mapCenters.at(i);
    4.95  	} 
    4.96  	return NULL;
    4.97 -
    4.98 -}
    4.99 -	
   4.100 -	/* FIXME copied from MCO, still needed?
   4.101 -void VymModel::updateLink()
   4.102 -{
   4.103 -	// set childPos to middle of MapCenterObj
   4.104 -	childPos.setX( clickBox.topLeft().x() + (int)(clickBox.width())/2 );
   4.105 -	childPos.setY( clickBox.topLeft().y() + (int)(clickBox.height())/2 );
   4.106 -	parPos=childPos;		
   4.107 -	for (int i=0; i<branch.size(); ++i)
   4.108 -		branch.at(i)->updateLink();
   4.109 -}
   4.110 -
   4.111 -*/
   4.112 -void VymModel::updateRelPositions()
   4.113 -{
   4.114 -	for (int i=0; i<mapCenters.count(); i++)
   4.115 -		mapCenters.at(i)->updateRelPositions();
   4.116 -}
   4.117 -
   4.118 -void VymModel::reposition()
   4.119 -{
   4.120 -	for (int i=0;i<mapCenters.count(); i++)
   4.121 -		mapCenters.at(i)->reposition();	//	for positioning heading
   4.122 -}
   4.123 -
   4.124 -void VymModel::setHideTmp (HideTmpMode mode)
   4.125 -{
   4.126 -	for (int i=0;i<mapCenters.count(); i++)
   4.127 -		mapCenters.at(i)->setHideTmp (mode);	
   4.128 -}
   4.129 -
   4.130 -QRectF VymModel::getTotalBBox()
   4.131 -{
   4.132 -	QRectF r;
   4.133 -	for (int i=0;i<mapCenters.count(); i++)
   4.134 -		r=addBBox (mapCenters.at(i)->getTotalBBox(), r);
   4.135 -	return r;	
   4.136  }
   4.137  
   4.138  LinkableMapObj* VymModel::findMapObj(QPointF p, LinkableMapObj *excludeLMO)
   4.139 @@ -274,7 +152,7 @@
   4.140  		QString typ;
   4.141  		QString num;
   4.142  		part=s.section(",",0,0);
   4.143 -		typ=part.left (3);
   4.144 +		typ=part.left (2);
   4.145  		num=part.right(part.length() - 3);
   4.146  		if (typ=="mc" && num.toInt()>=0 && num.toInt() <mapCenters.count() )
   4.147  			return mapCenters.at(num.toInt() );
   4.148 @@ -309,3 +187,96 @@
   4.149  }
   4.150  
   4.151  
   4.152 +//////////////////////////////////////////////
   4.153 +// View related
   4.154 +//////////////////////////////////////////////
   4.155 +
   4.156 +	/* FIXME copied from MCO, still needed?
   4.157 +void VymModel::updateLink()
   4.158 +{
   4.159 +	// set childPos to middle of MapCenterObj
   4.160 +	childPos.setX( clickBox.topLeft().x() + (int)(clickBox.width())/2 );
   4.161 +	childPos.setY( clickBox.topLeft().y() + (int)(clickBox.height())/2 );
   4.162 +	parPos=childPos;		
   4.163 +	for (int i=0; i<branch.size(); ++i)
   4.164 +		branch.at(i)->updateLink();
   4.165 +}
   4.166 +
   4.167 +*/
   4.168 +void VymModel::updateRelPositions()
   4.169 +{
   4.170 +	for (int i=0; i<mapCenters.count(); i++)
   4.171 +		mapCenters.at(i)->updateRelPositions();
   4.172 +}
   4.173 +
   4.174 +void VymModel::reposition()
   4.175 +{
   4.176 +	for (int i=0;i<mapCenters.count(); i++)
   4.177 +		mapCenters.at(i)->reposition();	//	for positioning heading
   4.178 +}
   4.179 +
   4.180 +
   4.181 +
   4.182 +//////////////////////////////////////////////
   4.183 +// Selection related
   4.184 +//////////////////////////////////////////////
   4.185 +
   4.186 +
   4.187 +// Only as long as we dont have Model/View yet
   4.188 +LinkableMapObj* VymModel::getSelection()
   4.189 +{
   4.190 +	return mapEditor->getSelection();
   4.191 +}
   4.192 +BranchObj* VymModel::getSelectedBranch()
   4.193 +{
   4.194 +	return mapEditor->getSelectedBranch();
   4.195 +}
   4.196 +
   4.197 +
   4.198 +bool VymModel::select (const QString &s)
   4.199 +{
   4.200 +	return mapEditor->select (s);
   4.201 +}
   4.202 +
   4.203 +QString VymModel::getSelectString (LinkableMapObj *lmo)
   4.204 +{
   4.205 +	QString s;
   4.206 +	if (!lmo) return s;
   4.207 +	if (typeid(*lmo)==typeid(BranchObj) ||
   4.208 +		typeid(*lmo)==typeid(MapCenterObj) )
   4.209 +	{	
   4.210 +		LinkableMapObj *par=lmo->getParObj();
   4.211 +		if (par)
   4.212 +		{
   4.213 +			if (lmo->getDepth() ==1)
   4.214 +				// Mainbranch, return 
   4.215 +				s= "bo:" + QString("%1").arg(((BranchObj*)lmo)->getNum());
   4.216 +			else	
   4.217 +				// Branch, call myself recursively
   4.218 +				s= getSelectString(par) + ",bo:" + QString("%1").arg(((BranchObj*)lmo)->getNum());
   4.219 +		} else
   4.220 +		{
   4.221 +			// MapCenter
   4.222 +			int i=mapCenters.indexOf ((MapCenterObj*)lmo);
   4.223 +			if (i>=0) s=QString("mc:%1").arg(i);
   4.224 +		}	
   4.225 +	}	
   4.226 +	return s;
   4.227 +
   4.228 +}
   4.229 +
   4.230 +	
   4.231 +void VymModel::setHideTmp (HideTmpMode mode)
   4.232 +{
   4.233 +	for (int i=0;i<mapCenters.count(); i++)
   4.234 +		mapCenters.at(i)->setHideTmp (mode);	
   4.235 +}
   4.236 +
   4.237 +QRectF VymModel::getTotalBBox()
   4.238 +{
   4.239 +	QRectF r;
   4.240 +	for (int i=0;i<mapCenters.count(); i++)
   4.241 +		r=addBBox (mapCenters.at(i)->getTotalBBox(), r);
   4.242 +	return r;	
   4.243 +}
   4.244 +
     5.1 --- a/vymmodel.h	Tue Jan 15 13:06:59 2008 +0000
     5.2 +++ b/vymmodel.h	Tue Jan 15 13:06:59 2008 +0000
     5.3 @@ -28,31 +28,30 @@
     5.4  	QGraphicsScene *getScene();
     5.5  	MapCenterObj* addMapCenter();
     5.6  	MapCenterObj* removeMapCenter(MapCenterObj *mco);
     5.7 -	LinkableMapObj* getSelection();
     5.8 -	BranchObj* getSelectedBranch();
     5.9 -	bool select (const QString &s);
    5.10 -	QString getSelectString (LinkableMapObj *lmo);
    5.11 -	/*
    5.12 -    void move      (double,double);		// FIXME needed at all?
    5.13 -    void moveBy    (double,double);		// FIXME needed at all?
    5.14 -    void moveAll   (double,double);		// FIXME needed at all?
    5.15 -    void moveAllBy (double,double);		// FIXME needed at all?
    5.16 -	*/
    5.17 +
    5.18  	BranchObj* first();					// FIXME replaced by ModelIndex later
    5.19  	BranchObj* next(BranchObj *bo);		// FIXME replaced by ModelIndex later
    5.20  
    5.21 -/*
    5.22 -    void updateLink();
    5.23 -*/
    5.24 +    LinkableMapObj* findMapObj(QPointF,LinkableMapObj*);	// find MapObj 
    5.25 +    LinkableMapObj* findObjBySelect (const QString &s);		// find MapObj by select string
    5.26 +    LinkableMapObj* findID (const QString &s);				// find MapObj by previously set ID
    5.27 +	QString saveToDir (const QString&,const QString&,int, const QPointF&);// Save data recursivly to tempdir
    5.28 +
    5.29 +
    5.30 +////////////////////////////////////////// View related
    5.31 +    // void updateLink();  FIXME needed?
    5.32      void updateRelPositions();
    5.33  
    5.34  	QRectF getTotalBBox();
    5.35  	void reposition();					//!< Call reposition for all MCOs
    5.36  	void setHideTmp (HideTmpMode mode);	
    5.37 -    LinkableMapObj* findMapObj(QPointF,LinkableMapObj*);	// find MapObj 
    5.38 -    LinkableMapObj* findObjBySelect (const QString &s);		// find MapObj by select string
    5.39 -    LinkableMapObj* findID (const QString &s);				// find MapObj by previously set ID
    5.40 -	QString saveToDir (const QString&,const QString&,int, const QPointF&);// Save data recursivly to tempdir
    5.41 +
    5.42 +////////////////////////////////////////// Selection related 
    5.43 +	LinkableMapObj* getSelection();
    5.44 +	BranchObj* getSelectedBranch();
    5.45 +	bool select (const QString &s);
    5.46 +	QString getSelectString (LinkableMapObj *lmo);
    5.47 +
    5.48  private:
    5.49  	QGraphicsScene *mapScene;
    5.50  	MapEditor *mapEditor;
     6.1 --- a/xml-freemind.cpp	Tue Jan 15 13:06:59 2008 +0000
     6.2 +++ b/xml-freemind.cpp	Tue Jan 15 13:06:59 2008 +0000
     6.3 @@ -26,7 +26,6 @@
     6.4      laststate = StateInit;
     6.5  	stateStack.clear();
     6.6  	stateStack.append(StateInit);
     6.7 -    branchDepth=0;
     6.8  	isVymPart=false;
     6.9      return true;
    6.10  }
     7.1 --- a/xml-vym.cpp	Tue Jan 15 13:06:59 2008 +0000
     7.2 +++ b/xml-vym.cpp	Tue Jan 15 13:06:59 2008 +0000
     7.3 @@ -34,7 +34,6 @@
     7.4      laststate = StateInit;
     7.5  	stateStack.clear();
     7.6  	stateStack.append(StateInit);
     7.7 -    branchDepth=0;
     7.8  	htmldata="";
     7.9  	isVymPart=false;
    7.10      return true;
    7.11 @@ -221,7 +220,6 @@
    7.12  					
    7.13  				} else
    7.14  					lastBranch->clear();
    7.15 -				branchDepth=1;
    7.16  				readBranchAttr (atts);
    7.17  			} else if (eName=="floatimage")
    7.18  			{
    7.19 @@ -234,7 +232,6 @@
    7.20  	} else if ( eName == "branch" && state == StateMapCenter) 
    7.21  	{
    7.22  		state=StateBranch;
    7.23 -		branchDepth=1;
    7.24  		lastBranch->addBranch();
    7.25  		lastBranch=lastBranch->getLastBranch();
    7.26  		readBranchAttr (atts);
    7.27 @@ -258,7 +255,6 @@
    7.28  	{
    7.29          lastBranch->addBranch();
    7.30  		lastBranch=lastBranch->getLastBranch();		
    7.31 -        branchDepth++;
    7.32  		readBranchAttr (atts);
    7.33      } else if ( eName == "html" && state == StateHtmlNote ) 
    7.34  	{
    7.35 @@ -425,7 +421,7 @@
    7.36  					return false;   // Couldn't read relPos
    7.37  			}           
    7.38  		}           
    7.39 -		if (!a.value( "absPosX").isEmpty() && loadMode==NewMap && branchDepth<2) 
    7.40 +		if (!a.value( "absPosX").isEmpty() && loadMode==NewMap ) 
    7.41  		{
    7.42  			if (!a.value( "absPosY").isEmpty() ) 
    7.43  			{