# HG changeset patch
# User insilmaril
# Date 1262637366 0
# Node ID 8f987e376035023b1dadc12d03ba27a3eb6039c8
# Parent  25ee6b988b737ae24120c6515987e4d15f1ecbfb
various fixes

diff -r 25ee6b988b73 -r 8f987e376035 branchitem.cpp
--- a/branchitem.cpp	Tue Dec 15 09:14:59 2009 +0000
+++ b/branchitem.cpp	Mon Jan 04 20:36:06 2010 +0000
@@ -178,7 +178,12 @@
 {
 	// Needed to hide relinked branch, if parent is scrolled
 	if (lmo)
-		lmo->setVisibility(!((BranchItem*)parentItem)->isScrolled());
+	{
+		if (hasScrolledParent(this) || hidden)
+			lmo->setVisibility (false);
+		else	
+			lmo->setVisibility (true);
+	}
 }
 
 void BranchItem::setHeadingColor (QColor color)
diff -r 25ee6b988b73 -r 8f987e376035 branchobj.cpp
--- a/branchobj.cpp	Tue Dec 15 09:14:59 2009 +0000
+++ b/branchobj.cpp	Mon Jan 04 20:36:06 2010 +0000
@@ -26,22 +26,6 @@
 	init();
 }
 
-/*
-BranchObj::BranchObj (QGraphicsScene* s, LinkableMapObj* p):OrnamentedObj (s)// FIXME-3 needed at all?
-{
-//    cout << "Const BranchObj (s,p)\n";
-    scene=s;
-    setParObj (p);	
-	if (treeItem->depth()==1)	// FIXME-3 needed to recursively calc depth?
-		// Calc angle to mapCenter if I am a mainbranch
-		// needed for reordering the mainbranches clockwise 
-		// around mapcenter 
-		angle=getAngle (QPointF (x() - parObj->getChildPos().x() , 
-								(y() - parObj->getChildPos().y() ) ) );
-    init();
-}
-*/
-
 BranchObj::~BranchObj ()
 {
 //	cout << "Destr BranchObj of "<<this<<" ("<<treeItem->getHeading().toStdString()<<")"<<endl;
@@ -95,7 +79,7 @@
 		delete xlink.takeFirst();
 }
 
-void BranchObj::setParObjTmp(LinkableMapObj* dst, QPointF m, int off)	//FIXME-1 when moving a mainbranch to a branch it still has relPos, not moved as child
+void BranchObj::setParObjTmp(LinkableMapObj* dst, QPointF m, int off)	
 {
 	// Temporary link to dst
 	// m is position of mouse pointer 
@@ -452,7 +436,7 @@
 			changed=true;
 		}	
 	}
-	updateContentSize();
+	if (changed) updateContentSize(); 
 }
 
 void BranchObj::setDefAttr (BranchModification mod)
@@ -628,12 +612,13 @@
 }
 
 
-QRectF BranchObj::getTotalBBox()
+QRectF BranchObj::getTotalBBox() // FIXME-2 not really needed, get rid of this
 {
 	QRectF r=bbox;
 
 	if ( ((BranchItem*)treeItem)->isScrolled() ) return r;
 
+/* FIXME-2 really include children _here_ ?  likely not needed anymore, but done in TreeItem */
 	for (int i=0; i<treeItem->branchCount(); ++i)
 		if (!treeItem->getBranchNum(i)->isHidden())
 			r=addBBox(treeItem->getBranchObjNum(i)->getTotalBBox(),r);
@@ -643,9 +628,11 @@
 			(have been NULL at least in calcBBoxSizeWithChilds...)
 */			
 
-	for (int i=0; i<treeItem->imageCount(); ++i)
+/* FIXME-2 in
+	for (int i=0; i<treeItem->imageCount(); ++i
 		if (!treeItem->isHidden())
 			r=addBBox(treeItem->getImageObjNum(i)->getTotalBBox(),r);
+*/			
 	return r;
 }
 
@@ -672,7 +659,7 @@
 		return MapObj::getBoundingPolygon();
 	}
 
-	calcBBoxSizeWithChildren();	//FIXME-3 really needed?
+	calcBBoxSizeWithChildren();	//FIXME-2 really needed?
 	QPolygonF p;
 	p<<bboxTotal.topLeft();
 	p<<bboxTotal.topRight();
@@ -749,15 +736,6 @@
 	bboxTotal.setHeight(max (r.height(),  bbox.height()));
 }
 
-QString BranchObj::getSelectString()
-{
-	VymModel *model=treeItem->getModel();
-	if (model)
-		return model->getSelectString (this);
-	else
-		return QString();
-}
-
 void BranchObj::setAnimation(const AnimPoint &ap)
 {
 	anim=ap;
diff -r 25ee6b988b73 -r 8f987e376035 branchobj.h
--- a/branchobj.h	Tue Dec 15 09:14:59 2009 +0000
+++ b/branchobj.h	Mon Jan 04 20:36:06 2010 +0000
@@ -51,7 +51,6 @@
 	virtual ConvexPolygon getBoundingPolygon();
 	virtual void calcBBoxSizeWithChildren();	// calc size of  BBox including children recursivly
 
-	virtual QString getSelectString();
 	virtual void setAnimation(const AnimPoint &ap);
 	virtual bool animate();
 
diff -r 25ee6b988b73 -r 8f987e376035 demos/vym-projectplan.vym
Binary file demos/vym-projectplan.vym has changed
diff -r 25ee6b988b73 -r 8f987e376035 exports.cpp
--- a/exports.cpp	Tue Dec 15 09:14:59 2009 +0000
+++ b/exports.cpp	Mon Jan 04 20:36:06 2010 +0000
@@ -14,6 +14,23 @@
 
 ExportBase::ExportBase()
 {
+	init();
+}
+
+ExportBase::ExportBase(VymModel *m)
+{
+	init();
+	model=m;
+}
+
+ExportBase::~ExportBase()
+{
+	// Cleanup tmpdir
+	removeDir (tmpDir);
+}
+
+void ExportBase::init()
+{
 	indentPerDepth="  ";
 	bool ok;
     tmpDir.setPath (makeTmpDir(ok,"vym-export"));
@@ -23,12 +40,6 @@
 	cancelFlag=false;				   
 }
 
-ExportBase::~ExportBase()
-{
-	// Cleanup tmpdir
-	removeDir (tmpDir);
-}
-
 void ExportBase::setDir(const QDir &d)
 {
 	outDir=d;
@@ -262,7 +273,7 @@
 		{
 			// Make indentstring
 			curIndent="";
-			for (i=0;i<cur->depth()-1;i++) curIndent+= indentPerDepth;
+			for (i=1;i<cur->depth()-1;i++) curIndent+= indentPerDepth;
 
 			if (!cur->hasHiddenExportParent() )
 			{
@@ -460,6 +471,176 @@
 }
 
 ////////////////////////////////////////////////////////////////////////
+ExportHTML::ExportHTML():ExportBase()
+{
+	init();
+}
+
+ExportHTML::ExportHTML(VymModel *m):ExportBase(m)
+{
+	init();
+}
+
+void ExportHTML::init()
+{
+	singularDelimiter=": ";
+	noSingulars=true;	
+	frameURLs=true;
+	useMapColors=true;
+
+	if (model &&model->getMapEditor()) 
+		offset=model->getMapEditor()->getTotalBBox().topLeft();
+}
+
+QString ExportHTML::getBranchText(BranchItem *current)
+{
+	if (current)
+	{
+		bool vis=false;
+		QRectF hr;
+		LinkableMapObj *lmo=current->getLMO();
+		if (lmo)
+		{
+			hr=((BranchObj*)lmo)->getBBoxHeading();
+			if (lmo->isVisibleObj()) vis=true;
+		}
+		QString col;
+		QString id=model->getSelectString(current);
+		if (useMapColors)
+			col=QString("style='color:%1'").arg(current->getHeadingColor().name());
+		QString s=QString("<span class='vym-branch%1' %2 id='%3'>")
+			.arg(current->depth())
+			.arg(col)
+			.arg(id);
+		QString url=current->getURL();	
+		if (!url.isEmpty())
+		{
+			s+=QString ("<a href=\"%1\">").arg(url);
+			s+=QString ("<img src=\"flags/flag-url-16x16.png\">%1</a>").arg(quotemeta(current->getHeading()));
+			s+="</a>";
+			
+			QRectF fbox=current->getBBoxFlag ("system-url");
+			if (vis)
+				imageMap+=QString("  <area shape='rect' coords='%1,%2,%3,%4' href='%5'>\n")
+					.arg(fbox.left()-offset.x())
+					.arg(fbox.top()-offset.y())
+					.arg(fbox.right()-offset.x())
+					.arg(fbox.bottom()-offset.y())
+					.arg(url);
+		} else	
+			s+=quotemeta(current->getHeading());
+		s+="</span>";
+
+		if (vis)
+			imageMap+=QString("  <area shape='rect' coords='%1,%2,%3,%4' href='#%5'>\n")
+				.arg(hr.left()-offset.x())
+				.arg(hr.top()-offset.y())
+				.arg(hr.right()-offset.x())
+				.arg(hr.bottom()-offset.y())
+				.arg(id);
+
+		// Include note
+		if (!current->getNoteObj().isEmpty())
+			s+="<table border=1><tr><td>"+current->getNote()+"</td></tr></table>";
+
+		return s;
+	} 
+	return QString();
+}
+
+QString ExportHTML::buildList (BranchItem *current)
+{
+    QString r;
+
+    uint i=0;
+	BranchItem *bi=current->getFirstBranch();
+
+	// Only add itemized list, if we have more than one subitem.
+	// For only one subitem, just add a separator to keep page more compact
+	bool noSingularsHere=false;
+	if (current->branchCount()<2 && noSingulars) noSingularsHere=true;
+
+	if (bi)
+    {
+		if (!noSingularsHere)
+			r+="<ul>\n";
+		else
+			r+=singularDelimiter;
+
+		while (bi)
+		{
+			if (!bi->hasHiddenExportParent() )	
+			{
+				if (!noSingularsHere) r+="<li>";
+				r+=getBranchText (bi);
+				if (!bi->getURL().isEmpty() && frameURLs && noSingularsHere)
+					// Add frame, if we have subitems to an URL
+					r+="<table border=1><tr><td>"+buildList (bi)+"</td></tr></table>";	// recursivly add deeper branches
+				else
+					r+=buildList (bi);	// recursivly add deeper branches
+				if (!noSingularsHere) r+="</li>";
+				r+="\n";
+			}
+			i++;
+			bi=current->getBranchNum(i);
+		}
+
+		if (!noSingularsHere) r+="</ul>\n";
+	}
+    return r;
+}
+
+void ExportHTML::doExport() 
+{
+	QFile file (outputFile);
+	if ( !file.open( QIODevice::WriteOnly ) ) 
+	{
+		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not write %1").arg(outputFile));
+		mainWindow->statusMessage(QString(QObject::tr("Export failed.")));
+		return;
+	}
+	QTextStream ts( &file );	// use LANG decoding here...
+	ts.setEncoding (QTextStream::UnicodeUTF8); // Force UTF8
+
+	// Write header
+	ts<<"<html><title>"+model->getMapName()<<"</title><body>";
+	ts<<" <link rel='stylesheet' id='css.stylesheet' href='vym.css' />\n";
+
+	// Include image
+	ts<<"<center><img src=\"xxx.png\" usemap='#imagemap'></center>\n";
+
+
+	// Main loop over all mapcenters
+	QString s;
+	TreeItem *rootItem=model->getRootItem();
+	BranchItem *bi;
+	for (int i=0; i<rootItem->branchCount(); i++)
+	{
+		bi=rootItem->getBranchNum(i);
+		if (!bi->hasHiddenExportParent())
+		{
+			ts<<getBranchText (bi);
+			ts<<buildList (bi);
+		}
+	}	
+
+	// Imagemap
+	ts<<"<map name='imagemap'>\n"+imageMap+"</map>\n";
+
+	// Write footer 
+	ts<<"<hr/>\n";
+	ts<<"<table class=\"vym-footer\">   \n\
+      <tr> \n\
+        <td class=\"vym-footerL\">"+model->getFileName()+"</td> \n\
+        <td class=\"vym-footerC\">"+model->getDate()+"</td> \n\
+        <td class=\"vym-footerR\"> vym "+model->getVersion()+"</td> \n\
+      </tr> \n \
+    </table>\n";
+	ts<<"</body></html>";
+	file.close();
+}
+
+////////////////////////////////////////////////////////////////////////
 void ExportTaskjuggler::doExport() 
 {
 	model->exportXML(tmpDir.path(),false);
@@ -550,11 +731,11 @@
 	BranchItem *bi=current->getFirstBranch();
 	if (bi)
     {
-		if (!bi->hasHiddenExportParent() )	// FIXME-3 use BranchItem...
+		// Start list
+		r+="<text:list text:style-name=\"vym-list\">\n";
+		while (bi)
 		{
-			// Start list
-			r+="<text:list text:style-name=\"vym-list\">\n";
-			while (bi)
+			if (!bi->hasHiddenExportParent() )	
 			{
 				r+="<text:list-item><text:p >";
 				r+=quotemeta(bi->getHeading());
@@ -564,11 +745,11 @@
 				r+="</text:p>";
 				r+=buildList (bi);	// recursivly add deeper branches
 				r+="</text:list-item>\n";
-				i++;
-				bi=current->getBranchNum(i);
 			}
-			r+="</text:list>\n";
+			i++;
+			bi=current->getBranchNum(i);
 		}
+		r+="</text:list>\n";
     }
     return r;
 }
diff -r 25ee6b988b73 -r 8f987e376035 exports.h
--- a/exports.h	Tue Dec 15 09:14:59 2009 +0000
+++ b/exports.h	Mon Jan 04 20:36:06 2010 +0000
@@ -18,7 +18,9 @@
 {
 public:
 	ExportBase();
+	ExportBase(VymModel *m);
 	virtual ~ExportBase();
+	virtual void init();
 	virtual void setDir(const QDir&);
 	virtual void setFile(const QString &);
 	virtual QString getFile ();
@@ -92,6 +94,27 @@
 };	
 
 ///////////////////////////////////////////////////////////////////////
+class ExportHTML:public ExportBase
+{
+public:
+	ExportHTML();
+	ExportHTML(VymModel *m);
+	virtual void init();
+	virtual void doExport();
+private:
+	QString getBranchText(BranchItem *);
+	QString buildList (BranchItem *);
+	QString imageMap;
+
+	bool frameURLs;
+	bool noSingulars;
+	QString singularDelimiter;
+	bool useMapColors;
+
+	QPointF offset;
+};	
+
+///////////////////////////////////////////////////////////////////////
 class ExportTaskjuggler:public ExportXMLBase
 {
 public:
diff -r 25ee6b988b73 -r 8f987e376035 flagrowobj.h
--- a/flagrowobj.h	Tue Dec 15 09:14:59 2009 +0000
+++ b/flagrowobj.h	Mon Jan 04 20:36:06 2010 +0000
@@ -32,8 +32,8 @@
 	void activate (Flag *flag);
 	void deactivate(const QString&);
 	void setShowFlags (bool);
+	FlagObj* findFlag (const QString&);
 private:	
-	FlagObj* findFlag (const QString&);
     QList <FlagObj*> flag; 
 	bool showFlags;							// FloatObjects want to hide their flags
 };
diff -r 25ee6b988b73 -r 8f987e376035 mainwindow.cpp
--- a/mainwindow.cpp	Tue Dec 15 09:14:59 2009 +0000
+++ b/mainwindow.cpp	Mon Jan 04 20:36:06 2010 +0000
@@ -411,9 +411,15 @@
 	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportOOPresentation() ) );
 	fileExportMenu->addAction (a);
 
-	a = new QAction(  "Webpage (XHTML)...",this );
-	a->setShortcut (Qt::ALT + Qt::Key_X);			//Export XHTML
+	a = new QAction(  "Webpage (HTML)...",this );
+	a->setShortcut (Qt::ALT + Qt::Key_X);			//Export HTML
 	a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
+	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportHTML() ) );
+	fileExportMenu->addAction (a);
+
+	a = new QAction(  "Webpage (XHTML)...",this );	//Export XHTML
+
+	//a->setShortcut (Qt::ALT + Qt::SHIFT + Qt::Key_X);	a->setStatusTip ( tr( "Export as %1","status tip file menu").arg(tr(" webpage (XHTML)","status tip file menu")));
 	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportXHTML() ) );
 	fileExportMenu->addAction (a);
 
@@ -1040,7 +1046,7 @@
 	tb->setObjectName ("viewTB");
 	QMenu *viewMenu = menuBar()->addMenu ( tr( "&View" ));
 
-	Switchboard switchboard;	//FIXME-1 testing...
+	Switchboard switchboard;	//FIXME-2 testing...
 
 	QAction *a;
 	a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom","View action" ), this);
@@ -2218,6 +2224,12 @@
 	if (m) m->exportXML();
 }
 
+void Main::fileExportHTML()	
+{
+	VymModel *m=currentModel();
+	if (m) m->exportHTML();
+}
+
 
 void Main::fileExportXHTML()	
 {
@@ -2833,7 +2845,11 @@
 void Main::editAddAttribute()
 {
 	VymModel *m=currentModel();
-	if (m) m->addAttribute();
+	if (m) 
+	{
+
+		m->addAttribute();
+	}
 }
 
 void Main::editAddMapCenter()
diff -r 25ee6b988b73 -r 8f987e376035 mainwindow.h
--- a/mainwindow.h	Tue Dec 15 09:14:59 2009 +0000
+++ b/mainwindow.h	Mon Jan 04 20:36:06 2010 +0000
@@ -94,6 +94,7 @@
     void fileImportMM();
     void fileImportDir();
     void fileExportXML();
+    void fileExportHTML();
     void fileExportXHTML();
     void fileExportImage();
     void fileExportAO();
diff -r 25ee6b988b73 -r 8f987e376035 mapeditor.cpp
--- a/mapeditor.cpp	Tue Dec 15 09:14:59 2009 +0000
+++ b/mapeditor.cpp	Mon Jan 04 20:36:06 2010 +0000
@@ -113,10 +113,7 @@
 
 	// Action to embed LineEdit for heading in Scene
 	editingHeading=false;
-	lineEdit=new QLineEdit;
-	lineEdit->hide();
-	QGraphicsProxyWidget *pw=scene()->addWidget (lineEdit);
-	pw->setZValue (Z_LINEEDIT);
+	lineEdit=NULL;
 
 	a = new QAction( tr( "Edit heading","MapEditor" ), this);
 	a->setShortcut ( Qt::Key_Return );					//Edit heading
@@ -405,35 +402,55 @@
 
 QRectF MapEditor::getTotalBBox()	
 {
-	QRectF r;
+	QPen pen;
+	pen.setWidth (1);
+	pen.setCapStyle ( Qt::RoundCap );
+
+	QRectF rt;
 	BranchObj *bo;
-	for (int i=0;i<model->getRootItem()->branchCount(); i++)
+	BranchItem *cur=NULL;
+	BranchItem *prev=NULL;
+	model->nextBranch(cur,prev);
+	while (cur) 
 	{
-		bo=(BranchObj*)(model->getRootItem()->getBranchNum(i)->getLMO());
-		if (bo) r=addBBox (bo->getTotalBBox(), r);
+		if (!cur->hasHiddenExportParent())
+		{
+			bo=(BranchObj*)(cur->getLMO());
+			if (bo && bo->isVisibleObj())
+			{
+				bo->calcBBoxSizeWithChildren();
+				// FIXME-3 testing
+				//QRectF r1=bo->getBBoxSizeWithChildren();
+				QRectF r1=bo->getBBox();
+				//pen.setColor ( QColor(qrand()%32*8,qrand()%32*8,qrand()%32*8));
+				//mapScene->addRect (r1,pen);
+
+				if (rt.isNull()) rt=r1;
+				rt=addBBox (r1, rt);
+				//FIXME-2 cout <<"ME: r1="<<r1<<"  "<<cur->getHeadingStd()<<endl;
+				//cout <<"    rt="<<rt<<endl;
+			}
+		}
+		model->nextBranch(cur,prev);
 	}
-	return r;	
+	return rt;	
 }
 
 
-QPixmap MapEditor::getPixmap()
+QImage MapEditor::getImage()
 {
 	QRectF mapRect=getTotalBBox();
-	QPixmap pix((int)mapRect.width()+2,(int)mapRect.height()+2);
+	int w=mapRect.width()+2;
+	int h=mapRect.height()+2;
+	
+	QImage pix (w,h,QImage::Format_RGB32);
+
 	QPainter pp (&pix);
-	
+
 	pp.setRenderHints(renderHints());
-
-	// Don't print the visualisation of selection
-	model->unselect();
-
 	mapScene->render (	&pp, 
-		QRectF(0,0,mapRect.width()+2,mapRect.height()+2),
+		QRectF(0,0,w,h),
 		QRectF(mapRect.x(),mapRect.y(),mapRect.width(),mapRect.height() ));
-
-	// Restore selection
-	model->reselect();
-	
 	return pix;
 }
 
@@ -448,6 +465,42 @@
 	setRenderHint(QPainter::SmoothPixmapTransform,b);
 }
 
+void MapEditor::setHideTmp (bool b)	// FIXME-4 better use signals
+{
+/*
+	if (b)
+	{
+		setHideTmpMode (HideExport);
+		mapCenter->calcBBoxSizeWithChilds();
+		QRectF totalBBox=mapCenter->getTotalBBox();
+		//QRectF mapRect=totalBBox;
+		cout << "  map has =("<<totalBBox.x()<<","<<totalBBox.y()<<","<<totalBBox.width()<<","<<totalBBox.height()<<")\n";
+	
+		mapRect.setRect (totalBBox.x(), totalBBox.y(), 
+			totalBBox.width(), totalBBox.height());
+			
+		QCanvasRectangle *frame=new QCanvasRectangle (mapRect,mapScene);
+		frame->setBrush (QColor(white));
+		frame->setPen (QColor(black));
+		frame->setZValue(0);
+		frame->show();    
+		
+	}	
+	else	
+	{
+		setHideTmpMode (HideNone);
+	}	
+	cout <<"  hidemode="<<hidemode<<endl;
+*/
+/*
+	// Toggle hidemode
+	if (hidemode==HideExport)
+		setHideTmpMode (HideNone);
+	else	
+		setHideTmpMode (HideExport);
+*/		
+}
+
 TreeItem* MapEditor::findMapItem (QPointF p,TreeItem *exclude)
 {
 	// Start with mapcenter, no images allowed at rootItem
@@ -472,9 +525,7 @@
 void MapEditor::testFunction1()
 {
 	cout << "ME::test1  selected TI="<<model->getSelectedItem()<<endl;
-
-	for (int i=0; i<200;i++)
-		model->addNewBranch();
+	model->setExportMode (true);
 
 	/*
 	// Code copied from Qt sources
@@ -543,44 +594,13 @@
 	 animation->start();
  */
 
-/* FIXME-4 Hide hidden stuff temporary, maybe add this as regular function somewhere
-	if (hidemode==HideNone)
-	{
-		setHideTmpMode (HideExport);
-		mapCenter->calcBBoxSizeWithChilds();
-		QRectF totalBBox=mapCenter->getTotalBBox();
-		QRectF mapRect=totalBBox;
-		QCanvasRectangle *frame=NULL;
-
-		cout << "  map has =("<<totalBBox.x()<<","<<totalBBox.y()<<","<<totalBBox.width()<<","<<totalBBox.height()<<")\n";
-	
-		mapRect.setRect (totalBBox.x(), totalBBox.y(), 
-			totalBBox.width(), totalBBox.height());
-		frame=new QCanvasRectangle (mapRect,mapScene);
-		frame->setBrush (QColor(white));
-		frame->setPen (QColor(black));
-		frame->setZValue(0);
-		frame->show();    
-	}	
-	else	
-	{
-		setHideTmpMode (HideNone);
-	}	
-	cout <<"  hidemode="<<hidemode<<endl;
-	*/
-
-/*
-	// Toggle hidemode
-	if (hidemode==HideExport)
-		setHideTmpMode (HideNone);
-	else	
-		setHideTmpMode (HideExport);
-*/		
-
 }
 	
 void MapEditor::testFunction2()
 {
+	model->setExportMode (false);
+	return;
+
 	// Create list with all bounding polygons
 	QList <LinkableMapObj*> mapobjects;
 	QList <ConvexPolygon> polys; 
@@ -899,6 +919,10 @@
 	{
 		model->setSelectionBlocked(true);
 
+		lineEdit=new QLineEdit;
+		QGraphicsProxyWidget *pw=scene()->addWidget (lineEdit);
+		pw->setZValue (Z_LINEEDIT);
+
 		lineEdit->setText (bi->getHeading());
 		QPoint p = mapTo (this,bo->getAbsPos().toPoint() );
 		lineEdit->setGeometry(p.x(),p.y(),230,25);
@@ -915,9 +939,10 @@
 {
 	editingHeading=false;
 	lineEdit->releaseKeyboard();
+	lineEdit->clearFocus();
 	model->setHeading (lineEdit->text() );
 	model->setSelectionBlocked(false);
-	lineEdit->hide();
+	delete (lineEdit);
 
 	// Maybe reselect previous branch 
 	mainWindow->editHeadingFinished (model);
@@ -1281,7 +1306,7 @@
 
 			} // depth>0
 				// Maybe we can relink temporary?
-				if (dsti)	// FIXME-1 check if dsti is ancestor of myself!
+				if (dsti)
 				{
 					if (e->modifiers()==Qt::ControlModifier)
 					{
diff -r 25ee6b988b73 -r 8f987e376035 mapeditor.h
--- a/mapeditor.h	Tue Dec 15 09:14:59 2009 +0000
+++ b/mapeditor.h	Mon Jan 04 20:36:06 2010 +0000
@@ -52,9 +52,10 @@
 public:
     void print();				//!< Print the map
 	QRectF getTotalBBox();		//!< Bounding box of all items in map
-	QPixmap getPixmap();		//!< Get a pixmap of the map
+	QImage getImage ();			//!< Get a pixmap of the map
 	void setAntiAlias (bool);	//!< Set or unset antialiasing
 	void setSmoothPixmap(bool); //!< Set or unset smoothing of pixmaps
+	void setHideTmp (bool);		//!< Hide parts temporary
 public:
 	TreeItem *findMapItem (QPointF p,TreeItem *exclude);	//! find item in map at position p. Ignore item exclude 
 
diff -r 25ee6b988b73 -r 8f987e376035 mapitem.cpp
--- a/mapitem.cpp	Tue Dec 15 09:14:59 2009 +0000
+++ b/mapitem.cpp	Mon Jan 04 20:36:06 2010 +0000
@@ -104,6 +104,14 @@
 	return s;
 }
 
+QRectF MapItem::getBBoxFlag (const QString &fname)
+{
+	if (lmo)
+		return ((OrnamentedObj*)lmo)->getBBoxFlag (fname);
+	else	
+		return QRectF ();
+}
+
 LinkableMapObj* MapItem::getLMO()
 {
 	return lmo;
diff -r 25ee6b988b73 -r 8f987e376035 mapitem.h
--- a/mapitem.h	Tue Dec 15 09:14:59 2009 +0000
+++ b/mapitem.h	Mon Jan 04 20:36:06 2010 +0000
@@ -54,6 +54,7 @@
 
 	virtual QString getMapAttr();	//! Get attributes for saving as XML
 
+	virtual QRectF getBBoxFlag   (const QString &fname);	//! get bbox of flag
 
 
 protected:
diff -r 25ee6b988b73 -r 8f987e376035 misc.cpp
--- a/misc.cpp	Tue Dec 15 09:14:59 2009 +0000
+++ b/misc.cpp	Mon Jan 04 20:36:06 2010 +0000
@@ -30,7 +30,7 @@
 
 ostream &operator<< (ostream &stream, QRectF const &r)
 { 
-	stream << "tL="<<r.topLeft()<<" - bR="<<r.bottomRight();
+	stream << "tL="<<r.topLeft()<<" - (w,h)="<<r.width()<<","<<r.height()<<"  bR="<<r.bottomRight();
 	return stream;
 }
 
diff -r 25ee6b988b73 -r 8f987e376035 ornamentedobj.cpp
--- a/ornamentedobj.cpp	Tue Dec 15 09:14:59 2009 +0000
+++ b/ornamentedobj.cpp	Mon Jan 04 20:36:06 2010 +0000
@@ -71,6 +71,11 @@
     return heading->getColor();
 }
 
+QRectF OrnamentedObj::getBBoxHeading()
+{
+    return heading->getBBox();
+}
+
 FrameObj* OrnamentedObj::getFrame()
 {
 	return frame;
@@ -248,13 +253,22 @@
 	standardFlags->deactivate(name);
 	calcBBoxSize();
 	positionBBox();
-	move (absPos.x(), absPos.y() );
+	move (absPos.x(),absPos.y() );
 	forceReposition();
 }
 
 
-QString OrnamentedObj::getSystemFlagName(const QPointF &p) //FIXME-3
+QString OrnamentedObj::getSystemFlagName(const QPointF &p) 
 {
 	return systemFlags->getFlagName(p);	
 }
 
+QRectF OrnamentedObj::getBBoxFlag (const QString &s)
+{
+	FlagObj *fo=systemFlags->findFlag (s);
+	if (fo) return fo->getBBox();
+	fo=standardFlags->findFlag (s);
+	if (fo) return fo->getBBox();
+	return QRectF();
+}
+
diff -r 25ee6b988b73 -r 8f987e376035 ornamentedobj.h
--- a/ornamentedobj.h	Tue Dec 15 09:14:59 2009 +0000
+++ b/ornamentedobj.h	Mon Jan 04 20:36:06 2010 +0000
@@ -30,6 +30,7 @@
 	virtual void setLinkColor();			// sets color according to colorhint, overloaded
 	virtual void setColor(QColor);			// set the color of text and link
 	QColor getColor ();						// get color of heading
+	QRectF getBBoxHeading();
 
 	virtual FrameObj* getFrame();
 	virtual FrameObj::FrameType getFrameType ();
@@ -56,6 +57,7 @@
 	virtual void activateStandardFlag(Flag *flag);
 	virtual void deactivateStandardFlag(const QString &name);
 	virtual QString getSystemFlagName (const QPointF &p);
+	virtual QRectF getBBoxFlag (const QString &name);
 
 protected:
     HeadingObj *heading;			// Heading
diff -r 25ee6b988b73 -r 8f987e376035 tex/vym.changelog
--- a/tex/vym.changelog	Tue Dec 15 09:14:59 2009 +0000
+++ b/tex/vym.changelog	Mon Jan 04 20:36:06 2010 +0000
@@ -1,3 +1,9 @@
+-------------------------------------------------------------------
+Mon Jan  4 09:36:24 CET 2010 - vym@insilmaril.de
+
+- Bugfix: Branch didn't unscroll when deleting last child
+- Feature: URL icons in image map of HTML export work now
+
 -------------------------------------------------------------------
 Tue Dec 15 10:14:11 CET 2009 - vym@insilmaril.de
 
diff -r 25ee6b988b73 -r 8f987e376035 treeitem.cpp
--- a/treeitem.cpp	Tue Dec 15 09:14:59 2009 +0000
+++ b/treeitem.cpp	Mon Jan 04 20:36:06 2010 +0000
@@ -625,45 +625,30 @@
 }
 
 
-void TreeItem::setHideTmp (HideTmpMode mode)  //FIXME-2	update visibility in derived objects...
+void TreeItem::setHideTmp (HideTmpMode mode)  //FIXME-2	update visibility in derived objects
 {
-		/*
-	if (type==Image)
-		((ImageItem*)this)->updateVisibility();
-		*/
+	if (type==Image || type==Branch || type==MapCenter)
+//		((ImageItem*)this)->updateVisibility();
+	{
+		LinkableMapObj* lmo=((MapItem*)this)->getLMO();
 
-		if (mode==HideExport && (hideExport || hasHiddenExportParent() ) )
+		if (mode==HideExport && (hideExport || hasHiddenExportParent() ) ) // FIXME-2  try to avoid calling hasScrolledParent repeatedly
+
 		{
 			// Hide stuff according to hideExport flag and parents
-	//		if (lmo) lmo->setVisibility (false);
 			hidden=true;
+			//if (lmo) lmo->setVisibility (false);
+			updateVisibility();	// FIXME-3 missing for images
 		}else
 		{
 			// Do not hide, but still take care of scrolled status
 			hidden=false;
-/*
-			XXXXXXXX treeItem should be THIS
-
-			move visible to TreeItem???
-
-			BranchObj now has updateContents
-*/
-/*
-		if (isBranchLikeType() )
-			((BranchItem*)this)->updateVisibility();
-
-			if ( ((BranchItem*)treeItem)->hasScrolledParent((BranchItem*)treeItem))
-				setVisibility (false);
-			else
-				setVisibility (true);
-*/			
-		}	
-
-/*
+			updateVisibility();
+		}
 		// And take care of my children
 		for (int i=0; i<branchCount(); ++i)
-			getBranchNum(i)->setHideTmp (mode);	// FIXME-4 maybe also consider images and other types
-*/
+			getBranchNum(i)->setHideTmp (mode);	
+	}
 }
 
 bool TreeItem::hasHiddenExportParent()
@@ -682,7 +667,7 @@
 
 void TreeItem::setHideInExport(bool b) 
 {
-	if (type==Branch || type==Image)
+	if (type==MapCenter ||type==Branch || type==Image)
 	{
 		hideExport=b;
 		if (b)
diff -r 25ee6b988b73 -r 8f987e376035 version.h
--- a/version.h	Tue Dec 15 09:14:59 2009 +0000
+++ b/version.h	Mon Jan 04 20:36:06 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 "2009-12-15"
+#define __VYM_BUILD_DATE "2010-01-04"
 
 
 bool checkVersion(const QString &);
diff -r 25ee6b988b73 -r 8f987e376035 vymmodel.cpp
--- a/vymmodel.cpp	Tue Dec 15 09:14:59 2009 +0000
+++ b/vymmodel.cpp	Mon Jan 04 20:36:06 2010 +0000
@@ -1458,6 +1458,11 @@
 	version=s;
 }
 
+QString VymModel::getVersion()
+{
+	return version;
+}
+
 void VymModel::setAuthor (const QString &s)
 {
 	saveState (
@@ -1493,7 +1498,7 @@
 	return QDate::currentDate().toString ("yyyy-MM-dd");
 }
 
-int VymModel::branchCount()	// FIXME-4 Optimize this: use internal counter instead of going through whole map each time...
+int VymModel::branchCount()	
 {
 	int c=0;
 	BranchItem *cur=NULL;
@@ -2143,7 +2148,7 @@
 	return NULL;
 }
 
-AttributeItem* VymModel::addAttribute()	// FIXME-2 savestate missing
+AttributeItem* VymModel::addAttribute()	
 {
 	BranchItem *selbi=getSelectedBranch();
 	if (selbi)
@@ -2151,19 +2156,28 @@
 		QList<QVariant> cData;
 		cData << "new attribute" << "undef";
 		AttributeItem *a=new AttributeItem (cData);
-
+		if (addAttribute (a)) return a;
+	}
+	return NULL;
+}
+
+AttributeItem* VymModel::addAttribute(AttributeItem *ai)	// FIXME-2 savestate missing
+{
+	BranchItem *selbi=getSelectedBranch();
+	if (selbi)
+	{
 		emit (layoutAboutToBeChanged() );
 
 		QModelIndex parix=index(selbi);
-		int n=selbi->getRowNumAppend (a);
+		int n=selbi->getRowNumAppend (ai);
 		beginInsertRows (parix,n,n);	
-		selbi->appendChild (a);	
+		selbi->appendChild (ai);	
 		endInsertRows ();
 
 		emit (layoutChanged() );
 
 		reposition();
-		return a;
+		return ai;
 	}
 	return NULL;
 }
@@ -2435,9 +2449,14 @@
 		unselect();
 		saveStateRemovingPart (selbi, QString ("Delete %1").arg(getObjectName(selbi)));
 
-		TreeItem *pi=deleteItem (selbi);
+		BranchItem *pi=(BranchItem*)(deleteItem (selbi));
 		if (pi)
 		{
+			if (pi->isScrolled() && pi->branchCount()==0)
+			{
+				pi->unScroll();
+				emitDataHasChanged(pi);
+			}	
 			select (pi);
 			emitShowSelection();
 		}
@@ -4074,8 +4093,9 @@
 	}
 
 	setExportMode (true);
-	QPixmap pix (mapEditor->getPixmap());
-	pix.save(fname, format);
+	mapEditor->getScene()->update();		// FIXME-2 check this...
+	QImage img (mapEditor->getImage());	//FIXME-2 calls getTotalBBox, but also in ExportHTML::doExport()
+	img.save(fname, format);
 	setExportMode (false);
 }
 
@@ -4167,6 +4187,62 @@
 	}
 }
 
+void VymModel::exportHTML (const QString &dir, bool askForName)
+{
+	ExportXHTMLDialog dia(NULL);
+	dia.setFilePath (filePath );
+	dia.setMapName (mapName );
+	dia.readSettings();
+	if (dir!="") dia.setDir (dir);
+
+	bool ok=true;
+	
+	/*
+	if (askForName)
+	{
+		if (dia.exec()!=QDialog::Accepted) 
+			ok=false;
+		else	
+		{
+			QDir d (dia.getDir());
+			// Check, if warnings should be used before overwriting
+			// the output directory
+			if (d.exists() && d.count()>0)
+			{
+				WarningDialog warn;
+				warn.showCancelButton (true);
+				warn.setText(QString(
+					"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");
+
+				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.doExport();
+		setExportMode (false);
+
+		//exportXML (dia.getDir(),false );
+		//dia.doExport(mapName );
+		//if (dia.hasChanged()) setChanged();
+
+		// Write image, too
+		exportImage ("x/xxx.png",false,"PNG");
+
+	}
+}
+
 void VymModel::exportXHTML (const QString &dir, bool askForName)
 {
 			ExportXHTMLDialog dia(NULL);
@@ -4795,10 +4871,13 @@
 void VymModel::setHideTmpMode (TreeItem::HideTmpMode mode)
 {
 	hidemode=mode;
-	for (int i=0;i<rootItem->childCount();i++)
-		rootItem->child(i)->setHideTmp (mode);	
+	for (int i=0;i<rootItem->branchCount();i++)
+		rootItem->getBranchNum(i)->setHideTmp (mode);	
 	reposition();
-	// FIXME-3 needed? scene()->update();
+	if (mode==TreeItem::HideExport)
+		unselect();
+	else
+		reselect();
 }
 
 //////////////////////////////////////////////
diff -r 25ee6b988b73 -r 8f987e376035 vymmodel.h
--- a/vymmodel.h	Tue Dec 15 09:14:59 2009 +0000
+++ b/vymmodel.h	Mon Jan 04 20:36:06 2010 +0000
@@ -237,6 +237,7 @@
 ////////////////////////////////////////////
 public:
 	void setVersion(const  QString &);
+	QString getVersion();
 	void setAuthor  (const QString &);
 	QString getAuthor ();
 	void setComment (const QString &);
@@ -316,6 +317,7 @@
 	XLinkItem* createXLink(BranchItem *dst,bool createMO=false);	//!< Create XLink starting at dst
 
 	AttributeItem* addAttribute();
+	AttributeItem* addAttribute(AttributeItem* );
 
 	/*! \brief Add new mapcenter
 
@@ -438,7 +440,8 @@
 	/*! Export as ASCII text to file */
 	void exportASCII (QString fname="",bool askForName=true);  
 
-	/*! Export as XHTML to directory */
+	/*! Export as HTML to directory */
+    void exportHTML(const QString& dir="", bool askForName=true);	
     void exportXHTML(const QString& dir="", bool askForName=true);	
 
     /*! Export as OpenOfficeOrg presentation */