vymmodel.cpp
changeset 750 ff3b01ce0960
parent 749 9ff332964015
child 753 25a77484ec72
     1.1 --- a/vymmodel.cpp	Wed Apr 01 15:06:57 2009 +0000
     1.2 +++ b/vymmodel.cpp	Thu Apr 02 09:46:29 2009 +0000
     1.3 @@ -670,6 +670,7 @@
     1.4  
     1.5  void VymModel::addMapInsertInt (const QString &path, int pos)
     1.6  {
     1.7 +/* FIXME-2  addMapInsertInt not ported yet
     1.8  	BranchObj *sel=getSelectedBranch();
     1.9  	if (sel)
    1.10  	{
    1.11 @@ -702,6 +703,7 @@
    1.12  		} else	
    1.13  			QMessageBox::critical( 0, tr( "Critical Error" ), tr("Could not read %1").arg(path));
    1.14  	}		
    1.15 +*/
    1.16  }
    1.17  
    1.18  FloatImageObj* VymModel::loadFloatImageInt (QString fn)
    1.19 @@ -817,6 +819,7 @@
    1.20  
    1.21  void VymModel::importDirInt(BranchObj *dst, QDir d)
    1.22  {
    1.23 +/* FIXME-2 importDirInt not ported yet
    1.24  	BranchObj *bo=getSelectedBranch();
    1.25  	if (bo)
    1.26  	{
    1.27 @@ -861,6 +864,7 @@
    1.28  				bo->setVymLink (fi.filePath());
    1.29  		}	
    1.30  	}		
    1.31 +*/
    1.32  }
    1.33  
    1.34  void VymModel::importDirInt (const QString &s)
    1.35 @@ -1470,8 +1474,8 @@
    1.36  int VymModel::branchCount()	// FIXME-2 Optimize this: use internal counter instead of going through whole map each time...
    1.37  {
    1.38  	int c=0;
    1.39 -	TreeItem *cur=NULL;
    1.40 -	TreeItem *prev=NULL;
    1.41 +	BranchItem *cur=NULL;
    1.42 +	BranchItem *prev=NULL;
    1.43  	int d;
    1.44  	next(cur,prev,d);
    1.45  	while (cur) 
    1.46 @@ -1981,10 +1985,10 @@
    1.47  	select (mco);
    1.48  }
    1.49  
    1.50 -void VymModel::createBranch()
    1.51 -{
    1.52 -	addNewBranchInt (-2);
    1.53 -	return;
    1.54 +BranchItem* VymModel::createBranch()	// FIXME-2 switcht addNewBrancInt to BranchItem...
    1.55 +{
    1.56 +	BranchObj* bo=addNewBranchInt (-2);
    1.57 +	return (BranchItem*)bo->getTreeItem();
    1.58  }
    1.59  
    1.60  TreeItem* VymModel::createImage()
    1.61 @@ -2735,7 +2739,8 @@
    1.62  void VymModel::parseAtom(const QString &atom)
    1.63  {
    1.64  	BranchObj *selb=getSelectedBranch();
    1.65 -	BranchItem *bi=getSelectedBranchItem();
    1.66 +	TreeItem* selti=getSelectedItem();
    1.67 +	BranchItem *selbi=getSelectedBranchItem();
    1.68  	QString s,t;
    1.69  	double x,y;
    1.70  	int n;
    1.71 @@ -2749,7 +2754,7 @@
    1.72  	/////////////////////////////////////////////////////////////////////
    1.73  	if (com=="addBranch")
    1.74  	{
    1.75 -		if (selection.isEmpty())
    1.76 +		if (!selti)
    1.77  		{
    1.78  			parser.setError (Aborted,"Nothing selected");
    1.79  		} else if (! selb )
    1.80 @@ -2773,7 +2778,7 @@
    1.81  	/////////////////////////////////////////////////////////////////////
    1.82  	} else if (com=="addBranchBefore")
    1.83  	{
    1.84 -		if (selection.isEmpty())
    1.85 +		if (!selti)
    1.86  		{
    1.87  			parser.setError (Aborted,"Nothing selected");
    1.88  		} else if (! selb )
    1.89 @@ -2801,7 +2806,7 @@
    1.90  	/////////////////////////////////////////////////////////////////////
    1.91  	} else if (com==QString("addMapReplace"))
    1.92  	{
    1.93 -		if (selection.isEmpty())
    1.94 +		if (!selti)
    1.95  		{
    1.96  			parser.setError (Aborted,"Nothing selected");
    1.97  		} else if (! selb )
    1.98 @@ -2817,7 +2822,7 @@
    1.99  	/////////////////////////////////////////////////////////////////////
   1.100  	} else if (com==QString("addMapInsert"))
   1.101  	{
   1.102 -		if (selection.isEmpty())
   1.103 +		if (!selti)
   1.104  		{
   1.105  			parser.setError (Aborted,"Nothing selected");
   1.106  		} else if (! selb )
   1.107 @@ -2836,7 +2841,7 @@
   1.108  	/////////////////////////////////////////////////////////////////////
   1.109  	} else if (com=="clearFlags")
   1.110  	{
   1.111 -		if (selection.isEmpty() )
   1.112 +		if (!selti )
   1.113  		{
   1.114  			parser.setError (Aborted,"Nothing selected");
   1.115  		} else if (! selb )
   1.116 @@ -2850,7 +2855,7 @@
   1.117  	/////////////////////////////////////////////////////////////////////
   1.118  	} else if (com=="colorBranch")
   1.119  	{
   1.120 -		if (selection.isEmpty())
   1.121 +		if (!selti)
   1.122  		{
   1.123  			parser.setError (Aborted,"Nothing selected");
   1.124  		} else if (! selb )
   1.125 @@ -2864,7 +2869,7 @@
   1.126  	/////////////////////////////////////////////////////////////////////
   1.127  	} else if (com=="colorSubtree")
   1.128  	{
   1.129 -		if (selection.isEmpty())
   1.130 +		if (!selti)
   1.131  		{
   1.132  			parser.setError (Aborted,"Nothing selected");
   1.133  		} else if (! selb )
   1.134 @@ -2878,7 +2883,7 @@
   1.135  	/////////////////////////////////////////////////////////////////////
   1.136  	} else if (com=="copy")
   1.137  	{
   1.138 -		if (selection.isEmpty())
   1.139 +		if (!selti)
   1.140  		{
   1.141  			parser.setError (Aborted,"Nothing selected");
   1.142  		} else if (! selb )
   1.143 @@ -2891,7 +2896,7 @@
   1.144  	/////////////////////////////////////////////////////////////////////
   1.145  	} else if (com=="cut")
   1.146  	{
   1.147 -		if (selection.isEmpty())
   1.148 +		if (!selti)
   1.149  		{
   1.150  			parser.setError (Aborted,"Nothing selected");
   1.151  		} else if ( selectionType()!=TreeItem::Branch  && 
   1.152 @@ -2906,7 +2911,7 @@
   1.153  	/////////////////////////////////////////////////////////////////////
   1.154  	} else if (com=="delete")
   1.155  	{
   1.156 -		if (selection.isEmpty())
   1.157 +		if (!selti)
   1.158  		{
   1.159  			parser.setError (Aborted,"Nothing selected");
   1.160  		} 
   1.161 @@ -2922,7 +2927,7 @@
   1.162  	/////////////////////////////////////////////////////////////////////
   1.163  	} else if (com=="deleteKeepChildren")
   1.164  	{
   1.165 -		if (selection.isEmpty())
   1.166 +		if (!selti)
   1.167  		{
   1.168  			parser.setError (Aborted,"Nothing selected");
   1.169  		} else if (! selb )
   1.170 @@ -2935,7 +2940,7 @@
   1.171  	/////////////////////////////////////////////////////////////////////
   1.172  	} else if (com=="deleteChildren")
   1.173  	{
   1.174 -		if (selection.isEmpty())
   1.175 +		if (!selti)
   1.176  		{
   1.177  			parser.setError (Aborted,"Nothing selected");
   1.178  		} else if (! selb)
   1.179 @@ -3013,7 +3018,7 @@
   1.180  	/////////////////////////////////////////////////////////////////////
   1.181  	} else if (com=="importDir")
   1.182  	{
   1.183 -		if (selection.isEmpty())
   1.184 +		if (!selti)
   1.185  		{
   1.186  			parser.setError (Aborted,"Nothing selected");
   1.187  		} else if (! selb )
   1.188 @@ -3027,7 +3032,7 @@
   1.189  	/////////////////////////////////////////////////////////////////////
   1.190  	} else if (com=="linkTo")
   1.191  	{
   1.192 -		if (selection.isEmpty())
   1.193 +		if (!selti)
   1.194  		{
   1.195  			parser.setError (Aborted,"Nothing selected");
   1.196  		} else if ( selb)
   1.197 @@ -3087,7 +3092,7 @@
   1.198  	/////////////////////////////////////////////////////////////////////
   1.199  	} else if (com=="loadImage")
   1.200  	{
   1.201 -		if (selection.isEmpty())
   1.202 +		if (!selti)
   1.203  		{
   1.204  			parser.setError (Aborted,"Nothing selected");
   1.205  		} else if (! selb )
   1.206 @@ -3101,7 +3106,7 @@
   1.207  	/////////////////////////////////////////////////////////////////////
   1.208  	} else if (com=="moveBranchUp")
   1.209  	{
   1.210 -		if (selection.isEmpty() )
   1.211 +		if (!selti )
   1.212  		{
   1.213  			parser.setError (Aborted,"Nothing selected");
   1.214  		} else if (! selb )
   1.215 @@ -3114,7 +3119,7 @@
   1.216  	/////////////////////////////////////////////////////////////////////
   1.217  	} else if (com=="moveBranchDown")
   1.218  	{
   1.219 -		if (selection.isEmpty() )
   1.220 +		if (!selti )
   1.221  		{
   1.222  			parser.setError (Aborted,"Nothing selected");
   1.223  		} else if (! selb )
   1.224 @@ -3127,7 +3132,7 @@
   1.225  	/////////////////////////////////////////////////////////////////////
   1.226  	} else if (com=="move")
   1.227  	{
   1.228 -		if (selection.isEmpty() )
   1.229 +		if (!selti )
   1.230  		{
   1.231  			parser.setError (Aborted,"Nothing selected");
   1.232  		} else if ( selectionType()!=TreeItem::Branch  && 
   1.233 @@ -3147,7 +3152,7 @@
   1.234  	/////////////////////////////////////////////////////////////////////
   1.235  	} else if (com=="moveRel")
   1.236  	{
   1.237 -		if (selection.isEmpty() )
   1.238 +		if (!selti )
   1.239  		{
   1.240  			parser.setError (Aborted,"Nothing selected");
   1.241  		} else if ( selectionType()!=TreeItem::Branch  && 
   1.242 @@ -3170,7 +3175,7 @@
   1.243  	/////////////////////////////////////////////////////////////////////
   1.244  	} else if (com=="paste")
   1.245  	{
   1.246 -		if (selection.isEmpty() )
   1.247 +		if (!selti )
   1.248  		{
   1.249  			parser.setError (Aborted,"Nothing selected");
   1.250  		} else if (! selb )
   1.251 @@ -3184,7 +3189,7 @@
   1.252  	/////////////////////////////////////////////////////////////////////
   1.253  	} else if (com=="qa")
   1.254  	{
   1.255 -		if (selection.isEmpty() )
   1.256 +		if (!selti )
   1.257  		{
   1.258  			parser.setError (Aborted,"Nothing selected");
   1.259  		} else if (! selb )
   1.260 @@ -3266,15 +3271,15 @@
   1.261  	/////////////////////////////////////////////////////////////////////
   1.262  	} else if (com=="scroll")
   1.263  	{
   1.264 -		if (selection.isEmpty() )
   1.265 +		if (!selti)
   1.266  		{
   1.267  			parser.setError (Aborted,"Nothing selected");
   1.268 -		} else if (! selb )
   1.269 +		} else if (! selbi )
   1.270  		{				  
   1.271  			parser.setError (Aborted,"Type of selection is not a branch");
   1.272  		} else if (parser.checkParCount(0))
   1.273  		{	
   1.274 -			if (!scrollBranch (bi))	
   1.275 +			if (!scrollBranch (selbi))	
   1.276  				parser.setError (Aborted,"Could not scroll branch");
   1.277  		}	
   1.278  	/////////////////////////////////////////////////////////////////////
   1.279 @@ -3288,7 +3293,7 @@
   1.280  	/////////////////////////////////////////////////////////////////////
   1.281  	} else if (com=="selectLastBranch")
   1.282  	{
   1.283 -		if (selection.isEmpty() )
   1.284 +		if (!selti )
   1.285  		{
   1.286  			parser.setError (Aborted,"Nothing selected");
   1.287  		} else if (! selb )
   1.288 @@ -3296,16 +3301,16 @@
   1.289  			parser.setError (Aborted,"Type of selection is not a branch");
   1.290  		} else if (parser.checkParCount(0))
   1.291  		{	
   1.292 -			BranchObj *bo=selb->getLastBranch();
   1.293 -			if (!bo)
   1.294 +			BranchItem *bi=selbi->getLastBranch();
   1.295 +			if (!bi)
   1.296  				parser.setError (Aborted,"Could not select last branch");
   1.297 -			selectInt (bo);	
   1.298 +			select (bi);		// FIXME-3 was selectInt
   1.299  				
   1.300  		}	
   1.301  	/////////////////////////////////////////////////////////////////////
   1.302  	} else if (com=="selectLastImage")
   1.303  	{
   1.304 -		if (selection.isEmpty() )
   1.305 +		if (!selti )
   1.306  		{
   1.307  			parser.setError (Aborted,"Nothing selected");
   1.308  		} else if (! selb )
   1.309 @@ -3316,7 +3321,7 @@
   1.310  			FloatImageObj *fio=selb->getLastFloatImage();
   1.311  			if (!fio)
   1.312  				parser.setError (Aborted,"Could not select last image");
   1.313 -			selectInt (fio);	
   1.314 +			select (fio);		// FIXME-3 was selectInt
   1.315  				
   1.316  		}	
   1.317  	/////////////////////////////////////////////////////////////////////
   1.318 @@ -3409,7 +3414,7 @@
   1.319  	/////////////////////////////////////////////////////////////////////
   1.320  	} else if (com=="setMapBackgroundColor")
   1.321  	{
   1.322 -		if (selection.isEmpty() )
   1.323 +		if (!selti )
   1.324  		{
   1.325  			parser.setError (Aborted,"Nothing selected");
   1.326  		} else if (! getSelectedBranch() )
   1.327 @@ -3423,7 +3428,7 @@
   1.328  	/////////////////////////////////////////////////////////////////////
   1.329  	} else if (com=="setMapDefLinkColor")
   1.330  	{
   1.331 -		if (selection.isEmpty() )
   1.332 +		if (!selti )
   1.333  		{
   1.334  			parser.setError (Aborted,"Nothing selected");
   1.335  		} else if (! selb )
   1.336 @@ -3445,7 +3450,7 @@
   1.337  	/////////////////////////////////////////////////////////////////////
   1.338  	} else if (com=="setHeading")
   1.339  	{
   1.340 -		if (selection.isEmpty() )
   1.341 +		if (!selti )
   1.342  		{
   1.343  			parser.setError (Aborted,"Nothing selected");
   1.344  		} else if (! selb )
   1.345 @@ -3460,7 +3465,7 @@
   1.346  	/////////////////////////////////////////////////////////////////////
   1.347  	} else if (com=="setHideExport")
   1.348  	{
   1.349 -		if (selection.isEmpty() )
   1.350 +		if (!selti )
   1.351  		{
   1.352  			parser.setError (Aborted,"Nothing selected");
   1.353  		} else if (selectionType()!=TreeItem::Branch && selectionType() != TreeItem::MapCenter &&selectionType()!=TreeItem::Image)
   1.354 @@ -3474,7 +3479,7 @@
   1.355  	/////////////////////////////////////////////////////////////////////
   1.356  	} else if (com=="setIncludeImagesHorizontally")
   1.357  	{ 
   1.358 -		if (selection.isEmpty() )
   1.359 +		if (!selti )
   1.360  		{
   1.361  			parser.setError (Aborted,"Nothing selected");
   1.362  		} else if (! selb)
   1.363 @@ -3488,7 +3493,7 @@
   1.364  	/////////////////////////////////////////////////////////////////////
   1.365  	} else if (com=="setIncludeImagesVertically")
   1.366  	{
   1.367 -		if (selection.isEmpty() )
   1.368 +		if (!selti )
   1.369  		{
   1.370  			parser.setError (Aborted,"Nothing selected");
   1.371  		} else if (! selb)
   1.372 @@ -3502,7 +3507,7 @@
   1.373  	/////////////////////////////////////////////////////////////////////
   1.374  	} else if (com=="setHideLinkUnselected")
   1.375  	{
   1.376 -		if (selection.isEmpty() )
   1.377 +		if (!selti )
   1.378  		{
   1.379  			parser.setError (Aborted,"Nothing selected");
   1.380  		} else if ( selectionType()!=TreeItem::Branch && selectionType()!= TreeItem::MapCenter && selectionType()!=TreeItem::Image)
   1.381 @@ -3524,7 +3529,7 @@
   1.382  	/////////////////////////////////////////////////////////////////////
   1.383  	} else if (com=="setURL")
   1.384  	{
   1.385 -		if (selection.isEmpty() )
   1.386 +		if (!selti )
   1.387  		{
   1.388  			parser.setError (Aborted,"Nothing selected");
   1.389  		} else if (! selb )
   1.390 @@ -3538,7 +3543,7 @@
   1.391  	/////////////////////////////////////////////////////////////////////
   1.392  	} else if (com=="setVymLink")
   1.393  	{
   1.394 -		if (selection.isEmpty() )
   1.395 +		if (!selti )
   1.396  		{
   1.397  			parser.setError (Aborted,"Nothing selected");
   1.398  		} else if (! selb )
   1.399 @@ -3553,7 +3558,7 @@
   1.400  	/////////////////////////////////////////////////////////////////////
   1.401  	else if (com=="setFlag")
   1.402  	{
   1.403 -		if (selection.isEmpty() )
   1.404 +		if (!selti )
   1.405  		{
   1.406  			parser.setError (Aborted,"Nothing selected");
   1.407  		} else if (! selb )
   1.408 @@ -3571,7 +3576,7 @@
   1.409  	/////////////////////////////////////////////////////////////////////
   1.410  	} else if (com=="setFrameType")
   1.411  	{
   1.412 -		if (selection.isEmpty() )
   1.413 +		if (!selti )
   1.414  		{
   1.415  			parser.setError (Aborted,"Nothing selected");
   1.416  		} else if (! selb )
   1.417 @@ -3586,7 +3591,7 @@
   1.418  	/////////////////////////////////////////////////////////////////////
   1.419  	} else if (com=="sortChildren")
   1.420  	{
   1.421 -		if (selection.isEmpty() )
   1.422 +		if (!selti )
   1.423  		{
   1.424  			parser.setError (Aborted,"Nothing selected");
   1.425  		} else if (! selb )
   1.426 @@ -3599,7 +3604,7 @@
   1.427  	/////////////////////////////////////////////////////////////////////
   1.428  	} else if (com=="toggleFlag")
   1.429  	{
   1.430 -		if (selection.isEmpty() )
   1.431 +		if (!selti )
   1.432  		{
   1.433  			parser.setError (Aborted,"Nothing selected");
   1.434  		} else if (! selb )
   1.435 @@ -3617,7 +3622,7 @@
   1.436  	/////////////////////////////////////////////////////////////////////
   1.437  	} else if (com=="unscroll")
   1.438  	{
   1.439 -		if (selection.isEmpty() )
   1.440 +		if (!selti)
   1.441  		{
   1.442  			parser.setError (Aborted,"Nothing selected");
   1.443  		} else if (! selb )
   1.444 @@ -3625,13 +3630,13 @@
   1.445  			parser.setError (Aborted,"Type of selection is not a branch");
   1.446  		} else if (parser.checkParCount(0))
   1.447  		{	
   1.448 -			if (!unscrollBranch (bi))	
   1.449 +			if (!unscrollBranch (selbi))	
   1.450  				parser.setError (Aborted,"Could not unscroll branch");
   1.451  		}	
   1.452  	/////////////////////////////////////////////////////////////////////
   1.453  	} else if (com=="unscrollChildren")
   1.454  	{
   1.455 -		if (selection.isEmpty() )
   1.456 +		if (!selti)
   1.457  		{
   1.458  			parser.setError (Aborted,"Nothing selected");
   1.459  		} else if (! selb )
   1.460 @@ -4021,8 +4026,8 @@
   1.461  	else
   1.462  		linkstyle=LinkableMapObj::UndefinedStyle;
   1.463  
   1.464 -	TreeItem *cur=NULL;
   1.465 -	TreeItem *prev=NULL;
   1.466 +	BranchItem *cur=NULL;
   1.467 +	BranchItem *prev=NULL;
   1.468  	int d=0;
   1.469  	BranchObj *bo;
   1.470  	next (cur,prev,d);
   1.471 @@ -4050,8 +4055,8 @@
   1.472  	);
   1.473  
   1.474  	defLinkColor=col;
   1.475 -	TreeItem *cur=NULL;
   1.476 -	TreeItem *prev=NULL;
   1.477 +	BranchItem *cur=NULL;
   1.478 +	BranchItem *prev=NULL;
   1.479  	int d=0;
   1.480  	BranchObj *bo;
   1.481  	cur=next(cur,prev,d);
   1.482 @@ -4067,8 +4072,8 @@
   1.483  void VymModel::setMapLinkColorHintInt()
   1.484  {
   1.485  	// called from setMapLinkColorHint(lch) or at end of parse
   1.486 -	TreeItem *cur=NULL;
   1.487 -	TreeItem *prev=NULL;
   1.488 +	BranchItem *cur=NULL;
   1.489 +	BranchItem *prev=NULL;
   1.490  	int d=0;
   1.491  	BranchObj *bo;
   1.492  	cur=next(cur,prev,d);
   1.493 @@ -4092,8 +4097,8 @@
   1.494  		linkcolorhint=LinkableMapObj::DefaultColor;
   1.495  	else	
   1.496  		linkcolorhint=LinkableMapObj::HeadingColor;
   1.497 -	TreeItem *cur=NULL;
   1.498 -	TreeItem *prev=NULL;
   1.499 +	BranchItem *cur=NULL;
   1.500 +	BranchItem *prev=NULL;
   1.501  	int d=0;
   1.502  	BranchObj *bo;
   1.503  	cur=next(cur,prev,d);
   1.504 @@ -4608,7 +4613,9 @@
   1.505  	emit (contentHasChanged (ix) );
   1.506  }
   1.507  
   1.508 -void VymModel::selectInt (LinkableMapObj *lmo)
   1.509 +
   1.510 +//void VymModel::selectInt (LinkableMapObj *lmo)	// FIXME-3 still needed?
   1.511 +/*
   1.512  {
   1.513  	if (selection.select(lmo))
   1.514  	{
   1.515 @@ -4617,6 +4624,15 @@
   1.516  	}
   1.517  }
   1.518  
   1.519 +void VymModel::selectInt (TreeItem *ti)	
   1.520 +{
   1.521 +	if (selection.select(lmo))
   1.522 +	{
   1.523 +		//selection.update();
   1.524 +		sendSelection ();	// FIXME-4 VM use signal
   1.525 +	}
   1.526 +}
   1.527 +*/
   1.528  
   1.529  void VymModel::selectNextBranchInt()
   1.530  {