Images are now also added to model
authorinsilmaril
Wed, 04 Feb 2009 11:52:52 +0000
changeset 7393d43b46a8564
parent 738 716a777c1c98
child 740 6dc0a20031f7
Images are now also added to model
mainwindow.cpp
treeitem.cpp
version.h
vymmodel.cpp
vymmodel.h
     1.1 --- a/mainwindow.cpp	Fri Jan 30 09:14:12 2009 +0000
     1.2 +++ b/mainwindow.cpp	Wed Feb 04 11:52:52 2009 +0000
     1.3 @@ -2871,9 +2871,9 @@
     1.4  	if (m)
     1.5  	{
     1.6  		BranchObj *bo=m->getSelectedBranch();
     1.7 +		prevSelection=m->getSelectString(bo);
     1.8  		BranchObj *newbo=m->addNewBranch(0);
     1.9  
    1.10 -		prevSelection=m->getSelectString(bo);
    1.11  		if (newbo) 
    1.12  			m->select (newbo);
    1.13  		else
     2.1 --- a/treeitem.cpp	Fri Jan 30 09:14:12 2009 +0000
     2.2 +++ b/treeitem.cpp	Wed Feb 04 11:52:52 2009 +0000
     2.3 @@ -105,6 +105,7 @@
     2.4  		case Undefined: return QString ("Undefined");
     2.5  		case MapCenter: return QString ("MapCenter");
     2.6  		case Branch: return QString ("Branch");
     2.7 +		case Image: return QString ("Image");
     2.8  		default: return QString ("TreeItem::getTypeName no typename defined?!");
     2.9  	}
    2.10  }
     3.1 --- a/version.h	Fri Jan 30 09:14:12 2009 +0000
     3.2 +++ b/version.h	Wed Feb 04 11:52:52 2009 +0000
     3.3 @@ -7,7 +7,7 @@
     3.4  #define __VYM_VERSION "1.13.0"
     3.5  //#define __VYM_CODENAME "Codename: RC-1"
     3.6  #define __VYM_CODENAME "Codename: development version"
     3.7 -#define __VYM_BUILD_DATE "2009-01-28"
     3.8 +#define __VYM_BUILD_DATE "2009-02-04"
     3.9  
    3.10  
    3.11  bool checkVersion(const QString &);
     4.1 --- a/vymmodel.cpp	Fri Jan 30 09:14:12 2009 +0000
     4.2 +++ b/vymmodel.cpp	Wed Feb 04 11:52:52 2009 +0000
     4.3 @@ -694,19 +694,16 @@
     4.4  
     4.5  FloatImageObj* VymModel::loadFloatImageInt (QString fn)
     4.6  {
     4.7 -	BranchObj *bo=getSelectedBranch();
     4.8 -	if (bo)
     4.9 +	TreeItem *fi=createImage();
    4.10 +	if (fi)
    4.11  	{
    4.12 -		FloatImageObj *fio;
    4.13 -		bo->addFloatImage();
    4.14 -		fio=bo->getLastFloatImage();
    4.15 -		fio->load(fn);
    4.16 +		FloatImageObj *fio= ((FloatImageObj*)fi->getLMO());
    4.17 +		fio->load (fn);
    4.18  		reposition();
    4.19 -		// FIXME VM needed? scene()->update();
    4.20  		return fio;
    4.21  	}
    4.22  	return NULL;
    4.23 -}	
    4.24 +	}	
    4.25  
    4.26  void VymModel::loadFloatImage ()
    4.27  {
    4.28 @@ -1976,26 +1973,34 @@
    4.29  
    4.30  void VymModel::createBranch()
    4.31  {
    4.32 +	addNewBranchInt (-2);
    4.33 +	return;
    4.34 +}
    4.35 +
    4.36 +TreeItem* VymModel::createImage()
    4.37 +{
    4.38  	BranchObj *bo=getSelectedBranch();
    4.39  	if (bo)
    4.40  	{
    4.41 -		BranchObj *newbo=addNewBranchInt (-2); // FIXME VM Old model, merge with below
    4.42 +		FloatImageObj *newfio=bo->addFloatImage(); // FIXME VM Old model, merge with below
    4.43  
    4.44  		// Create TreeItem
    4.45  		QList<QVariant> cData;
    4.46 -		cData << "VM:createBranch" << "undef"<<"undef";
    4.47 +		cData << "VM:createImage" << "undef"<<"undef";
    4.48  		TreeItem *parti=bo->getTreeItem();
    4.49  		TreeItem *ti=new TreeItem (cData,parti);
    4.50 -		ti->setLMO (newbo);
    4.51 -		ti->setType (TreeItem::Branch);
    4.52 +		ti->setLMO (newfio);
    4.53 +		ti->setType (TreeItem::Image);
    4.54  		parti->appendChild (ti);
    4.55  
    4.56 -		if (newbo)
    4.57 +		if (newfio)
    4.58  		{
    4.59 -			newbo->setTreeItem (ti);
    4.60 -			select (newbo); // FIXME VM really needed here?
    4.61 +			newfio->setTreeItem (ti);
    4.62 +			select (newfio); // FIXME VM really needed here?
    4.63 +			return ti;
    4.64  		}
    4.65  	}
    4.66 +	return NULL;
    4.67  }
    4.68  
    4.69  MapCenterObj* VymModel::addMapCenter ()
    4.70 @@ -2074,6 +2079,21 @@
    4.71  			// save scroll state. If scrolled, automatically select
    4.72  			// new branch in order to tmp unscroll parent...
    4.73  			newbo=bo->addBranch();
    4.74 +
    4.75 +			// Create TreeItem
    4.76 +			QList<QVariant> cData;
    4.77 +			cData << "VM:createBranch" << "undef"<<"undef";
    4.78 +			TreeItem *parti=bo->getTreeItem();
    4.79 +			TreeItem *ti=new TreeItem (cData,parti);
    4.80 +			ti->setLMO (newbo);
    4.81 +			ti->setType (TreeItem::Branch);
    4.82 +			parti->appendChild (ti);
    4.83 +
    4.84 +			if (newbo)
    4.85 +			{
    4.86 +				newbo->setTreeItem (ti);
    4.87 +				select (newbo); // FIXME VM really needed here?
    4.88 +			}
    4.89  			
    4.90  		}else if (num==-1)
    4.91  		{
    4.92 @@ -2086,7 +2106,6 @@
    4.93  			bo=(BranchObj*)bo->getParObj();
    4.94  			if (bo) newbo=bo->insertBranch(num);
    4.95  		}
    4.96 -		if (!newbo) return NULL;
    4.97  	}	
    4.98  	return newbo;
    4.99  }	
   4.100 @@ -2116,7 +2135,7 @@
   4.101  				QString ("Add new branch to %1").arg(getObjectName(bo)));	
   4.102  
   4.103  			reposition();
   4.104 -			selection.update();
   4.105 +			// selection.update(); FIXME
   4.106  			latestSelectionString=getSelectString(newbo);
   4.107  			// In Network mode, the client needs to know where the new branch is,
   4.108  			// so we have to pass on this information via saveState.
   4.109 @@ -2156,7 +2175,7 @@
   4.110  				QString ("Add branch before %1").arg(getObjectName(bo)));
   4.111  
   4.112  			reposition();
   4.113 -			selection.update();
   4.114 +			// selection.update(); FIXME 
   4.115  		}
   4.116  	}	
   4.117  	latestSelectionString=selection.getSelectString();
   4.118 @@ -4330,7 +4349,7 @@
   4.119  	updateSelection (newsel);
   4.120  }
   4.121  
   4.122 -void VymModel::updateSelection(const QItemSelection &oldsel)
   4.123 +void VymModel::updateSelection(const QItemSelection &)
   4.124  {
   4.125  	QItemSelection newsel=selModel->selection();
   4.126  	/*
   4.127 @@ -4800,7 +4819,6 @@
   4.128  void VymModel::selectLastSelectedBranch()
   4.129  {
   4.130  	TreeItem *ti=getSelectedBranchItem();
   4.131 -	BranchObj *bo1=getSelectedBranch();
   4.132  	if (ti)
   4.133  	{
   4.134  		ti=ti->getLastSelectedBranch();
   4.135 @@ -4811,7 +4829,6 @@
   4.136  void VymModel::selectParent()
   4.137  {
   4.138  	TreeItem *ti=getSelectedItem();
   4.139 -	LinkableMapObj *lmo=getSelectedLMO();
   4.140  	TreeItem *par;
   4.141  	if (ti)
   4.142  	{
     5.1 --- a/vymmodel.h	Fri Jan 30 09:14:12 2009 +0000
     5.2 +++ b/vymmodel.h	Wed Feb 04 11:52:52 2009 +0000
     5.3 @@ -278,8 +278,9 @@
     5.4  	void sortChildren();	//!< Sort children lexically
     5.5  
     5.6  	// The create methods are used to quickly parse a XML file
     5.7 -	void createMapCenter();	//!< Create and select MapCenter
     5.8 -	void createBranch();	//!< Create and select Branch
     5.9 +	void createMapCenter();			//!< Create and select MapCenter
    5.10 +	void createBranch();			//!< Create and select Branch
    5.11 +	TreeItem* createImage();		//!< Create and select image
    5.12  
    5.13  	/*! \brief Add new mapcenter
    5.14