# HG changeset patch
# User insilmaril
# Date 1265809722 0
# Node ID c2ce9944148c7f0d9b32aa3cf857967a073fdee2
# Parent  4a84d7e444d89c999961efac768fa1349338e571
More fixes and sorting lexically backwards

diff -r 4a84d7e444d8 -r c2ce9944148c attributeitem.cpp
--- a/attributeitem.cpp	Thu Jan 21 11:56:57 2010 +0000
+++ b/attributeitem.cpp	Wed Feb 10 13:48:42 2010 +0000
@@ -6,7 +6,7 @@
 
 extern bool debug;
 
-AttributeItem::AttributeItem(const QList<QVariant> &data, TreeItem *parent):TreeItem (data,parent)
+AttributeItem::AttributeItem(const QList<QVariant> &data, TreeItem *parent):BranchItem (data,parent)
 {
 	TreeItem::setType (Attribute);
 	//table=NULL;
diff -r 4a84d7e444d8 -r c2ce9944148c attributeitem.h
--- a/attributeitem.h	Thu Jan 21 11:56:57 2010 +0000
+++ b/attributeitem.h	Wed Feb 10 13:48:42 2010 +0000
@@ -4,13 +4,13 @@
 #include <QStringList>
 #include <QVariant>
 
-#include "treeitem.h"
+#include "branchitem.h"
 
 /*! \brief A key and a value 
     The data itself is stored in Attribute Definitions (AttributeDef). 
 	A list of these tables AttributeTable is maintained for every MapEditor.
 */
-class AttributeItem:public TreeItem {
+class AttributeItem:public BranchItem {
 
 enum Type {
 	Undefined,	//!< Undefined type
diff -r 4a84d7e444d8 -r c2ce9944148c branchitem.cpp
--- a/branchitem.cpp	Thu Jan 21 11:56:57 2010 +0000
+++ b/branchitem.cpp	Wed Feb 10 13:48:42 2010 +0000
@@ -1,3 +1,4 @@
+#include "attributeitem.h"
 #include "branchitem.h"
 #include "branchobj.h"
 #include "vymmodel.h"
@@ -118,7 +119,7 @@
 		+getMapAttr()
 		+getGeneralAttr()
 		+scrolledAttr 
-	//	+areaAttr	// FIXME-2
+	//	+areaAttr	// FIXME-4 not needed anymore. Wait until end of 2010 before removing...
 		+idAttr 
 		+getIncludeImageAttr() 
 		);
@@ -290,7 +291,7 @@
 	return result;
 }
 
-void BranchItem::sortChildren()
+void BranchItem::sortChildren(bool inverse)
 {
 	int childCount=branchCounter; 
 	int curChildIndex;
@@ -298,15 +299,28 @@
 	do
 	{
 		madeChanges=false;
-		for(curChildIndex=1;curChildIndex<childCount;curChildIndex++){
-			BranchItem* curChild =getBranchNum(curChildIndex);
-			BranchItem* prevChild=getBranchNum(curChildIndex-1);
-			if(prevChild->getHeading().compare(curChild->getHeading())>0)
+		if (inverse)
+			for(curChildIndex=1;curChildIndex<childCount;curChildIndex++)
 			{
-				model->moveUp(curChild);
-				madeChanges=true;
+				BranchItem* curChild =getBranchNum(curChildIndex);
+				BranchItem* prevChild=getBranchNum(curChildIndex-1);
+				if (prevChild->getHeading().compare(curChild->getHeading())<0)
+				{
+					model->moveUp (curChild);
+					madeChanges=true;
+				}	
+			} 
+		else
+			for(curChildIndex=1;curChildIndex<childCount;curChildIndex++)
+			{
+				BranchItem* curChild =getBranchNum(curChildIndex);
+				BranchItem* prevChild=getBranchNum(curChildIndex-1);
+				if ( prevChild->getHeading().compare(curChild->getHeading())>0)
+				{
+					model->moveUp(curChild);
+					madeChanges=true;
+				}	
 			}
-		}
 	}while(madeChanges);
 }
 
@@ -387,7 +401,6 @@
 
 
 
-
 TreeItem* BranchItem::findMapItem (QPointF p, TreeItem* excludeTI)
 {
 	// Search branches
@@ -415,34 +428,24 @@
 			mo->isVisibleObj() 
 		) return ii;
 	}
+
+	// Search attributes
+	AttributeItem *ai;
+    for (int i=0; i<attributeCount(); ++i )
+	{
+		ai=getAttributeNum (i);
+		LinkableMapObj *mo=ai->getLMO();
+		if (mo && mo->isInClickBox(p) && 
+			(ii != excludeTI) && 
+			this!= excludeTI &&
+			mo->isVisibleObj() 
+		) return ai;
+	}
+
 	return NULL;
 }
-/*
-TreeItem* BranchItem::findID (QString sid)	//FIXME-3 move to TreeItem	//FIXME-4 search images
-{
-	// Search branches
-    TreeItem *ti;
-	for (int i=0; i<branchCount(); ++i)
-    {	
-		ti=getBranchNum(i)->findID (sid);
-		if (ti != NULL) return ti;
-    }
-	
-	// Search myself
-	if (sid==objID) return this;
 
-
-	// Search float images 
-    for (int i=0; i<floatimage.size(); ++i )
-		if (floatimage.at(i)->inBox(p) && 
-			(floatimage.at(i) != excludeLMO) && 
-			floatimage.at(i)->getParObj()!= excludeLMO &&
-			floatimage.at(i)->isVisibleObj() 
-		) return floatimage.at(i);
-    return NULL;
-}
-*/
-void BranchItem::updateStyles()
+void BranchItem::updateStyles(const bool &keepFrame)
 {
 	// FIXME-5 compare also MapItem::initLMO...
 
@@ -452,7 +455,7 @@
 			lmo->setParObj ( ((MapItem*)parentItem)->getLMO() );
 		else
 			lmo->setParObj (NULL);
-		((BranchObj*)lmo)->setDefAttr(BranchObj::MovedBranch);
+		((BranchObj*)lmo)->setDefAttr(BranchObj::MovedBranch,keepFrame);
 	}
 }
 
diff -r 4a84d7e444d8 -r c2ce9944148c branchitem.h
--- a/branchitem.h	Thu Jan 21 11:56:57 2010 +0000
+++ b/branchitem.h	Wed Feb 10 13:48:42 2010 +0000
@@ -35,7 +35,7 @@
 	virtual bool hasScrolledParent(BranchItem*);	// true, if any of the parents is scrolled
 	virtual bool tmpUnscroll();				// unscroll scrolled parents temporary e.g. during "find" process
 	virtual bool resetTmpUnscroll();		// scroll all tmp scrolled parents again e.g. when unselecting
-	virtual void sortChildren();		//! Sort children 
+	virtual void sortChildren(bool inverse=false);		//! Sort children 
 
 protected:
 	bool includeImagesVer;			//! include floatimages in bbox vertically
@@ -58,11 +58,10 @@
 
 public:
 	TreeItem* findMapItem (QPointF p,TreeItem* excludeTI);	//! search map for branches or images. Ignore excludeTI, where search is started 
-//	virtual TreeItem* findID (QString sid);	//! search map for object with ID string
 
-	virtual void updateStyles ();			//! update related fonts, parObjects, links, ...
+	virtual void updateStyles (const bool &keepFrame=false);		//! update related fonts, parObjects, links, ...
 	virtual BranchObj* getBranchObj();	
-	virtual BranchObj* createMapObj(QGraphicsScene *scene);		//! Create classic object in GraphicsView
+	virtual BranchObj* createMapObj(QGraphicsScene *scene);	//! Create classic object in GraphicsView
 };
 
 #endif
diff -r 4a84d7e444d8 -r c2ce9944148c branchobj.cpp
--- a/branchobj.cpp	Thu Jan 21 11:56:57 2010 +0000
+++ b/branchobj.cpp	Wed Feb 10 13:48:42 2010 +0000
@@ -1,5 +1,6 @@
 #include "branchobj.h"
 
+#include "attributeitem.h"
 #include "branchitem.h"
 #include "geometry.h"
 #include "mapeditor.h"
@@ -439,26 +440,22 @@
 	if (changed) updateContentSize(); 
 }
 
-void BranchObj::setDefAttr (BranchModification mod)
+void BranchObj::setDefAttr (BranchModification mod, bool keepFrame)
 {
 	int fontsize;
 	switch (treeItem->depth())
 	{
 		case 0: 
 			fontsize=16; 
-			setFrameType (FrameObj::Rectangle);
 			break;
 		case 1: 
 			fontsize=14; 
-			setFrameType (FrameObj::NoFrame);
 			break;
 		case 2: 
 			fontsize=12; 
-			setFrameType (FrameObj::NoFrame);
 			break;
 		default: 
 			fontsize=10; 
-			setFrameType (FrameObj::NoFrame);
 			break;
 	}	
 	setLinkStyle(getDefLinkStyle(treeItem->parent() ));
@@ -467,12 +464,20 @@
 	font.setPointSize(fontsize);
 	heading->setFont(font );
 
+	if (mod==NewBranch && !keepFrame)
+	if (treeItem->depth()==0)
+		setFrameType (FrameObj::Rectangle);
+	else	
+		setFrameType (FrameObj::NoFrame);
+
 	if (mod==NewBranch)
 		setColor (treeItem->getHeadingColor() );
 	else
+	{
 		// Also set styles for children
 		for (int i=0; i<treeItem->branchCount(); ++i)
 			treeItem->getBranchObjNum(i)->setDefAttr(MovedBranch);
+	}		
 	calcBBoxSize();
 }
 
@@ -559,7 +564,21 @@
 	else	
 		ref2.setY(ref.y() );	
 
-    // Align the children depending on reference point 
+    // Align the attribute children depending on reference point 
+	// on top like in TreeEditor
+	for (int i=0; i<treeItem->attributeCount(); ++i)
+    {	
+		if (!treeItem->getAttributeNum(i)->isHidden())
+		{
+			BranchObj *bo=(BranchObj*)(treeItem->getAttributeNum(i)->getBranchObj());
+			if (!bo) break;
+			bo->alignRelativeTo (ref2,true);
+
+			// append next branch below current one
+			ref2.setY(ref2.y() + bo->getBBoxSizeWithChildren().height() );
+		}
+    }
+    // Align the branch children depending on reference point 
 	for (int i=0; i<treeItem->branchCount(); ++i)
     {	
 		if (!treeItem->getBranchNum(i)->isHidden())
@@ -718,8 +737,22 @@
 	{
 		if (!bi->getBranchNum(i)->isHidden())
 		{
-			bi->getBranchObjNum(i)->calcBBoxSizeWithChildren();
-			br=bi->getBranchObjNum(i)->getBBoxSizeWithChildren();
+			BranchObj *bo=bi->getBranchObjNum(i);
+			bo->calcBBoxSizeWithChildren();
+			br=bo->getBBoxSizeWithChildren();
+			r.setWidth( max (br.width(), r.width() ));
+			r.setHeight(br.height() + r.height() );
+			if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y());
+			if (br.x()<bboxTotal.x()) bboxTotal.setX(br.x());
+		}
+	}
+	for (int i=0; i<treeItem->attributeCount(); i++)
+	{
+		if (!bi->getAttributeNum(i)->isHidden())
+		{
+			BranchObj *bo=bi->getAttributeNum(i)->getBranchObj();
+			bo->calcBBoxSizeWithChildren();
+			br=bo->getBBoxSizeWithChildren();
 			r.setWidth( max (br.width(), r.width() ));
 			r.setHeight(br.height() + r.height() );
 			if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y());
diff -r 4a84d7e444d8 -r c2ce9944148c branchobj.h
--- a/branchobj.h	Thu Jan 21 11:56:57 2010 +0000
+++ b/branchobj.h	Wed Feb 10 13:48:42 2010 +0000
@@ -40,7 +40,7 @@
     virtual void updateData();	//! Update represantatio of heading, flags, etc.
 
 public:	
-	virtual void setDefAttr (BranchModification);	// set default attributes (font, size, ...)
+	virtual void setDefAttr (BranchModification, bool keepFrame=false);	// set default attributes (frame, font, size, ...)
 
     virtual void alignRelativeTo(const QPointF, bool alignSelf=false );
 	virtual void reposition();
diff -r 4a84d7e444d8 -r c2ce9944148c exports.cpp
--- a/exports.cpp	Thu Jan 21 11:56:57 2010 +0000
+++ b/exports.cpp	Wed Feb 10 13:48:42 2010 +0000
@@ -607,7 +607,7 @@
 	ts<<" <link rel='stylesheet' id='css.stylesheet' href='vym.css' />\n";
 
 	// Include image
-	ts<<"<center><img src=\"xxx.png\" usemap='#imagemap'></center>\n";
+	ts<<"<center><img src=\""<<model->getMapName()<<".png\" usemap='#imagemap'></center>\n";
 
 
 	// Main loop over all mapcenters
diff -r 4a84d7e444d8 -r c2ce9944148c exportxhtmldialog.cpp
--- a/exportxhtmldialog.cpp	Thu Jan 21 11:56:57 2010 +0000
+++ b/exportxhtmldialog.cpp	Wed Feb 10 13:48:42 2010 +0000
@@ -273,6 +273,7 @@
 
 void ExportXHTMLDialog::doExport (const QString &mapname)
 {
+
 	// Save options to settings file 
 	// (but don't save at destructor, which
 	// is called for "cancel", too)
@@ -310,6 +311,12 @@
 			(filepath,"/export/xhtml/css",css);	
 	}
 
+	if (!saveSettingsInMap)
+		settings.clearLocal("/export/xhtml");
+	else	
+		settings.setLocalEntry 
+			(filepath,"/export/xhtml/saveSettingsInMap","yes");
+
 	// Provide a smaller URL-icon to improve Layout
 	QPixmap pm;
 	if (!pm.load(ipath,"PNG") )
@@ -318,11 +325,6 @@
 		
 	if(!pm.save (dir + "flags/flag-url-16x16.png","PNG"))
 		QMessageBox::warning( 0, tr( "Warning" ),tr("Could not write %1").arg(ipath));
-	if (!saveSettingsInMap)
-		settings.clearLocal("/export/xhtml");
-	else	
-		settings.setLocalEntry 
-			(filepath,"/export/xhtml/saveSettingsInMap","yes");
 
 	// Copy CSS file
 	QFile css_src (css);
diff -r 4a84d7e444d8 -r c2ce9944148c icons/editsortback.png
Binary file icons/editsortback.png has changed
diff -r 4a84d7e444d8 -r c2ce9944148c mainwindow.cpp
--- a/mainwindow.cpp	Thu Jan 21 11:56:57 2010 +0000
+++ b/mainwindow.cpp	Wed Feb 10 13:48:42 2010 +0000
@@ -312,7 +312,7 @@
 		progressDialog.setValue (v+progressDialog.value());
 }
 
-void Main::removeProgressValue(int v)
+void Main::removeProgressCounter()
 {
 	progressMax=0;
 	progressCounter--;
@@ -691,6 +691,13 @@
 	editMenu->addAction (a);
 	actionSortChildren=a;
 
+	a = new QAction( QPixmap(iconPath+"editsortback.png" ), tr( "Sort children backwards","Edit menu" ), this );
+	connect( a, SIGNAL( activated() ), this, SLOT( editSortBackChildren() ) );
+	a->setEnabled (true);
+	a->addTo( tb );
+	editMenu->addAction (a);
+	actionSortBackChildren=a;
+
 	alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch","Edit menu" ), this);
 	alt->setShortcut ( Qt::Key_S );					// Scroll branch
 	alt->setStatusTip (tr( "Scroll branch" )); 
@@ -2893,7 +2900,13 @@
 void Main::editSortChildren()
 {
 	VymModel *m=currentModel();
-	if (m) m->sortChildren();
+	if (m) m->sortChildren(false);
+}
+
+void Main::editSortBackChildren()
+{
+	VymModel *m=currentModel();
+	if (m) m->sortChildren(true);
 }
 
 void Main::editToggleScroll()
@@ -3606,6 +3619,7 @@
 					actionMoveDown->setEnabled (false);
 
 				actionSortChildren->setEnabled (true);
+				actionSortBackChildren->setEnabled (true);
 
 				actionToggleHideExport->setEnabled (true);	
 				actionToggleHideExport->setChecked (selbi->hideInExport() );	
@@ -3657,6 +3671,7 @@
 			actionMoveDown->setEnabled (false);
 			actionFormatHideLinkUnselected->setEnabled (false);
 			actionSortChildren->setEnabled (false);
+			actionSortBackChildren->setEnabled (false);
 			actionToggleHideExport->setEnabled (false);	
 		}	
 	} // m
@@ -3741,6 +3756,35 @@
 
 void Main::testFunction1()
 {
+
+	Process p;
+	QString script="test/sleep.sh";
+	p.start (script);
+	if (!p.waitForStarted())
+	{
+		cout <<"VM::getBugzillaData couldn't start "<<script.toStdString()<<endl;
+		return;
+	}	
+	if (!p.waitForFinished())
+	{
+		cout <<"VM::getBugzillaData couldn't finish "<<script.toStdString()<<endl;
+		return;
+	}
+	//QByteArray result=p.readAll();
+	QString result=p.getStdout();
+	while (result.endsWith("\n")) result.chop(1); 
+	//cout << QString(result).toStdString()<<endl;
+	QString err=p.getErrout();
+	if (!err.isEmpty())
+	{
+		cout << "VM::getBugzillaData Error:\n";
+		cout <<err.toStdString()<<endl;
+	}
+	else if (!result.isEmpty())
+	{
+		cout << "ok\n";
+	}	
+/*
 	int max=100000;
 	QProgressDialog p ("testprogress","cancel",0,max,this);
 	p.setWindowModality (Qt::WindowModal);
@@ -3768,9 +3812,11 @@
 	p.setValue (max);
 	cout << "Done.\n";
 	return;
-
+*/
+/*
 	if (!currentMapEditor()) return;
 	currentMapEditor()->testFunction1();
+*/
 /*
 
 	VymModel *m=currentModel();
diff -r 4a84d7e444d8 -r c2ce9944148c mainwindow.h
--- a/mainwindow.h	Thu Jan 21 11:56:57 2010 +0000
+++ b/mainwindow.h	Wed Feb 10 13:48:42 2010 +0000
@@ -44,7 +44,7 @@
 	void setProgressMaximum (int max);
 	void addProgressValue (float v);
 	void setProgressCounter (int v);
-	void removeProgressValue (int v);
+	void removeProgressCounter();
 
 public slots:
     void fileNew();
@@ -151,6 +151,7 @@
     void editMoveDown();	
     void editDetach();	
 	void editSortChildren();
+	void editSortBackChildren();
     void editToggleScroll();
     void editExpandAll();
     void editExpandOneLevel();
@@ -288,6 +289,7 @@
 	QAction *actionMoveDown;
 	QAction *actionDetach;
 	QAction *actionSortChildren;
+	QAction *actionSortBackChildren;
 	QAction *actionToggleScroll;
 	QAction *actionExpandAll;
 	QAction *actionExpandOneLevel;
diff -r 4a84d7e444d8 -r c2ce9944148c mysortfilterproxymodel.cpp
--- a/mysortfilterproxymodel.cpp	Thu Jan 21 11:56:57 2010 +0000
+++ b/mysortfilterproxymodel.cpp	Wed Feb 10 13:48:42 2010 +0000
@@ -25,7 +25,7 @@
 }
 */
 
-bool MySortFilterProxyModel::filterAcceptsRow(int sourceRow,	// FIXME-2 find a way to show _all_ rows which match, independent of parent
+bool MySortFilterProxyModel::filterAcceptsRow(int sourceRow,	// FIXME-3 find a way to show _all_ rows which match, independent of parent
         const QModelIndex &sourceParent) const
 {
     QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent);
diff -r 4a84d7e444d8 -r c2ce9944148c tex/vym.changelog
--- a/tex/vym.changelog	Thu Jan 21 11:56:57 2010 +0000
+++ b/tex/vym.changelog	Wed Feb 10 13:48:42 2010 +0000
@@ -1,3 +1,13 @@
+-------------------------------------------------------------------
+Wed Feb 10 14:47:49 CET 2010 - vym@insilmaril.de
+
+- Feature: Sort lexically backwards
+
+-------------------------------------------------------------------
+Tue Feb  9 10:26:23 CET 2010 - vym@insilmaril.de
+
+- Bugfix: Relinking now keeps frametype 
+
 -------------------------------------------------------------------
 Thu Jan 21 09:22:08 CET 2010 - vym@insilmaril.de
 
diff -r 4a84d7e444d8 -r c2ce9944148c treeeditor.cpp
--- a/treeeditor.cpp	Thu Jan 21 11:56:57 2010 +0000
+++ b/treeeditor.cpp	Wed Feb 10 13:48:42 2010 +0000
@@ -67,7 +67,7 @@
 void TreeEditor::cursorUp()
 {
 	QModelIndex ix=getSelectedIndex();
-	// FIXME-2 useproxymodel ix=proxyModel->mapToSource (indexAbove(ix));
+	// FIXME-3 useproxymodel ix=proxyModel->mapToSource (indexAbove(ix));
 	ix=indexAbove (ix);
 	if (ix.isValid())
 		model->select (ix );
@@ -76,7 +76,7 @@
 void TreeEditor::cursorDown()
 {
 	QModelIndex ix=getSelectedIndex();
-	//FIXME-2 useProxymodel ix=proxyModel->mapToSource (indexBelow(ix));
+	//FIXME-3 useProxymodel ix=proxyModel->mapToSource (indexBelow(ix));
 	ix=indexBelow (ix);
 	if (ix.isValid())
 		model->select (ix );
diff -r 4a84d7e444d8 -r c2ce9944148c treeitem.cpp
--- a/treeitem.cpp	Thu Jan 21 11:56:57 2010 +0000
+++ b/treeitem.cpp	Wed Feb 10 13:48:42 2010 +0000
@@ -13,6 +13,8 @@
 
 extern FlagRow* standardFlagsMaster;
 
+uint TreeItem::idLast=0;	// Create instance
+
 TreeItem::TreeItem()
 {
 	cout << "Constr. TI  this="<<this<<endl;
@@ -50,10 +52,14 @@
 {
 	model=NULL;
 
+	// Reset ID  //FIXME-2 compare objID (string), so far only used for xLinks during load/save (Id=selString)
+	idLast++;
+	id=idLast;
+
 	branchOffset=0;
 	branchCounter=0;
 
-	imageOffset=0;
+ 	imageOffset=0;
 	imageCounter=0;
 
 	attributeCounter=0;
@@ -69,9 +75,6 @@
 	hidden=false;
 	hideExport=false;
 
-	// Reset ID
-	objID="";
-
 	standardFlags.setMasterRow (standardFlagsMaster);
 }
 
@@ -510,14 +513,21 @@
 	}
 }
 
-void TreeItem::setID (const QString &s)
+uint TreeItem::getID()
 {
-	objID=s;
+	return id;
 }
 
-QString TreeItem::getID()
+TreeItem* TreeItem::findID (const uint &n)
 {
-	return objID;
+	if (n>=0 && n<childItems.count() )
+	{
+		for (int i=0;i<childItems.count(); i++)
+			if (n==childItems.at(i)->id)
+				return childItems.at(n);
+	}
+	else
+		return NULL;
 }
 
 
diff -r 4a84d7e444d8 -r c2ce9944148c treeitem.h
--- a/treeitem.h	Thu Jan 21 11:56:57 2010 +0000
+++ b/treeitem.h	Wed Feb 10 13:48:42 2010 +0000
@@ -135,12 +135,13 @@
 	virtual bool canMoveUp();
 
 protected:
-	QString objID;					//! id set during load/save currently used for xLinks
+	static uint idLast;			// the last used unique ID
+	uint id;
 public:
-	virtual void setID (const QString &s);
-	virtual QString getID ();
+	virtual uint getID ();
 
 	// Navigation and selection
+	virtual TreeItem* findID (const uint &n);
 	virtual TreeItem* getChildNum(const int &n);
 	virtual BranchItem* getFirstBranch();
 	virtual BranchItem* getLastBranch();
@@ -194,7 +195,6 @@
 
 	int xlinkOffset;
 	int xlinkCounter;
-
 };
 
 #endif
diff -r 4a84d7e444d8 -r c2ce9944148c version.h
--- a/version.h	Thu Jan 21 11:56:57 2010 +0000
+++ b/version.h	Wed Feb 10 13:48:42 2010 +0000
@@ -7,7 +7,7 @@
 #define __VYM_VERSION "1.13.0"
 //#define __VYM_CODENAME "Codename: RC-1"
 #define __VYM_CODENAME "Codename: development version, not for production!"
-#define __VYM_BUILD_DATE "2010-01-21"
+#define __VYM_BUILD_DATE "2010-02-10"
 
 
 bool checkVersion(const QString &);
diff -r 4a84d7e444d8 -r c2ce9944148c vymmodel.cpp
--- a/vymmodel.cpp	Thu Jan 21 11:56:57 2010 +0000
+++ b/vymmodel.cpp	Wed Feb 10 13:48:42 2010 +0000
@@ -143,9 +143,6 @@
 	// Network
 	netstate=Offline;
 
-	// Create MapCenter
-	//  addMapCenter();  FIXME-2 VM create this in MapEditor until BO and MCO are independent of scene
-
 	//Initialize DBUS object
 	adaptorModel=new AdaptorModel(this);	// Created and not deleted as documented in Qt
     if (!dbusConnection.registerObject (QString("/vymmodel_%1").arg(mapNum),this))
@@ -1438,14 +1435,14 @@
 	return  ti;
 }
 
-TreeItem* VymModel::findID (const QString &s)	//FIXME-4 Search also other types...
+TreeItem* VymModel::findID (const uint &i)	//FIXME-3 Search also other types...
 {
 	BranchItem *cur=NULL;
 	BranchItem *prev=NULL;
 	nextBranch(cur,prev);
 	while (cur) 
 	{
-		if (s==cur->getID() ) return cur;
+		if (i==cur->getID() ) return cur;
 		nextBranch(cur,prev);
 	}
 	return NULL;
@@ -1553,7 +1550,6 @@
 
 void VymModel::setNote(const QString &s)
 {
-	cout << "VM::setNote\n";
 	TreeItem *selti=getSelectedItem();
 	if (selti) 
 	{
@@ -1881,7 +1877,7 @@
 	}	
 }
 
-void VymModel::setHideLinkUnselected (bool b)//FIXME-2
+void VymModel::setHideLinkUnselected (bool b) // FIXME-2 Images still have visible link after load
 {
 	TreeItem *ti=getSelectedItem();
 	if (ti && (ti->getType()==TreeItem::Image ||ti->isBranchLikeType()))
@@ -2023,7 +2019,7 @@
 	}
 }
 
-bool VymModel::moveUp(BranchItem *bi)	//FIXME-2 crashes if trying to move MCO
+bool VymModel::moveUp(BranchItem *bi)	
 {
 	if (bi && bi->canMoveUp()) 
 		return relinkBranch (bi,(BranchItem*)bi->parent(),bi->num()-1);
@@ -2094,17 +2090,20 @@
 	}
 }
 
-void VymModel::sortChildren()
+void VymModel::sortChildren(bool inverse)
 {
 	BranchItem* selbi=getSelectedBranch();
 	if (selbi)
 	{
 		if(selbi->branchCount()>1)
 		{
+			if (!inverse)
+			{
 			saveStateChangingPart(
 				selbi,selbi, "sortChildren ()",
 				QString("Sort children of %1").arg(getObjectName(selbi)));
-			selbi->sortChildren();
+			}
+			selbi->sortChildren(inverse);
 			reposition();
 			emitShowSelection();
 		}
@@ -2221,6 +2220,7 @@
 
 		emit (layoutChanged() );
 
+		ai->createMapObj(mapScene);		//FIXME-2 check that...
 		reposition();
 		return ai;
 	}
@@ -2399,6 +2399,10 @@
 	{
 		unselect();
  
+		// Do we need to update frame type?
+		bool keepFrame=false;
+		 
+
 		emit (layoutAboutToBeChanged() );
 		BranchItem *branchpi=(BranchItem*)branch->parent();
 		// Remove at current position
@@ -2432,7 +2436,7 @@
 			branch->setType(TreeItem::Branch);
 
 		// reset parObj, fonts, frame, etc in related LMO or other view-objects
-		branch->updateStyles();
+		branch->updateStyles(keepFrame);
 
 		emit (layoutChanged() );
 		reposition();	// both for moveUp/Down and relinking
@@ -2937,19 +2941,9 @@
 				QString bugID=rx.cap(1);
 				cout << "VM::getBugzillaData bug="<<bugID.toStdString()<<endl;
 
+				Process p;
+				//QString script="test/sleep.sh";
 				QString script="test/vym-bug.pl";
-				/*
-				QProgressDialog progress2("Copying files...", "Abort Copy", 0, 40, mainWindow);
-				progress2.setWindowModality(Qt::WindowModal);
-				progress2.setValue (3);
-				progress2.update();
-				QProgressDialog progress ("Contacting Bugzilla...","empty",0,0);
-				progress.setCancelButton (NULL);
-				progress.setWindowModality(Qt::WindowModal);
-				progress.show();
-				progress.update();
-*/
-				Process p;
 				p.start (script,QStringList()<<bugID);
 				if (!p.waitForStarted())
 				{
@@ -2959,10 +2953,8 @@
 				if (!p.waitForFinished())
 				{
 					cout <<"VM::getBugzillaData couldn't finish "<<script.toStdString()<<endl;
-					//progress.hide();
 					return;
 				}
-				//progress.hide();
 				//QByteArray result=p.readAll();
 				QString result=p.getStdout();
 				while (result.endsWith("\n")) result.chop(1); 
@@ -4091,6 +4083,10 @@
 		} else if (parser.checkParCount(0))
 		{
 			sortChildren();
+		} else if (parser.checkParCount(1))
+		{
+			b=parser.parBool(ok,0);
+			if (ok) sortChildren(b);
 		}
 	/////////////////////////////////////////////////////////////////////
 	} else if (com=="toggleFlag")
@@ -4223,8 +4219,8 @@
 	}
 
 	setExportMode (true);
-	mapEditor->getScene()->update();		// FIXME-2 check this...
-	QImage img (mapEditor->getImage());	//FIXME-2 calls getTotalBBox, but also in ExportHTML::doExport()
+	mapEditor->getScene()->update();		// FIXME-3 check this...
+	QImage img (mapEditor->getImage());	//FIXME-3 calls getTotalBBox, but also in ExportHTML::doExport()
 	img.save(fname, format);
 	setExportMode (false);
 }
@@ -4317,24 +4313,23 @@
 	}
 }
 
-void VymModel::exportHTML (const QString &dir, bool askForName)
-{
-	ExportXHTMLDialog dia(NULL);
+void VymModel::exportHTML (const QString &dir, bool askForName)	//FIXME-2 own dialogue missing and also option to save settings in map
+{
+	ExportXHTMLDialog dia(NULL);	
 	dia.setFilePath (filePath );
 	dia.setMapName (mapName );
 	dia.readSettings();
 	if (dir!="") dia.setDir (dir);
-
+	QDir d;
 	bool ok=true;
 	
-	/*
 	if (askForName)
 	{
 		if (dia.exec()!=QDialog::Accepted) 
 			ok=false;
 		else	
 		{
-			QDir d (dia.getDir());
+			d=dia.getDir();
 			// Check, if warnings should be used before overwriting
 			// the output directory
 			if (d.exists() && d.count()>0)
@@ -4345,21 +4340,20 @@
 					"The directory %1 is not empty.\n"
 					"Do you risk to overwrite some of its contents?").arg(d.path() ));
 				warn.setCaption("Warning: Directory not empty");
-				warn.setShowAgainName("mainwindow/overwrite-dir-xhtml");
+				warn.setShowAgainName("mainwindow/export-XML-overwrite-dir");
 
 				if (warn.exec()!=QDialog::Accepted) ok=false;
 			}
 		}	
 	}
-*/ 
-	ok=true;
 	if (ok)
 	{
 		// Hide stuff during export, if settings want this
 		setExportMode (true);
 
 		ExportHTML ex (this);
-		ex.setFile ("x/xxx.html");
+		ex.setFile (d.path()+"/"+mapName+".html");
+		cout << "VM::exportHTML  writing "<<ex.getFile().toStdString()<<endl;
 		ex.doExport();
 		setExportMode (false);
 
@@ -4368,7 +4362,7 @@
 		//if (dia.hasChanged()) setChanged();
 
 		// Write image, too
-		exportImage ("x/xxx.png",false,"PNG");
+		exportImage (d.path()+"/"+mapName+".png",false,"PNG");
 
 	}
 }
@@ -4604,8 +4598,7 @@
 	}
 }
 
-void VymModel::selectMapBackgroundImage ()	// FIXME-2 move to ME
-// FIXME-4 for using background image: view.setCacheMode(QGraphicsView::CacheBackground);
+void VymModel::selectMapBackgroundImage ()	// FIXME-3 for using background image: view.setCacheMode(QGraphicsView::CacheBackground);  Also this belongs into ME
 {
 	Q3FileDialog *fd=new Q3FileDialog( NULL);
 	fd->setMode (Q3FileDialog::ExistingFile);
diff -r 4a84d7e444d8 -r c2ce9944148c vymmodel.h
--- a/vymmodel.h	Thu Jan 21 11:56:57 2010 +0000
+++ b/vymmodel.h	Wed Feb 10 13:48:42 2010 +0000
@@ -229,7 +229,7 @@
 	QGraphicsScene *getScene();
 
     TreeItem* findBySelectString (QString s);		
-    TreeItem* findID (const QString &s);				// find MapObj by previously set ID
+    TreeItem* findID (const uint &i);		// find MapObj by unique ID
 
 
 ////////////////////////////////////////////
@@ -309,7 +309,7 @@
     bool moveDown(BranchItem *bi);	//!< Move branch down without saving state
     void moveDown();		//!< Move branch down
 	void detach();					//!< Detach branch and use as new mapcenter
-	void sortChildren();	//!< Sort children lexically
+	void sortChildren(bool inverse=false);	//!< Sort children lexically
 
 	// The create methods are used to quickly parse a XML file
 	BranchItem* createMapCenter();				//!< Create MapCenter 
diff -r 4a84d7e444d8 -r c2ce9944148c vymview.cpp
--- a/vymview.cpp	Thu Jan 21 11:56:57 2010 +0000
+++ b/vymview.cpp	Wed Feb 10 13:48:42 2010 +0000
@@ -28,7 +28,7 @@
 	treeEditor->setColumnWidth (0,150);
 	treeEditor->setAnimated (true);
 
-	// FIXME-2 use proxySelModel=treeEditor->selectionModel();
+	// FIXME-3 use proxySelModel=treeEditor->selectionModel();
 	selModel=new QItemSelectionModel (model);
 
 	//model->setSelectionModel (proxySelModel);
@@ -162,7 +162,7 @@
 	if (newsel.indexes().count()>0)
 	{
 
-	/* FIXME-2 use proxymodel
+	/* FIXME-3 use proxymodel
 		proxySelModel->select (
 			treeEditor->getProxyModel()->mapSelectionFromSource (newsel),
 			QItemSelectionModel::ClearAndSelect );
@@ -217,7 +217,7 @@
 	model->nextBranch(cur,prev);
 	while (cur) 
 	{
-		// FIXME-2 use proxy pix=treeEditor->getProxyModel()->mapFromSource (model->index (cur));
+		// FIXME-3 use proxy pix=treeEditor->getProxyModel()->mapFromSource (model->index (cur));
 		pix=model->index (cur);
 		d=cur->depth();
 		if (!treeEditor->isExpanded(pix) && d < level)
@@ -231,7 +231,7 @@
 	model->nextBranch(cur,prev);
 	while (cur) 
 	{
-		// FIXME-2 use proxy pix=treeEditor->getProxyModel()->mapFromSource (model->index (cur));
+		// FIXME-3 use proxy pix=treeEditor->getProxyModel()->mapFromSource (model->index (cur));
 		pix=model->index (cur);
 		d=cur->depth();
 		if (!treeEditor->isExpanded(pix) && d <= level && cur->branchCount()>0)
@@ -261,7 +261,7 @@
 	model->nextBranch(cur,prev);
 	while (cur) 
 	{
-		// FIXME-2 use proxy pix=treeEditor->getProxyModel()->mapFromSource (model->index (cur));
+		// FIXME-3 use proxy pix=treeEditor->getProxyModel()->mapFromSource (model->index (cur));
 		pix=model->index (cur);
 		d=cur->depth();
 		if (treeEditor->isExpanded(pix) && d > level)
@@ -275,7 +275,7 @@
 	model->nextBranch(cur,prev);
 	while (cur) 
 	{
-		// FIXME-2 use proxy pix=treeEditor->getProxyModel()->mapFromSource (model->index (cur));
+		// FIXME-3 use proxy pix=treeEditor->getProxyModel()->mapFromSource (model->index (cur));
 		pix=model->index (cur);
 		d=cur->depth();
 		if (treeEditor->isExpanded(pix) && d >= level)
diff -r 4a84d7e444d8 -r c2ce9944148c xml-freemind.cpp
--- a/xml-freemind.cpp	Thu Jan 21 11:56:57 2010 +0000
+++ b/xml-freemind.cpp	Wed Feb 10 13:48:42 2010 +0000
@@ -12,7 +12,6 @@
 #include "version.h"
 
 //static FloatObj *lastFloat;
-static OrnamentedObj *lastOO;
 
 extern Settings settings;
 extern QString vymVersion;
@@ -258,7 +257,6 @@
 
 bool parseFreemindHandler::readNodeAttr (const QXmlAttributes& a)	//FIXME-3
 {
-	//lastOO=lastBranch;
 	//lastBranchItem=(BranchItem*)(lastBranch->getTreeItem() );
 
 	if (a.value( "FOLDED")=="true" )
diff -r 4a84d7e444d8 -r c2ce9944148c xml-vym.cpp
--- a/xml-vym.cpp	Thu Jan 21 11:56:57 2010 +0000
+++ b/xml-vym.cpp	Wed Feb 10 13:48:42 2010 +0000
@@ -272,7 +272,7 @@
     switch ( state ) 
 	{
 		case StateMap:
-			mainWindow->removeProgressValue (branchesTotal); //FIXME-2 let mainWindow handle this 
+			mainWindow->removeProgressCounter(); 
 			break;
         case StateMapCenter: 
 			model->emitDataHasChanged (lastBranch);
@@ -447,9 +447,6 @@
 					return false;   // Couldn't read absPos
 			}           
 		}           
-		if (!a.value( "id").isEmpty() ) 
-			lastMI->setID (a.value ("id"));		
-			
 		if (!a.value( "url").isEmpty() ) 
 			lastMI->setURL (a.value ("url"));
 		if (!a.value( "vymLink").isEmpty() ) 
@@ -555,8 +552,8 @@
 	{ 
 		if (!a.value( "endID").isEmpty() ) 
 		{
-			TreeItem *beginBI=model->findID (a.value( "beginID"));
-			TreeItem   *endBI=model->findID (a.value( "endID"));
+			TreeItem *beginBI=model->findBySelectString (a.value( "beginID"));
+			TreeItem   *endBI=model->findBySelectString (a.value( "endID"));
 			if (beginBI && endBI && beginBI->isBranchLikeType() && endBI->isBranchLikeType() )
 			{
 				XLinkItem *xli=model->createXLink (lastBranch,true);