mapeditor.cpp
changeset 753 25a77484ec72
parent 750 ff3b01ce0960
child 754 db0ec4bcf416
     1.1 --- a/mapeditor.cpp	Thu Apr 02 09:57:47 2009 +0000
     1.2 +++ b/mapeditor.cpp	Tue Apr 07 16:15:53 2009 +0000
     1.3 @@ -252,11 +252,12 @@
     1.4  
     1.5  void MapEditor::toggleStandardFlag(QString f)
     1.6  {
     1.7 -	BranchObj *bo=model->getSelectedBranch();
     1.8 -	if (bo) 
     1.9 +	BranchItem *bi=model->getSelectedBranchItem();
    1.10 +	if (bi) 
    1.11  	{
    1.12  		QString u,r;
    1.13 -		if (bo->isSetStandardFlag(f))
    1.14 +		/* FIXME-2 isSetStandardFlag needs to be ported
    1.15 +		if (bi->isSetStandardFlag(f))
    1.16  		{
    1.17  			r="unsetFlag";
    1.18  			u="setFlag";
    1.19 @@ -266,13 +267,14 @@
    1.20  			u="unsetFlag";
    1.21  			r="setFlag";
    1.22  		}	
    1.23 +		*/
    1.24  		model->saveState(
    1.25 -			bo,
    1.26 +			bi,
    1.27  			QString("%1 (\"%2\")").arg(u).arg(f), 
    1.28 -			bo,
    1.29 +			bi,
    1.30  			QString("%1 (\"%2\")").arg(r).arg(f),
    1.31 -			QString("Toggling standard flag \"%1\" of %2").arg(f).arg(model->getObjectName(bo)));
    1.32 -		bo->toggleStandardFlag (f,mainWindow->useFlagGroups());
    1.33 +			QString("Toggling standard flag \"%1\" of %2").arg(f).arg(model->getObjectName(bi)));
    1.34 +		// FIXME-2 bi->toggleStandardFlag (f,mainWindow->useFlagGroups());
    1.35  		model->updateSelection();	// geometry has changed
    1.36  	}
    1.37  }
    1.38 @@ -292,7 +294,7 @@
    1.39  		cout << "*** " <<cur->getHeading().toStdString()<<endl;
    1.40  
    1.41  
    1.42 -	//BranchObj *bo=model->getSelectedBranch();
    1.43 +	//BranchObj *bo=model->getSelectedBranchObj();
    1.44  	//if (bo) model->moveAway (bo);
    1.45  	//if (bo) bo->setLinkStyle (LinkableMapObj::Line);
    1.46  	
    1.47 @@ -367,12 +369,13 @@
    1.48  		editHeadingFinished();
    1.49  		return;
    1.50  	}
    1.51 -	BranchObj *bo=model->getSelectedBranch();
    1.52 -	if (bo)
    1.53 +	BranchObj *bo=model->getSelectedBranchObj();
    1.54 +	BranchItem *bi=model->getSelectedBranchItem();
    1.55 +	if (bo)	//FIXME-3
    1.56  	{
    1.57  		model->setSelectionBlocked(true);
    1.58  
    1.59 -		lineEdit->setText (bo->getHeading());
    1.60 +		lineEdit->setText (bi->getHeading());
    1.61  		QPoint p = mapTo (this,bo->getAbsPos().toPoint() );
    1.62  		lineEdit->setGeometry(p.x(),p.y(),230,25);
    1.63  		lineEdit->selectAll();
    1.64 @@ -412,7 +415,7 @@
    1.65  			model->select(lmo);
    1.66  		}
    1.67  		// Context Menu 
    1.68 -		if (model->getSelectedBranch() ) 
    1.69 +		if (model->getSelectedBranchObj() ) 
    1.70  		{
    1.71  			// Context Menu on branch or mapcenter
    1.72  			//FIXME-3 model->updateActions(); needed?
    1.73 @@ -533,7 +536,7 @@
    1.74  			if (lmo)
    1.75  				bo_begin=(BranchObj*)(lmo);
    1.76  			else	
    1.77 -				bo_begin=model->getSelectedBranch();
    1.78 +				bo_begin=model->getSelectedBranchObj();
    1.79  			if (bo_begin)	
    1.80  			{
    1.81  				drawingLink=true;
    1.82 @@ -674,9 +677,9 @@
    1.83  					QString pold=qpointfToString(movingObj_orgRelPos);
    1.84  					QString pnow=qpointfToString(fio->getRelPos());
    1.85  					model->saveState(
    1.86 -						fio,
    1.87 +						fio->getTreeItem(),  // FIXME-3 
    1.88  						"moveRel "+pold,
    1.89 -						fio,
    1.90 +						fio->getTreeItem(),
    1.91  						"moveRel "+pnow,
    1.92  						QString("Move %1 to relative position %2").arg(model->getObjectName(fio)).arg(pnow));
    1.93  					fio->getParObj()->requestReposition();
    1.94 @@ -719,7 +722,7 @@
    1.95  				} 
    1.96  
    1.97  				// Maybe we can relink temporary?
    1.98 -				if (lmo && (lmo!=lmosel) && model->getSelectedBranch() && 
    1.99 +				if (lmo && (lmo!=lmosel) && model->getSelectedBranchObj() && 
   1.100  					 (typeid(*lmo)==typeid(BranchObj) ||
   1.101  					  typeid(*lmo)==typeid(MapCenterObj)) ) 
   1.102  
   1.103 @@ -821,9 +824,9 @@
   1.104  		    QString pold=qpointfToString(movingObj_orgRelPos);
   1.105  		    QString pnow=qpointfToString(fo->getRelPos());
   1.106  			model->saveState(
   1.107 -				fo,
   1.108 +				fo->getTreeItem(),	// FIXME-3
   1.109  				"moveRel "+pold,
   1.110 -				fo,
   1.111 +				fo->getTreeItem(),	// FIXME-3
   1.112  				"moveRel "+pnow,
   1.113  				QString("Move %1 to relative position %2").arg(model->getObjectName(fo)).arg(pnow));
   1.114  
   1.115 @@ -838,19 +841,20 @@
   1.116  		if (dst && (typeid(*dst)!=typeid(BranchObj) && typeid(*dst)!=typeid(MapCenterObj))) 
   1.117  			dst=NULL;
   1.118  		
   1.119 -		BranchObj *bo=model->getSelectedBranch();
   1.120 -		if (bo && bo->getDepth()==0)
   1.121 +		BranchItem *bi=model->getSelectedBranchItem();
   1.122 +		if (bi && bi->depth()==0)
   1.123  		{	
   1.124 -            if (movingObj_orgPos != bo->getAbsPos())
   1.125 +            if (movingObj_orgPos != bi->getBranchObj()->getAbsPos())	// FIXME-3 check getBO here...
   1.126              {
   1.127                  QString pold=qpointfToString(movingObj_orgPos);
   1.128 -                QString pnow=qpointfToString(bo->getAbsPos());
   1.129 +                QString pnow=qpointfToString(bi->getBranchObj()->getAbsPos());		// FIXME-3 check getBO here...
   1.130 +
   1.131                  model->saveState(
   1.132 -                    bo,
   1.133 +                    bi,
   1.134                      "move "+pold,
   1.135 -                    bo,
   1.136 +                    bi,
   1.137                      "move "+pnow,
   1.138 -                    QString("Move mapcenter %1 to position %2").arg(model->getObjectName(bo)).arg(pnow));
   1.139 +                    QString("Move mapcenter %1 to position %2").arg(model->getObjectName(bi)).arg(pnow));
   1.140              }
   1.141  		}
   1.142  	
   1.143 @@ -871,7 +875,7 @@
   1.144  			{
   1.145  				// We have a destination, relink to that
   1.146  
   1.147 -				BranchObj* bsel=model->getSelectedBranch();
   1.148 +				BranchObj* bsel=model->getSelectedBranchObj();
   1.149  				TreeItem * tisel=model->getSelectedItem();
   1.150  				BranchObj* bdst=(BranchObj*)dst;
   1.151  				TreeItem* tidst=dst->getTreeItem();
   1.152 @@ -938,7 +942,7 @@
   1.153  				if (settings.value("/animation/use",false).toBool() && lmosel->getDepth()>1) 
   1.154  				{
   1.155  					lmosel->setRelPos();	// calc relPos first for starting point
   1.156 -					QPointF dst=bo->getParObj()->getChildPos();
   1.157 +					QPointF dst=bi->getBranchObj()->getParObj()->getChildPos();		// FIXME-3 check getBO here...
   1.158  			//		if (lmosel->getOrientation()==LinkableMapObj::LeftOfCenter) dst.setX (dst.x()+lmosel->width() );
   1.159  					
   1.160  					model->startAnimation(
   1.161 @@ -1012,8 +1016,8 @@
   1.162  
   1.163  void MapEditor::dropEvent(QDropEvent *event)
   1.164  {
   1.165 -	BranchObj *sel=model->getSelectedBranch();
   1.166 -	if (sel)
   1.167 +	BranchItem *selbi=model->getSelectedBranchItem();
   1.168 +	if (selbi)
   1.169  	{
   1.170  		if (debug)
   1.171  			foreach (QString format,event->mimeData()->formats()) 
   1.172 @@ -1034,15 +1038,16 @@
   1.173  			QStringList files;
   1.174  			QString s;
   1.175  			QString heading;
   1.176 -			BranchObj *bo;
   1.177 +			BranchItem *bi;
   1.178  			for (int i=0; i<uris.count();i++)
   1.179  			{
   1.180  				// Workaround to avoid adding empty branches
   1.181  				if (!uris.at(i).toString().isEmpty())
   1.182  				{
   1.183 -					bo=sel->addBranch();
   1.184 -					if (bo)
   1.185 +					bi=model->createBranch();
   1.186 +					if (bi)
   1.187  					{
   1.188 +						   /* FIXME-2 
   1.189  						s=uris.at(i).toLocalFile();
   1.190  						if (!s.isEmpty()) 
   1.191  						{
   1.192 @@ -1050,18 +1055,20 @@
   1.193  						   heading = QFileInfo(file).baseName();
   1.194  						   files.append(file);
   1.195  						   if (file.endsWith(".vym", false))
   1.196 -							   bo->setVymLink(file);
   1.197 +							   bi->setVymLink(file);
   1.198  						   else
   1.199 -							   bo->setURL(uris.at(i).toString());
   1.200 +							   bi->setURL(uris.at(i).toString());
   1.201  					   } else 
   1.202  					   {
   1.203  						   bo->setURL(uris.at(i).toString());
   1.204  					   }
   1.205 +							 */  
   1.206  
   1.207  					   if (!heading.isEmpty())
   1.208 -						   bo->setHeading(heading);
   1.209 +						   bi->setHeading(heading);
   1.210  					   else
   1.211 -						   bo->setHeading(uris.at(i).toString());
   1.212 +						   bi->setHeading(uris.at(i).toString());
   1.213 +						   
   1.214  					}
   1.215  				}
   1.216  			}
   1.217 @@ -1112,18 +1119,22 @@
   1.218  	}
   1.219  }
   1.220  
   1.221 -void MapEditor::updateCurrent (const QModelIndex &,const QModelIndex &)	//FIXME-3 not used?
   1.222 +void MapEditor::updateData (const QModelIndex &sel)
   1.223  {
   1.224 +	TreeItem *ti= static_cast<TreeItem*>(sel.internalPointer());
   1.225  
   1.226  /* testing
   1.227 +	cout << "ME::updateData\n";
   1.228  
   1.229 -	cout << "ME::updateCurrent\n";
   1.230 -
   1.231 -	TreeItem *item = static_cast<TreeItem*>(newsel.internalPointer());
   1.232 -	LinkableMapObj *lmo=item->getLMO();
   1.233 -	cout << "  lmo="<<lmo<<endl;
   1.234 -	cout << "  h="<<((BranchObj*)lmo)->getHeading().toStdString()<<endl;
   1.235 +	cout << "  ti="<<ti<<endl;
   1.236 +	cout << "  h="<<ti->getHeading().toStdString()<<endl;
   1.237  	*/
   1.238 +	
   1.239 +	if (ti->isBranchLikeType())
   1.240 +	{
   1.241 +		BranchObj *bo=(BranchObj*)ti->getLMO();
   1.242 +		bo->updateHeading();
   1.243 +	}
   1.244  
   1.245  }
   1.246  
   1.247 @@ -1134,6 +1145,7 @@
   1.248  	updateSelection(sel,sel);
   1.249  }
   1.250  
   1.251 +
   1.252  QColor MapEditor::getSelectionColor ()
   1.253  {
   1.254  	return selectionColor;