# HG changeset patch
# User insilmaril
# Date 1233748372 0
# Node ID 3d43b46a856406902c5db2c6606b7a4f19690b33
# Parent  716a777c1c98ecae396771910dc8054e2dfbc5d6
Images are now also added to model

diff -r 716a777c1c98 -r 3d43b46a8564 mainwindow.cpp
--- a/mainwindow.cpp	Fri Jan 30 09:14:12 2009 +0000
+++ b/mainwindow.cpp	Wed Feb 04 11:52:52 2009 +0000
@@ -2871,9 +2871,9 @@
 	if (m)
 	{
 		BranchObj *bo=m->getSelectedBranch();
+		prevSelection=m->getSelectString(bo);
 		BranchObj *newbo=m->addNewBranch(0);
 
-		prevSelection=m->getSelectString(bo);
 		if (newbo) 
 			m->select (newbo);
 		else
diff -r 716a777c1c98 -r 3d43b46a8564 treeitem.cpp
--- a/treeitem.cpp	Fri Jan 30 09:14:12 2009 +0000
+++ b/treeitem.cpp	Wed Feb 04 11:52:52 2009 +0000
@@ -105,6 +105,7 @@
 		case Undefined: return QString ("Undefined");
 		case MapCenter: return QString ("MapCenter");
 		case Branch: return QString ("Branch");
+		case Image: return QString ("Image");
 		default: return QString ("TreeItem::getTypeName no typename defined?!");
 	}
 }
diff -r 716a777c1c98 -r 3d43b46a8564 version.h
--- a/version.h	Fri Jan 30 09:14:12 2009 +0000
+++ b/version.h	Wed Feb 04 11:52:52 2009 +0000
@@ -7,7 +7,7 @@
 #define __VYM_VERSION "1.13.0"
 //#define __VYM_CODENAME "Codename: RC-1"
 #define __VYM_CODENAME "Codename: development version"
-#define __VYM_BUILD_DATE "2009-01-28"
+#define __VYM_BUILD_DATE "2009-02-04"
 
 
 bool checkVersion(const QString &);
diff -r 716a777c1c98 -r 3d43b46a8564 vymmodel.cpp
--- a/vymmodel.cpp	Fri Jan 30 09:14:12 2009 +0000
+++ b/vymmodel.cpp	Wed Feb 04 11:52:52 2009 +0000
@@ -694,19 +694,16 @@
 
 FloatImageObj* VymModel::loadFloatImageInt (QString fn)
 {
-	BranchObj *bo=getSelectedBranch();
-	if (bo)
+	TreeItem *fi=createImage();
+	if (fi)
 	{
-		FloatImageObj *fio;
-		bo->addFloatImage();
-		fio=bo->getLastFloatImage();
-		fio->load(fn);
+		FloatImageObj *fio= ((FloatImageObj*)fi->getLMO());
+		fio->load (fn);
 		reposition();
-		// FIXME VM needed? scene()->update();
 		return fio;
 	}
 	return NULL;
-}	
+	}	
 
 void VymModel::loadFloatImage ()
 {
@@ -1976,26 +1973,34 @@
 
 void VymModel::createBranch()
 {
+	addNewBranchInt (-2);
+	return;
+}
+
+TreeItem* VymModel::createImage()
+{
 	BranchObj *bo=getSelectedBranch();
 	if (bo)
 	{
-		BranchObj *newbo=addNewBranchInt (-2); // FIXME VM Old model, merge with below
+		FloatImageObj *newfio=bo->addFloatImage(); // FIXME VM Old model, merge with below
 
 		// Create TreeItem
 		QList<QVariant> cData;
-		cData << "VM:createBranch" << "undef"<<"undef";
+		cData << "VM:createImage" << "undef"<<"undef";
 		TreeItem *parti=bo->getTreeItem();
 		TreeItem *ti=new TreeItem (cData,parti);
-		ti->setLMO (newbo);
-		ti->setType (TreeItem::Branch);
+		ti->setLMO (newfio);
+		ti->setType (TreeItem::Image);
 		parti->appendChild (ti);
 
-		if (newbo)
+		if (newfio)
 		{
-			newbo->setTreeItem (ti);
-			select (newbo); // FIXME VM really needed here?
+			newfio->setTreeItem (ti);
+			select (newfio); // FIXME VM really needed here?
+			return ti;
 		}
 	}
+	return NULL;
 }
 
 MapCenterObj* VymModel::addMapCenter ()
@@ -2074,6 +2079,21 @@
 			// save scroll state. If scrolled, automatically select
 			// new branch in order to tmp unscroll parent...
 			newbo=bo->addBranch();
+
+			// Create TreeItem
+			QList<QVariant> cData;
+			cData << "VM:createBranch" << "undef"<<"undef";
+			TreeItem *parti=bo->getTreeItem();
+			TreeItem *ti=new TreeItem (cData,parti);
+			ti->setLMO (newbo);
+			ti->setType (TreeItem::Branch);
+			parti->appendChild (ti);
+
+			if (newbo)
+			{
+				newbo->setTreeItem (ti);
+				select (newbo); // FIXME VM really needed here?
+			}
 			
 		}else if (num==-1)
 		{
@@ -2086,7 +2106,6 @@
 			bo=(BranchObj*)bo->getParObj();
 			if (bo) newbo=bo->insertBranch(num);
 		}
-		if (!newbo) return NULL;
 	}	
 	return newbo;
 }	
@@ -2116,7 +2135,7 @@
 				QString ("Add new branch to %1").arg(getObjectName(bo)));	
 
 			reposition();
-			selection.update();
+			// selection.update(); FIXME
 			latestSelectionString=getSelectString(newbo);
 			// In Network mode, the client needs to know where the new branch is,
 			// so we have to pass on this information via saveState.
@@ -2156,7 +2175,7 @@
 				QString ("Add branch before %1").arg(getObjectName(bo)));
 
 			reposition();
-			selection.update();
+			// selection.update(); FIXME 
 		}
 	}	
 	latestSelectionString=selection.getSelectString();
@@ -4330,7 +4349,7 @@
 	updateSelection (newsel);
 }
 
-void VymModel::updateSelection(const QItemSelection &oldsel)
+void VymModel::updateSelection(const QItemSelection &)
 {
 	QItemSelection newsel=selModel->selection();
 	/*
@@ -4800,7 +4819,6 @@
 void VymModel::selectLastSelectedBranch()
 {
 	TreeItem *ti=getSelectedBranchItem();
-	BranchObj *bo1=getSelectedBranch();
 	if (ti)
 	{
 		ti=ti->getLastSelectedBranch();
@@ -4811,7 +4829,6 @@
 void VymModel::selectParent()
 {
 	TreeItem *ti=getSelectedItem();
-	LinkableMapObj *lmo=getSelectedLMO();
 	TreeItem *par;
 	if (ti)
 	{
diff -r 716a777c1c98 -r 3d43b46a8564 vymmodel.h
--- a/vymmodel.h	Fri Jan 30 09:14:12 2009 +0000
+++ b/vymmodel.h	Wed Feb 04 11:52:52 2009 +0000
@@ -278,8 +278,9 @@
 	void sortChildren();	//!< Sort children lexically
 
 	// The create methods are used to quickly parse a XML file
-	void createMapCenter();	//!< Create and select MapCenter
-	void createBranch();	//!< Create and select Branch
+	void createMapCenter();			//!< Create and select MapCenter
+	void createBranch();			//!< Create and select Branch
+	TreeItem* createImage();		//!< Create and select image
 
 	/*! \brief Add new mapcenter