# HG changeset patch
# User insilmaril
# Date 1149605891 0
# Node ID 608f976aa7bb2b4dac092947ec03150442c82641
# Parent  9eb7767c2dfa3be1552a2467fd928d7bddc34b52
First compilation on QT4

diff -r 9eb7767c2dfa -r 608f976aa7bb aboutdialog.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aboutdialog.cpp	Tue Jun 06 14:58:11 2006 +0000
@@ -0,0 +1,208 @@
+#include <qmime.h>
+#include <q3process.h>
+//Added by qt3to4:
+#include <Q3VBoxLayout>
+#include <Q3Frame>
+
+#include "aboutdialog.h"
+#include "version.h"
+#include "settings.h"
+#include "mainwindow.h"
+
+
+extern Main *mainWindow;
+extern Settings settings;
+extern QString iconPath;
+
+AboutDialog::AboutDialog( QWidget *parent, const char *name)
+    : QDialog( parent, name)
+{
+ 
+    mainLayout=new QVBoxLayout( this, 10);
+
+    tabs=new QTabWidget (this);
+    credits=new AboutTextBrowser (tabs,"credits");
+
+    credits->setText (
+	"<center><img src=\""+iconPath+"vym-128x128.png\"></center>"
+	"<h3><center>VYM - View Your Mind </h3>"
+	"<p align=\"center\"> A tool to put the things you have got in your mind into a map.</p>"
+	"<p align=\"center\"> (c) by Uwe Drechsel (<a href=\"mailto:vym@InSilmaril.de\">vym@InSilmaril.de</a>)</p>"
+	"<p align=\"center\"> Version " __VYM_VERSION" - " __BUILD_DATE"</p>"
+	"<ul>"
+	"<li> Contact</li>"
+		"<ul>"
+			"<li> vym homepage:<br> <a href=\"http://www.InSilmaril.de/vym\">"
+			"http://www.InSilmaril.de/vym</a></li>"
+			"<li> Project homepage on Sourceforge:<br> <a href=\"http://sourceforge.net/projects/vym/\">"
+			"http://sourceforge.net/projects/vym/</a></li>"
+			"<li> Mailinglists are also on Sourceforge:"
+				"<ul>"
+					"<li>Please ask general questions about vym  on "
+				"<a href=\"mailto:vym-forum@lists.sourceforge.net\">vym-forum</a></li>"
+				"<li>Subscribe/Unsubscribe and archives can be found  <a href=\"https://sourceforge.net/mail/?group_id=127802\">here</a></li>"
+				"</ul>"
+		"</ul>"		
+	"<li> Credits " 
+	"<ul>"
+	"<li>Matt from <a href=\"http://www.satbp.com\">www.satbp.com</a> for <a href=\"http://www.taskjuggler.org\">Taskjuggler</a> export</li>"
+	"<li>Jakob Hilmer for image drag and drop, &quot;About vym&quot; window patch </li>"
+	"<li>Thomas Schraitle for the stylesheet  used for XHTML-export </li>"
+	"<li>Debianization by Christoph Thielecke and Steffen Joeris</li>"
+	"<li>Clemens Kraus for HTML-export "
+	"<a href=\"http://www.clemens-kraus.de\">(www.clemens-kraus.de)</a></li>"
+	"<li>Ken Wimer and Olaf Hering for Mac support</li>"
+	"</ul>"
+	"</li>");
+    credits->setFrameStyle( Q3Frame::Panel | Q3Frame::Plain );
+    tabs->addTab (credits,"Credits");
+
+    license=new AboutTextBrowser (tabs,"license");
+	//license->setTextFormat (PlainText);
+    license->setText (
+	"<h3>VYM - View Your Mind</h3>"
+    "<p>Copyright (C) 2004-2005  Uwe Drechsel</p>"  
+
+    "<p>This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.</p>"
+
+    "<p>This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License below for more details.</p>"
+
+	"<p>In addition, as a special exception, Uwe Drechsel gives permission to link the code of this program with the QT libraries from trolltech.com (or with modified versions of QT that use the same license as QT), and distribute linked combinations including the two. You must obey the GNU General Public License in all respects for all of the code used other than QT. If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.</p> "
+
+	"<p>Uwe Drechsel can be contacted at <a href=\"mailto:vym@insilmaril.de\">vym@insilmaril.de</a></p>"
+
+	"<hr>"
+
+ "<p align=\"center\">GNU GENERAL PUBLIC LICENSE<br>"
+"Version 2, June 1991</p>"
+
+"<p align=\"center\">Copyright (C) 1989, 1991 Free Software Foundation, Inc.  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA</p>"
+	 
+"<p align=\"center\"> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.</p>"
+
+"<p align=\"center\">Preamble</p>"
+
+"<p>The licenses for most software are designed to take away your freedom to share and change it.  By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users.  This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it.  (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.)  You can apply it to your programs, too.</p>"
+
+"<p>When we speak of free software, we are referring to freedom, not price.  Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.</p>"
+
+"<p>  To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights.  These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.</p>"
+
+"<p>  For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have.  You must make sure that they, too, receive or can get the source code.  And you must show them these terms so they know their rights.</p>"
+
+"<p>  We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software.</p>"
+
+"<p>  Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software.  If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations.</p>"
+
+"<p>  Finally, any free program is threatened constantly by software patents.  We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary.  To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all.</p>"
+
+"<p>  The precise terms and conditions for copying, distribution and modification follow.</p>"
+
+"<p align=\"center\">		    GNU GENERAL PUBLIC LICENSE</p>"
+"<p align=\"center\">   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION</p>"
+
+"<p>  0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License.  The \"Program\", below, refers to any such program or work, and a \"work based on the Program\" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language.  (Hereinafter, translation is included without limitation in the term \"modification\".)  Each licensee is addressed as \"you\".</p>"
+
+"<p>Activities other than copying, distribution and modification are not covered by this License; they are outside its scope.  The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program).  Whether that is true depends on what the Program does.</p>"
+
+"<p>  1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.</p>"
+
+"<p>You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.</p>"
+
+"<p>  2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:"
+"<ol type=\"a\">"
+	"<li> You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.</li>"
+
+    "<li> You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.</li>"
+
+    "<li> If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License.  (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)</li>"
+"</ol>"
+"</p>"
+
+"<p>These requirements apply to the modified work as a whole.  If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works.  But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.</p>"
+
+"<p>Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.</p>"
+
+"<p>In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.</p>"
+
+"<p>  3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:" "<ol type=\"a\">"
+
+"    <li> Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,</li>"
+
+"    <li> Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,</li>"
+
+"    <li> Accompany it with the information you received as to the offer to distribute corresponding source code.  (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)</li>"
+"</ol></p>"
+
+"<p>The source code for a work means the preferred form of the work for making modifications to it.  For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable.  However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.</p>"
+
+"<p>If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.</p>"
+
+"<p>  4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License.  Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License.  However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.</p>"
+
+"<p>  5. You are not required to accept this License, since you have not signed it.  However, nothing else grants you permission to modify or distribute the Program or its derivative works.  These actions are prohibited by law if you do not accept this License.  Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.</p>"
+
+"<p>  6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions.  You may not impose any further restrictions on the recipients' exercise of the rights granted herein.  You are not responsible for enforcing compliance by third parties to this License.</p>"
+
+"<p>  7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License.  If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all.  For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.</p>"
+
+"<p>If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.</p>"
+
+"<p>It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices.  Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.</p>"
+
+"<p>This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.</p>"
+
+"<p>  8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded.  In such case, this License incorporates the limitation as if written in the body of this License.</p>"
+
+"<p>  9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time.  Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.</p>"
+
+"<p>Each version is given a distinguishing version number.  If the Program specifies a version number of this License which applies to it and \"any later version\", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation.  If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.</p>"
+
+"<p>  10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission.  For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this.  Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.</p>"
+
+"<p align=\"center\">NO WARRANTY</p>"
+
+"<p>  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.</p>"
+
+"<p>  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.</p>"
+
+"<p align=\"center\">END OF TERMS AND CONDITIONS</p>"
+	
+	);
+    credits->setFrameStyle( Q3Frame::Panel | Q3Frame::Plain );
+    tabs->addTab (license,"License");
+
+    mainLayout->addWidget (tabs);
+    tabs->showPage (credits);
+
+    okbutton =new QPushButton (this,"okbutton");
+    okbutton->setText (tr("Ok"));
+    okbutton->setMaximumSize (QSize (50,30));
+    okbutton->setAutoDefault (true);
+    mainLayout->addWidget( okbutton); 
+
+    connect( okbutton, SIGNAL( clicked() ), this, SLOT( accept() ) );
+}
+
+AboutTextBrowser::AboutTextBrowser(QWidget *parent, const char *name)
+    : Q3TextBrowser(parent, name)
+{
+    
+}
+
+void AboutTextBrowser::setSource(const QString &name)
+{
+    Q3MimeSourceFactory *factory = Q3MimeSourceFactory::defaultFactory();
+    const QMimeSource *data = factory->data(name);
+    if (data) {
+	Q3TextBrowser::setSource(name);
+    } else {
+	Q3Process *proc = new Q3Process( this );
+	proc->addArgument( settings.readEntry("/vym/mainwindow/readerURL" ));
+	proc->addArgument( name);
+	
+	if ( !proc->start() ) 
+	    if (mainWindow->settingsURL() ) 
+		setSource(name);
+    }
+}
diff -r 9eb7767c2dfa -r 608f976aa7bb aboutdialog.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/aboutdialog.h	Tue Jun 06 14:58:11 2006 +0000
@@ -0,0 +1,41 @@
+#ifndef ABOUTDIALOG_H
+#define ABOUTDIALOG_H
+
+#include <qtabwidget.h>
+#include <q3textbrowser.h>
+#include <qlayout.h>
+#include <qdialog.h>
+#include <qpushbutton.h>
+#include <qstring.h>
+
+class AboutTextBrowser;
+/////////////////////////////////////////////////////////////////////////////
+class AboutDialog :public QDialog
+{
+	Q_OBJECT
+
+public:
+	AboutDialog(QWidget* parent = 0, const char* name = 0);
+
+private:
+	QTabWidget *tabs;
+	AboutTextBrowser *credits;
+	AboutTextBrowser *license;
+
+	QLayout *mainLayout;
+	QLayout *topLayout;
+	QLayout *bottomLayout;
+	QPushButton *okbutton;
+	
+};
+
+class AboutTextBrowser : public Q3TextBrowser
+{
+  Q_OBJECT;
+ public:
+  AboutTextBrowser(QWidget *parent, const char *name = 0);
+ public slots:
+   void setSource(const QString &name);
+};
+
+#endif
diff -r 9eb7767c2dfa -r 608f976aa7bb branchobj.cpp
--- a/branchobj.cpp	Sun Jan 30 12:58:47 2005 +0000
+++ b/branchobj.cpp	Tue Jun 06 14:58:11 2006 +0000
@@ -24,13 +24,14 @@
     depth=-1;
 }
 
-BranchObj::BranchObj (QCanvas* c):OrnamentedObj (c)
+BranchObj::BranchObj (Q3Canvas* c):OrnamentedObj (c)
 {
 //    cout << "Const BranchObj (c)  called from MapCenterObj (c)\n";
+	parObj=NULL;
     canvas=c;
 }
 
-BranchObj::BranchObj (QCanvas* c, LinkableMapObj* p):OrnamentedObj (c)
+BranchObj::BranchObj (Q3Canvas* c, LinkableMapObj* p):OrnamentedObj (c)
 {
 //    cout << "Const BranchObj (c,p)\n";
     canvas=c;
@@ -47,16 +48,18 @@
 
 BranchObj::~BranchObj ()
 {
-    //cout << "Destr BranchObj\n";
+//	cout << "Destr BranchObj of "<<this<<endl;
 	// Check, if this branch was the last child to be deleted
 	// If so, unset the scrolled flags
 
 	BranchObj *po=(BranchObj*)(parObj);
+	BranchObj *bo;
 	if (po)
 	{
-		BranchObj *bo=((BranchObj*)(parObj))->getLastBranch();
+		bo=((BranchObj*)(parObj))->getLastBranch();
 		if (!bo) po->unScroll();
 	}
+	clear();
 }
 
 bool BranchObj::operator< ( const BranchObj & other )
@@ -69,7 +72,7 @@
     return angle == other.angle;
 }
 
-int BranchObjPtrList::compareItems ( QPtrCollection::Item i, QPtrCollection::Item j)
+int BranchObjPtrList::compareItems ( Q3PtrCollection::Item i, Q3PtrCollection::Item j)
 {
 	// Make sure PtrList::find works
 	if (i==j) return 0;
@@ -82,17 +85,15 @@
 
 void BranchObj::init () 
 {
-    branch.setAutoDelete (true);
+    branch.setAutoDelete (false);
     floatimage.setAutoDelete (true);
+    xlink.setAutoDelete (false);
 
-	absPos=getRandPos();
-	absPos+=parObj->getChildPos();
-
-    // TODO This should be done in TextObj later
-    QFont font("Sans Serif,8,-1,5,50,0,0,0,0,0");
-//    font.setPointSize(12);
-   heading->setFont(font );
-//    heading->setText(QObject::tr("new branch"));
+	if (parObj)
+	{
+		absPos=getRandPos();
+		absPos+=parObj->getChildPos();
+	}
 
     lastSelectedBranch=-1;
 
@@ -101,8 +102,8 @@
 	scrolled=false;
 	tmpUnscrolled=false;
 
-	url="";
-	vymLink="";
+	includeImagesVer=false;
+	includeImagesHor=false;
 }
 
 void BranchObj::copy (BranchObj* other)
@@ -125,9 +126,6 @@
 	tmpUnscrolled=other->tmpUnscrolled;
 	setVisibility (other->visible);
 
-	url=other->url;
-	vymLink=other->vymLink;
-
 	angle=other->angle;
 
     positionBBox();
@@ -135,8 +133,17 @@
 
 void BranchObj::clear() 
 {
-	branch.clear();
 	floatimage.clear();
+	while (!xlink.isEmpty())
+		deleteXLink (xlink.first() );
+
+	BranchObj *bo;
+	while (!branch.isEmpty())
+	{
+		bo=branch.first();
+		branch.removeFirst();
+		delete (bo);
+	}
 }
 
 int BranchObj::getNum()
@@ -149,7 +156,12 @@
 
 int BranchObj::getNum(BranchObj *bo)
 {
-	return branch.findRef (bo);
+	// keep current pointer in branch, 
+	// otherwise save might fail
+	int cur=branch.at();
+	int ind=branch.findRef (bo);
+	branch.at(cur);
+	return ind;
 }
 
 int BranchObj::getFloatImageNum(FloatImageObj *fio)
@@ -167,6 +179,11 @@
 	return floatimage.count();
 }
 
+int BranchObj::countXLinks()
+{
+	return xlink.count();
+}
+
 void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPoint m, int off)
 {
 	// Temporary link to lmo
@@ -181,19 +198,10 @@
 	// ignore mapcenter and mainbranch
 	if (lmo->getDepth()<2) off=0;
 	if (off==0)
-	{
 		link2ParPos=false;
-		parObj=o;
-	}	
 	else
-	{	
 		link2ParPos=true;
-		if (off>0)
-			parObj=o->getParObj();
-		else	
-			parObj=o->getParObj();
-		parObj=o;
-	}		
+	parObj=o;
 
 	depth=parObj->getDepth()+1;
 
@@ -254,6 +262,7 @@
 		parObjTmpBuf=NULL;
 		depth=parObj->getDepth()+1;
 		setLinkStyle (getDefLinkStyle() );
+		updateLink();
 	}		
 }
 
@@ -350,6 +359,7 @@
 		standardFlags->setVisibility(v);
 		LinkableMapObj::setVisibility (v);
 		
+		// Only change childs, if I am not scrolled
 		if (!scrolled && (depth < toDepth))
 		{
 			// Now go recursivly through all childs
@@ -359,9 +369,11 @@
 			FloatImageObj *fio;
 			for (fio=floatimage.first(); fio; fio=floatimage.next())
 				fio->setVisibility (v);
+			XLinkObj* xlo;
+			for (xlo=xlink.first(); xlo;xlo=xlink.next() ) 
+				xlo->setVisibility ();	
 		}
     } // depth <= toDepth	
-	move (absPos.x(), absPos.y() );
 	requestReposition();
 }	
 
@@ -376,25 +388,21 @@
 	// Overloaded from LinkableMapObj
 	// BranchObj can use color of heading
 
-	if (mapEditor->getLinkColorHint()==HeadingColor)
-		LinkableMapObj::setLinkColor (heading->getColor() );
-	else	
-		LinkableMapObj::setLinkColor ();
+	if (mapEditor)
+		if (mapEditor->getLinkColorHint()==HeadingColor)
+			LinkableMapObj::setLinkColor (heading->getColor() );
+		else	
+			LinkableMapObj::setLinkColor ();
 }
 
-void BranchObj::setColor (QColor col, bool colorChilds)
+void BranchObj::setColorChilds (QColor col)
 {
-    heading->setColor(col);
-	setLinkColor();
-    if (colorChilds) 
-    {
-		BranchObj *bo;
-		for (bo=branch.first(); bo; bo=branch.next() )
-			bo->setColor(col,colorChilds);
-    }	
+	OrnamentedObj::setColor (col);
+	BranchObj *bo;
+	for (bo=branch.first(); bo; bo=branch.next() )
+		bo->setColorChilds(col);
 }
 
-
 BranchObj* BranchObj::first()
 {
 	itLast=NULL;	
@@ -521,10 +529,20 @@
 	itLast=it;
 }
 
+void BranchObj::positionContents()
+{
+	FloatImageObj *fio;
+    for (fio=floatimage.first(); fio; fio=floatimage.next() )
+		fio->reposition();
+	OrnamentedObj::positionContents();
+}
 
 void BranchObj::move (double x, double y)
 {
 	OrnamentedObj::move (x,y);
+	FloatImageObj *fio;
+    for (fio=floatimage.first(); fio; fio=floatimage.next() )
+		fio->reposition();
     positionBBox();
 }
 
@@ -536,12 +554,12 @@
 void BranchObj::moveBy (double x, double y)
 {
 	OrnamentedObj::moveBy (x,y);
-    positionBBox();
     BranchObj* b;
     for (b=branch.first(); b;b=branch.next() ) 
 		b->moveBy (x,y);
+    positionBBox();
 }
-
+	
 void BranchObj::moveBy (QPoint p)
 {
 	moveBy (p.x(), p.y());
@@ -550,30 +568,25 @@
 
 void BranchObj::positionBBox()
 {
-
-    heading->positionBBox();
-	systemFlags->positionBBox();
-	standardFlags->positionBBox();
-	// It seems that setting x,y also affects width,height
-	int w_old=bbox.width();
-	int h_old=bbox.height();
-    bbox.setX (absPos.x() );
-	bbox.setY (absPos.y() );
-	bbox.setWidth(w_old);
-	bbox.setHeight(h_old);
-
-
+	QPoint ap=getAbsPos();
+	bbox.moveTopLeft (ap);
+	positionContents();
 	setSelBox();
 
 	// set the frame
 	frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
+
+	// Update links to other branches
+	XLinkObj *xlo;
+    for (xlo=xlink.first(); xlo; xlo=xlink.next() )
+		xlo->updateXLink();
 }
 
 void BranchObj::calcBBoxSize()
 {
     QSize heading_r=heading->getSize();
-    int heading_w=static_cast <int> (heading_r.width() );
-    int heading_h=static_cast <int> (heading_r.height() );
+    int heading_w=(int) heading_r.width() ;
+    int heading_h=(int) heading_r.height() ;
     QSize sysflags_r=systemFlags->getSize();
 	int sysflags_h=sysflags_r.height();
 	int sysflags_w=sysflags_r.width();
@@ -589,11 +602,73 @@
 	h=max (sysflags_h,stanflags_h);
 	h=max (h,heading_h);
 
+	// Save the dimension of flags and heading
+	ornamentsBBox.setSize ( QSize(w,h));
+
+	// clickBox includes Flags and Heading
+    clickBox.setSize (ornamentsBBox.size() );
+
+	// Floatimages 
+	QPoint rp;
+	FloatImageObj *foi;
+
+	topPad=botPad=leftPad=rightPad=0;
+	if (includeImagesVer || includeImagesHor)
+	{
+		if (countFloatImages()>0)
+		{
+			for (foi=floatimage.first(); foi; foi=floatimage.next() )
+			{
+				rp=foi->getRelPos();
+				if (includeImagesVer)
+				{
+					if (rp.y() < 0) 
+						topPad=max (topPad,-rp.y()-h);
+					if (rp.y()+foi->height() > 0)
+						botPad=max (botPad,rp.y()+foi->height());
+				}		
+				if (includeImagesHor)
+				{
+					if (orientation==OrientRightOfCenter)
+					{
+						if (-rp.x()-w > 0) 
+							leftPad=max (leftPad,-rp.x()-w);
+						if (rp.x()+foi->width() > 0)
+							rightPad=max (rightPad,rp.x()+foi->width());
+					} else
+					{
+						if (rp.x()< 0) 
+							leftPad=max (leftPad,-rp.x());
+						if (rp.x()+foi->width() > w)
+							rightPad=max (rightPad,rp.x()+foi->width()-w);
+					}
+				}		
+			}	
+		}	
+		h+=topPad+botPad;
+		w+=leftPad+rightPad;
+	}
+
+	// Frame thickness
     w+=frame->getBorder();
     h+=frame->getBorder();
+	
+	// Finally set size
     bbox.setSize (QSize (w,h));
 }
 
+void BranchObj::setDockPos()
+{
+	if (getOrientation()==OrientLeftOfCenter )
+    {
+		childPos=QPoint (ornamentsBBox.bottomLeft().x(), ornamentsBBox.bottomLeft().y() );
+		parPos=QPoint (ornamentsBBox.bottomRight().x(),ornamentsBBox.bottomRight().y() );
+    } else
+    {
+		childPos=QPoint (ornamentsBBox.bottomRight().x(), ornamentsBBox.bottomRight().y() );
+		parPos=QPoint (ornamentsBBox.bottomLeft().x(),ornamentsBBox.bottomLeft().y() );
+    }
+}
 LinkableMapObj* BranchObj::findMapObj(QPoint p, LinkableMapObj* excludeLMO)
 {
 	// Search branches
@@ -606,89 +681,67 @@
     }
 	
 	// Search myself
-    if (inBBox (p) && (this != excludeLMO) && isVisibleObj() ) 
+    if (inBox (p) && (this != excludeLMO) && isVisibleObj() ) 
 		return this;
 
 	// Search float images
 	FloatImageObj *foi;
     for (foi=floatimage.first(); foi; foi=floatimage.next() )
-		if (foi->inBBox(p) && (foi != excludeLMO) && foi->getParObj()!= excludeLMO) return foi;
+		if (foi->inBox(p) && 
+			(foi != excludeLMO) && 
+			foi->getParObj()!= excludeLMO &&
+			foi->isVisibleObj() 
+		) return foi;
 
     return NULL;
 }
 
 void BranchObj::setHeading(QString s)
 {
-    // Adjusting font size
-    QFont font=heading->getFont();
-	if (depth==0)
-		font.setPointSize(16);
-	else	
-		if (depth>1) 
-			font.setPointSize(10);
-		else
-			font.setPointSize(12);
-    heading->setFont(font);
     heading->setText(s);	// set new heading
 	calcBBoxSize();			// recalculate bbox
     positionBBox();			// rearrange contents
 	requestReposition();
 }
 
-void BranchObj::setURL(QString s)
+void BranchObj::setHideTmp (HideTmpMode mode)
 {
-	url=s;
-	if (!url.isEmpty())
-		systemFlags->activate("url");
-	else	
-		systemFlags->deactivate("url");
-	calcBBoxSize();			// recalculate bbox
-    positionBBox();			// rearrange contents
-	forceReposition();
+	if (mode==HideExport && hasHiddenExportParent(this))
+	{
+		setVisibility (false);
+		hidden=true;
+	}else
+	{
+		if (hasScrolledParent(this))
+			setVisibility (false);
+		else
+			setVisibility (true);
+		hidden=false;
+	}	
+
+    BranchObj *bo;
+    for (bo=branch.first(); bo; bo=branch.next() )
+		bo->setHideTmp (mode);
 }
 
-QString BranchObj::getURL()
+bool BranchObj::hasHiddenExportParent(BranchObj *start)
 {
-	return url;
-}
+	// Calls parents recursivly to
+	// find out, if we are temp. hidden
 
-void BranchObj::setVymLink(QString s)
-{
-	if (!s.isEmpty())
-	{
-		// We need the relative (from loading) 
-		// or absolute path (from User event)
-		// and build the absolute path.
-		// Note: If we have relative, use path of
-		// current map to build absolute path
-		QDir d(s);
-		if (!d.path().startsWith ("/"))
-		{
-			QString p=mapEditor->getDestPath();
-			int i=p.findRev("/",-1);
-			d.setPath(p.left(i)+"/"+s);
-			d.convertToAbs();
-		}
-		vymLink=d.path();
-		systemFlags->activate("vymLink");
-	}	
-	else	
-	{
-		systemFlags->deactivate("vymLink");
-		vymLink="";
-	}	
-	calcBBoxSize();			// recalculate bbox
-    positionBBox();			// rearrange contents
-	forceReposition();
-}
+	if (hideExport) return true;
 
-QString BranchObj::getVymLink()
-{
-	return vymLink;
+	BranchObj* bo=(BranchObj*)(parObj);
+	if (bo) 
+		return bo->hasHiddenExportParent(start);
+	else
+		return false;
 }
 
 QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPoint& offset)
 {
+	if (hidden) return "";
+
     QString s,a;
 	QString scrolledAttr;
 	if (scrolled) 
@@ -696,21 +749,6 @@
 	else
 		scrolledAttr="";
 
-	QString posAttr;
-	if (depth<2) posAttr=
-		attribut("absPosX",QString().setNum(absPos.x(),10)) +
-		attribut("absPosY",QString().setNum(absPos.y(),10)); 
-	else
-		posAttr="";
-
-	QString urlAttr;
-	if (!url.isEmpty())
-		urlAttr=attribut ("url",url);
-
-	QString vymLinkAttr;
-	if (!vymLink.isEmpty())
-		vymLinkAttr=attribut ("vymLink",convertToRel(mapEditor->getDestPath(),vymLink) );
-
 	QString frameAttr;
 	if (frame->getFrameType()!=NoFrame)
 		frameAttr=attribut ("frameType",frame->getFrameTypeName());
@@ -730,11 +768,24 @@
 	} else
 		areaAttr="";
 	
-    s=beginElement ("branch" +scrolledAttr +posAttr +urlAttr +vymLinkAttr +frameAttr +areaAttr);
+	// Providing an ID for a branch makes export to XHTML easier
+	QString idAttr;
+	if (countXLinks()>0)
+		idAttr=attribut ("id",getSelectString());
+	else
+		idAttr="";
+
+    s=beginElement ("branch" 
+		+getOrnAttr() 
+		+scrolledAttr 
+		+frameAttr 
+		+areaAttr 
+		+idAttr 
+		+getIncludeImageAttr() );
     incIndent();
 
 	// save heading
-    s=s+valueElement("heading", getHeading(),
+    s+=valueElement("heading", getHeading(),
 		attribut ("textColor",QColor(heading->getColor()).name()));
 
 	// save names of flags set
@@ -748,17 +799,120 @@
     BranchObj *bo;
     for (bo=branch.first(); bo; bo=branch.next() )
 		s+=bo->saveToDir(tmpdir,prefix,offset);
-    decIndent();
 
 	// Save FloatImages
 	FloatImageObj *fio;
 	for (fio=floatimage.first(); fio; fio=floatimage.next() )
-		s+=fio->saveToDir (tmpdir,prefix);
+		s+=fio->saveToDir (tmpdir,prefix,offset);
 
+	// Save XLinks
+	XLinkObj *xlo;
+	//FIXME exponential increase in xlinks...
+	QString ol;	// old link
+	QString cl;	// current link
+    for (xlo=xlink.first(); xlo; xlo=xlink.next() )
+	{
+		cl=xlo->saveToDir();
+		if (cl!=ol)
+		{
+			s+=cl;
+			ol=cl;
+		} else
+		{
+			qWarning (QString("Ignoring of duplicate xLink in %1").arg(getHeading()));
+		}
+	}	
+
+    decIndent();
     s+=endElement   ("branch");
     return s;
 }
 
+void BranchObj::addXLink (XLinkObj *xlo)
+{
+	xlink.append (xlo);
+	
+}
+
+void BranchObj::removeXLinkRef (XLinkObj *xlo)
+{
+	xlink.remove (xlo);
+}
+
+void BranchObj::deleteXLink(XLinkObj *xlo)
+{
+	xlo->deactivate();
+	if (!xlo->isUsed()) delete (xlo);
+}
+
+void BranchObj::deleteXLinkAt (int i)
+{
+	XLinkObj *xlo=xlink.at(i);
+	xlo->deactivate();
+	if (!xlo->isUsed()) delete(xlo);
+}
+
+XLinkObj* BranchObj::XLinkAt (int i)
+{
+	return xlink.at(i);
+}
+
+int BranchObj::countXLink()
+{
+	return xlink.count();
+}
+
+
+BranchObj* BranchObj::XLinkTargetAt (int i)
+{
+	if (xlink.at(i))
+		return xlink.at(i)->otherBranch (this);
+	else
+		return NULL;
+}
+
+void BranchObj::setIncludeImagesVer(bool b)
+{
+	includeImagesVer=b;
+	calcBBoxSize();
+	positionBBox();
+	requestReposition();
+	//FIXME undo needed
+}
+
+bool BranchObj::getIncludeImagesVer()
+{
+	return includeImagesVer;
+}
+
+void BranchObj::setIncludeImagesHor(bool b)
+{
+	includeImagesHor=b;
+	calcBBoxSize();
+	positionBBox();
+	requestReposition();
+	//FIXME undo needed
+}
+
+bool BranchObj::getIncludeImagesHor()
+{
+	return includeImagesHor;
+}
+
+QString BranchObj::getIncludeImageAttr()
+{
+	QString a;
+	if (includeImagesVer)
+		a=attribut ("incImgV","true");
+	else
+		a=attribut ("incImgV","false");
+	if (includeImagesHor)
+		a+=attribut ("incImgH","true");
+	else
+		a+=attribut ("incImgH","false");
+	return a;	
+}
+
 LinkableMapObj* BranchObj::addFloatImage ()
 {
 	FloatImageObj *newfi=new FloatImageObj (canvas,this);
@@ -767,8 +921,11 @@
 		newfi->setVisibility (false);
 	else	
 		newfi->setVisibility(visible);
+	calcBBoxSize();
+	positionBBox();
 	requestReposition();
 	return newfi;
+	//FIXME undo needed
 }
 
 LinkableMapObj* BranchObj::addFloatImage (FloatImageObj *fio)
@@ -780,8 +937,11 @@
 		newfi->setVisibility (false);
 	else	
 		newfi->setVisibility(visible);
+	calcBBoxSize();
+	positionBBox();
 	requestReposition();
 	return newfi;
+	// FIMXE undo needed
 }
 
 FloatImageObj* BranchObj::getFirstFloatImage ()
@@ -802,7 +962,10 @@
 void BranchObj::removeFloatImage (FloatImageObj *fio)
 {
 	floatimage.remove (fio);
+	calcBBoxSize();
+	positionBBox();
 	requestReposition();
+	// FIMXE undo needed
 }
 
 void BranchObj::savePosInAngle ()
@@ -817,19 +980,40 @@
 	}
 }
 
+void BranchObj::setDefAttr (BranchModification mod)
+{
+	int fontsize;
+	switch (depth)
+	{
+		case 0: fontsize=16; break;
+		case 1: fontsize=12; break;
+		default: fontsize=10; break;
+	}	
+
+	setLinkColor ();
+	setLinkStyle(getDefLinkStyle());
+	QFont font("Sans Serif,8,-1,5,50,0,0,0,0,0");
+	font.setPointSize(fontsize);
+	heading->setFont(font );
+
+	if (mod==NewBranch)
+		setColor (((BranchObj*)(parObj))->getColor());
+	
+	calcBBoxSize();
+}
+
 BranchObj* BranchObj::addBranch()
 {
     BranchObj* newbo=new BranchObj(canvas,this);
     branch.append (newbo);
     newbo->setParObj(this);
-    newbo->setColor(getColor(),false);	
-    newbo->setLinkColor();	
+	newbo->setDefAttr(NewBranch);
     newbo->setHeading ("new");
-	newbo->setLinkStyle (newbo->getDefLinkStyle());
 	if (scrolled)
 		newbo->setVisibility (false);
 	else	
 		newbo->setVisibility(visible);
+	newbo->updateLink();	
 	requestReposition();
 	return newbo;
 }
@@ -840,16 +1024,27 @@
     branch.append (newbo);
     newbo->copy(bo);
     newbo->setParObj(this);
-	newbo->setHeading (newbo->getHeading());	// adjust fontsize to depth
-	newbo->setLinkStyle (newbo->getDefLinkStyle());
+	newbo->setDefAttr(MovedBranch);
 	if (scrolled)
 		newbo->setVisibility (false);
 	else	
 		newbo->setVisibility(bo->visible);
+	newbo->updateLink();	
 	requestReposition();
 	return newbo;
 }
 
+BranchObj* BranchObj::addBranchPtr(BranchObj* bo)
+{
+	branch.append (bo);
+	bo->setParObj (this);
+	bo->depth=depth+1;
+	bo->setDefAttr(MovedBranch);
+	if (scrolled) tmpUnscroll();
+	setLastSelectedBranch (bo);
+	return bo;
+}
+
 BranchObj* BranchObj::insertBranch(int pos)
 {
 	savePosInAngle();
@@ -870,11 +1065,56 @@
 	return newbo;
 }
 
+BranchObj* BranchObj::insertBranchPtr (BranchObj* bo, int pos)
+{
+	savePosInAngle();
+	// Add new bo and resort branches
+	bo->angle=pos-0.5;
+	branch.append (bo);
+	bo->setParObj (this);
+	bo->depth=depth+1;
+	bo->setDefAttr (MovedBranch);
+	if (scrolled) tmpUnscroll();
+	setLastSelectedBranch (bo);
+	branch.sort();
+	return bo;
+}
+
+void BranchObj::removeBranchHere(BranchObj* borem)
+{
+	// This removes the branch bo from list, but 
+	// inserts its childs at the place of bo
+	BranchObj *bo;
+	bo=borem->getLastBranch();
+	int pos=borem->getNum();
+	while (bo)
+	{
+		bo->moveBranchTo (this,pos+1);
+		bo=borem->getLastBranch();
+	}	
+	removeBranch (borem);
+}
+
+void BranchObj::removeChilds()
+{
+	clear();
+}
+
 void BranchObj::removeBranch(BranchObj* bo)
 {
     // if bo is not in branch remove returns false, we
     // don't care...
-    branch.remove (bo);
+	
+    if (branch.remove (bo))
+		delete (bo);
+	else
+		qWarning ("BranchObj::removeBranch tried to remove non existing branch?!\n");
+	requestReposition();
+}
+
+void BranchObj::removeBranchPtr(BranchObj* bo)
+{
+	branch.remove (bo);
 	requestReposition();
 }
 
@@ -908,6 +1148,15 @@
     return branch.at(i);
 }
 
+bool BranchObj::canMoveBranchUp() 
+{
+	if (!parObj) return false;
+	BranchObj* par=(BranchObj*)parObj;
+	if (this==par->getFirstBranch())
+		return false;
+	else
+		return true;
+}
 
 BranchObj* BranchObj::moveBranchUp(BranchObj* bo1) // move a branch up (modify myself)
 {
@@ -923,6 +1172,16 @@
 		return branch.at(i);
 }
 
+bool BranchObj::canMoveBranchDown() 
+{
+	if (!parObj) return false;
+	BranchObj* par=(BranchObj*)parObj;
+	if (this==par->getLastBranch())
+		return false;
+	else
+		return true;
+}
+
 BranchObj* BranchObj::moveBranchDown(BranchObj* bo1)
 {
 	savePosInAngle();
@@ -939,29 +1198,63 @@
 		return branch.at(i);
 }
 
+BranchObj* BranchObj::moveBranchTo (BranchObj* dst, int pos)
+{
+	// Find current parent and 
+	// remove pointer to myself there
+	if (!dst) return NULL;
+	BranchObj *par=(BranchObj*)(parObj);
+	if (par)
+		par->removeBranchPtr (this);
+	else
+		return NULL;
+
+	// Create new pointer to myself at dst
+	if (pos<0||dst->getDepth()==0)
+	{	
+		// links myself as last branch at dst
+		dst->addBranchPtr (this);
+		updateLink();
+		return this;
+	} else
+	{
+		// inserts me at pos in parent of dst
+		if (par)
+		{
+			BranchObj *bo=dst->insertBranchPtr (this,pos);
+			bo->setDefAttr(MovedBranch);
+			updateLink();
+			return bo;
+
+		} else
+			return NULL;
+	}	
+}
+
 void BranchObj::alignRelativeTo (QPoint ref)
 {
-/* FIXME testing
-	if (!getHeading().isEmpty())
-		cout << "BO::alignRelTo "<<getHeading()<<endl;
-	else	
-		cout << "BO::alignRelTo  ???"<<endl;
-	cout << "  d="<<depth<<endl;
-*/	
 	int th = bboxTotal.height();	
+// TODO testing
+/*
+	cout << "BO::alignRelTo "<<getHeading()<<endl;
+	cout << "  d="<<depth<<
+		"  ref="<<ref<<
+//		"  bbox.topLeft="<<bboxTotal.topLeft()<<
+		"  absPos="<<absPos<<
+//		"  pad="<<topPad<<","<<botPad<<","<<leftPad<<","<<rightPad<<
+		"  hidden="<<hidden<<
+		"  th="<<th<<endl;
+*/
 
 	// If I am the mapcenter or a mainbranch, reposition heading
 	if (depth<2)
-	{
-		move (absPos.x(),absPos.y());
+	{	//FIXME ugly! optimize this   move for MCO needed to initially position text in box...
 		if (depth==1)
-		{
 			// Calc angle to mapCenter if I am a mainbranch
 			// needed for reordering the mainbranches clockwise 
 			// around mapcenter 
 			angle=getAngle (QPoint ((int)(x() - parObj->getChildPos().x() ), 
 									(int)(y() - parObj->getChildPos().y() ) ) );
-		}	
 	} 
 	else
     {
@@ -970,29 +1263,25 @@
 		switch (orientation) 
 		{
 			case OrientLeftOfCenter:
-				move (ref.x()-bbox.width(), ref.y() + (th-bbox.height())/2 );
+				move (ref.x() - bbox.width(), ref.y() + (th-bbox.height())/2 );
 			break;
 			case OrientRightOfCenter:	
-				move (ref.x(), ref.y() + (th-bbox.height())/2 );
+				move (ref.x() , ref.y() + (th-bbox.height())/2  );
 			break;
 			default:
-				cout <<"LMO::alignRelativeTo: oops, no orientation given...\n";
+				qWarning ("LMO::alignRelativeTo: oops, no orientation given...");
 			break;
 		}		
     }		
 
-	FloatImageObj *fio;
-    for (fio=floatimage.first(); fio; fio=floatimage.next() )
-		fio->reposition();
-
 	if (scrolled) return;
 
     // Set reference point for alignment of childs
     QPoint ref2;
     if (orientation==OrientLeftOfCenter)
-		ref2.setX(childPos.x() - linkwidth);
+		ref2.setX(bbox.topLeft().x() - linkwidth);
     else	
-		ref2.setX(childPos.x() + linkwidth);
+		ref2.setX(bbox.topRight().x() + linkwidth);
 
 	if (depth==1)
 		ref2.setY(absPos.y()-(bboxTotal.height()-bbox.height())/2);
@@ -1003,15 +1292,18 @@
     BranchObj *b;
     for (b=branch.first(); b; b=branch.next() )
     {	
-		b->alignRelativeTo (ref2);
-		ref2.setY(ref2.y() + b->getBBoxSizeWithChilds().height() );
+		if (!b->isHidden())
+		{
+			b->alignRelativeTo (ref2);
+			ref2.setY(ref2.y() + b->getBBoxSizeWithChilds().height() );
+		}
     }
 }
 
 
 void BranchObj::reposition()
 {	
-/* FIXME testing
+/* TODO testing only
 	if (!getHeading().isEmpty())
 		cout << "BO::reposition  "<<getHeading()<<endl;
 	else	
@@ -1023,9 +1315,13 @@
 		// changes its height,
 		// all upper LMOs have to change, too.
 		calcBBoxSizeWithChilds();
+		updateLink();	// This update is needed if the canvas is resized 
+						// due to excessive moving of a FIO
+
 	    alignRelativeTo ( QPoint (absPos.x(),
 			absPos.y()-(bboxTotal.height()-bbox.height())/2) );
 		branch.sort();	
+		positionBBox();	// Reposition bbox and contents
 	} else
 	{
 		// This is only important for moving branches:
@@ -1044,11 +1340,13 @@
 
 	BranchObj* b;
 	for (b=branch.first();b ;b=branch.next() )
-		r=addBBox(b->getTotalBBox(),r);
+		if (!b->isHidden())
+			r=addBBox(b->getTotalBBox(),r);
 
 	FloatImageObj* fio;
 	for (fio=floatimage.first();fio ;fio=floatimage.next() )
-		r=addBBox(fio->getTotalBBox(),r);
+		if (!fio->isHidden())
+			r=addBBox(fio->getTotalBBox(),r);
 		
 	return r;
 }
@@ -1059,14 +1357,14 @@
 }
 
 void BranchObj::calcBBoxSizeWithChilds()
-{
-	// This is called only from reposition and
+{	
+	// This is initially called only from reposition and
 	// and only for mapcenter. So it won't be
 	// called more than once for a single user 
 	// action
 	
+
 	// Calculate size of LMO including all childs (to align them later)
-
 	bboxTotal.setX(bbox.x() );
 	bboxTotal.setY(bbox.y() );
 
@@ -1078,6 +1376,22 @@
 		return;
 	}
 	
+	if (hidden)
+	{
+		bboxTotal.setWidth (0);
+		bboxTotal.setHeight(0);
+		if (parObj)
+		{
+			bboxTotal.setX (parObj->x());
+			bboxTotal.setY (parObj->y());
+		} else
+		{
+			bboxTotal.setX (bbox.x());
+			bboxTotal.setY (bbox.y());
+		}
+		return;
+	}
+	
 	QRect r(0,0,0,0);
 	QRect br;
 	// Now calculate recursivly
@@ -1087,11 +1401,14 @@
 	BranchObj* b;
 	for (b=branch.first();b ;b=branch.next() )
 	{
-		b->calcBBoxSizeWithChilds();
-		br=b->getBBoxSizeWithChilds();
-		r.setWidth( max (br.width(), r.width() ));
-		r.setHeight(br.height() + r.height() );
-		if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y());
+		if (!b->isHidden())
+		{
+			b->calcBBoxSizeWithChilds();
+			br=b->getBBoxSizeWithChilds();
+			r.setWidth( max (br.width(), r.width() ));
+			r.setHeight(br.height() + r.height() );
+			if (br.y()<bboxTotal.y()) bboxTotal.setY(br.y());
+		}
 	}
 	// Add myself and also
 	// add width of link to sum if necessary
@@ -1099,12 +1416,21 @@
 		bboxTotal.setWidth (bbox.width() + r.width() );
 	else	
 		bboxTotal.setWidth (bbox.width() + r.width() + linkwidth);
-	bboxTotal.setHeight(max (r.height(),  bbox.height() ) );
-//	frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) );
+	
+	bboxTotal.setHeight(max (r.height(),  bbox.height()));
 }
 
 void BranchObj::select()
 {
+	// set Text in Editor	
+	textEditor->setText(note.getNote() );
+	QString fnh=note.getFilenameHint();
+	if (fnh!="")
+		textEditor->setFilenameHint(note.getFilenameHint() );
+	else	
+		textEditor->setFilenameHint(getHeading() );
+	textEditor->setFontHint (note.getFontHint() );
+
     LinkableMapObj::select();
 	// Tell parent that I am selected now:
 	BranchObj* po=(BranchObj*)(parObj);
@@ -1114,13 +1440,6 @@
 	// temporary unscroll, if we have scrolled parents somewhere
 	if (parObj) ((BranchObj*)(parObj))->tmpUnscroll();
 
-	// set Text in Editor	
-	textEditor->setText(note.getNote() );
-	textEditor->setFilename(note.getFilenameHint() );
-	textEditor->setFontHint (note.getFontHint() );
-	connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag() ) ); 
-	connect (textEditor, SIGNAL (fontSizeHasChanged() ), this, SLOT (updateNoteFlag() ) ); 
-
 	// Show URL and link in statusbar
 	QString status;
 	if (!url.isEmpty()) status+="URL: "+url+"  ";
@@ -1128,13 +1447,7 @@
 	if (!status.isEmpty()) mainWindow->statusMessage (status);
 
 	// Update Toolbar
-	standardFlags->updateToolBar();
-
-	// Update Browserbutton
-	if (!url.isEmpty())
-		actionEditOpenURL->setEnabled (true);
-	else	
-		actionEditOpenURL->setEnabled (false);
+	standardFlags->updateToolbar();
 
 	// Update actions in mapeditor
 	mapEditor->updateActions();
@@ -1154,15 +1467,11 @@
 	// reset temporary unscroll, if we have scrolled parents somewhere
 	if (parObj) ((BranchObj*)(parObj))->resetTmpUnscroll();
 
-	// Disconnect textEditor from this LMO
-	disconnect( textEditor, SIGNAL(textHasChanged()), 0, 0 );
-	disconnect( textEditor, SIGNAL (fontSizeHasChanged()),0,0 ); 
-
 	// Erase content of editor 
 	textEditor->setInactive();
 
 	// unselect all buttons in toolbar
-	standardFlagsDefault->updateToolBar();
+	standardFlagsDefault->updateToolbar();
 }
 
 QString BranchObj::getSelectString()
@@ -1170,15 +1479,12 @@
 	QString s;
 	if (parObj)
 	{
-		if (parObj->getDepth()==0)
+		if (depth==1)
 			s= "bo:" + QString("%1").arg(getNum());
 		else	
 			s= ((BranchObj*)(parObj))->getSelectString() + ",bo:" + QString("%1").arg(getNum());
 	} else
-	{
 		s="mc:";
-	}
-	
 	return s;
 }
 
diff -r 9eb7767c2dfa -r 608f976aa7bb branchobj.h
--- a/branchobj.h	Sun Jan 30 12:58:47 2005 +0000
+++ b/branchobj.h	Tue Jun 06 14:58:11 2006 +0000
@@ -4,18 +4,24 @@
 #include "floatimageobj.h"
 #include "linkablemapobj.h"
 #include "ornamentedobj.h"
+#include "xlinkobj.h"
+//Added by qt3to4:
+#include <Q3PtrList>
 
-class BranchObjPtrList : public QPtrList<BranchObj>
+class BranchObjPtrList : public Q3PtrList<BranchObj>
 {
-	virtual int compareItems (QPtrCollection::Item i, QPtrCollection::Item j);
+	virtual int compareItems (Q3PtrCollection::Item i, Q3PtrCollection::Item j);
 };
 
+enum BranchModification {NewBranch, MovedBranch};
+enum HideTmpMode {HideNone, HideExport};
+
 /////////////////////////////////////////////////////////////////////////////
 class BranchObj:public OrnamentedObj {
 public:
     BranchObj ();
-    BranchObj (QCanvas*);
-    BranchObj (QCanvas*, LinkableMapObj* parent);
+    BranchObj (Q3Canvas*);
+    BranchObj (Q3Canvas*, LinkableMapObj* parent);
     ~BranchObj ();
 	bool operator< ( const BranchObj & );
 	bool operator== ( const BranchObj & );
@@ -27,6 +33,7 @@
 	virtual int getFloatImageNum(FloatImageObj*);		
 	virtual int countBranches();		
 	virtual int countFloatImages();		
+	virtual int countXLinks();		
     virtual void setParObjTmp (LinkableMapObj*,QPoint,int);// Only for moving Obj around
 	virtual void unsetParObjTmp();			// reuse original ParObj
 
@@ -40,27 +47,40 @@
 	virtual void setVisibility(bool,int);	// set visibility
     virtual void setVisibility(bool);	    // set vis. for w
 	virtual void setLinkColor();			// set the color of link
-	virtual void setColor(QColor,bool);		// set the color of heading
-
+	virtual void setColorChilds(QColor);			// set the color of heading
 
 	BranchObj* first ();				// set Iterator to first LMO
 	BranchObj* next ();					// find next LMO after given one
 	BranchObj* getLastIterator();		// to interrupt and resume next iteration
 	void setLastIterator (BranchObj*);	// needed by next() 
 
+	virtual void positionContents();
     virtual void move (double x,double y);
     virtual void move (QPoint);
     virtual void moveBy (double x,double y);
     virtual void moveBy (QPoint);
     virtual void positionBBox();
     virtual void calcBBoxSize();
+	virtual void setDockPos();
     virtual LinkableMapObj* findMapObj(QPoint,LinkableMapObj*);	// find MapObj 
     virtual void setHeading (QString);
-    virtual void setURL (QString);
-    virtual QString getURL ();
-    virtual void setVymLink (QString);
-    virtual QString getVymLink ();
+
+	virtual void setHideTmp (HideTmpMode);
+	virtual bool hasHiddenExportParent (BranchObj*);
+
 	virtual QString saveToDir (const QString&,const QString&, const QPoint&);// Save data recursivly to tempdir
+	virtual void addXLink (XLinkObj*);
+	virtual void removeXLinkRef (XLinkObj*);// Remove ref in list
+	virtual void deleteXLink (XLinkObj*);	// remove references and delete XLinkObj 
+	virtual void deleteXLinkAt (int);		// remove references and delete XLinkObj 
+	virtual XLinkObj* XLinkAt (int);		// return reference of XLinkObj 
+	virtual int countXLink ();
+	virtual BranchObj* XLinkTargetAt (int);
+	void setIncludeImagesVer(bool);
+	bool getIncludeImagesVer();
+	void setIncludeImagesHor(bool);
+	bool getIncludeImagesHor();
+	QString getIncludeImageAttr();
 	virtual LinkableMapObj* addFloatImage();
 	virtual LinkableMapObj* addFloatImage(FloatImageObj*);
 	virtual void removeFloatImage(FloatImageObj*);
@@ -68,21 +88,29 @@
     virtual FloatImageObj* getLastFloatImage();
 	virtual FloatImageObj* getFloatImageNum(const uint &);
 protected:	
-	virtual void savePosInAngle();			// write pos in angle for resorting			
+	virtual void savePosInAngle();					// write pos in angle for resorting			
+	virtual void setDefAttr (BranchModification);	// set default attributes (font, size, ...)
 public:	
     virtual BranchObj* addBranch();
     virtual BranchObj* addBranch(BranchObj*);		// makes deep copy of BranchObj
+    virtual BranchObj* addBranchPtr(BranchObj*);	// just adds pointer
     virtual BranchObj* insertBranch(int);
     virtual BranchObj* insertBranch(BranchObj*,int);
+    virtual BranchObj* insertBranchPtr (BranchObj*,int);
+    virtual void removeBranchHere(BranchObj*);  
+    virtual void removeChilds();  
     virtual void removeBranch(BranchObj*);  
+    virtual void removeBranchPtr (BranchObj*);  
     virtual void setLastSelectedBranch(BranchObj*);
     virtual BranchObj* getLastSelectedBranch();
     virtual BranchObj* getFirstBranch();
     virtual BranchObj* getLastBranch();
 	virtual BranchObj* getBranchNum(const uint &);
+    virtual bool canMoveBranchUp();
     virtual BranchObj* moveBranchUp(BranchObj*);
+    virtual bool canMoveBranchDown();
     virtual BranchObj* moveBranchDown(BranchObj*);
-
+    virtual BranchObj* moveBranchTo (BranchObj*, int);
     virtual void alignRelativeTo(const QPoint );
 	virtual void reposition();
 
@@ -97,15 +125,17 @@
 protected:
 	static BranchObj* itLast;		// iterator for first(), next()
     BranchObjPtrList branch;		// all child branches
-	QPtrList<FloatImageObj> floatimage;	// child images
+	Q3PtrList<FloatImageObj> floatimage;	// child images
+	Q3PtrList<XLinkObj> xlink;		// xlinks to other branches
 public:	
 	float angle;					// used in mainbranch to reorder mainbranches
 protected:	
     int lastSelectedBranch;			// for going deeper into tree
 	bool scrolled;					// true if all childs are scrolled and thus invisible
 	bool tmpUnscrolled;				// can only be true (temporary) for a scrolled subtree
-	QString url;					// url to external doc
-	QString vymLink;				// path to another map
+	bool includeImagesVer;			// include floatimages in bbox vertically
+	bool includeImagesHor;			// include floatimages in bbox horizontally
+
 };
 
 
diff -r 9eb7767c2dfa -r 608f976aa7bb demos/todo.vym
Binary file demos/todo.vym has changed
diff -r 9eb7767c2dfa -r 608f976aa7bb exportoofiledialog.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/exportoofiledialog.cpp	Tue Jun 06 14:58:11 2006 +0000
@@ -0,0 +1,87 @@
+#include <iostream>
+
+#include "exportoofiledialog.h"
+
+ExportOOFileDialog::ExportOOFileDialog():Q3FileDialog()
+{
+	init();
+}
+
+ExportOOFileDialog::ExportOOFileDialog (QWidget * parent, const char* name, bool modal):Q3FileDialog(parent, name,modal)
+{
+	init();
+}
+
+QString ExportOOFileDialog::selectedConfig()
+{
+	QStringList::Iterator itpath=configPaths.begin();
+	QStringList::Iterator itf=filters.begin();
+	while (itf != filters.end()) 
+	{
+		if (*itf==lastFilter) return *itpath;
+		itpath++;	
+		itf++;
+    }
+	qWarning ("ExportOOFileDialog::selectedConfig  No filter found!");
+	return "";
+}
+
+void ExportOOFileDialog::newConfigPath(const QString &s)
+{
+	lastFilter=s;
+}
+
+QString ExportOOFileDialog::selectedFile()
+{
+	return Q3FileDialog::selectedFile();
+}
+
+
+void ExportOOFileDialog::addFilter(const QString &f)
+{
+	lastFilter=f;
+	filters.append (f);
+	Q3FileDialog::addFilter (f);
+}
+
+void ExportOOFileDialog::init()
+{
+	setMode( Q3FileDialog::AnyFile );
+	QDir d;
+	d.setPath ("/usr/share/vym/exports");
+	scanExportConfigs(d);
+	d.setPath (d.homeDirPath()+"/.vym/exports");
+	scanExportConfigs(d);
+	d.setPath ("exports");
+	scanExportConfigs(d);
+
+	connect (
+		this,SIGNAL (filterSelected(const QString&)),
+		this, SLOT( newConfigPath(const QString &)));
+}
+
+void ExportOOFileDialog::scanExportConfigs(QDir dir)
+{
+	// Scan existing export configurations
+	SimpleSettings set;
+	QFile f;
+	if (dir.exists())
+	{
+		// Traverse files
+        QDir dir;
+        dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
+
+        QFileInfoList list = dir.entryInfoList();
+        for (int i = 0; i < list.size(); ++i) {
+            QFileInfo fi = list.at(i);
+
+			if (fi.fileName().endsWith(".conf") )
+			{
+				configPaths.append (fi.absFilePath());
+				set.clear();
+				set.readSettings (fi.absFilePath());
+				addFilter (set.readEntry("Name") + " (*.odp)");
+			}		
+        }
+	}		
+}
diff -r 9eb7767c2dfa -r 608f976aa7bb exportoofiledialog.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/exportoofiledialog.h	Tue Jun 06 14:58:11 2006 +0000
@@ -0,0 +1,32 @@
+#ifndef EXPORTOOFILEDIALOG
+#define EXPORTOOFILEDIALOG
+
+#include <q3filedialog.h>
+#include <qstringlist.h>
+
+#include "settings.h"
+
+class ExportOOFileDialog:public Q3FileDialog
+{
+	Q_OBJECT
+public:
+	ExportOOFileDialog();
+
+	ExportOOFileDialog (QWidget * parent = 0, const char * name = 0, bool
+	modal = false);
+	QString selectedConfig();
+	QString selectedFile();
+	void addFilter(const QString &);
+	 
+private slots:
+	void  newConfigPath (const QString&f);
+
+private:
+	void init();
+	void scanExportConfigs(QDir );
+	QStringList configPaths;
+	QStringList filters;
+	QString lastFilter;
+	
+};
+#endif
diff -r 9eb7767c2dfa -r 608f976aa7bb exports.cpp
--- a/exports.cpp	Sun Jan 30 12:58:47 2005 +0000
+++ b/exports.cpp	Tue Jun 06 14:58:11 2006 +0000
@@ -1,87 +1,103 @@
+#include <q3filedialog.h>
+#include <qmessagebox.h>
+#include <q3process.h>
+//Added by qt3to4:
+#include <QTextStream>
+
 #include "exports.h"
+#include "file.h"
+#include "linkablemapobj.h"
+#include "misc.h"
+#include "mainwindow.h"
+#include "warningdialog.h"
+#include "xsltproc.h"
 
-#include "linkablemapobj.h"
+extern Main *mainWindow;
+extern QDir vymBaseDir;
 
 
-Export::Export()
+ExportBase::ExportBase()
 {
 	indentPerDepth="  ";
+	// Create tmpdir
+	tmpDir.setPath (makeUniqueDir("/tmp/vym-XXXXXX"));
 }
 
-bool Export::setOutputDir(QString dirname)
+ExportBase::~ExportBase()
 {
-	outdir.setPath (dirname);
-	if ( outdir.exists() )
-	{
-		// FIXME
-		// ask for confirmation
-		// then delete outdir
-		return true;
-	} else
-	{
-		// try to create directory
-		//return outdir.mkdir (outdir.absPath());
-		// FIXME
-		return true;
-	}
+	// Remove tmpdir
+	removeDir (tmpDir);
 }
 
-void Export::setPath (const QString &p)
+void ExportBase::setDir(const QString &p)
 {
-	filepath=p;
+	outputDir=p;
 }
 
-void Export::setMapCenter(MapCenterObj *mc)
+void ExportBase::setFile (const QString &p)
+{
+	outputFile=p;
+}
+
+void ExportBase::setMapCenter(MapCenterObj *mc)
 {
 	mapCenter=mc;
 }
 
-void Export::exportMap()
+void ExportBase::setCaption (const QString &s)
 {
-	QFile file (filepath);
-	if ( !file.open( IO_WriteOnly ) )
-	{
-		// FIXME
-		cout << "Export::exportMap  couldn't open "<<filepath<<endl;
-		return;
-	}
-	QTextStream ts( &file );	// use LANG decoding here...
-
-	// Main loop over all branches
-	QString s;
-	QString actIndent("");
-	int i;
-	BranchObj *bo;
-	bo=mapCenter->first();
-	while (bo) 
-	{
-		// Make indentstring
-		for (i=0;i<bo->getDepth();i++) actIndent+= indentPerDepth;
-
-		// Write heading
-		//	write (actIndent + getSectionString(bo) + bo->getHeading()+ "\n");
-		if (bo->getDepth()==1)
-			ts << (getSectionString(bo) + bo->getHeading()+ "\n");
-		else	
-			ts << (actIndent + " - " + bo->getHeading()+ "\n");
-		
-		// If necessary, write note
-		if (!bo->getNote().isEmpty())
-		{
-			ts << ("-------------------Begin of Note-----------------\n");
-			ts << (bo->getNote());
-			ts << ("\n");
-			ts << ("-------------------End of Note-------------------\n");
-		}
-		
-		bo=bo->next();
-		actIndent="";
-	}
-	file.close();
+	caption=s;
 }
 
-QString Export::getSectionString(BranchObj *bostart)
+void ExportBase::addFilter(const QString &s)
 {
+	filter=s;
+}
+
+bool ExportBase::execDialog()
+{
+	if (mapCenter && mapCenter->getMapEditor())
+	{
+		Q3FileDialog *fd=new Q3FileDialog( mapCenter->getMapEditor(), caption);
+		fd->addFilter (filter);
+		fd->setCaption(caption);
+		fd->setMode( Q3FileDialog::AnyFile );
+		fd->show();
+
+		if ( fd->exec() == QDialog::Accepted )
+		{
+			if (QFile (fd->selectedFile()).exists() )
+			{
+				QMessageBox mb( __VYM,
+					QObject::tr("The file %1 exists already.\nDo you want to overwrite it?").arg(fd->selectedFile()), 
+				QMessageBox::Warning,
+				QMessageBox::Yes | QMessageBox::Default,
+				QMessageBox::Cancel | QMessageBox::Escape,
+				Qt::NoButton );
+				mb.setButtonText( QMessageBox::Yes, QObject::tr("Overwrite") );
+				mb.setButtonText( QMessageBox::No, QObject::tr("Cancel"));
+				ExportBase ex;
+				switch( mb.exec() ) 
+				{
+					case QMessageBox::Yes:
+						// save 
+						break;;
+					case QMessageBox::Cancel:
+						// return, do nothing
+						return false;
+						break;
+				}
+			}
+			outputFile=fd->selectedFile();
+			return true;
+		}
+	}
+	return false;
+}
+
+QString ExportBase::getSectionString(BranchObj *bostart)
+{
+	// Make prefix like "2.5.3" for "bo:2,bo:5,bo:3"
 	QString r;
 	BranchObj *bo=bostart;
 	int depth=bo->getDepth();
@@ -97,13 +113,24 @@
 		return r + " ";
 }
 
-void Export::exportAsHTML()
+
+////////////////////////////////////////////////////////////////////////
+void ExportASCII::doExport()
 {
-	// FIXME  just testing...
+	QFile file (outputFile);
+	if ( !file.open( QIODevice::WriteOnly ) )
+	{
+		// FIXME experimental, testing
+		qWarning ("ExportBase::exportXML  couldn't open "+outputFile);
+		return;
+	}
+	QTextStream ts( &file );	// use LANG decoding here...
+
 	// Main loop over all branches
 	QString s;
 	QString actIndent("");
 	int i;
+	uint j;
 	BranchObj *bo;
 	bo=mapCenter->first();
 	while (bo) 
@@ -111,22 +138,338 @@
 		// Make indentstring
 		for (i=0;i<bo->getDepth();i++) actIndent+= indentPerDepth;
 
-		// Write heading
-		write (actIndent + getSectionString(bo) + bo->getHeading()+ "\n");
+		if (bo->getDepth()==0)
+		{
+			ts << (bo->getHeading()+ "\n");
+			for (j=0;j<bo->getHeading().length();j++) ts<<"=";
+			ts << "\n";
+		} else 	if (bo->getDepth()==1)
+			ts << ("\n"+getSectionString(bo) + bo->getHeading()+ "\n");
+		else	if (bo->getDepth()==2)
+			ts << (actIndent + " o " + bo->getHeading()+ "\n");
+		else	
+			ts << (actIndent + " - " + bo->getHeading()+ "\n");
 		
 		// If necessary, write note
 		if (!bo->getNote().isEmpty())
 		{
-			write (bo->getNote());
+			s =bo->getNoteASCII();
+			s=s.replace ("\n","\n"+actIndent);
+			ts << (s+"\n\n");
 		}
-		
 		bo=bo->next();
 		actIndent="";
 	}
+	file.close();
 }
 
-void Export::write(QString s)
+////////////////////////////////////////////////////////////////////////
+void ExportKDEBookmarks::doExport() 
 {
-	cout << s;
+	MapEditor *me=NULL;
+	if (mapCenter) me=mapCenter->getMapEditor();
+	if (me)
+	{
+		WarningDialog dia;
+		dia.setCancelButton (true);
+		dia.setText(QObject::tr("Exporting the %1 bookmarks will overwrite\nyour existing bookmarks file.").arg("KDE"));
+		dia.setCaption(QObject::tr("Warning: Overwriting %1 bookmarks").arg("KDE"));
+		dia.setShowAgainName("/vym/warnings/overwriteKDEBookmarks");
+		if (dia.exec()==QDialog::Accepted)
+		{
+			me->exportXML(tmpDir.path());
+
+			XSLTProc p;
+			p.setInputFile (tmpDir.path()+"/"+me->getMapName()+".xml");
+			p.setOutputFile (tmpDir.home().path()+"/.kde/share/apps/konqueror/bookmarks.xml");
+			p.setXSLFile (vymBaseDir.path()+"/styles/vym2kdebookmarks.xsl");
+			p.process();
+
+			QString ub=vymBaseDir.path()+"/scripts/update-bookmarks";
+			Q3Process *proc = new Q3Process( );
+			proc->addArgument(ub);
+
+			if ( !proc->start() ) 
+			{
+				QMessageBox::warning(0, 
+					QObject::tr("Warning"),
+					QObject::tr("Couldn't find script %1\nto notifiy Browsers of changed bookmarks.").arg(ub));
+			}	
+
+
+		}
+	}
+
 }
 
+////////////////////////////////////////////////////////////////////////
+void ExportFirefoxBookmarks::doExport() 
+{
+	MapEditor *me=NULL;
+	if (mapCenter) me=mapCenter->getMapEditor();
+	if (me)
+	{
+		WarningDialog dia;
+		dia.setCancelButton (true);
+		dia.setText(QObject::tr("Exporting the %1 bookmarks will overwrite\nyour existing bookmarks file.").arg("Firefox"));
+		dia.setCaption(QObject::tr("Warning: Overwriting %1 bookmarks").arg("Firefox"));
+		dia.setShowAgainName("/vym/warnings/overwriteImportBookmarks");
+		if (dia.exec()==QDialog::Accepted)
+		{
+			me->exportXML(tmpDir.path());
+
+/*
+			XSLTProc p;
+			p.setInputFile (tmpDir.path()+"/"+me->getMapName()+".xml");
+			p.setOutputFile (tmpDir.home().path()+"/.kde/share/apps/konqueror/bookmarks.xml");
+			p.setXSLFile (vymBaseDir.path()+"/styles/vym2kdebookmarks.xsl");
+			p.process();
+
+			QString ub=vymBaseDir.path()+"/scripts/update-bookmarks";
+			QProcess *proc = new QProcess( );
+			proc->addArgument(ub);
+
+			if ( !proc->start() ) 
+			{
+				QMessageBox::warning(0, 
+					QObject::tr("Warning"),
+					QObject::tr("Couldn't find script %1\nto notifiy Browsers of changed bookmarks.").arg(ub));
+			}	
+
+*/
+
+		}
+	}
+}
+
+////////////////////////////////////////////////////////////////////////
+void ExportTaskjuggler::doExport() 
+{
+	MapEditor *me=NULL;
+	if (mapCenter) me=mapCenter->getMapEditor();
+	if (me)
+	{
+		me->exportXML(tmpDir.path());
+
+		XSLTProc p;
+		p.setInputFile (tmpDir.path()+"/"+me->getMapName()+".xml");
+		p.setOutputFile (outputFile);
+		p.setXSLFile (vymBaseDir.path()+"/styles/vym2taskjuggler.xsl");
+		p.process();
+	}
+
+}
+
+////////////////////////////////////////////////////////////////////////
+void ExportLaTeX::doExport() 
+{
+	// Exports a map to a LaTex file.  
+	// This file needs to be included 
+	// or inported into a LaTex document
+	// it will not add a preamble, or anything 
+	// that makes a full LaTex document.
+  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
+  
+  // Main loop over all branches
+  QString s;
+  // QString actIndent("");
+  // int i;
+  BranchObj *bo;
+  bo=mapCenter->first();
+  while (bo) {
+	if (bo->getDepth()==0);
+	else if (bo->getDepth()==1) {
+	  ts << ("\\chapter{" + bo->getHeading()+ "}\n");
+	}
+	else if (bo->getDepth()==2) {
+	  ts << ("\\section{" + bo->getHeading()+ "}\n");
+	}
+	else if (bo->getDepth()==3) {
+	  ts << ("\\subsection{" + bo->getHeading()+ "}\n");
+	}
+	else if (bo->getDepth()==4) {
+	  ts << ("\\subsubsection{" + bo->getHeading()+ "}\n");
+	}
+	else {
+	  ts << ("\\paragraph*{" + bo->getHeading()+ "}\n");
+	}
+	
+	// If necessary, write note
+	if (!bo->getNote().isEmpty()) {
+	  ts << (bo->getNoteASCII());
+	  ts << ("\n");
+	}
+    bo=bo->next();
+   }
+  file.close();
+}
+
+////////////////////////////////////////////////////////////////////////
+ExportOO::ExportOO()
+{
+	useSections=false;
+}
+
+ExportOO::~ExportOO()
+{
+}	
+
+QString ExportOO::buildList (BranchObj *current)
+{
+    QString r;
+    BranchObj *bo;
+
+    uint i=0;
+    bo=current->getFirstBranch();
+    if (bo)
+    {
+        // Start list
+        r+="<text:list text:style-name=\"vym-list\">\n";
+        while (bo)
+        {
+			r+="<text:list-item><text:p >";
+			r+=quotemeta(bo->getHeading());
+			// If necessary, write note
+			if (!bo->getNote().isEmpty())
+				r+=bo->getNoteOpenDoc();
+			r+="</text:p>";
+			r+=buildList (bo);	// recursivly add deeper branches
+			r+="</text:list-item>\n";
+			i++;
+			bo=current->getBranchNum(i);
+        }
+        r+="</text:list>\n";
+    }
+    return r;
+}
+
+
+void ExportOO::exportPresentation()
+{
+	QString allPages;
+
+	// Insert new content
+	content.replace ("<!-- INSERT TITLE -->",quotemeta(mapCenter->getHeading()));
+	content.replace ("<!-- INSERT AUTHOR -->",quotemeta(mapCenter->getAuthor()));
+
+	QString	onePage;
+	QString list;
+	
+	BranchObj *sectionBO=mapCenter->getFirstBranch();
+    int i=0;
+	BranchObj *pagesBO;
+    int j=0;
+
+	// Walk sections
+	while (sectionBO)
+	{
+		if (useSections)
+		{
+			// Add page with section title
+			onePage=sectionTemplate;
+			onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta(sectionBO->getHeading() ) );
+			allPages+=onePage;
+		} else
+		{
+			i=-2;	// only use inner loop to 
+			        // turn mainbranches into pages
+			sectionBO=mapCenter;
+		}
+
+		// Walk mainpages
+		pagesBO=sectionBO->getFirstBranch();
+		j=0;
+		while (pagesBO)
+		{
+			// Add page with list of items
+			onePage=pageTemplate;
+			onePage.replace ("<!-- INSERT PAGE HEADING -->", quotemeta (pagesBO->getHeading() ) );
+			list=buildList (pagesBO);
+			onePage.replace ("<!-- INSERT LIST -->", list);
+			allPages+=onePage;
+			j++;
+			pagesBO=sectionBO->getBranchNum(j);
+		}
+		i++;
+		sectionBO=mapCenter->getBranchNum(i);
+	}
+	
+	content.replace ("<!-- INSERT PAGES -->",allPages);
+
+	// Write modified content
+	QFile f (contentFile);
+    if ( !f.open( QIODevice::WriteOnly ) ) 
+	{
+		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not write %1").arg(contentFile));
+		mainWindow->statusMessage(QString(QObject::tr("Export failed.")));
+		return;
+    }
+
+    QTextStream t( &f );
+    t << content;
+    f.close();
+
+	// zip tmpdir to destination
+	zipDir (tmpDir,outputFile);	
+}
+
+bool ExportOO::setConfigFile (const QString &cf)
+{
+	configFile=cf;
+	int i=cf.findRev ("/");
+	if (i>=0) configDir=cf.left(i);
+	SimpleSettings set;
+	set.readSettings(configFile);
+
+	// set paths
+	templateDir=configDir+"/"+set.readEntry ("Template");
+
+	QDir d (templateDir);
+	if (!d.exists())
+	{
+		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Check \"%1\" in\n%2").arg("Template="+set.readEntry ("Template")).arg(configFile));
+		return false;
+
+	}
+
+	contentTemplateFile=templateDir+"content-template.xml";
+	contentFile=tmpDir.path()+"/content.xml";
+	pageTemplateFile=templateDir+"page-template.xml";
+	sectionTemplateFile=templateDir+"section-template.xml";
+
+	if (set.readEntry("useSections").contains("yes"))
+		useSections=true;
+
+	// Copy template to tmpdir
+	system ("cp -r "+templateDir+"* "+tmpDir.path());
+
+	// Read content-template
+	if (!loadStringFromDisk (contentTemplateFile,content))
+	{
+		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not read %1").arg(contentTemplateFile));
+		return false;
+	}
+
+	// Read page-template
+	if (!loadStringFromDisk (pageTemplateFile,pageTemplate))
+	{
+		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not read %1").arg(pageTemplateFile));
+		return false;
+	}
+	
+	// Read section-template
+	if (useSections && !loadStringFromDisk (sectionTemplateFile,sectionTemplate))
+	{
+		QMessageBox::critical (0,QObject::tr("Critical Export Error"),QObject::tr("Could not read %1").arg(sectionTemplateFile));
+		return false;
+	}
+	return true;
+}
+
diff -r 9eb7767c2dfa -r 608f976aa7bb exportxhtmldialog.ui.h
--- a/exportxhtmldialog.ui.h	Sun Jan 30 12:58:47 2005 +0000
+++ b/exportxhtmldialog.ui.h	Tue Jun 06 14:58:11 2006 +0000
@@ -1,3 +1,6 @@
+//Added by qt3to4:
+#include <QPixmap>
+#include <QTextStream>
 /****************************************************************************
 ** ui.h extension file, included from the uic-generated form implementation.
 **
@@ -9,22 +12,22 @@
 
 
 extern Settings settings;
+extern QDir vymBaseDir;
+extern Options options;
 
 void ExportXHTMLDialog::init()
 {
-	dia=new ShowTextDialog ();
-	xsltprocessor="xsltproc";
 	filepath="";
 	settingsChanged=false;
+	scriptProc=new Process;
 }
 
 void ExportXHTMLDialog::readSettings()
 {
 
-	dir=settings.readLocalEntry (filepath,"/vym/export/xhtml/exportDir","./" );
+	dir=settings.readLocalEntry (filepath,"/vym/export/xhtml/exportDir",vymBaseDir.currentDirPath() );
 	lineEditDir->setText(dir);
 	
-	
     if ( settings.readLocalEntry (filepath,"/vym/export/xhtml/useImage","yes")=="yes")
 		useImage=true;
 	else	
@@ -63,12 +66,19 @@
 		showOutput=false;
 	outputButton->setChecked(showOutput);
 
-	xsl=settings.readLocalEntry 
-		(filepath,"/vym/export/xhtml/xsl","/usr/share/vym/styles/vym2xhtml.xsl");
+	// For testing better use local styles
+	if (options.isOn ("local"))
+	{
+		xsl=vymBaseDir.path()+"/styles/vym2xhtml.xsl";
+		css=vymBaseDir.path()+"/styles/vym.css";
+	} else
+	{
+		xsl=settings.readLocalEntry 
+			(filepath,"/vym/export/xhtml/xsl","/usr/share/vym/styles/vym2xhtml.xsl");
+		css=settings.readLocalEntry 
+			(filepath,"/vym/export/xhtml/css","/usr/share/vym/styles/vym.css");	
+	}
 	lineEditXSL->setText(xsl);
-	
-	css=settings.readLocalEntry 
-		(filepath,"/vym/export/xhtml/css","/usr/share/vym/styles/vym.css");	
 	lineEditCSS->setText(css);
 	
 	prescript=settings.readLocalEntry
@@ -83,17 +93,16 @@
 	{
 		QMessageBox::warning( 0, tr( "Warning" ),tr(
 		"The settings saved in the map "
-		"would like to run scripts:\n\n") +
-		prescript +"  "+postscript +"\n\n"+
-		tr("Please check, if you really\n"
-		"want to allow this in your system!"));
+		"would like to run scripts:\n\n"
+		"%1\n\n"
+		"Please check, if you really\n"
+		"want to allow this in your system!").arg(prescript+"  "+postscript));
 		
 	}
 }
 
 void ExportXHTMLDialog::destroy()
 {
-	delete (dia);
 }
 
 void ExportXHTMLDialog::dirChanged()
@@ -106,8 +115,8 @@
 
 void ExportXHTMLDialog::browseDirectoryPressed()
 {
-   	QFileDialog fd( this, tr("VYM - Export HTML to directory"));
-	fd.setMode (QFileDialog::DirectoryOnly);
+   	Q3FileDialog fd( this, tr("VYM - Export HTML to directory"));
+	fd.setMode (Q3FileDialog::DirectoryOnly);
 	fd.setCaption(tr("VYM - Export HTML to directory"));
 	fd.setModal (true);
 	fd.show();
@@ -159,7 +168,7 @@
 
 void ExportXHTMLDialog::browseCSSPressed()
 {
-   	QFileDialog fd( this, tr("VYM - Path to CSS file"));
+   	Q3FileDialog fd( this, tr("VYM - Path to CSS file"));
 	fd.setModal (true);
 	fd.addFilter ("Cascading Stylesheet (*.css)");
 	fd.show();
@@ -186,9 +195,9 @@
 
 void ExportXHTMLDialog::browseXSLPressed()
 {
-   	QFileDialog fd( this, tr("VYM - Path to XSL file"));
+   	Q3FileDialog fd( this, tr("VYM - Path to XSL file"));
 	fd.setModal (true);
-	fd.addFilter ("Extensible Styleshee Language (*.xsl)");
+	fd.addFilter ("Extensible Stylesheet Language (*.xsl)");
 	fd.show();
 
 	if ( fd.exec() == QDialog::Accepted )
@@ -207,7 +216,7 @@
 
 void ExportXHTMLDialog::browsePreExportButtonPressed()
 {
-	QFileDialog fd( this, tr("VYM - Path to pre export script"));
+	Q3FileDialog fd( this, tr("VYM - Path to pre export script"));
 	fd.setModal (true);
 	fd.addFilter ("Scripts (*.sh *.pl *.py *.php)");
 	fd.show();
@@ -223,7 +232,7 @@
 
 void ExportXHTMLDialog::browsePostExportButtonPressed()
 {
-	QFileDialog fd( this, tr("VYM - Path to post export script"));
+	Q3FileDialog fd( this, tr("VYM - Path to post export script"));
 	fd.setModal (true);
 	fd.addFilter ("Scripts (*.sh *.pl *.py *.php)");
 	fd.show();
@@ -243,7 +252,6 @@
 	// (but don't save at destructor, which
 	// is called for "cancel", too)
 	settings.setLocalEntry (filepath,"/vym/export/xhtml/exportDir",dir);
-
 	settings.setLocalEntry (filepath,"/vym/export/xhtml/prescript",prescript);
 	settings.setLocalEntry (filepath,"/vym/export/xhtml/postscript",postscript);
 
@@ -266,19 +274,25 @@
 		settings.writeEntry ("/vym/export/xhtml/showOutput","yes");
 	else
 		settings.writeEntry ("/vym/export/xhtml/showOutput","no");	
-		
-	settings.setLocalEntry 
-		(filepath,"/vym/export/xhtml/xsl",xsl);
-	settings.setLocalEntry 
-		(filepath,"/vym/export/xhtml/css",css);	
 
-	//FIXME add option for url image (globe flag) here	
-	if (true) 
-	{	
-		QPixmap pm (flag_url_xpm);
-		pm.save (dir + "/flags/url.png","PNG");
+	QString ipath;	
+	ipath=vymBaseDir.path()+"/flags/flag-url-16x16.png";
+	if (!options.isOn ("local"))
+	{
+		settings.setLocalEntry 
+			(filepath,"/vym/export/xhtml/xsl",xsl);
+		settings.setLocalEntry 
+			(filepath,"/vym/export/xhtml/css",css);	
 	}
 
+	// Provide a smaller URL-icon to improve Layout
+	QPixmap pm;
+	if (!pm.load(ipath,"PNG") )
+		QMessageBox::warning( 0, tr( "Warning" ),tr("Could not open %1").arg(ipath));
+		
+		
+	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("/vym/export/xhtml");
 	else	
@@ -288,12 +302,12 @@
 	// Copy CSS file
 	QFile css_src (css);
 	QFile css_dst (dir+"vym.css");
-	if (!css_src.open ( IO_ReadOnly))
-		QMessageBox::warning( 0, tr( "Warning" ),css +tr(" could not be opened!"));
+	if (!css_src.open ( QIODevice::ReadOnly))
+		QMessageBox::warning( 0, tr( "Warning" ),tr("Could not open %1").arg(css));
 	else
 	{
-		if (!css_dst.open( IO_WriteOnly))
-			QMessageBox::warning( 0, tr( "Warning" ), dir+"vym.css" +tr(" could not be opened!"));
+		if (!css_dst.open( QIODevice::WriteOnly))
+			QMessageBox::warning( 0, tr( "Warning" ), tr("Could not open %1").arg(dir+"vym.css"));
 		else
 		{	
 		
@@ -308,52 +322,19 @@
 
 	if (!prescript.isEmpty()) runScript (prescript,dir+mapname+".xml");
 	
-	Process *xsltProc=new Process ();
-	xsltProc->clearArguments();
-	xsltProc->addArgument (xsltprocessor);	
 	if (useImage)
-	{
-		xsltProc->addArgument ("--stringparam");
-		xsltProc->addArgument ("imagemap");
-		xsltProc->addArgument ("images/"+mapname+".png");
-	}	
+		p.addStringParam ("imagemap","images/"+mapname+".png");
 	if (useTextColor)
-	{
-		xsltProc->addArgument ("--stringparam");
-		xsltProc->addArgument ("use.textcolor");
-		xsltProc->addArgument ("1");
-	}	
-	xsltProc->addArgument ("--stringparam");
-	xsltProc->addArgument ("mapname");
-	xsltProc->addArgument (mapname+".vym");
+		p.addStringParam ("use.textcolor","1");
+	p.addStringParam ("mapname",mapname+".vym");
 	
-	xsltProc->addArgument ("--output");
-	xsltProc->addArgument (dir+mapname+".html");
-	xsltProc->addArgument (xsl);
-	xsltProc->addArgument (dir+mapname+".xml");
-	dia->append ("vym is executing: \n" + xsltProc->arguments().join(" ") );	
-	if (!xsltProc->start() )
-	{
-		QMessageBox::critical( 0, tr( "Critical Error" ),
-					   tr("Couldn't start ") + xsltprocessor );
-	} else
-	{
-		xsltProc->waitFinished();
-		if (!xsltProc->normalExit() )
-			QMessageBox::critical( 0, tr( "Critical Error" ),
-			   xsltprocessor +" " +tr("didn't exit normally") +
-			   xsltProc->getErrout() );
-		else
-			if (xsltProc->exitStatus()>0) showOutput=true;
-			
-	}	
-	dia->append ("\n");
-	dia->append (xsltProc->getErrout());
-	dia->append (xsltProc->getStdout());
-	
+	p.setOutputFile (dir+mapname+".html");
+	p.setInputFile (dir+mapname+".xml");
+	p.setXSLFile (xsl);
+	p.process();
+
 	if (!postscript.isEmpty()) runScript (postscript,dir+mapname+".html");
 
-	if (showOutput) dia->exec();
 }
 
 void ExportXHTMLDialog::setFilePath(const QString &s)
@@ -387,26 +368,25 @@
 	spath.replace ("%f",fpath);
 	QStringList args=QStringList::split (' ',spath,false);
 		
-	Process *scriptProc=new Process ();
 	scriptProc->clearArguments();
 	scriptProc->setArguments (args);	
-	dia->append ("vym is executing: \n" + scriptProc->arguments().join(" ") );	
+	p.addOutput ("vym is executing: \n" + scriptProc->arguments().join(" ") );	
 	if (!scriptProc->start() )
 	{
 		QMessageBox::critical( 0, tr( "Critical Error" ),
-					   tr("Couldn't start ") + spath );
+					   tr("Could not start %1").arg(spath) );
 	} else
 	{
 		scriptProc->waitFinished();
 		if (!scriptProc->normalExit() )
 			QMessageBox::critical( 0, tr( "Critical Error" ),
-			   spath +" " +tr("didn't exit normally") +
+			   tr("%1 didn't exit normally").arg(spath) +
 			   scriptProc->getErrout() );
 		else
 			if (scriptProc->exitStatus()>0) showOutput=true;
 			
 	}	
-	dia->append ("\n");
-	dia->append (scriptProc->getErrout());
-	dia->append (scriptProc->getStdout());
+	p.addOutput ("\n");
+	p.addOutput (scriptProc->getErrout());
+	p.addOutput (scriptProc->getStdout());
 }
diff -r 9eb7767c2dfa -r 608f976aa7bb file.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/file.cpp	Tue Jun 06 14:58:11 2006 +0000
@@ -0,0 +1,305 @@
+#include <qobject.h>
+#include <qmessagebox.h>
+//Added by qt3to4:
+#include <QPixmap>
+#include <QLabel>
+#include <QTextStream>
+#include <iostream>
+
+#include "file.h"
+#include "process.h"
+
+
+QString maskPath(QString p)
+{
+	// Change " " to "\ " to enable blanks in filenames
+	p=p.replace(QChar('&'),"\\&");
+	return p.replace(QChar(' '),"\\ ");
+}
+
+QString convertToRel (const QString &src, const QString &dst)
+{
+	QString s=src;
+	QString d=dst;
+	int i;
+
+	if (s==d) 
+	{
+		// Special case, we just need the name of the file,
+		// not the complete path
+		i=d.findRev ("/");
+		d=d.right (d.length()-i-1);
+	} else
+	{
+		// Find relative path from src to dst
+
+		// Remove the first "/"
+		if (s.section ("/",0,0).isEmpty()) 
+		{
+			s=s.right (s.length()-1);
+			d=d.right (d.length()-1);
+		}
+		
+		// remove identical left parts
+		while (s.section("/",0,0) == d.section("/",0,0) ) 
+		{
+			i=s.find ("/");
+			s=s.right (s.length()-i-1);
+			d=d.right (d.length()-i-1);
+		}
+
+		// Now take care of paths where we have to go back first
+		int srcsep=s.count("/");
+		int dstsep=d.count("/");
+		if (srcsep <=  dstsep )
+		{
+			// find path to go up first and then back to dst
+			i=1;
+			while (i<=srcsep) 
+			{
+				d="../"+d;
+				i++;
+			}	
+		}
+	}	
+	return d;
+}
+
+QString makeUniqueDir (QString s)
+{
+	// Create unique directory e.g. s="/tmp/vym-XXXXXX"
+
+	// Convert QString to string first
+	char *p;
+	int bytes=s.length();
+	p=(char*) malloc (bytes+1);
+	int i;
+	for (i=0;i<bytes;i++)
+		p[i]=s.at(i).latin1();
+	p[bytes]=0;	
+	QString r=mkdtemp (p);
+	free (p);
+	return r;
+}
+
+void removeDir(QDir d)
+{
+	if (d.path().left(4)!="/tmp")
+	{
+		// This _should_ not be necessary, but proved to be useful ;-)
+		qWarning ("file.cpp::removeDir should remove "+d.path()+" - aborted.");
+		return;
+	}
+
+	// Traverse directories
+	d.setFilter( QDir::Dirs| QDir::Hidden | QDir::NoSymLinks );
+	QFileInfoList list = d.entryInfoList();
+	QFileInfo fi;
+
+	for (int i = 0; i < list.size(); ++i) 
+	{
+		fi=list.at(i);
+		if (fi.fileName() != "." && fi.fileName() != ".." )
+		{
+			if ( !d.cd(fi.fileName()) ) 
+				qWarning ("removeDir() cannot find the directory "+fi.fileName());
+			else 
+			{
+				// Recursively remove subdirs
+				removeDir (d);
+				d.cdUp();
+			}
+		}	
+	}
+
+	// Traverse files
+	d.setFilter( QDir::Files| QDir::Hidden | QDir::NoSymLinks );
+	list = d.entryInfoList();
+
+	for (int i = 0; i < list.size(); ++i) 
+	{
+		fi=list.at(i);
+		QFile (fi.filePath()).remove(); 
+	}	
+
+	if (!d.rmdir(d.path()))
+		qWarning ("removeDir("+d.path()+") failed!");
+}		
+
+void makeSubDirs (const QString &s)
+{
+	QDir d(s);
+	d.mkdir(s);
+	d.mkdir ("images");	
+	d.mkdir ("flags");	
+}
+
+ErrorCode zipDir (const QDir &zipDir, const QString &zipName)
+{
+	ErrorCode err=success;
+	
+	// zip the temporary directory
+	Process *zipProc=new Process ();
+	zipProc->clearArguments();
+	zipProc->setWorkingDirectory (QDir(zipDir));
+	zipProc->addArgument ("zip");
+	zipProc->addArgument ("-r");
+	zipProc->addArgument (zipName);
+	zipProc->addArgument (".");
+
+	if (!zipProc->start() )
+	{	
+		// zip could not be started
+		QMessageBox::critical( 0, QObject::tr( "Critical Error" ),
+					   QObject::tr("Couldn't start zip to compress data."));
+		err=aborted;
+	} else
+	{
+		// zip could be started
+		zipProc->waitFinished();
+		if (!zipProc->normalExit() )
+		{
+			QMessageBox::critical( 0, QObject::tr( "Critical Error" ),
+						   QObject::tr("zip didn't exit normally")+
+						   "\n" + zipProc->getErrout());
+			err=aborted;
+		} else
+		{
+			if (zipProc->exitStatus()>0)
+			{
+				QMessageBox::critical( 0, QObject::tr( "Critical Error" ),
+						   QString("zip exit code:  %1").arg(zipProc->exitStatus() )+
+						   "\n" + zipProc->getErrout() );
+				err=aborted;
+			}
+		}
+	}	// zip could be started
+	return err;	
+}
+
+ErrorCode unzipDir (const QDir &zipDir, const QString &zipName)
+{
+	ErrorCode err=success;
+
+	// Try to unzip file
+	Process *zipProc=new Process ();
+	zipProc->clearArguments();
+	zipProc->setWorkingDirectory (zipDir);
+	zipProc->addArgument ("unzip");
+	zipProc->addArgument ("-o");	// overwrite existing files!
+	zipProc->addArgument (zipName );
+	zipProc->addArgument ("-d");
+	zipProc->addArgument (zipDir.path());
+
+	if (!zipProc->start() )
+	{
+		QMessageBox::critical( 0, QObject::tr( "Critical Error" ),
+					   QObject::tr("Couldn't start unzip to decompress data."));
+		err=aborted;
+		
+	} else
+	{
+		zipProc->waitFinished();
+		if (!zipProc->normalExit() )
+		{
+			QMessageBox::critical( 0,QObject::tr( "Critical Error" ),
+						   QObject::tr("unzip didn't exit normally") +
+						   zipProc->getErrout() );
+			err=aborted;
+		} else
+		{
+			if (zipProc->exitStatus()>0)
+			{
+				if (zipProc->exitStatus()==9)
+					// no zipped file, but maybe .xml or old version? Try again.
+					err=nozip;
+				else	
+				{
+					QMessageBox::critical( 0, QObject::tr( "Critical Error" ),
+								   QString("unzip exit code:  %1").arg(zipProc->exitStatus() ) +
+								   zipProc->getErrout() );
+					err=aborted;
+				}
+			} 
+		}
+	}
+	return err;	
+}
+
+bool loadStringFromDisk (const QString &fname, QString &s)
+{
+	s="";
+	QFile file ( fname);
+	if ( !file.open( QIODevice::ReadOnly ) ) return false;
+
+	QTextStream ts( &file );
+	ts.setEncoding (QTextStream::UnicodeUTF8);
+	while ( !ts.atEnd() ) 
+		s+=ts.readLine()+"\n"; 
+	file.close();
+	return true;
+}
+
+bool saveStringToDisk (const QString &fname, const QString &s)
+{
+	QFile file( fname);
+
+	file.setName ( fname);
+	if ( !file.open( QIODevice::WriteOnly ) ) 
+	{
+		file.close();
+		return false;
+	}	
+
+	// Write it finally, and write in UTF8, no matter what 
+	QTextStream ts( &file );
+	ts.setEncoding (QTextStream::UnicodeUTF8);
+	ts << s;
+	file.close();
+	return true;
+}
+
+
+ImagePreview::ImagePreview (QWidget *par=0): QLabel (par)
+{
+	fdia=(Q3FileDialog*)par;
+}
+
+void ImagePreview::previewUrl( const Q3Url &u )
+{
+    QString path = u.path();
+    QPixmap pix( path );
+    if ( pix.isNull() )
+	{
+		// Strange: If we have fd->setMode (QFileDialog::ExistingFiles)
+		// in the filedialog, then there are 3 calls to previewURL 
+		// for each selection. And only the first is the actual selected file
+		// while the following 2 point to the directory above the current one.
+		// So here's my workaround:
+		
+		if (fdia && fdia->selectedFiles().count()==0)
+			setText( QObject::tr("This is not an image.") );
+		if (fdia &&fdia->selectedFiles().count()>1)
+			setText( QObject::tr("Sorry, no preview for\nmultiple selected files.") );
+	}	
+    else
+	{
+		float max_w=300;
+		float max_h=300;
+		float r;
+		if (pix.width()>max_w)
+		{
+			r=max_w / pix.width();
+			pix.resize(qRound(pix.width()*r), qRound(pix.height()*r));
+			// FIXME not a resize, but a shrink/enlarge is needed here...
+		}
+		if (pix.height()>max_h)
+		{
+			r=max_h / pix.height();
+			pix.resize(qRound(pix.width()*r), qRound(pix.height()*r));
+			// FIXME not a resize, but a shrink/enlarge is needed here...
+		}
+        setPixmap( pix );
+	}	
+}
+
diff -r 9eb7767c2dfa -r 608f976aa7bb file.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/file.h	Tue Jun 06 14:58:11 2006 +0000
@@ -0,0 +1,36 @@
+#ifndef FILE_H
+#define FILE_H
+
+#include <qdir.h>
+
+enum LoadMode {NewMap,ImportAdd,ImportReplace};
+enum SaveMode {PartOfMap,CompleteMap,UndoCommand};
+enum ErrorCode {success,aborted,nozip};
+
+
+/////////////////////////////////////////////////////////////////////////////
+QString maskPath (QString );
+QString convertToRel (const QString &,const QString &);
+QString makeUniqueDir (QString);
+void removeDir(QDir);
+void makeSubDirs (const QString &);
+ErrorCode zipDir (const QDir &,const QString&);
+ErrorCode unzipDir (const QDir &,const QString&);
+bool loadStringFromDisk (const QString &, QString &);
+bool saveStringToDisk (const QString &, const QString &s);
+
+/////////////////////////////////////////////////////////////////////////////
+#include <qlabel.h>
+#include <q3filedialog.h>
+#include <qpixmap.h>
+
+class ImagePreview : public QLabel, public Q3FilePreview
+{
+public:
+    ImagePreview( QWidget * );
+    void previewUrl( const Q3Url & );
+protected:
+	Q3FileDialog *fdia;
+};
+
+#endif
diff -r 9eb7767c2dfa -r 608f976aa7bb findwindow.cpp
--- a/findwindow.cpp	Sun Jan 30 12:58:47 2005 +0000
+++ b/findwindow.cpp	Tue Jun 06 14:58:11 2006 +0000
@@ -1,21 +1,26 @@
 #include <qlineedit.h>
+//Added by qt3to4:
+#include <Q3HBoxLayout>
+#include <Q3VBoxLayout>
+#include <QLabel>
 
 #include "findwindow.h"
+#include "version.h"
 
 
-FindWindow::FindWindow(QWidget* parent, const char* name, WFlags f) 
-	: QGroupBox( 0, Horizontal, "Find", parent, name )
+FindWindow::FindWindow(QWidget* parent, const char* name) 
+	: Q3GroupBox( 0, Qt::Horizontal, "Find", parent, name )
 
 {
-	setCaption ("VYM - Find Text");
+	setCaption (__VYM " - " +tr("Find Text"));
 	//resize (180,130);
 	move (130,130);
 
-	setMargin( 100 );
+	//FIXME not avail in QT4 setMargin( 100 );
 
-    QVBoxLayout* box = new QVBoxLayout( layout() );
+    Q3VBoxLayout* box = new Q3VBoxLayout( layout() );
     
-    QHBoxLayout *row1 = new QHBoxLayout( box );
+    Q3HBoxLayout *row1 = new Q3HBoxLayout( box );
     row1->setMargin( 10 );
 
     // Create a Label
@@ -23,7 +28,7 @@
     row1->addWidget( label );
 
 	// Create LineEdit (here QComboBox)
-    QHBoxLayout *row2 = new QHBoxLayout( box );
+    Q3HBoxLayout *row2 = new Q3HBoxLayout( box );
     row2->setMargin( 10 );
     findcombo = new QComboBox( true, this );
 	findcombo->setMinimumWidth(150);
@@ -35,7 +40,7 @@
     //findcombo->insertItem( "Normal", -1 );
 
 	// Create Buttons
-    QHBoxLayout *row3 = new QHBoxLayout( box );
+    Q3HBoxLayout *row3 = new Q3HBoxLayout( box );
     row3->setMargin( 10 );
 	clearbutton = new QPushButton (tr("Clear"),this);
 	connect ( clearbutton, SIGNAL( clicked() ), 
@@ -46,7 +51,7 @@
 	row3->addItem(si1);
 	
 	cancelbutton = new QPushButton (tr("Cancel"),this);
-	cancelbutton->setAccel (Key_Escape);
+	cancelbutton->setAccel (Qt::Key_Escape);
 	connect ( cancelbutton, SIGNAL( clicked() ), 
 		this, SLOT( cancelPressed() ) );
 	row3->addWidget (cancelbutton);
diff -r 9eb7767c2dfa -r 608f976aa7bb findwindow.h
--- a/findwindow.h	Sun Jan 30 12:58:47 2005 +0000
+++ b/findwindow.h	Tue Jun 06 14:58:11 2006 +0000
@@ -1,20 +1,20 @@
 #ifndef FINDWINDOW_H 
 #define FINDWINDOW_H
 
-#include <qmainwindow.h>
+#include <q3mainwindow.h>
 #include <qcombobox.h>
 #include <qpushbutton.h>
-#include <qgroupbox.h>
+#include <q3groupbox.h>
 #include <qlayout.h>
 #include <qlabel.h>
 
 
-class FindWindow : public QGroupBox
+class FindWindow : public Q3GroupBox
 {
 	Q_OBJECT
 
 public:
-	FindWindow (QWidget* parent=0, const char* namme=0, WFlags f=0);
+	FindWindow (QWidget* parent=0, const char* namme=0);
 
 public slots:	
 	void popup();
@@ -27,7 +27,7 @@
 	void somethingChanged();	// emit to mainwindow
 
 private:
-	QGroupBox *findbox;
+	Q3GroupBox *findbox;
 	QComboBox *findcombo;
 	QPushButton *clearbutton;
 	QPushButton *findbutton;
diff -r 9eb7767c2dfa -r 608f976aa7bb flagobj.cpp
--- a/flagobj.cpp	Sun Jan 30 12:58:47 2005 +0000
+++ b/flagobj.cpp	Tue Jun 06 14:58:11 2006 +0000
@@ -1,17 +1,19 @@
 #include "flagobj.h"
+//Added by qt3to4:
+#include <QPixmap>
 
 /////////////////////////////////////////////////////////////////
 // FlagObj
 /////////////////////////////////////////////////////////////////
 FlagObj::FlagObj()
 {
-//    cout << "Const FlagObj ()\n";
+//	cout << "Const FlagObj ()\n";
     init ();
 }
 
-FlagObj::FlagObj(QCanvas* c):MapObj(c) 
+FlagObj::FlagObj(Q3Canvas* c):MapObj(c) 
 {
-//    cout << "Const FlagObj\n";
+//	cout << "Const FlagObj  canvas="<<c<<endl;
     init ();
 }
 
@@ -23,13 +25,14 @@
 FlagObj::~FlagObj()
 {
 //    cout << "Destr FlagObj  " << name << "\n";
-	delete (icon);
+	if (icon) delete (icon);
 }
 
 
 void FlagObj::init ()
 {
 	name="undefined";
+	group="undefined";
 
 	icon=new ImageObj (canvas);
 	icon->move (absPos.x(), absPos.y() );
@@ -41,6 +44,7 @@
 {
     MapObj::copy(other);
 	name=other->name;
+	group=other->group;
 	tooltip=other->tooltip;
 	state=other->state;
 	icon->copy(other->icon);
@@ -95,6 +99,16 @@
 	return name;
 }
 
+void FlagObj::setGroup (const QString &n)
+{
+	group=n;
+}
+
+const QString FlagObj::getGroup()
+{
+	return group;
+}
+
 void FlagObj::setToolTip(const QString &n)
 {
 	tooltip=n;
@@ -182,8 +196,8 @@
 
 void FlagObj::positionBBox()
 {
-    bbox.setX (absPos.x() );
-    bbox.setY (absPos.y() );
+    bbox.moveTopLeft (absPos );
+    clickBox.moveTopLeft (absPos );
 }
 
 void FlagObj::calcBBoxSize()
@@ -197,5 +211,6 @@
 	{
 		bbox.setSize (QSize(0,0));
 	}
+	clickBox.setSize (bbox.size());
 }
 
diff -r 9eb7767c2dfa -r 608f976aa7bb flagobj.h
--- a/flagobj.h	Sun Jan 30 12:58:47 2005 +0000
+++ b/flagobj.h	Tue Jun 06 14:58:11 2006 +0000
@@ -2,8 +2,10 @@
 #define FLAGOBJ_H
 
 
-#include <qcanvas.h>
+#include <q3canvas.h>
 #include <qaction.h>
+//Added by qt3to4:
+#include <QPixmap>
 
 #include "mapobj.h"
 #include "imageobj.h"
@@ -12,7 +14,7 @@
 class FlagObj:public MapObj {
 public:
     FlagObj ();
-    FlagObj (QCanvas*);
+    FlagObj (Q3Canvas*);
     FlagObj (FlagObj*);
     ~FlagObj ();
     virtual void init ();
@@ -24,6 +26,8 @@
 	void load (const QPixmap&);
 	void setName (const QString&);
 	const QString getName ();
+	void setGroup (const QString&);
+	const QString getGroup();
 	void setToolTip(const QString&);
 	const QString getToolTip();
 	void setButton (QAction*);
@@ -40,6 +44,7 @@
 	
 protected:	
 	QString name;
+	QString group;
 	QString tooltip;
 	bool state;
 	bool used;
diff -r 9eb7767c2dfa -r 608f976aa7bb flagrowobj.cpp
--- a/flagrowobj.cpp	Sun Jan 30 12:58:47 2005 +0000
+++ b/flagrowobj.cpp	Tue Jun 06 14:58:11 2006 +0000
@@ -5,11 +5,11 @@
 /////////////////////////////////////////////////////////////////
 FlagRowObj::FlagRowObj()
 {
-    cout << "Const FlagRowObj ()\n";
+//    cout << "Const FlagRowObj ()\n";
     init ();
 }
 
-FlagRowObj::FlagRowObj(QCanvas* c):MapObj(c) 
+FlagRowObj::FlagRowObj(Q3Canvas* c):MapObj(c) 
 {
 //    cout << "Const FlagRowObj\n";
     init ();
@@ -25,6 +25,7 @@
 {
     flag.setAutoDelete (true);
 	parentRow=NULL;
+	showFlags=true;
 }
 
 void FlagRowObj::copy (FlagRowObj* other)
@@ -86,8 +87,8 @@
 
 void FlagRowObj::positionBBox()
 {
-    bbox.setX (absPos.x() );
-    bbox.setY (absPos.y() );
+    bbox.moveTopLeft(absPos );
+    clickBox.moveTopLeft(absPos );
 }
 
 void FlagRowObj::calcBBoxSize()
@@ -104,15 +105,16 @@
 		if (size.height() > boxsize.height() ) 
 			boxsize.setHeight(size.height() );
 	}
-	bbox.setSize (QSize(boxsize.width(), boxsize.height() ));
+	bbox.setSize (boxsize);
+	clickBox.setSize (boxsize);
 }
 
 QString FlagRowObj::getFlagName (const QPoint &p)
 {
-	if (!inBBox (p)) return "";
+	if (!inBox (p)) return "";
 	FlagObj *fo;
 	for (fo=flag.first();fo; fo=flag.next() )
-		if (fo->inBBox (p)) return fo->getName();
+		if (fo->inBox (p)) return fo->getName();
 	return "";	
 
 	
@@ -121,19 +123,14 @@
 bool FlagRowObj::isActive (const QString &foname)
 {
 	FlagObj *fo=findFlag (foname);
-	if (parentRow)
-	{
-		if (fo)
-			return fo->isActive();
-		else
-			qWarning ("FlagRowObj::isActive of "+name+" couldn't find "+foname);
-			
-	} else
+	if (parentRow && fo)
+		return fo->isActive();
+	else
 		if (fo) return true;
 	return false;
 }
 
-void FlagRowObj::toggle (const QString &foname)
+void FlagRowObj::toggle (const QString &foname, bool exclusive)
 {
 	FlagObj *fo=findFlag (foname);
 	if (fo)
@@ -150,6 +147,11 @@
 		{
 			fo=addFlag (fo);
 			fo->activate();
+			if (exclusive) 
+			{
+				deactivateGroup (fo);
+				updateToolbar();
+			}
 		} else
 			qWarning ("FlagRowObj ("+name+")::toggle ("+foname+")  failed - could not find it in parentRow");
 	}	
@@ -159,6 +161,8 @@
 
 void FlagRowObj::activate (const QString &foname)
 {
+	// Note: "activate" is also called during loading of a map
+	// Here we do not check for exclusive flags!
 	FlagObj *fo=findFlag (foname);
 	if (parentRow)
 	{
@@ -171,9 +175,11 @@
 			{
 				fo=addFlag (fo);
 				fo->activate();
-				fo->setVisibility (visible);
+				if (showFlags) 
+					fo->setVisibility (visible);
+				else
+					fo->setVisibility (false);
 				calcBBoxSize();
-				positionBBox();
 			} else
 				qWarning ("FlagRowObj ("+name+")::activate ("+foname+")  failed - could not find it in parentRow");
 		}	
@@ -190,6 +196,7 @@
 	}
 }
 
+
 void FlagRowObj::deactivate (const QString &foname)
 {
 	FlagObj *fo=findFlag (foname);
@@ -204,13 +211,27 @@
 	{
 		FlagObj *fo;
 		for (fo=flag.first();fo; fo=flag.next() )
-		{
 			fo->deactivate();
-		}
 	} else
 		qWarning ("FlagRowObj::deactivateAll mustn't be called for ordinary rows");
 }
 
+void FlagRowObj::deactivateGroup (FlagObj *keepfo)
+{
+	// deactivate all flags in keepof, but keep keepfo [sic!]
+	if (keepfo)
+	{
+		QString g=keepfo->getGroup();
+		if (g!="undefined")
+		{
+			FlagObj *fo;
+			for (fo=flag.first();fo; fo=flag.next() )
+				if (g==fo->getGroup() && keepfo!=fo) 
+					flag.remove(fo);
+		}		
+	}	
+}
+
 void FlagRowObj::setEnabled (bool b)
 {
 	// If we have no parent, we are the default FlagRowObj
@@ -223,6 +244,11 @@
 	}
 }
 
+void FlagRowObj::setShowFlags (bool b)
+{
+	showFlags=b;
+}
+
 void FlagRowObj::resetUsedCounter()
 {
 	FlagObj *fo;
@@ -260,26 +286,28 @@
 	name=n;
 }
 
-void FlagRowObj::makeToolbar (QMainWindow *w, const QString &n)
+void FlagRowObj::makeToolbar (Q3MainWindow *w, const QString &n)
 {
+	//Only make toolbar for the parentrow, not each row in branches
 	if (!parentRow)
 	{
 		// create bar and buttons
-		QToolBar* tb = new QToolBar( w);
+		Q3ToolBar* tb = new Q3ToolBar( w);
 		tb->setLabel (n);
 		QAction *a;
 		FlagObj *fo;
 		for (fo=flag.first();fo; fo=flag.next() )
 		{
 			a=new QAction (
-				fo->getToolTip(),
+// FIXME was in QT3:				fo->getToolTip(),
 				fo->getPixmap(),
 				fo->getName(),
-				0,
-				w,
-				fo->getName()
+//				0,
+				w
+//				fo->getName()
 			);
 			a->setToggleAction(true);
+//			a->setTooltip (fo->getToolTip());
 			// FIXME should not be enabled by default, later in updateToolbar
 			a->setEnabled(true);
 			a->addTo (tb);
@@ -288,10 +316,10 @@
 					w, SLOT( standardFlagChanged() ) );
 		}
 	} else
-		qWarning ("FlagRowObj::makeToolbar mustn't be called for ordinary rows");
+		qWarning ("FlagRowObj::makeToolbar must not be called for ordinary rows");
 }
 
-void  FlagRowObj::updateToolBar()
+void  FlagRowObj::updateToolbar()
 {
 	FlagObj *fo;
 	if (parentRow)
@@ -301,7 +329,7 @@
 		// In parentRow activate all existing (==active) flags
 		for (fo=flag.first();fo; fo=flag.next() ) 
 			parentRow->activate(fo->getName());
-		parentRow->updateToolBar();	
+		parentRow->updateToolbar();	
 	} else
 	{
 		// We are the toolbar default
diff -r 9eb7767c2dfa -r 608f976aa7bb flagrowobj.h
--- a/flagrowobj.h	Sun Jan 30 12:58:47 2005 +0000
+++ b/flagrowobj.h	Tue Jun 06 14:58:11 2006 +0000
@@ -1,7 +1,9 @@
 #ifndef FLAGROWOBJ_H
 #define FLAGROWOBJ_H
 
-#include <qmainwindow.h>
+#include <q3mainwindow.h>
+//Added by qt3to4:
+#include <Q3PtrList>
 
 #include "mapobj.h"
 #include "flagobj.h"
@@ -9,7 +11,7 @@
 class FlagRowObj:public QObject,public MapObj {
 public:
     FlagRowObj ();
-    FlagRowObj (QCanvas*);
+    FlagRowObj (Q3Canvas*);
     ~FlagRowObj ();
     virtual void init ();
     virtual void copy (FlagRowObj*);
@@ -22,20 +24,23 @@
     virtual void calcBBoxSize();
 	virtual QString getFlagName (const QPoint &p);	// Find flag by position
 	bool isActive(const QString&);
-	void toggle (const QString&);
+	void toggle (const QString&,bool);
 	void activate(const QString&);
 	void deactivate(const QString&);
 	void deactivateAll();
+	void deactivateGroup(FlagObj *);
 	void setEnabled (bool);
+	void setShowFlags (bool);
 	void resetUsedCounter();
 	QString saveToDir (const QString &,const QString &,bool);
 	void setName (const QString&);			// prefix for exporting flags to dir
-	void makeToolbar (QMainWindow*, const QString &);	// Create Toolbar buttons
-	void updateToolBar();					// Update Toolbar buttons	
+	void makeToolbar (Q3MainWindow*, const QString &);	// Create Toolbar buttons
+	void updateToolbar();					// Update Toolbar buttons	
 private:	
 	FlagRowObj* parentRow;					// look for flags in this row
 	FlagObj* findFlag (const QString&);
-    QPtrList <FlagObj> flag; 
+    Q3PtrList <FlagObj> flag; 
 	QString name;
+	bool showFlags;							// FloatObjects want to hide their flags
 };
 #endif
diff -r 9eb7767c2dfa -r 608f976aa7bb floatimageobj.cpp
--- a/floatimageobj.cpp	Sun Jan 30 12:58:47 2005 +0000
+++ b/floatimageobj.cpp	Tue Jun 06 14:58:11 2006 +0000
@@ -1,13 +1,14 @@
 #include "floatimageobj.h"
 #include "branchobj.h"
-#include <math.h>
+//Added by qt3to4:
+#include <QPixmap>
 
 
 /////////////////////////////////////////////////////////////////
 // FloatImageObj
 /////////////////////////////////////////////////////////////////
 
-int FloatImageObj::counter=0;		// make instance 
+uint FloatImageObj::saveCounter=0;		// make instance 
 
 
 FloatImageObj::FloatImageObj ():FloatObj()
@@ -18,7 +19,7 @@
     depth=-1;
 }
 
-FloatImageObj::FloatImageObj (QCanvas* c):FloatObj(c)
+FloatImageObj::FloatImageObj (Q3Canvas* c):FloatObj(c)
 {
  //   cout << "Const FloatImageObj (c)  called from MapCenterObj (c)\n";
     setParObj (this);	
@@ -26,7 +27,7 @@
     depth=-1;
 }
 
-FloatImageObj::FloatImageObj (QCanvas* c, LinkableMapObj* p):FloatObj(c,p)
+FloatImageObj::FloatImageObj (Q3Canvas* c, OrnamentedObj* p):FloatObj(c,p)
 {
  //   cout << "Const FloatImageObj (c,p)\n";
     init();
@@ -43,18 +44,26 @@
 	icon=new ImageObj (canvas);
 	icon->move (absPos.x(), absPos.y() );
 	icon->setVisibility (true);
+	setZ (Z_FLOATIMG);
 	bbox.setSize (QSize(icon->size().width(), icon->size().height()));
+	clickBox.setSize (QSize(icon->size().width(), icon->size().height()));
 	filename="";
 	originalFilename="no original name available";
 	filetype="";
 	saveInMap=true;
+	useRelPos=true;
+
+	//Hide flags
+	systemFlags->setShowFlags(false);
 }
 
 void FloatImageObj::copy (FloatImageObj* other)
 {					
 	FloatObj::copy (other);
 	icon->copy (other->icon);
+	filetype=other->filetype;
 	filename=other->filename;
+	originalFilename=other->originalFilename;
 	saveInMap=other->saveInMap;
     positionBBox();
 }
@@ -67,7 +76,17 @@
 
 int FloatImageObj::z ()
 {
-	return lrint (icon->z());
+	return qRound (icon->z());
+}
+
+void FloatImageObj::load (const QPixmap &pixmap)
+{
+  icon->load(pixmap);
+  bbox.setSize (QSize(icon->size().width()+8, icon->size().height()+8));
+  clickBox.setSize (QSize(icon->size().width()+8, icon->size().height()+8));
+  positionBBox();
+  filetype="PNG";
+  filename="noname.png";
 }
 
 bool FloatImageObj::load (const QString &fn)
@@ -77,7 +96,8 @@
 		bbox.setSize (QSize(icon->size().width()+8, icon->size().height()+8));
 		positionBBox();
 		filename=fn;
-		filetype=QPixmap::imageFormat (fn);
+//FIXME QT3 was		filetype=QPixmap::imageFormat (fn);
+		setOriginalFilename (fn);
 		return true;
 	} else
 		return false;
@@ -92,6 +112,10 @@
 void FloatImageObj::setOriginalFilename(const QString & fn)
 {
 	originalFilename=fn;
+
+	// Set short name, too. Search from behind:
+	int i=originalFilename.findRev("/");
+	if (i>=0) originalFilename=originalFilename.remove (0,i+1);
 }
 
 QString FloatImageObj::getOriginalFilename()
@@ -101,7 +125,7 @@
 
 void FloatImageObj::setVisibility(bool v)
 {
-    LinkableMapObj::setVisibility(v);
+    OrnamentedObj::setVisibility(v);
 	if (v)
 	    icon->setVisibility(true);
 	else
@@ -122,7 +146,7 @@
 
 void FloatImageObj::positionBBox()
 {
-	// TODO
+	clickBox=bbox;
 }
 
 void FloatImageObj::calcBBoxSize()
@@ -130,14 +154,12 @@
 	// TODO
 }
 
-QString FloatImageObj::saveToDir (const QString &tmpdir,const QString &prefix)
+QString FloatImageObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPoint &p)
 {
-	counter++;
+	if (hidden) return "";
 
-	QString posAttr=
-		attribut("relPosX",QString().setNum(relPos.x(),10)) +
-		attribut("relPosY",QString().setNum(relPos.y(),10)); 
-
+	saveCounter++;
+	
 	QString useOrientAttr;
 	if (useOrientation)
 		useOrientAttr=attribut ("useOrientation","true");
@@ -164,24 +186,27 @@
 	if (filetype=="GIF")
 		filetype="PNG";
 		
-	url="images/"+prefix+"image-" + QString().number(counter,10) + "." +filetype;
+	url="images/"+prefix+"image-" + QString().number(saveCounter,10) + "." +filetype;
 
 	// And really save the image
 	icon->save (tmpdir + "/" + url, filetype);
+ 
+	QString nameAttr=attribut ("orgName",originalFilename);
 
     return singleElement ("floatimage",  
-		posAttr + 
-		useOrientAttr + 
-		saveInMapAttr + 
-		exportAttr + 
-		zAttr + 
-		attribut ("href",QString ("file:")+url)
+		getOrnAttr() 
+		+useOrientAttr 
+		+saveInMapAttr 
+		+exportAttr  
+		+zAttr  
+		+attribut ("href",QString ("file:")+url)
+		+nameAttr
 	);	
 }
 
 void FloatImageObj::resetSaveCounter()
 {
-	counter=0;
+	saveCounter=0;
 }
 
 
diff -r 9eb7767c2dfa -r 608f976aa7bb floatimageobj.h
--- a/floatimageobj.h	Sun Jan 30 12:58:47 2005 +0000
+++ b/floatimageobj.h	Tue Jun 06 14:58:11 2006 +0000
@@ -2,19 +2,22 @@
 #define FLOATIMAGEOBJ_H
 
 #include "floatobj.h"
+//Added by qt3to4:
+#include <QPixmap>
 
 /////////////////////////////////////////////////////////////////////////////
 class FloatImageObj:public FloatObj {
 public:
     FloatImageObj ();
-    FloatImageObj (QCanvas*);
-    FloatImageObj (QCanvas*, LinkableMapObj* parent);
+    FloatImageObj (Q3Canvas*);
+    FloatImageObj (Q3Canvas*, OrnamentedObj* parent);
     ~FloatImageObj ();
     virtual void init ();
     virtual void copy (FloatImageObj*);
 	virtual void setZ (const int&);
 	virtual int z();
 
+	virtual void load (const QPixmap &);
 	virtual bool load (const QString &);
 	virtual void save (const QString &, const char *);
 	virtual void setOriginalFilename(const QString &);
@@ -27,7 +30,7 @@
 	virtual QRect getTotalBBox();			// return BBox including childs			
 	virtual QRect getBBoxSizeWithChilds();	// return size of BBox including childs  
 	virtual void calcBBoxSizeWithChilds();	// calc size of  BBox including childs recursivly
-	virtual QString saveToDir(const QString &,const QString&);
+	virtual QString saveToDir(const QString &,const QString&, const QPoint &);
 	virtual void resetSaveCounter();
 	virtual QString getSelectString();
 
@@ -35,7 +38,7 @@
 protected:
 	ImageObj *icon;
 	bool saveInMap;
-	static int counter;			// numerate the files during saveToDir
+	static uint saveCounter;	// numerate the files during saveToDir
 	QString filetype;
 	QString filename;
 	QString originalFilename;
diff -r 9eb7767c2dfa -r 608f976aa7bb floatobj.cpp
--- a/floatobj.cpp	Sun Jan 30 12:58:47 2005 +0000
+++ b/floatobj.cpp	Tue Jun 06 14:58:11 2006 +0000
@@ -6,7 +6,7 @@
 // FloatObj
 /////////////////////////////////////////////////////////////////
 
-FloatObj::FloatObj ():LinkableMapObj() 
+FloatObj::FloatObj ():OrnamentedObj() 
 {
 //    cout << "Const FloatObj ()\n";
     setParObj (this);	
@@ -14,7 +14,7 @@
     depth=-1;
 }
 
-FloatObj::FloatObj (QCanvas* c):LinkableMapObj(c)
+FloatObj::FloatObj (Q3Canvas* c):OrnamentedObj(c)
 {
 //	cout << "Const FloatObj (c)  called from MapCenterObj (c)\n";
     setParObj (this);	
@@ -22,7 +22,7 @@
     depth=-1;
 }
 
-FloatObj::FloatObj (QCanvas* c, LinkableMapObj* p):LinkableMapObj (c)
+FloatObj::FloatObj (Q3Canvas* c, LinkableMapObj* p):OrnamentedObj (c)
 {
 //    cout << "Const FloatObj (c,p)\n";
     setParObj (p);	
@@ -38,39 +38,18 @@
 void FloatObj::init () 
 {
     setChildObj(this);
-	relPos=getRandPos();
-	useOrientation=true;
 	floatExport=true;
 	zPlane=Z_ICON;
+	setLinkStyle (StyleParabel);
+	setHideLinkUnselected(true);
 }
 
 void FloatObj::copy (FloatObj* other)
 {
 	LinkableMapObj::copy (other);
-	relPos=other->relPos;
-	useOrientation=other->useOrientation;
 	setVisibility (other->visible);
 }
 
-void FloatObj::setRelPos()
-{
-	if (useOrientation)
-	{
-		if (parObj->getOrientation()==OrientLeftOfCenter)
-			relPos.setX ( parObj->x() +parObj->width() - bbox.width() -absPos.x());
-		else	
-			relPos.setX (absPos.x() - parObj->x() );
-	}
-	else
-		relPos.setX (absPos.x() - parObj->x() );
-	relPos.setY (absPos.y() - parObj->y() );
-}
-
-void FloatObj::setRelPos(const QPoint &p)
-{
-	relPos=p;
-}
-
 void FloatObj::setZ(const int &i)
 {
 	zPlane=i;
@@ -81,16 +60,6 @@
 	return zPlane;
 }
 
-
-void FloatObj::setUseOrientation (const bool &b)
-{	
-	if (useOrientation!=b)
-	{
-		useOrientation=b;
-		requestReposition();
-	}	
-}
-
 void FloatObj::setFloatExport(const bool& b)
 {
 	floatExport=b;
@@ -112,17 +81,15 @@
 	move (p.x(), p.y());
 }
 
+void FloatObj::setDockPos()
+{
+	parPos=absPos;
+	childPos=absPos;
+}
+
 void FloatObj::reposition()
 {
-	if (useOrientation)
-	{
-		if (parObj->getOrientation()==OrientLeftOfCenter)
-			move (parObj->x() - relPos.x() + parObj->width() - bbox.width(), parObj->y()+relPos.y());
-		else	
-			move (parObj->x()+relPos.x(), parObj->y()+relPos.y());
-	}		
-	else
-		move (parObj->x()+relPos.x(), parObj->y()+relPos.y());
+	move (parObj->getChildPos().x()+relPos.x(), parObj->getChildPos().y()+relPos.y());
 	updateLink();	
 }
 
@@ -139,25 +106,11 @@
 void FloatObj::select()
 {
     LinkableMapObj::select();
-	// Temporary draw the link while FO is selected
-	if (style==StyleUndef) 
-	{
-		setLinkStyle(getDefLinkStyle());
-		setLinkColor(parObj->getLinkColor());
-	}	
-
-	// Update FloatExport switch in context menu
-	if (floatExport)
-		actionEditToggleFloatExport->setEnabled (true);
-	else	
-		actionEditToggleFloatExport->setEnabled (true);
-
-
+	LinkableMapObj::setLinkColor(parObj->getLinkColor());
 }
 
 void FloatObj::unselect()
 {
 	LinkableMapObj::unselect();
-	setLinkStyle (StyleUndef);
 }
 
diff -r 9eb7767c2dfa -r 608f976aa7bb floatobj.h
--- a/floatobj.h	Sun Jan 30 12:58:47 2005 +0000
+++ b/floatobj.h	Tue Jun 06 14:58:11 2006 +0000
@@ -1,43 +1,37 @@
 #ifndef FLOATOBJ_H
 #define FLOATOBJ_H
 
-#include "linkablemapobj.h"
+#include "ornamentedobj.h"
 
 /////////////////////////////////////////////////////////////////////////////
-class FloatObj:public LinkableMapObj {
+class FloatObj:public OrnamentedObj {
 public:
     FloatObj ();
-    FloatObj (QCanvas*);
-    FloatObj (QCanvas*, LinkableMapObj* parent);
+    FloatObj (Q3Canvas*);
+    FloatObj (Q3Canvas*, LinkableMapObj* parent);
     ~FloatObj ();
     virtual void init ();
     virtual void copy (FloatObj*);
 	virtual bool load (const QString&)=0;
-	virtual void setRelPos();				// set relPos to current parentPos
-	virtual void setRelPos(const QPoint&);	
 	virtual void setZ(const int&);		// set zPlane
 	virtual int z();
-	virtual void setUseOrientation (const bool &);
 	virtual void setFloatExport (const bool &);
 	virtual bool getFloatExport ();
 
 	virtual void move (double,double);
 	virtual void move (QPoint);
-
+	virtual void setDockPos();
 	virtual void reposition();
 											
 	virtual QRect getTotalBBox();			// return BBox including childs			
 	virtual QRect getBBoxSizeWithChilds();	// return size of BBox including childs  
 
-	virtual QString saveToDir(const QString &,const QString&)=0;
 	virtual void resetSaveCounter()=0;
 
 	virtual void select();
 	virtual void unselect();
 
 protected:
-	QPoint relPos;
-	bool useOrientation;		
 	bool floatExport;
 	int zPlane;
 };
diff -r 9eb7767c2dfa -r 608f976aa7bb frameobj.cpp
--- a/frameobj.cpp	Sun Jan 30 12:58:47 2005 +0000
+++ b/frameobj.cpp	Tue Jun 06 14:58:11 2006 +0000
@@ -11,7 +11,7 @@
     init ();
 }
 
-FrameObj::FrameObj(QCanvas* c) :MapObj(c)
+FrameObj::FrameObj(Q3Canvas* c) :MapObj(c)
 {
 //    cout << "Const FrameObj\n";
     init ();
@@ -117,16 +117,13 @@
 				break;
 			case Rectangle:
 				border=10;
-				rectFrame = new QCanvasRectangle (canvas);
+				rectFrame = new Q3CanvasRectangle (canvas);
 				rectFrame->setZ(Z_FRAME);
 				rectFrame->setBrush( QColor("white") );
 				rectFrame->setPen( QPen(QColor("black") ));
-				if (visible)
-					rectFrame->show();
-				else    
-					rectFrame->hide();
 				break;
 		}
+		setVisibility (visible);
 	}
 }
 
@@ -141,6 +138,16 @@
 void FrameObj::setVisibility (bool v)
 {
     MapObj::setVisibility(v);
-    setFrameType (type);    // changes on visibility depend on type...
+	switch (type)
+	{
+		case NoFrame:
+			break;
+		case Rectangle:
+			if (visible)
+				rectFrame->show();
+			else    
+				rectFrame->hide();
+			break;
+	}
 }
 
diff -r 9eb7767c2dfa -r 608f976aa7bb frameobj.h
--- a/frameobj.h	Sun Jan 30 12:58:47 2005 +0000
+++ b/frameobj.h	Tue Jun 06 14:58:11 2006 +0000
@@ -8,7 +8,7 @@
 class FrameObj:public MapObj {
 public:
     FrameObj();
-    FrameObj(QCanvas*);
+    FrameObj(Q3Canvas*);
     ~FrameObj();
     void init();
     void clear();
@@ -26,7 +26,7 @@
 
 protected:
     FrameType type;
-    QCanvasRectangle* rectFrame;
+    Q3CanvasRectangle* rectFrame;
     int border;									// distance text - frame
 };
 #endif
diff -r 9eb7767c2dfa -r 608f976aa7bb headingobj.cpp
--- a/headingobj.cpp	Sun Jan 30 12:58:47 2005 +0000
+++ b/headingobj.cpp	Tue Jun 06 14:58:11 2006 +0000
@@ -1,4 +1,5 @@
 #include "headingobj.h"
+#include <qregexp.h>
 
 /////////////////////////////////////////////////////////////////
 // HeadingObj
@@ -9,7 +10,7 @@
     init ();
 }
 
-HeadingObj::HeadingObj(QCanvas* c) :MapObj(c)
+HeadingObj::HeadingObj(Q3Canvas* c) :MapObj(c)
 {
 //    cout << "Const HeadingObj\n";
     init ();
@@ -26,6 +27,7 @@
     textwidth=40;
     color=QColor ("black");
     font=QFont();
+	heading="";
 }
 
 void HeadingObj::copy(HeadingObj *other)
@@ -40,13 +42,15 @@
 void HeadingObj::move(double x, double y)
 {
     MapObj::move(x,y);
+
     int h;	// height of a textline
     int ho;	// offset of height while drawing all lines
+
     if (textline.first() )
 		h=textline.first()->boundingRect().height();
     else
 		h=2;
-    QCanvasText *t;
+    Q3CanvasText *t;
     ho=0;
     for (t=textline.first(); t; t=textline.next() )
     {
@@ -76,7 +80,7 @@
 	// then no selection would be visible, thus we prevent it in ::setText()
 	if (!textline.isEmpty() )
 	{
-		QCanvasText *t;
+		Q3CanvasText *t;
 		for (t=textline.first(); t; t=textline.next() )
 		{
 			h+=t->boundingRect().height();
@@ -87,14 +91,15 @@
     bbox.setSize (QSize(w,h));
 }
 
-QCanvasText* HeadingObj::newLine(QString s)
+Q3CanvasText* HeadingObj::newLine(QString s)
 {
-    QCanvasText *t;
-    t = new QCanvasText(canvas);
+    Q3CanvasText *t;
+    t = new Q3CanvasText(canvas);
     t->setFont (font);
     t->setColor (color);
     t->setZ(Z_TEXT);
     t->setText(s);
+	t->setTextFlags(Qt::AlignLeft);
     t->show();
     return t;
 }
@@ -114,15 +119,17 @@
     int j=0;	// index of last ws
 	int k=0;	// index of "<br>" or similar linebreak
 	int br=0;	// width of found break, e.g. for <br> it is 4
+	QRegExp re("<br.*/>");
+	re.setMinimal (true);
 
     // set the text and wrap lines
     while (s.length()>0)
     {
 		// ok, some people wanted manual linebreaks, here we go
-		k=s.find ("<br>",i,false);
+		k=re.search (s,i);
 		if (k>=0)
 		{
-			br=4;
+			br=re.cap(0).length();
 			i=k;
 		} else
 			i=s.find (" ",i,false);
@@ -184,6 +191,7 @@
 		}		    
     }
 	setVisibility (visible);
+	move (absPos.x(),absPos.y());
 	calcBBoxSize();
 }
 
@@ -212,7 +220,7 @@
     if (color!=c)
     {
 		color=c;
-		QCanvasText *t;
+		Q3CanvasText *t;
 		for (t=textline.first(); t; t=textline.next() )
 			t->setColor(c);
     }	    
@@ -226,7 +234,7 @@
 void HeadingObj::setVisibility (bool v)
 {
     MapObj::setVisibility(v);
-    QCanvasText *t;
+    Q3CanvasText *t;
     for (t=textline.first(); t; t=textline.next() )
 		if (v)
 			t->show();
diff -r 9eb7767c2dfa -r 608f976aa7bb headingobj.h
--- a/headingobj.h	Sun Jan 30 12:58:47 2005 +0000
+++ b/headingobj.h	Tue Jun 06 14:58:11 2006 +0000
@@ -2,11 +2,13 @@
 #define HEADINGOBJ_H
 
 #include "mapobj.h"
+//Added by qt3to4:
+#include <Q3PtrList>
 
 class HeadingObj:public MapObj {
 public:
     HeadingObj();
-    HeadingObj(QCanvas*);
+    HeadingObj(Q3Canvas*);
     virtual ~HeadingObj();
     virtual void init();
     virtual void copy(HeadingObj*);
@@ -15,7 +17,7 @@
     virtual void positionBBox();
 	virtual void calcBBoxSize();
 private:
-    QCanvasText* newLine(QString);				// generate new textline
+    Q3CanvasText* newLine(QString);				// generate new textline
 public:    
     virtual void setText(QString);
     virtual QString text();
@@ -30,7 +32,7 @@
 protected:
     QString heading;
     uint textwidth;								// width for formatting text
-    QPtrList <QCanvasText> textline;			// a part of e.g. the parabel
+    Q3PtrList <Q3CanvasText> textline;			// a part of e.g. the parabel
     QColor color;
     QFont font;
 };
diff -r 9eb7767c2dfa -r 608f976aa7bb imageobj.cpp
--- a/imageobj.cpp	Sun Jan 30 12:58:47 2005 +0000
+++ b/imageobj.cpp	Tue Jun 06 14:58:11 2006 +0000
@@ -1,10 +1,12 @@
 #include "imageobj.h"
+//Added by qt3to4:
+#include <QPixmap>
 
 /////////////////////////////////////////////////////////////////
 // ImageObj
 /////////////////////////////////////////////////////////////////
-ImageObj::ImageObj( QCanvas *canvas )
-    : QCanvasRectangle( canvas )
+ImageObj::ImageObj( Q3Canvas *canvas )
+    : Q3CanvasRectangle( canvas )
 {
 //	cout << "Const ImageObj (canvas)\n";
     setZ(Z_ICON);	
@@ -39,7 +41,7 @@
 {
 	switch (type)
 	{
-		case undef: qWarning("undef");break;
+		case undef: qWarning("Warning: ImageObj::save() type=undef");break;
 		case qimage: image.save (fn,format,-1);break;
 		case qpixmap: pixmap.save (fn,format,-1);break;
 	}
@@ -54,7 +56,7 @@
 	type=qimage;
 
 #if !defined(Q_WS_QWS)
-    pixmap.convertFromImage(image, OrderedAlphaDither);
+    pixmap.convertFromImage(image, Qt::OrderedAlphaDither);
 #endif
 	return true;
 }
@@ -78,7 +80,7 @@
 {
 	type=qimage;
 	image=img;
-    pixmap.convertFromImage(image, OrderedAlphaDither);
+    pixmap.convertFromImage(image, Qt::OrderedAlphaDither);
 }
 
 QPixmap ImageObj::getPixmap()
@@ -91,7 +93,7 @@
 // On Qt/Embedded, we can paint a QImage as fast as a QPixmap,
 // but on other platforms, we need to use a QPixmap.
 #if defined(Q_WS_QWS)
-    p.drawImage( int(x()), int(y()), image, 0, 0, -1, -1, OrderedAlphaDither );
+    p.drawImage( int(x()), int(y()), image, 0, 0, -1, -1, Qt::OrderedAlphaDither );
 #else
     p.drawPixmap( int(x()), int(y()), pixmap );
 #endif
diff -r 9eb7767c2dfa -r 608f976aa7bb imageobj.h
--- a/imageobj.h	Sun Jan 30 12:58:47 2005 +0000
+++ b/imageobj.h	Tue Jun 06 14:58:11 2006 +0000
@@ -2,17 +2,19 @@
 #define IMAGEOBJ_H
 
 #include <qimage.h>
-#include <qcanvas.h>
+#include <q3canvas.h>
 #include <qpainter.h>
+//Added by qt3to4:
+#include <QPixmap>
 
 #include "mapobj.h"
 
 enum ImageType {qimage,qpixmap,undef};
 
-class ImageObj: public QCanvasRectangle
+class ImageObj: public Q3CanvasRectangle
 {
 public:
-    ImageObj( QCanvas *canvas );
+    ImageObj( Q3Canvas *canvas );
     ~ImageObj();
 	virtual void copy (ImageObj*);
     virtual void setVisibility(bool);
diff -r 9eb7767c2dfa -r 608f976aa7bb imports.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/imports.cpp	Tue Jun 06 14:58:11 2006 +0000
@@ -0,0 +1,115 @@
+#include <qmessagebox.h>
+//Added by qt3to4:
+#include <QTextStream>
+
+#include "file.h"
+#include "imports.h"
+#include "linkablemapobj.h"
+#include "misc.h"
+#include "mainwindow.h"
+#include "xsltproc.h"
+
+extern Main *mainWindow;
+extern QDir vymBaseDir;
+
+ImportBase::ImportBase()
+{
+	// Create tmpdir
+	tmpDir.setPath (makeUniqueDir("/tmp/vym-XXXXXX"));
+}
+
+
+ImportBase::~ImportBase()
+{
+	// Remove tmpdir
+	removeDir (tmpDir);
+}
+
+void ImportBase::setDir(const QString &p)
+{
+	inputDir=p;
+}
+
+void ImportBase::setFile (const QString &p)
+{
+	inputFile=p;
+}
+
+void ImportBase::setMapCenter(MapCenterObj *mc)
+{
+	mapCenter=mc;
+}
+
+bool ImportBase::transform()
+{
+	return true;
+}
+
+QString ImportBase::getTransformedFile()
+{
+	return transformedFile;
+}
+
+/////////////////////////////////////////////////
+bool ImportKDEBookmarks::transform()
+{
+	transformedFile=tmpDir.path()+"/bookmarks.xml";
+
+	XSLTProc p;
+	p.setInputFile (tmpDir.home().path()+"/.kde/share/apps/konqueror/bookmarks.xml");
+	p.setOutputFile (transformedFile);
+	p.setXSLFile (vymBaseDir.path()+"/styles/kdebookmarks2vym.xsl");
+	p.process();
+
+	return true;
+}
+
+
+/////////////////////////////////////////////////
+bool ImportFirefoxBookmarks::transform()
+{
+	transformedFile=tmpDir.path()+"/bookmarks.xml";
+
+	QStringList lines;
+	QFile file( inputFile );
+	if ( file.open( QIODevice::ReadOnly ) ) 
+	{
+		QTextStream stream( &file );
+		while ( !stream.atEnd() ) 
+			lines += stream.readLine(); // line of text excluding '\n'
+		file.close();
+	}
+	// FIXME
+	// Generate vym from broken bookmarks above...
+
+	return true;
+}
+
+
+/////////////////////////////////////////////////
+bool ImportMM::transform()
+{
+	// try to unzip 
+	if (success==unzipDir (tmpDir, inputFile))
+	{
+		
+		// Set short name, too. Search from behind:
+		transformedFile=inputFile;
+		int i=transformedFile.findRev("/");
+		if (i>=0) transformedFile=transformedFile.remove (0,i+1);
+		transformedFile.replace(".mmap",".xml");
+		transformedFile=tmpDir.path()+"/"+transformedFile;
+
+		XSLTProc p;
+		p.setInputFile (tmpDir.path()+"/Document.xml");
+		p.setOutputFile (transformedFile);
+		p.setXSLFile (vymBaseDir.path()+"/styles/mmap2vym.xsl");
+		p.process();
+
+		cout << "  xslt done"<<endl;
+
+		return true;
+	} else
+		return false;
+	
+}
diff -r 9eb7767c2dfa -r 608f976aa7bb linkablemapobj.cpp
--- a/linkablemapobj.cpp	Sun Jan 30 12:58:47 2005 +0000
+++ b/linkablemapobj.cpp	Tue Jun 06 14:58:11 2006 +0000
@@ -1,10 +1,12 @@
-//#include <math.h>
+#include <math.h>
 
 #include "linkablemapobj.h"
 #include "branchobj.h"
 #include "mapeditor.h"
 
 #include "version.h"
+//Added by qt3to4:
+#include <Q3PointArray>
 
 
 /////////////////////////////////////////////////////////////////
@@ -17,7 +19,7 @@
     init ();
 }
 
-LinkableMapObj::LinkableMapObj(QCanvas* c) :MapObj(c)
+LinkableMapObj::LinkableMapObj(Q3Canvas* c) :MapObj(c)
 {
 //    cout << "Const LinkableMapObj\n";
     init ();
@@ -62,6 +64,7 @@
 void LinkableMapObj::init ()
 {
     depth=-1;	
+	mapEditor=NULL;
     childObj=NULL;
     parObj=NULL;
     parObjTmpBuf=NULL;
@@ -76,35 +79,45 @@
 	linkpos=LinkBottom;
     segment.setAutoDelete (TRUE);
     arcsegs=13;
-	QPointArray pa(arcsegs*2+2);
+	Q3PointArray pa(arcsegs*2+2);
     
-    bottomline=new QCanvasLine(canvas);
+    bottomline=new Q3CanvasLine(canvas);
     bottomline->setPen( QPen(linkcolor, 1) );
     bottomline->setZ(Z_LINK);
     bottomline->show();
 
     // Prepare showing the selection of a MapObj
-    selbox = new QCanvasRectangle (canvas);
+    selbox = new Q3CanvasRectangle (canvas);
     selbox->setZ(Z_SELBOX);
     selbox->setBrush( QColor(255,255,0) );
     selbox->setPen( QPen(QColor(255,255,0) ));
     selbox->hide();
     selected=false;
 
+	hideLinkUnselected=false;
+
+	topPad=botPad=leftPad=rightPad=0;
+
 	// initialize frame
 	frame = new FrameObj (canvas);
 	
 	repositionRequest=false;
+
+	// Rel Positions
+	relPos=QPoint(0,0);
+	useRelPos=false;
+	useOrientation=true;
 }
 
 void LinkableMapObj::copy (LinkableMapObj* other)
 {
     MapObj::copy(other);
 	bboxTotal=other->bboxTotal;
-//    linkwidth=other->linkwidth;		
-
     setLinkStyle(other->style);
     setLinkColor (other->linkcolor);
+	relPos=other->relPos;
+	useOrientation=other->useOrientation;
+
 }
 
 void LinkableMapObj::setChildObj(LinkableMapObj* o)
@@ -126,8 +139,57 @@
 {
 }
 
+bool LinkableMapObj::hasParObjTmp()
+{
+	if (parObjTmpBuf) return true;
+	return false;
+}
+
+void LinkableMapObj::setUseRelPos (const bool &b)
+{
+	useRelPos=b;
+}
+
+void LinkableMapObj::setRelPos()
+{
+	if (parObj)
+	{	
+		relPos.setX (absPos.x() - parObj->getChildPos().x() );
+		relPos.setY (absPos.y() - parObj->getChildPos().y() );
+
+		parObj->calcBBoxSize();
+		parObj->requestReposition();
+	}	
+}
+
+void LinkableMapObj::setRelPos(const QPoint &p)
+{
+	relPos=p;
+	if (parObj)
+	{	parObj->calcBBoxSize();
+		parObj->requestReposition();
+	}	
+}
+
+int LinkableMapObj::getTopPad()
+{
+	return topPad;
+}
+
+int LinkableMapObj::getLeftPad()
+{
+	return leftPad;
+}
+
+int LinkableMapObj::getRightPad()
+{
+	return rightPad;
+}
+
 LinkStyle LinkableMapObj::getDefLinkStyle ()
 {
+	if (!mapEditor) return StyleUndef;
+
 	LinkStyle ls=mapEditor->getLinkStyle();
 	switch (ls)
 	{
@@ -157,6 +219,7 @@
 
 void LinkableMapObj::setLinkStyle(LinkStyle newstyle)
 {
+	//if (newstyle=style) return;
 	delLink();
 		
 	style=newstyle;
@@ -164,14 +227,14 @@
     if (childObj!=NULL && parObj != NULL)
     {
 		int i;
-		QCanvasLine* cl;
+		Q3CanvasLine* cl;
 		switch (style)
 		{
 			case StyleUndef:
 				bottomline->hide();
 				break;
 			case StyleLine: 
-				l = new QCanvasLine(canvas);
+				l = new Q3CanvasLine(canvas);
 				l->setPen( QPen(linkcolor, 1) );
 				l->setZ(Z_LINK);
 				if (visible)
@@ -182,7 +245,7 @@
 			case StyleParabel:
 				for (i=0;i<arcsegs;i++)
 				{
-					cl = new QCanvasLine(canvas);
+					cl = new Q3CanvasLine(canvas);
 					cl->setPen( QPen(linkcolor, 1) );
 					cl->setPoints( 0,0,i*10,100);
 					cl->setZ(Z_LINK);
@@ -195,7 +258,7 @@
 				pa0.resize (arcsegs+1);
 				break;
 			case StylePolyLine:	
-				p = new QCanvasPolygon(canvas);
+				p = new Q3CanvasPolygon(canvas);
 				p->setBrush( linkcolor );
 				p->setZ(Z_LINK);
 				if (visible)
@@ -203,10 +266,9 @@
 				else
 					p->hide();
 				pa0.resize (3);
-				// TODO
-				// a bit awkward: draw the lines additionally to polygon, to avoid
+				// TODO a bit awkward: draw the lines additionally to polygon, to avoid
 				// missing pixels, when polygon is extremly flat
-				l = new QCanvasLine(canvas);
+				l = new Q3CanvasLine(canvas);
 				l->setPen( QPen(linkcolor, 1) );
 				l->setZ(Z_LINK);
 				if (visible)
@@ -215,7 +277,7 @@
 					l->hide();
 				break;
 			case StylePolyParabel:	
-				p = new QCanvasPolygon(canvas);
+				p = new Q3CanvasPolygon(canvas);
 				p->setBrush( linkcolor );
 				p->setZ(Z_LINK);
 				if (visible)
@@ -226,13 +288,12 @@
 				pa1.resize (arcsegs+1);
 				pa2.resize (arcsegs+1);
 
-				// TODO
-				// a bit awkward: draw the lines additionally 
+				// TODO a bit awkward: draw the lines additionally 
 				// to polygon, to avoid missing pixels, 
 				// if polygon is extremly flat
 				for (i=0;i<arcsegs;i++)
 				{
-					cl = new QCanvasLine(canvas);
+					cl = new Q3CanvasLine(canvas);
 					cl->setPen( QPen(linkcolor, 1) );
 					cl->setPoints( 0,0,i*10,100);
 					cl->setZ(Z_LINK);
@@ -246,10 +307,7 @@
 			default: 
 				break;	
 		}	
-	} else
-	{
-		cout << "Error: ChildObj or parObj == NULL in LinkableMapObj::setLinkStyle\n";
-	}
+	} 
 }
 
 LinkStyle LinkableMapObj::getLinkStyle()
@@ -257,6 +315,18 @@
 	return style;
 }
 
+void LinkableMapObj::setHideLinkUnselected(bool b)
+{
+	hideLinkUnselected=b;
+	setVisibility (visible);
+	updateLink();
+}
+
+bool LinkableMapObj::getHideLinkUnselected()
+{
+	return hideLinkUnselected;
+}
+
 void LinkableMapObj::setLinkPos(LinkPos lp)
 {
 	linkpos=lp;
@@ -272,14 +342,15 @@
 {
 	// Overloaded in BranchObj and childs
 	// here only set default color
-	setLinkColor (mapEditor->getDefLinkColor());
+	if (mapEditor)
+		setLinkColor (mapEditor->getDefLinkColor());
 }
 
 void LinkableMapObj::setLinkColor(QColor col)
 {
 	linkcolor=col;
     bottomline->setPen( QPen(linkcolor, 1) );
-	QCanvasLine *cl;
+	Q3CanvasLine *cl;
 	switch (style)
 	{
 		case StyleLine:
@@ -301,7 +372,6 @@
 		default:
 			break;
 	} // switch (style)	
-	updateLink();
 }
 
 QColor LinkableMapObj::getLinkColor()
@@ -332,32 +402,62 @@
 
 void LinkableMapObj::setVisibility (bool v)
 {
+	Q3CanvasLine* cl;
 	MapObj::setVisibility (v);
-	if (visible) 
+	bool visnow=visible;
+
+	// We can hide the link, while object is not selected
+	if (hideLinkUnselected && !selected)
+		visnow=false;
+
+	if (visnow) 
 	{
 		bottomline->show();
-		// FIXME lines and segments should be done in LMO?
-		if (style==StyleLine && l) 
+		switch (style)
 		{
-			l->show();
-		} else
-		{
-			QCanvasLine* cl;
-			for (cl=segment.first(); cl; cl=segment.next() )
-				cl->show();
-		} 
+			case StyleLine:
+				if (l) l->show();
+				break;
+			case StyleParabel:	
+				for (cl=segment.first(); cl; cl=segment.next() )
+					cl->show();
+				break;	
+			case StylePolyLine:
+				if (p) p->show();
+				if (l) l->show();
+				break;
+			case StylePolyParabel:	
+				for (cl=segment.first(); cl; cl=segment.next() )
+					cl->show();
+				if (p) p->show();
+				break;
+			default:
+				break;
+		}
 	} else 
 	{
 		bottomline->hide();
-		if (style==StyleLine && l) 
+		switch (style)
 		{
-			l->hide();
-		} else
-		{
-			QCanvasLine* cl;
-			for (cl=segment.first(); cl; cl=segment.next() )
-				cl->hide();
-		} 
+			case StyleLine:
+				if (l) l->hide();
+				break;
+			case StyleParabel:	
+				for (cl=segment.first(); cl; cl=segment.next() )
+					cl->hide();
+				break;	
+			case StylePolyLine:
+				if (p) p->hide();
+				if (l) l->hide();
+				break;
+			case StylePolyParabel:	
+				for (cl=segment.first(); cl; cl=segment.next() )
+					cl->hide();
+				if (p) p->hide();
+				break;
+			default:
+				break;
+		}
 	}	
 }
 
@@ -370,12 +470,11 @@
     // 
     // sets:
     //	orientation
-    //	childPos
-    //	parPos
-	//  offset
+    //	childPos	(by calling setDockPos())
+    //	parPos		(by calling setDockPos())
+	//  bottomlineY
     //	drawing of the link itself
 
-
 	// updateLink is called from move, but called from constructor we don't
 	// have parents yet...
 	if (style==StyleUndef) return;	
@@ -387,10 +486,10 @@
 	switch (linkpos)
 	{
 		case LinkMiddle:
-			offset=bbox.height() /2;
+			bottomlineY=bbox.top()+bbox.height() /2;	// draw link to middle (of frame)
 			break;
 		default :
-			offset=bbox.height()-1;			// draw link to bottom of bbox
+			bottomlineY=bbox.bottom()-1;	// draw link to bottom of box
 			break;
 	}
 	
@@ -431,23 +530,7 @@
 		reposition();
 	}
 	
-    if (orientation==OrientLeftOfCenter )
-    {
-		childPos=QPoint (absPos.x(),absPos.y()+offset);
-		parPos=QPoint (absPos.x()+ bbox.width(), absPos.y() + offset );
-    } else
-    {
-		childPos=QPoint (absPos.x()+ bbox.width(), absPos.y() + offset ); 
-		parPos=QPoint (absPos.x(),absPos.y()+offset);
-    }
-	/* FIXME
-		cout << "      LMO::updateLink   absPos="<<absPos<<endl;
-		cout << "      LMO::updateLink childPos="<<childPos<<endl;
-		cout << "      LMO::updateLink   parPos="<<parPos<<endl;
-		cout << "      LMO::updateLink   offset="<<offset<<endl;
-		cout << "      LMO::updateLink   bbox.w="<<bbox.width()<<endl;
-		cout << "      LMO::updateLink   bbox.h="<<bbox.height()<<endl;
-	*/	
+	setDockPos();
 
 	double p1x=parPos.x();	// Link is drawn from P1 to P2
 	double p1y=parPos.y();
@@ -456,10 +539,10 @@
 	double vy=p2y - p1y;
 
 	// Draw the horizontal line below heading (from ChildPos to ParPos)
-	bottomline->setPoints (lrint(childPos.x()),
-		lrint(childPos.y()),
-		lrint(p1x),
-		lrint(p1y) );
+	bottomline->setPoints (qRound(childPos.x()),
+		qRound(childPos.y()),
+		qRound(p1x),
+		qRound(p1y) );
 
 	double a;	// angle
 	if (vx > -0.000001 && vx < 0.000001)
@@ -467,9 +550,9 @@
 	else
 		a=atan( vy / vx );
 	// "turning point" for drawing polygonal links
-	QPoint tp (-lrint(sin (a)*thickness_start), lrint(cos (a)*thickness_start));	
+	QPoint tp (-qRound(sin (a)*thickness_start), qRound(cos (a)*thickness_start));	
 	
-	QCanvasLine *cl;
+	Q3CanvasLine *cl;
 
 	int i;
 
@@ -477,10 +560,10 @@
 	switch (style)
 	{
 		case StyleLine:
-			l->setPoints( lrint (parPos.x()),
-				lrint(parPos.y()),
-				lrint(p2x),
-				lrint(p2y) );
+			l->setPoints( qRound (parPos.x()),
+				qRound(parPos.y()),
+				qRound(p2x),
+				qRound(p2y) );
 			break;	
 		case StyleParabel:	
 			parabel (pa0, p1x,p1y,p2x,p2y);
@@ -492,15 +575,15 @@
 			}
 			break;
 		case StylePolyLine:
-			pa0[0]=QPoint (lrint(p2x+tp.x()), lrint(p2y+tp.y()));
-			pa0[1]=QPoint (lrint(p2x-tp.x()), lrint(p2y-tp.y()));
-			pa0[2]=QPoint (lrint (parPos.x()), lrint(parPos.y()) );
+			pa0[0]=QPoint (qRound(p2x+tp.x()), qRound(p2y+tp.y()));
+			pa0[1]=QPoint (qRound(p2x-tp.x()), qRound(p2y-tp.y()));
+			pa0[2]=QPoint (qRound (parPos.x()), qRound(parPos.y()) );
 			p->setPoints (pa0);
 			// here too, draw line to avoid missing pixels
-			l->setPoints( lrint (parPos.x()),
-				lrint(parPos.y()),
-				lrint(p2x),
-				lrint(p2y) );
+			l->setPoints( qRound (parPos.x()),
+				qRound(parPos.y()),
+				qRound(p2x),
+				qRound(p2y) );
 			break;
 		case StylePolyParabel:	
 			parabel (pa1, p1x,p1y,p2x+tp.x(),p2y+tp.y());
@@ -534,6 +617,44 @@
     return parObj;
 }
 
+LinkableMapObj* LinkableMapObj::findObjBySelect (QString s)
+{
+	LinkableMapObj *lmo=this;
+	QString part;
+	QString typ;
+	QString num;
+	while (!s.isEmpty() )
+	{
+		part=s.section(",",0,0);
+		typ=part.left (3);
+		num=part.right(part.length() - 3);
+		if (typ=="mc:")
+		{
+			if (depth>0)
+				return false;	// in a subtree there is no center
+			else
+				break;
+		} else
+			if (typ=="bo:")
+				lmo=((BranchObj*)(lmo))->getBranchNum (num.toUInt());
+			else
+				if (typ=="fi:")
+					lmo=((BranchObj*)(lmo))->getFloatImageNum (num.toUInt());
+		if (!lmo) break;
+		
+		if (s.contains(","))
+			s=s.right(s.length() - part.length() -1 );
+		else	
+			break;
+	}
+	return lmo;
+}
+
+void LinkableMapObj::setDockPos()
+{
+	cout <<"LMO::setDockPos()\n";
+}
+
 QPoint LinkableMapObj::getChildPos()
 {
     return childPos;
@@ -546,11 +667,26 @@
 
 QPoint LinkableMapObj::getRelPos()
 {
+	return relPos;
+/* FIXME not needed? relPos was moved in 1.7.10 from
+   floatobj to linkablemapobj. Before we had:
+	
 	if (!parObj) return QPoint (0,0);
     return QPoint(
 		absPos.x() - parObj->x(),
 		absPos.y() - parObj->y()
 	);
+*/	
+}
+
+
+void LinkableMapObj::setUseOrientation (const bool &b)
+{	
+	if (useOrientation!=b)
+	{
+		useOrientation=b;
+		requestReposition();
+	}	
 }
 
 LinkOrient LinkableMapObj::getOrientation()
@@ -583,11 +719,12 @@
 
 void LinkableMapObj::alignRelativeTo (QPoint ref)
 {
+	// FIXME testing, seems not to be used right now...
+	cout << "LMO::alignRelTo   ref="<<ref<<endl;
 }
 
 void LinkableMapObj::reposition()
 {
-cout << "LMO::reposition  ???"<<endl;
 	if (depth==0)
 	{
 		// only calculate the sizes once. If the deepest LMO changes its height,
@@ -626,14 +763,15 @@
 	// we want to block expensive repositioning, but just do it once at
 	// the end, thus check first:
 
-	if (mapEditor->blockReposition()) return;
+	if (mapEditor->isRepositionBlocked()) return;
 	
 	// Pass on the request to parental objects, if this hasn't been done yet
 	
 	if (parObj) 
 		parObj->forceReposition(); 
 	else 
-		reposition(); }
+		reposition(); 
+}
 
 bool LinkableMapObj::repositionRequested()
 {
@@ -643,9 +781,9 @@
 
 void LinkableMapObj::setSelBox()
 {
-    selbox->setX (bbox.x() );
-    selbox->setY (bbox.y() );
-    selbox->setSize (bbox.width(), bbox.height() );
+    selbox->setX (clickBox.x() );
+    selbox->setY (clickBox.y() );
+    selbox->setSize (clickBox.width(), clickBox.height() );
 }
 
 void LinkableMapObj::select()
@@ -653,6 +791,8 @@
 	setSelBox();
     selected=true;
     selbox->show();
+// FIXME not needed?	
+	setVisibility (visible);
 }
 
 
@@ -660,9 +800,11 @@
 {
     selected=false;
     selbox->hide();
+	// Maybe we have to hide the link:
+	setVisibility (visible);
 }
 
-void LinkableMapObj::parabel (QPointArray &ya, double p1x, double p1y, double p2x, double p2y)
+void LinkableMapObj::parabel (Q3PointArray &ya, double p1x, double p1y, double p2x, double p2y)
 
 {
 	double vx=p2x - p1x;	// V=P2-P1
@@ -680,14 +822,22 @@
 		m=(vy / (vx*vx));
 	dx=vx/(arcsegs);
 	int i;
-	ya.setPoint (0,QPoint (lrint(p1x),lrint(p1y)));
+	ya.setPoint (0,QPoint (qRound(p1x),qRound(p1y)));
 	for (i=1;i<=arcsegs;i++)
 	{	
 		pnx=p1x+dx;
 		pny=m*(pnx-parPos.x())*(pnx-parPos.x())+parPos.y();
-		ya.setPoint (i,QPoint (lrint(pnx),lrint(pny)));
+		ya.setPoint (i,QPoint (qRound(pnx),qRound(pny)));
 		p1x=pnx;
 		p1y=pny;
 	}	
 }
 
+QString LinkableMapObj::getLinkAttr ()
+{
+	if (hideLinkUnselected)
+		return attribut ("hideLink","true");
+	else
+		return attribut ("hideLink","false");
+	
+}
diff -r 9eb7767c2dfa -r 608f976aa7bb linkablemapobj.h
--- a/linkablemapobj.h	Sun Jan 30 12:58:47 2005 +0000
+++ b/linkablemapobj.h	Tue Jun 06 14:58:11 2006 +0000
@@ -5,6 +5,9 @@
 #include "noteobj.h"
 #include "headingobj.h"
 #include "flagrowobj.h"
+//Added by qt3to4:
+#include <Q3PointArray>
+#include <Q3PtrList>
 
 #define MAX_DEPTH 999
 
@@ -23,7 +26,7 @@
 	Q_OBJECT
 public:
     LinkableMapObj ();
-    LinkableMapObj (QCanvas*);
+    LinkableMapObj (Q3Canvas*);
     LinkableMapObj (LinkableMapObj*);
     ~LinkableMapObj ();
 	virtual void delLink();
@@ -33,9 +36,22 @@
     virtual void setParObj (LinkableMapObj*);
     virtual void setParObjTmp (LinkableMapObj*,QPoint,int);	// Only for moving Obj around
 	virtual void unsetParObjTmp();						// reuse original ParObj
+	virtual bool hasParObjTmp();
+
+	virtual void setUseRelPos (const bool&);
+	virtual void setRelPos();				// set relPos to current parentPos
+	virtual void setRelPos(const QPoint&);	
+	virtual void setUseOrientation (const bool &);
+
+
+	virtual int getTopPad();
+	virtual int getLeftPad();
+	virtual int getRightPad();
 	LinkStyle getDefLinkStyle();
     void setLinkStyle(LinkStyle);            
 	LinkStyle getLinkStyle();
+	void setHideLinkUnselected(bool);
+	bool getHideLinkUnselected();
 	void setLinkPos (LinkPos);
 	LinkPos getLinkPos ();
 
@@ -51,6 +67,8 @@
 											// redraw link with given style
     LinkableMapObj* getChildObj();			// returns pointer to fromObj
     LinkableMapObj* getParObj();			// returns pointer to toObj
+    virtual LinkableMapObj* findObjBySelect(QString s);	// find obj by selectstring
+	virtual void setDockPos();				// sets childPos and parPos
     QPoint getChildPos();					// returns pos where childs dock
     QPoint getParPos();						// returns pos where parents dock
     QPoint getRelPos();						// get position relative to parent (or (0,0))
@@ -75,9 +93,12 @@
     virtual void select();
     virtual void unselect();
 	virtual	QString getSelectString()=0;
+	virtual QString saveToDir (const QString&,const QString&, const QPoint&)=0;// Save data to tempdir
 
 protected:
-	void parabel(QPointArray &,double,double,double,double);	// Create Parabel connecting two points
+	void parabel(Q3PointArray &,double,double,double,double);	// Create Parabel connecting two points
+	QString getLinkAttr();
+
     QPoint childPos;
     QPoint parPos;
 	bool link2ParPos;				// While moving around, sometimes link to parent
@@ -90,24 +111,31 @@
     LinkableMapObj* childObj;
     LinkableMapObj* parObj;
     LinkableMapObj* parObjTmpBuf;	// temporary buffer the original parent
-    int offset;                     // vertical offset of dockpos to pos
+    int bottomlineY;                // vertical offset of dockpos to pos
 
 	int thickness_start;			// for StylePoly*	
-    LinkStyle style;
-	LinkPos linkpos;
+    LinkStyle style;				// Current style
+	LinkPos linkpos;				// Link at bottom of object or middle of height
     QColor linkcolor;               // Link color
-    QCanvasLine* l;                 // line style
-	QCanvasPolygon* p;				// poly styles
+    Q3CanvasLine* l;                 // line style
+	Q3CanvasPolygon* p;				// poly styles
     int arcsegs;                    // arc: number of segments
-    QPtrList <QCanvasLine> segment; // a part of e.g. the parabel
-	QPointArray pa0;				// For drawing of PolyParabel and PolyLine
-	QPointArray pa1;				// For drawing of PolyParabel 
-	QPointArray pa2;				// For drawing of PolyParabel	
-    QCanvasLine* bottomline;        // on bottom of BBox
+    Q3PtrList <Q3CanvasLine> segment; // a part of e.g. the parabel
+	Q3PointArray pa0;				// For drawing of PolyParabel and PolyLine
+	Q3PointArray pa1;				// For drawing of PolyParabel 
+	Q3PointArray pa2;				// For drawing of PolyParabel	
+    Q3CanvasLine* bottomline;        // on bottom of BBox
 	bool repositionRequest;			// 
 
 	bool selected;					// Used for marking the selection
-	QCanvasRectangle* selbox;
+	bool hideLinkUnselected;		// to hide links if unselected
+	Q3CanvasRectangle* selbox;
 	FrameObj *frame;				// frame around object
+	int topPad, botPad,
+		leftPad, rightPad;          // padding within bbox
+
+	QPoint relPos;					// position relative to childPos of parent
+	bool useRelPos;
+	bool useOrientation;
 };
 #endif
diff -r 9eb7767c2dfa -r 608f976aa7bb main.cpp
--- a/main.cpp	Sun Jan 30 12:58:47 2005 +0000
+++ b/main.cpp	Tue Jun 06 14:58:11 2006 +0000
@@ -1,14 +1,19 @@
 #include <qapplication.h>
 #include <qpixmap.h>
 #include <qtranslator.h>
+#include <qdir.h>
+#include <q3ptrlist.h>
+#include <qtextcodec.h>
+#include <q3network.h>
+#include <qmime.h>
+//Added by qt3to4:
+#include <Q3PopupMenu>
+#include <Q3ActionGroup>
 
 #include "settings.h"
 #include "options.h"
 #include "mainwindow.h"
 
-#include "icons/vym-48x48.xpm"
-#include "icons/vym-editor.xpm"
-
 #include "flagrowobj.h"
 
 // Global variables
@@ -16,14 +21,24 @@
 								// initialized in mainwindow
 
 Main *mainWindow;				// used in BranchObj::select()								
-MapEditor *clipboardME;			
+QString tmpVymDir;				// All temp files go there, created in mainwindow
+QString clipboardDir;			// Clipboard used in all mapEditors
+QDir vymBaseDir;				// Containing all styles, scripts, images, ...
+QString iconPath;				// Pointing to icons used for toolbars
+QString flagsPath;				// Pointing to flags
+bool clipboardEmpty;			
 FlagRowObj *systemFlagsDefault;	// used to copy from in LinkableMapObj
 FlagRowObj *standardFlagsDefault;
 
+// Lists of actions
+// (QActionGroup could not be "enabled")
+Q3PtrList <QAction> actionListBranches;
+
 // Actions which change sometimes
 QAction *actionFileSave;
 QAction *actionFilePrint;
 QAction *actionEditUndo;
+QAction *actionEditRedo;
 QAction *actionEditCopy;
 QAction *actionEditCut;
 QAction *actionEditPaste;
@@ -31,25 +46,30 @@
 QAction *actionEditMoveDown;
 QAction *actionEditToggleScroll;
 QAction *actionEditOpenURL;
+QAction *actionEditOpenURLTab;
 QAction *actionEditURL;
 QAction *actionEditHeading2URL;
 QAction *actionEditBugzilla2URL;
+QAction *actionEditFATE2URL;
 QAction *actionEditOpenVymLink;
 QAction *actionEditVymLink;
+QAction *actionEditToggleHideExport;
 QAction *actionEditDeleteVymLink;
 QAction *actionEditMapInfo;
 QAction *actionEditHeading;
 QAction *actionEditDelete;
 QAction *actionEditAddBranch;
+QAction *actionEditAddBranchHere;
 QAction *actionEditAddBranchAbove;
 QAction *actionEditAddBranchBelow;
+QAction *actionEditRemoveBranchKeepChilds;
+QAction *actionEditRemoveChilds;
 QAction *actionEditImportAdd;
 QAction *actionEditImportReplace;
 QAction *actionEditSaveBranch;
 QAction *actionEditSelectFirst;
 QAction *actionEditSelectLast;
 QAction *actionEditLoadImage;
-QAction *actionEditToggleFloatExport;
 
 QAction *actionFormatColor;		
 QAction *actionFormatPickColor;		
@@ -59,31 +79,47 @@
 QAction *actionFormatLinkColorHint;
 QAction *actionFormatLinkColor;		
 
-QActionGroup *actionGroupFormatFrameTypes;
+Q3ActionGroup *actionGroupModModes;
+QAction *actionModModeColor;
+QAction *actionModModeLink;
+QAction *actionModModeCopy;
+
+Q3ActionGroup *actionGroupFormatFrameTypes;
 QAction *actionFormatFrameNone;
 QAction *actionFormatFrameRectangle;
 
-QActionGroup *actionGroupFormatLinkStyles;
+Q3ActionGroup *actionGroupFormatLinkStyles;
+QAction *actionFormatIncludeImagesVer;
+QAction *actionFormatIncludeImagesHor;
+QAction *actionFormatHideLinkUnselected;
 QAction *actionFormatLinkStyleLine;
 QAction *actionFormatLinkStyleParabel;
 QAction *actionFormatLinkStylePolyLine;
 QAction *actionFormatLinkStylePolyParabel;
 
 QAction *actionViewToggleNoteEditor;
+QAction *actionViewToggleHistoryWindow;
 
 QAction *actionSettingsAutoselectHeading;
 QAction *actionSettingsAutoselectText;
 QAction *actionSettingsPasteNewHeading;
 QAction *actionSettingsAutoedit;
 QAction *actionSettingsUseDelKey;
+QAction *actionSettingsUseFlagGroups;
+QAction *actionSettingsUseHideExport;
 
-QPopupMenu *branchContextMenu;
-QPopupMenu *floatimageContextMenu;
-QPopupMenu *saveImageFormatMenu;
-QPopupMenu *canvasContextMenu;
-QPopupMenu *lastMapsMenu;
-QPopupMenu *exportMenu;
-QPopupMenu *exportImageFormatMenu;
+Q3PopupMenu *branchContextMenu;
+Q3PopupMenu *branchAddContextMenu;
+Q3PopupMenu *branchRemoveContextMenu;
+Q3PopupMenu *branchLinksContextMenu;
+Q3PopupMenu *branchLinksContextMenuDup;
+Q3PopupMenu *floatimageContextMenu;
+Q3PopupMenu *saveImageFormatMenu;
+Q3PopupMenu *canvasContextMenu;
+Q3PopupMenu *lastMapsMenu;
+Q3PopupMenu *importMenu;
+Q3PopupMenu *exportMenu;
+Q3PopupMenu *exportImageFormatMenu;
 
 
 Settings settings;
@@ -96,19 +132,9 @@
     QApplication app(argc,argv);
 
 
-	// Initialize translations
-	QTranslator translator (0);
-	translator.load( "vym_de", "." );
-    app.installTranslator( &translator );
-
-	// Initializing the row of system flags
-	// is done in first call to MapEditor(),
-	// because we need at least one canvas first
-	systemFlagsDefault=NULL;
-	standardFlagsDefault=NULL;
-
 	// Reading and initializing options commandline options
 	options.add ("version", SwitchOption, "v","version");
+	options.add ("local", SwitchOption, "l", "local");
 	options.add ("help", SwitchOption, "h", "help");
 	options.add ("quit", SwitchOption, "q", "quit");
 	options.add ("test", StringOption, "t", "test");
@@ -121,45 +147,82 @@
 		"http://www.InSilmaril.de/vym\n");
 	if (options.parse())
 	{
-		cout << endl << options.getHelpText()<<endl;
+//FIXME QT3		cout << endl << options.getHelpText()<<endl;
 		return 1;
 	}
 
 	if (options.isOn ("version"))
 	{
-		cout << "vym version "<<__VYM_VERSION__
+		cout << "vym version "<<__VYM_VERSION
 			<<"  (c) 2004 Uwe Drechsel - "
-			<<__BUILD_DATE__<<endl;
+			<<__BUILD_DATE<<endl;
 			
 		return 0;	
 	}		
 	
+	// Use /usr/share/vym or /usr/local/share/vym or . ?
+	// First try options
+	if (options.isOn ("local"))
+	{
+		vymBaseDir.setPath (vymBaseDir.currentDirPath());
+	} else
+	// then look for environment variable
+	if (getenv("VYMHOME")!=0)
+	{
+		vymBaseDir.setPath (getenv("VYMHOME"));
+	} else
+	// ok, let's find my way on my own
+	{
+		vymBaseDir.setPath ("/usr/share/vym");
+		if (!vymBaseDir.exists())
+		{
+			vymBaseDir.setPath ("/usr/local/share/vym");
+			if (!vymBaseDir.exists())
+				vymBaseDir.setPath(vymBaseDir.currentDirPath() );
+		}		
+	}
+
+	iconPath=vymBaseDir.path()+"/icons/";
+	flagsPath=vymBaseDir.path()+"/flags/";
+
 	if (options.isOn ("help"))
 	{
-		cout << options.getHelpText()<<endl;
+//FIXME QT3 		cout << options.getHelpText()<<endl;
 		return 0;	
 	}	
 
 	if (options.isOn ("test"))
 	{
 		// FIXME testing string option only
-		cout << "Testing: "<<options.getArg("test")<< endl;
+//FIXME QT3		cout << "Testing: "<<options.getArg("test")<< endl;
 	}	
 
+
+    Q3MimeSourceFactory *factory = Q3MimeSourceFactory::defaultFactory();
+    factory->setPixmap("vym-128x128", QPixmap(iconPath+"vym-128x128.png"));
+    q3InitNetworkProtocols();
+
+
+	// Initialize translations
+	QTranslator translator (0);
+	translator.load( QString("vym_")+QTextCodec::locale(), vymBaseDir.path() + "/lang");
+    app.installTranslator( &translator );
+
+	// Initializing the row of system flags
+	// is done in first call to MapEditor(),
+	// because we need at least one canvas first
+	systemFlagsDefault=NULL;
+	standardFlagsDefault=NULL;
+
 	// Initialize window of TextEditor
 	textEditor = new TextEditor();
-	textEditor->setIcon (QPixmap (vym_editor_xpm));
+	textEditor->setIcon (QPixmap (iconPath+"vym-editor.png"));
 	if (textEditor->showWithMain()) textEditor->show();
 
-	clipboardME = new MapEditor();
-	clipboardME->resize (800,600);
-	clipboardME->setCaption("VYM - clipboard");
-	clipboardME->hide();
-
-	// Initialize mainwindow after Mapeditors (because of Flags)
+	// Initialize mainwindow 
     Main m;
 	//m.resize(m.sizeHint());
-	m.setIcon (QPixmap (vym_logo_xpm));
+	m.setIcon (QPixmap (iconPath+"vym-48x48.png"));
 	m.show();
 	m.fileNew();
 	m.loadCmdLine();
diff -r 9eb7767c2dfa -r 608f976aa7bb mainwindow.cpp
--- a/mainwindow.cpp	Sun Jan 30 12:58:47 2005 +0000
+++ b/mainwindow.cpp	Tue Jun 06 14:58:11 2006 +0000
@@ -7,61 +7,58 @@
 #include <qpainter.h>
 #include <qprinter.h>
 #include <qfile.h>
-#include <qfiledialog.h>
+#include <q3filedialog.h>
 #include <qcolor.h>
 #include <qcolordialog.h>
 #include <qbitmap.h>
 #include <qinputdialog.h>
+//Added by qt3to4:
+#include <Q3StrList>
+#include <QPixmap>
+#include <QCloseEvent>
+#include <QShowEvent>
+#include <QHideEvent>
+#include <Q3PopupMenu>
+#include <Q3ActionGroup>
+#include <Q3PtrList>
+//#include <qdatetime.h>			// for random seed
 
 
 #include <iostream>
-#include <stdlib.h>
+#include <cstdlib>
 #include <typeinfo>
 
-#include "version.h"
-
-#include "icons/filenew.xpm"
-#include "icons/fileopen.xpm"
-#include "icons/filesave.xpm"
-#include "icons/fileprint.xpm"
-#include "icons/editundo.xpm"
-//#include "icons/editredo.xpm"	// TODO
-#include "icons/editcopy.xpm"
-#include "icons/editcut.xpm"
-#include "icons/editpaste.xpm"
-#include "icons/editmoveup.xpm"
-#include "icons/editmovedown.xpm"
-#include "icons/formatcoloritem.xpm"
-#include "icons/formatcolorbranch.xpm"
-#include "icons/formatcolorpicker.xpm"
-#include "icons/viewzoomreset.xpm"
-#include "icons/viewzoomin.xpm"
-#include "icons/viewzoomout.xpm"
-#include "icons/vym-48x48.xpm"
-#include "icons/flag-note.xpm"
-#include "icons/flag-url.xpm"
-#include "icons/flag-vymlink.xpm"	
-#include "icons/flag-scrolled-right.xpm"
-
+#include "aboutdialog.h"
+#include "exportoofiledialog.h"
+#include "exports.h"
+#include "exportxhtmldialog.h"
+#include "file.h"
 #include "flagrowobj.h"
-#include "texteditor.h"
+#include "imports.h"
 #include "mapeditor.h"
-#include "exporthtmldialog.h"
-#include "exportxhtmldialog.h"
-#include "showtextdialog.h"
+#include "misc.h"
+#include "options.h"
 #include "process.h"
 #include "settings.h"
-#include "options.h"
+#include "showtextdialog.h"
+#include "texteditor.h"
+#include "version.h"
 
 extern TextEditor *textEditor;
 extern Main *mainWindow;
+extern QString tmpVymDir;
+extern QString clipboardDir;
+extern bool clipboardEmpty;
 extern int statusbarTime;
-extern MapEditor *clipboardME;
 extern FlagRowObj* standardFlagsDefault;
+extern FlagRowObj* systemFlagsDefault;
+
+extern Q3PtrList <QAction> actionListBranches;
 
 extern QAction* actionFileSave;
 extern QAction* actionFilePrint;
 extern QAction* actionEditUndo;
+extern QAction* actionEditRedo;
 extern QAction *actionEditCopy;
 extern QAction *actionEditCut;
 extern QAction *actionEditPaste;
@@ -69,25 +66,30 @@
 extern QAction *actionEditMoveDown;
 extern QAction *actionEditToggleScroll;
 extern QAction* actionEditOpenURL;
+extern QAction* actionEditOpenURLTab;
 extern QAction* actionEditURL;
 extern QAction* actionEditHeading2URL;
 extern QAction* actionEditBugzilla2URL;
+extern QAction* actionEditFATE2URL;
 extern QAction *actionEditOpenVymLink;
 extern QAction *actionEditVymLink;
 extern QAction *actionEditDeleteVymLink;
+extern QAction *actionEditToggleHideExport;
 extern QAction *actionEditMapInfo;
 extern QAction *actionEditHeading;
 extern QAction *actionEditDelete;
 extern QAction *actionEditAddBranch;
+extern QAction *actionEditAddBranchHere;
 extern QAction *actionEditAddBranchAbove;
 extern QAction *actionEditAddBranchBelow;
+extern QAction *actionEditRemoveBranchKeepChilds;
+extern QAction *actionEditRemoveChilds;
 extern QAction *actionEditImportAdd;
 extern QAction *actionEditImportReplace;
 extern QAction *actionEditSaveBranch;
 extern QAction *actionEditSelectFirst;
 extern QAction *actionEditSelectLast;
 extern QAction *actionEditLoadImage;
-extern QAction *actionEditToggleFloatExport;
 
 extern QAction* actionFormatColor;
 extern QAction* actionFormatPickColor;
@@ -96,18 +98,27 @@
 extern QAction* actionFormatLinkColorHint;
 extern QAction* actionFormatBackColor;
 extern QAction* actionFormatLinkColor;
+extern QAction *actionFormatIncludeImagesVer;
+extern QAction *actionFormatIncludeImagesHor;
 
-extern QActionGroup *actionGroupFormatFrameTypes;
+extern Q3ActionGroup* actionGroupModModes;
+extern QAction* actionModModeColor;
+extern QAction* actionModModeLink;
+extern QAction* actionModModeCopy;
+
+extern Q3ActionGroup *actionGroupFormatFrameTypes;
 extern QAction *actionFormatFrameNone;
 extern QAction *actionFormatFrameRectangle;
 
-extern QActionGroup *actionGroupFormatLinkStyles;
+extern Q3ActionGroup *actionGroupFormatLinkStyles;
 extern QAction *actionFormatLinkStyleLine;
 extern QAction *actionFormatLinkStyleParabel;
 extern QAction *actionFormatLinkStylePolyLine;
 extern QAction *actionFormatLinkStylePolyParabel;
+extern QAction *actionFormatHideLinkUnselected;
 
 extern QAction *actionViewToggleNoteEditor;
+extern QAction *actionViewToggleHistoryWindow;
 
 extern QAction* actionSettingsAutoedit;
 extern QAction* actionSettingsAutoselectHeading;
@@ -115,25 +126,31 @@
 extern QAction* actionSettingsAutoselectText;
 extern QAction* actionSettingsPasteNewHeading;
 extern QAction* actionSettingsUseDelKey;
+extern QAction* actionSettingsUseFlagGroups;
+extern QAction* actionSettingsUseHideExport;
 
-extern QPopupMenu* branchContextMenu;
-extern QPopupMenu* floatimageContextMenu;
-extern QPopupMenu* saveImageFormatMenu;
-extern QPopupMenu* canvasContextMenu;
-extern QPopupMenu* lastMapsMenu;
-extern QPopupMenu* exportMenu;
-extern QPopupMenu* exportImageFormatMenu;
+extern Q3PopupMenu* branchContextMenu;
+extern Q3PopupMenu* branchAddContextMenu;
+extern Q3PopupMenu* branchRemoveContextMenu;
+extern Q3PopupMenu* branchLinksContextMenu;
+extern Q3PopupMenu* branchLinksContextMenuDup;
+extern Q3PopupMenu* floatimageContextMenu;
+extern Q3PopupMenu* saveImageFormatMenu;
+extern Q3PopupMenu* canvasContextMenu;
+extern Q3PopupMenu* lastMapsMenu;
+extern Q3PopupMenu* importMenu;
+extern Q3PopupMenu* exportMenu;
+extern Q3PopupMenu* exportImageFormatMenu;
 
 
 extern Settings settings;
 extern Options options;
+extern QDir vymBaseDir;
+extern QString iconPath;
+extern QString flagsPath;
 
-#if defined(Q_OS_LINUX)
-extern void qt_wait_for_window_manager( QWidget* w );
-#endif
-
-Main::Main(QWidget* parent, const char* name, WFlags f) :
-    QMainWindow(parent,name,f)
+Main::Main(QWidget* parent, const char* name, Qt::WFlags f) :
+    Q3MainWindow(parent,name,f)
 {
 	mainWindow=this;
 
@@ -146,6 +163,24 @@
 	        settings.readNumEntry( "/vym/mainwindow/geometry/posY", 100));
 
 
+	// Create unique temporary directory
+	tmpVymDir=makeUniqueDir ("/tmp/vym-XXXXXX");
+
+	// Create direcctory for clipboard
+	clipboardDir=tmpVymDir+"/clipboard";
+	QDir d(clipboardDir);
+	d.mkdir (clipboardDir,true);
+	makeSubDirs (clipboardDir);
+	clipboardEmpty=true;
+
+	procBrowser=NULL;
+
+	// FIXME not used currently
+	// Set random seed (random used for object IDs)
+    // QTime t = QTime::currentTime();		// set random seed
+    // srand( t.hour()*12+t.minute()*60+t.second()*60 );
+
+
 	// Initialize some settings, which are platform dependant
 	QString p,s;
 
@@ -155,7 +190,7 @@
 			s=settings.readEntry (p,"konqueror");
 		#else
 			#if defined(Q_OS_MACX)
-				s=settings.readEntry (p,"/Applications/Safari.app/Contents/MacOS/Safari");
+				s=settings.readEntry (p,"/usr/bin/open");
 			#else
 				s=settings.readEntry (p,"mozilla");
 			#endif
@@ -168,7 +203,7 @@
 			s=settings.readEntry (p,"acroread");
 		#else
 			#if defined(Q_OS_MACX)
-				s=settings.readEntry (p,"/Applications/Safari.app/Contents/MacOS/Safari");
+				s=settings.readEntry (p,"/usr/bin/open");
 			#else
 				s=settings.readEntry (p,"acroread");
 			#endif
@@ -189,6 +224,7 @@
     setupEditActions();
     setupFormatActions();
     setupViewActions();
+    setupModeActions();
 	setupFlagActions();
     setupSettingsActions();
 	setupContextMenus();
@@ -200,10 +236,6 @@
 
     statusBar();
 
-	// Create the default map into first tab
-//	fileNew();
-//	tabWidget->addTab (new MapEditor(tabWidget,true), "unnamed");
-//	currentMapEditor()->show();
 
 	// Initialize Find window
 	findWindow=new FindWindow(NULL,"findwindow");
@@ -212,6 +244,9 @@
 	connect (findWindow, SIGNAL( somethingChanged() ), 
 		this, SLOT(editFindChanged() ) );	
 
+	// Connect TextEditor, so that we can update flags if text changes
+	connect (textEditor, SIGNAL (textHasChanged() ), this, SLOT (updateNoteFlag()));
+
 	updateGeometry();
 }
 
@@ -223,29 +258,33 @@
 	settings.writeEntry( "/vym/mainwindow/geometry/posX", pos().x() );
 	settings.writeEntry( "/vym/mainwindow/geometry/posY", pos().y() );
 
-	settings.writeEntry( "/vym/version/version", __VYM_VERSION__ );
-	settings.writeEntry( "/vym/version/builddate", __BUILD_DATE__ );
+	settings.writeEntry( "/vym/version/version", __VYM_VERSION );
+	settings.writeEntry( "/vym/version/builddate", __BUILD_DATE );
 
 	settings.writeEntry( "/vym/mapeditor/editmode/autoselectheading",actionSettingsAutoselectHeading->isOn() );
 	settings.writeEntry( "/vym/mapeditor/editmode/autoselecttext",actionSettingsAutoselectText->isOn() );
 	settings.writeEntry( "/vym/mapeditor/editmode/pastenewheading",actionSettingsPasteNewHeading->isOn() );
 	settings.writeEntry( "/vym/mapeditor/editmode/autoedit",actionSettingsAutoedit->isOn() );
 	settings.writeEntry( "/vym/mapeditor/editmode/useDelKey",actionSettingsUseDelKey->isOn() );
+	settings.writeEntry( "/vym/mapeditor/editmode/useFlagGroups",actionSettingsUseFlagGroups->isOn() );
+	settings.writeEntry( "/vym/export/useHideExport",actionSettingsUseHideExport->isOn() );
 
 	QString s;
 	int maps=lastMaps.count();
 	settings.writeEntry( "/vym/lastMaps/number",maps );
 	for (int i=1;i<=maps;i++)
 	{
-		QStringList::Iterator it = lastMaps.at(i-1);
 		s=QString("/vym/lastMaps/map-%1").arg(i);
 		if (!s.isEmpty() && i<=maxLastMaps) 
-			settings.writeEntry (s, *it);
+			settings.writeEntry (s, lastMaps.at(i-1));
 	}
 
 
 	// To make the texteditor save its settings, call the destructor
 	delete (textEditor);
+
+	// Remove temporary directory
+	removeDir (QDir(tmpVymDir));
 }
 
 void Main::loadCmdLine()
@@ -280,385 +319,622 @@
 // File Actions
 void Main::setupFileActions()
 {
-    QToolBar *tb = new QToolBar( this );
+    Q3ToolBar *tb = new Q3ToolBar( this );
     tb->setLabel( "File Actions" );
-    QPopupMenu *menu = new QPopupMenu( this );
+    Q3PopupMenu *menu = new Q3PopupMenu( this );
     menuBar()->insertItem( tr( "&File" ), menu );
 
 	// Keycodes:  /usr/lib64/qt3/include/qnamespace.h
 
     QAction *a;
-    a = new QAction( tr( "New map" ), QPixmap( filenew_xpm ), tr( "&New..." ), CTRL + Key_N, this, "fileNew" );
-    connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
+    a = new QAction(QPixmap( iconPath+"filenew.png"), tr( "&New..." ),this);
+	a->setStatusTip ( tr( "New map","File menu" ) );
+	a->setShortcut ( Qt::CTRL + Qt::Key_N );
     a->addTo( tb );
     a->addTo( menu );
+    connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
 	
-    a = new QAction( tr( "Open" ), QPixmap( fileopen_xpm), tr( "&Open..." ), CTRL + Key_O, this, "fileOpen" );
-    connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
+    a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Open..." ),this);
+	a->setStatusTip (tr( "Open","File menu" ) );
+	a->setShortcut ( Qt::CTRL + Qt::Key_O );
     a->addTo( tb );
     a->addTo( menu );
+    connect( a, SIGNAL( activated() ), this, SLOT( fileLoad() ) );
 	
-	lastMapsMenu = new QPopupMenu (this);
+	lastMapsMenu = new Q3PopupMenu (this);
 
     menu->insertItem (tr("Open Recent"),lastMapsMenu );
     menu->insertSeparator();
 	
-    a = new QAction( tr( "Save" ), QPixmap( filesave_xpm ), tr( "&Save..." ), CTRL + Key_S, this, "fileSave" );
-    connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
+    a = new QAction( QPixmap( iconPath+"filesave.png"), tr( "&Save..." ), this);
+	a->setStatusTip ( tr( "Save" ));
+	a->setShortcut (Qt::CTRL + Qt::Key_S );
     a->addTo( tb );
     a->addTo( menu );
+    connect( a, SIGNAL( activated() ), this, SLOT( fileSave() ) );
 	actionFileSave=a;
 	
-    a = new QAction( tr( "Save &As" ), QPixmap(), tr( "Save &As..." ), 0, this, "fileSaveAs" );
+    a = new QAction( QPixmap(iconPath+"filesaveas.png"), tr( "Save &As..." ), this);
+	a->setStatusTip (tr( "Save &As" ) );
+    a->addTo( menu );
     connect( a, SIGNAL( activated() ), this, SLOT( fileSaveAs() ) );
-    a->addTo( menu );
 
     menu->insertSeparator();
 
-    a = new QAction( tr( "Import directory structure (experimental)" ), QPixmap(), tr( "Import Dir" ), 0, this, "export" );
+	importMenu = new Q3PopupMenu (this);
+    menu->insertItem (tr("Import"),importMenu );
+
+	a = new QAction(tr("KDE Bookmarks"), this);
+	a->setStatusTip ( tr( "Import")+" "+tr("KDE Bookmarks" ));
+	a->addTo (importMenu);
+	connect( a, SIGNAL( activated() ), this, SLOT( fileImportKDEBookmarks() ) );
+
+    if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) 
+	{
+		a = new QAction( QPixmap(), tr("Firefox Bookmarks"),this);
+		a->setStatusTip (tr( "Import")+" "+tr("Firefox Bookmarks" ) );
+		a->addTo (importMenu);
+		connect( a, SIGNAL( activated() ), this, SLOT( fileImportFirefoxBookmarks() ) );
+	}	
+
+	a = new QAction("Mind Manager...",this);
+	a->setStatusTip ( tr( "Import")+" Mind Manager"  );
+	a->addTo (importMenu);
+	connect( a, SIGNAL( activated() ), this, SLOT( fileImportMM() ) );
+
+    a = new QAction( tr( "Import Dir"+QString("...") ), this);
+	a->setStatusTip (tr( "Import directory structure (experimental)" ) );
+    a->addTo( importMenu);
     connect( a, SIGNAL( activated() ), this, SLOT( fileImportDir() ) );
-    a->addTo( menu );
 
-	exportMenu = new QPopupMenu (this);
+	exportMenu = new Q3PopupMenu (this);
     menu->insertItem (tr("Export"),exportMenu );
 
     menu->insertSeparator();
 
 
-    a = new QAction( tr( "Print" ), QPixmap( fileprint_xpm ), tr( "&Print..." ), CTRL + Key_P, this, "filePrint" );
-    connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
+    a = new QAction(QPixmap( iconPath+"fileprint.png"), tr( "&Print")+QString("..."), this);
+	a->setStatusTip ( tr( "Print" ) );
+	a->setShortcut (Qt::CTRL + Qt::Key_P );
     a->addTo( tb );
     a->addTo( menu );
+    connect( a, SIGNAL( activated() ), this, SLOT( filePrint() ) );
 	actionFilePrint=a;
 
-    a = new QAction( tr( "Close Map" ), QPixmap(), tr( "&Close Map" ), ALT + Key_C, this, "fileCloseMap" );
+    a = new QAction( QPixmap(iconPath+"fileclose.png"), tr( "&Close Map" ), this);
+	a->setStatusTip (tr( "Close Map" ) );
+	a->setShortcut (Qt::ALT + Qt::Key_C );
+    a->addTo( menu );
     connect( a, SIGNAL( activated() ), this, SLOT( fileCloseMap() ) );
+
+    a = new QAction(QPixmap(iconPath+"exit.png"), tr( "E&xit")+" "+__VYM, this);
+	a->setStatusTip ( tr( "Exit")+" "+__VYM );
+	a->setShortcut (Qt::CTRL + Qt::Key_Q );
     a->addTo( menu );
-
-    a = new QAction( tr( "Exit VYM" ), QPixmap(), tr( "E&xit VYM" ), CTRL + Key_Q, this, "fileExitVYM" );
     connect( a, SIGNAL( activated() ), this, SLOT( fileExitVYM() ) );
-    a->addTo( menu );
 }
 
 
 //Edit Actions
 void Main::setupEditActions()
 {
-    QToolBar *tb = new QToolBar( this );
+    Q3ToolBar *tb = new Q3ToolBar( this );
     tb->setLabel( "Edit Actions" );
-    QPopupMenu *menu = new QPopupMenu( this );
+    Q3PopupMenu *menu = new Q3PopupMenu( this );
     menuBar()->insertItem( tr( "&Edit" ), menu );
 
     QAction *a;
-    a = new QAction( tr( "Undo" ), QPixmap( editundo_xpm ), tr( "&Undo" ), CTRL + Key_Z, this, "editUndo" );
+	QAction *alt;
+    a = new QAction( QPixmap( iconPath+"undo.png"), tr( "&Undo" ),this);
     connect( a, SIGNAL( activated() ), this, SLOT( editUndo() ) );
+	a->setStatusTip (tr( "Undo" ) );
+	a->setShortcut ( Qt::CTRL + Qt::Key_Z );
 	a->setEnabled (false);
     a->addTo( tb );
     a->addTo( menu );
 	actionEditUndo=a;
-    /*
-    a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" ); 
-    connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
-    a->addTo( tb );
-    a->addTo( menu );
-    */
+    
+    if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) 
+	{
+		a = new QAction( QPixmap( iconPath+"redo.png"), tr( "&Redo" ), this); 
+		a->setStatusTip (tr( "Redo" ));
+		a->setShortcut (Qt::CTRL + Qt::Key_Y );
+		a->addTo( tb );
+		a->addTo( menu );
+		connect( a, SIGNAL( activated() ), this, SLOT( editRedo() ) );
+	}
+   
     menu->insertSeparator();
-    a = new QAction( tr( "Copy" ), QPixmap( editcopy_xpm ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
-    connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
+    a = new QAction(QPixmap( iconPath+"editcopy.png"), tr( "&Copy" ), this);
+	a->setStatusTip ( tr( "Copy" ) );
+	a->setShortcut (Qt::CTRL + Qt::Key_C );
 	a->setEnabled (false);
     a->addTo( tb );
     a->addTo( menu );
+    connect( a, SIGNAL( activated() ), this, SLOT( editCopy() ) );
 	actionEditCopy=a;
-    a = new QAction( tr( "Cut" ), QPixmap( editcut_xpm ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
-    connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
+	
+    a = new QAction(QPixmap( iconPath+"editcut.png" ), tr( "Cu&t" ), this);
+	a->setStatusTip ( tr( "Cut" ) );
+	a->setShortcut (Qt::CTRL + Qt::Key_X );
 	a->setEnabled (false);
     a->addTo( tb );
     a->addTo( menu );
 	actionEditCut=a;
-    a = new QAction( tr( "Paste" ), QPixmap( editpaste_xpm ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
+    connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
+	
+    a = new QAction(QPixmap( iconPath+"editpaste.png"), tr( "&Paste" ),this);
     connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
+	a->setStatusTip ( tr( "Paste" ) );
+	a->setShortcut ( Qt::CTRL + Qt::Key_V );
 	a->setEnabled (false);
     a->addTo( tb );
     a->addTo( menu );
 	actionEditPaste=a;
-    a = new QAction( tr( "Move branch up" ), QPixmap( editmoveup_xpm ), tr( "Move up" ), Key_PageUp, this, "editMoveUp" );
-    connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
+
+    a = new QAction(QPixmap(iconPath+"up.png" ), tr( "Move up" ), this);
+	a->setStatusTip ( tr( "Move branch up" ) );
+	a->setShortcut (Qt::Key_PageUp );
 	a->setEnabled (false);
     a->addTo( tb );
     a->addTo( menu );
+    connect( a, SIGNAL( activated() ), this, SLOT( editMoveUp() ) );
 	actionEditMoveUp=a;
-    a = new QAction( tr( "Move branch down" ), QPixmap( editmovedown_xpm ), tr( "Move down" ), Key_PageDown, this, "editMoveDown" );
+
+    a = new QAction( QPixmap( iconPath+"down.png"), tr( "Move down" ),this);
     connect( a, SIGNAL( activated() ), this, SLOT( editMoveDown() ) );
+	a->setStatusTip (tr( "Move branch down" ) );
+	a->setShortcut ( Qt::Key_PageDown );
 	a->setEnabled (false);
     a->addTo( tb );
     a->addTo( menu );
 	actionEditMoveDown=a;
+	
 
-    a = new QAction( tr( "Scroll branch" ), QPixmap(flag_scrolled_right_xpm), tr( "Scroll branch" ), Key_ScrollLock, this, "scroll" );
+	a = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ),this);
+	a->setShortcut ( Qt::Key_ScrollLock );
+	a->setStatusTip (tr( "Scroll branch" ) );
     connect( a, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
-	a->setEnabled (false);
-    a->addTo( tb );
+	alt = new QAction( QPixmap(flagsPath+"flag-scrolled-right.png"), tr( "Scroll branch" ), this);
+	alt->setShortcut ( Qt::Key_S );
+	alt->setStatusTip (tr( "Scroll branch" )); 
+    connect( alt, SIGNAL( activated() ), this, SLOT( editToggleScroll() ) );
+	#if defined(Q_OS_MACX)
+		actionEditToggleScroll=alt;
+	#else	
+		actionEditToggleScroll=a;
+	#endif	
+	actionEditToggleScroll->setEnabled (false);
+	actionEditToggleScroll->setToggleAction(true);
+    actionEditToggleScroll->addTo( tb );
+    actionEditToggleScroll->addTo( menu );
+	actionListBranches.append(actionEditToggleScroll);
+	
+    a = new QAction( tr( "Unscroll all scrolled branches" ), this);
+	a->setStatusTip (tr( "Unscroll all" ));
     a->addTo( menu );
-	actionEditToggleScroll=a;
-	
-    a = new QAction( tr( "Unscroll all" ), QPixmap(), tr( "Unscroll all scrolled branches" ), 0, this, "scroll" );
     connect( a, SIGNAL( activated() ), this, SLOT( editUnScrollAll() ) );
-    a->addTo( menu );
 	
     menu->insertSeparator();
 
-	a = new QAction( tr( "Find" ), QPixmap(), tr( "Find" ), CTRL + Key_F, this, "find" );
+	a = new QAction( QPixmap(iconPath+"find.png"), tr( "Find"+QString("...") ), this);
+	a->setStatusTip (tr( "Find" ) );
+	a->setShortcut (Qt::CTRL + Qt::Key_F );
+    a->addTo( menu );
     connect( a, SIGNAL( activated() ), this, SLOT( editOpenFindWindow() ) );
-    a->addTo( menu );
     
 	menu->insertSeparator();
 
-	a = new QAction( tr( "Open URL" ), QPixmap(flag_url_xpm), tr( "Open URL" ), CTRL + Key_U, this, "url" );
-    connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
-    a->addTo( menu );
+	a = new QAction( QPixmap(flagsPath+"flag-url.png"), tr( "Open URL" ), this);
+	a->setShortcut (Qt::CTRL + Qt::Key_U );
+	a->setShortcut (tr( "Open URL" ));
     a->addTo( tb );
 	a->setEnabled (false);
+    connect( a, SIGNAL( activated() ), this, SLOT( editOpenURL() ) );
 	actionEditOpenURL=a;
 
-	a = new QAction( tr( "Edit URL" ), QPixmap(), tr( "Edit URL" ), SHIFT + CTRL + Key_U, this, "url" );
+	a = new QAction( tr( "Open URL in new tab" ), this);
+	a->setStatusTip (tr( "Open URL in new tab" ));
+	a->setShortcut (Qt::CTRL+Qt::Key_U );
+	a->setEnabled (false);
+    connect( a, SIGNAL( activated() ), this, SLOT( editOpenURLTab() ) );
+	actionEditOpenURLTab=a;
+
+	a = new QAction(QPixmap(), tr( "Edit URL"+QString("...") ), this);
+	a->setStatusTip ( tr( "Edit URL" ) );
+	a->setShortcut (Qt::SHIFT + Qt::CTRL+Qt::Key_U );
+	a->setEnabled (false);
+	actionListBranches.append(a);
     connect( a, SIGNAL( activated() ), this, SLOT( editURL() ) );
-    a->addTo( menu );
-	a->setEnabled (false);
 	actionEditURL=a;
 	
-	a = new QAction( tr( "Use heading of selected branch as URL" ), QPixmap(), tr( "Use heading for URL" ), 0, this, "heading2url" );
+	a = new QAction( tr( "Use heading for URL" ), this);
+	a->setStatusTip ( tr( "Use heading of selected branch as URL" ));
+	a->setEnabled (false);
+	actionListBranches.append(a);
     connect( a, SIGNAL( activated() ), this, SLOT( editHeading2URL() ) );
-    a->addTo( menu );
-	a->setEnabled (false);
 	actionEditHeading2URL=a;
     
-	a = new QAction( tr( "Create URL to Bugzilla" ), QPixmap(), tr( "Create URL to Bugzilla" ), 0, this, "bugzilla2url" );
+	a = new QAction(tr( "Create URL to Bugzilla" ), this);
+	a->setStatusTip ( tr( "Create URL to Bugzilla" ));
+	a->setEnabled (false);
+	actionListBranches.append(a);
     connect( a, SIGNAL( activated() ), this, SLOT( editBugzilla2URL() ) );
-	a->setEnabled (false);
 	actionEditBugzilla2URL=a;
     
-	menu->insertSeparator();
+	a = new QAction(tr( "Create URL to FATE" ), this);
+	a->setStatusTip ( tr( "Create URL to FATE" ));
+	a->setEnabled (false);
+	actionListBranches.append(a);
+    connect( a, SIGNAL( activated() ), this, SLOT( editFATE2URL() ) );
+	actionEditFATE2URL=a;
 	
-    a = new QAction( tr( "Jump to another vym map, if needed load it first" ), QPixmap(flag_vymlink_xpm), tr( "Jump to map" ), 0, this, "jumpMap" );
-    connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
-    a->addTo( menu );
+    a = new QAction(QPixmap(flagsPath+"flag-vymlink.png"), tr( "Jump to map" ), this);
+	a->setStatusTip ( tr( "Jump to another vym map, if needed load it first" ));
     a->addTo( tb );
 	a->setEnabled (false);
+    connect( a, SIGNAL( activated() ), this, SLOT( editOpenVymLink() ) );
 	actionEditOpenVymLink=a;
 	
-    a = new QAction( tr( "Edit link to another vym map" ), QPixmap(), tr( "Edit vym link" ), 0, this, "editLinkMap" );
+    a = new QAction(tr( "Edit vym link"+QString("...") ), this);
+	a->setEnabled (false);
+	a->setStatusTip ( tr( "Edit link to another vym map" ));
     connect( a, SIGNAL( activated() ), this, SLOT( editVymLink() ) );
-    a->addTo( menu );
-	a->setEnabled (false);
+	actionListBranches.append(a);
 	actionEditVymLink=a;
 
-    a = new QAction( tr( "Delete link to another vym map" ), QPixmap(), tr( "Delete vym link" ), 0, this, "deleteLinkMap" );
+    a = new QAction(tr( "Delete vym link" ),this);
+	a->setStatusTip ( tr( "Delete link to another vym map" ));
+	a->setEnabled (false);
     connect( a, SIGNAL( activated() ), this, SLOT( editDeleteVymLink() ) );
-    a->addTo( menu );
-	a->setEnabled (false);
 	actionEditDeleteVymLink=a;
 
-	menu->insertSeparator();
+    a = new QAction(QPixmap(flagsPath+"flag-hideexport.png"), tr( "Hide in exports" ), this);
+	a->setStatusTip ( tr( "Hide object in exports" ) );
+	a->setShortcut (Qt::Key_H );
+	a->setToggleAction(true);
+    a->addTo( tb );
+	a->setEnabled (false);
+    connect( a, SIGNAL( activated() ), this, SLOT( editToggleHideExport() ) );
+	actionEditToggleHideExport=a;
 
-    a = new QAction( tr( "Edit Map Info" ), QPixmap(), tr( "Edit Map Info" ), 0, this, "editMapInfo" );
+    a = new QAction(tr( "Edit Map Info"+QString("...") ),this);
+	a->setStatusTip ( tr( "Edit Map Info" ));
+	a->setEnabled (true);
     connect( a, SIGNAL( activated() ), this, SLOT( editMapInfo() ) );
-    a->addTo( menu );
-	a->setEnabled (true);
 	actionEditMapInfo=a;
 
 	menu->insertSeparator();
 
     // Shortcuts to modify heading:
-    a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Enter, this, "editHeading" );
+    a = new QAction(tr( "Edit heading" ),this);
+	a->setStatusTip ( tr( "edit Heading" ));
+	a->setShortcut ( Qt::Key_Enter );
+    connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
+	actionListBranches.append(a);
+    a = new QAction( tr( "Edit heading" ), this);
+	a->setStatusTip (tr( "edit Heading" ));
+	a->setShortcut (Qt::Key_Return );
+    connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
+	actionListBranches.append(a);
+	actionEditHeading=a;
+    a = new QAction( tr( "Edit heading" ),this);
+	a->setStatusTip (tr( "edit Heading" ));
+	a->setShortcut ( Qt::Key_F2 );
     connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
 	a->setEnabled (false);
-    a->addTo ( menu );
 	actionEditHeading=a;
-    a = new QAction( tr( "edit Heading" ),tr( "Edit heading" ), Key_Return, this, "editHeading" );
-    connect( a, SIGNAL( activated() ), this, SLOT( editHeading() ) );
-    //a->addTo ( menu );
+	actionListBranches.append(a);
     
     // Shortcut to delete selection
-    a = new QAction( tr( "Delete Selection" ),tr( "Delete Selection" ), Key_Delete, this, "deleteBranch" );
+    a = new QAction( tr( "Delete Selection" ),this);
+	a->setStatusTip (tr( "Delete Selection" ));
+	a->setShortcut ( Qt::Key_Delete);
     connect( a, SIGNAL( activated() ), this, SLOT( editDeleteSelection() ) );
 	a->setEnabled (false);
-    a->addTo ( menu );
 	actionEditDelete=a;
     
     // Shortcut to add branch
+	alt = new QAction(tr( "Add branch as child" ), this);
+	alt->setStatusTip ( tr( "Add a branch as child of selection" ));
+	alt->setShortcut (Qt::Key_A);
+    connect( alt, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
+	a = new QAction(tr( "Add branch as child" ), this);
+	a->setStatusTip ( tr( "Add a branch as child of selection" ));
+	a->setShortcut (Qt::Key_Insert);	
+	a->setEnabled (false);
+    connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
+	actionListBranches.append(a);
 	#if defined (Q_OS_MACX)
-		a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), CTRL + Key_I, this, "newBranch" );
-	#else
-		a = new QAction( tr( "Add a branch as child of selection" ),tr( "Add branch as child" ), Key_Insert, this, "newBranch" );
-	#endif
-    connect( a, SIGNAL( activated() ), this, SLOT( editNewBranch() ) );
+		// In OSX show different shortcut in menues, the keys work independtly always			
+		actionEditAddBranch=alt;
+	#else	
+		actionEditAddBranch=a;
+	#endif	
+
+    // Add branch by inserting it at selection
+	a = new QAction(tr( "Add branch (insert)" ), this);
+	a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
+	a->setShortcut (Qt::ALT + Qt::Key_Insert );
+    connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
 	a->setEnabled (false);
-    a->addTo ( menu );
-	actionEditAddBranch=a;
+	actionListBranches.append(a);
+	actionEditAddBranchHere=a;
+	a = new QAction(tr( "Add branch (insert)" ),this);
+	a->setStatusTip ( tr( "Add a branch by inserting and making selection its child" ));
+	a->setShortcut ( Qt::ALT + Qt::Key_A );
+    connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchHere() ) );
+	actionListBranches.append(a);
 
 	// Add branch above
-    a = new QAction( tr( "Add a branch above selection" ),tr( "Add branch above" ), SHIFT+Key_Insert, this, "newBranch" );
+    a = new QAction(tr( "Add branch above" ), this);
+	a->setStatusTip ( tr( "Add a branch above selection" ));
+	a->setShortcut (Qt::SHIFT+Qt::Key_Insert );
     connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
 	a->setEnabled (false);
-    a->addTo ( menu );
+	actionListBranches.append(a);
 	actionEditAddBranchAbove=a;
+    a = new QAction(tr( "Add branch above" ), this);
+	a->setStatusTip ( tr( "Add a branch above selection" ));
+	a->setShortcut (Qt::SHIFT+Qt::Key_A );
+    connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchAbove() ) );
+	actionListBranches.append(a);
 
 	// Add branch below 
-    a = new QAction( tr( "Add a branch below selection" ),tr( "Add branch below" ), CTRL +Key_Insert, this, "newBranch" );
+    a = new QAction(tr( "Add branch below" ), this);
+	a->setStatusTip ( tr( "Add a branch below selection" ));
+	a->setShortcut (Qt::CTRL +Qt::Key_Insert );
     connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
 	a->setEnabled (false);
-    a->addTo ( menu );
+	actionListBranches.append(a);
 	actionEditAddBranchBelow=a;
+    a = new QAction(tr( "Add branch below" ), this);
+	a->setStatusTip ( tr( "Add a branch below selection" ));
+	a->setShortcut (Qt::CTRL +Qt::Key_A );
+    connect( a, SIGNAL( activated() ), this, SLOT( editNewBranchBelow() ) );
+	actionListBranches.append(a);
 
 	// Import at selection (adding to selection)
-    a = new QAction( tr( "Add map at selection" ),tr( "Import (add)" ), 0, this, "importAdd" );
+    a = new QAction( tr( "Add map (insert)" ),this);
+	a->setStatusTip (tr( "Add map at selection" ));
     connect( a, SIGNAL( activated() ), this, SLOT( editImportAdd() ) );
 	a->setEnabled (false);
-    a->addTo ( menu );
+	actionListBranches.append(a);
 	actionEditImportAdd=a;
 
 	// Import at selection (replacing selection)
-    a = new QAction( tr( "Replace selection with map" ),tr( "Import (replace)" ), 0, this, "importReplace" );
+    a = new QAction( tr( "Add map (replace)" ), this);
+	a->setStatusTip (tr( "Replace selection with map" ));
     connect( a, SIGNAL( activated() ), this, SLOT( editImportReplace() ) );
 	a->setEnabled (false);
-    a->addTo ( menu );
+	actionListBranches.append(a);
 	actionEditImportReplace=a;
 
 	// Save selection 
-    a = new QAction( tr( "Save selction" ),tr( "Save selection" ), 0, this, "saveSelection" );
+    a = new QAction( tr( "Save selection" ), this);
+	a->setStatusTip (tr( "Save selection" ));
     connect( a, SIGNAL( activated() ), this, SLOT( editSaveBranch() ) );
 	a->setEnabled (false);
-    a->addTo ( menu );
+	actionListBranches.append(a);
 	actionEditSaveBranch=a;
 
+	// Only remove branch, not its childs
+    a = new QAction(tr( "Remove only branch " ), this);
+	a->setStatusTip ( tr( "Remove only branch and keep its childs" ));
+	a->setShortcut (Qt::ALT + Qt::Key_Delete );
+    connect( a, SIGNAL( activated() ), this, SLOT( editRemoveBranchKeepChilds() ) );
+	a->setEnabled (false);
+	actionListBranches.append(a);
+	actionEditRemoveBranchKeepChilds=a;
+
+	// Only remove childs of a branch
+    a = new QAction( tr( "Remove childs" ), this);
+	a->setStatusTip (tr( "Remove childs of branch" ));
+	a->setShortcut (Qt::SHIFT + Qt::Key_Delete );
+    connect( a, SIGNAL( activated() ), this, SLOT( editRemoveChilds() ) );
+	a->setEnabled (false);
+	actionListBranches.append(a);
+	actionEditRemoveChilds=a;
+
     // Shortcuts for navigating with cursor:
-    a = new QAction( tr( "Select upper branch" ),tr( "Select upper branch" ), Key_Up, this, "upperBranch" );
+    a = new QAction(tr( "Select upper branch" ), this);
+	a->setStatusTip ( tr( "Select upper branch" ));
+	a->setShortcut (Qt::Key_Up );
     connect( a, SIGNAL( activated() ), this, SLOT( editUpperBranch() ) );
-    a = new QAction( tr( "Select lower branch" ),tr( "Select lower branch" ), Key_Down, this, "lowerBranch" );
+    a = new QAction( tr( "Select lower branch" ),this);
+	a->setStatusTip (tr( "Select lower branch" ));
+	a->setShortcut ( Qt::Key_Down );
     connect( a, SIGNAL( activated() ), this, SLOT( editLowerBranch() ) );
-    a = new QAction( tr( "Select left branch" ),tr( "Select left branch" ), Key_Left, this, "upperBranch" );
+    a = new QAction(tr( "Select left branch" ), this);
+	a->setStatusTip ( tr( "Select left branch" ));
+	a->setShortcut (Qt::Key_Left );
     connect( a, SIGNAL( activated() ), this, SLOT( editLeftBranch() ) );
-    a = new QAction( tr( "Select right branch" ),tr( "Select child branch" ), Key_Right, this, "rightBranch" );
+    a = new QAction( tr( "Select child branch" ), this);
+	a->setStatusTip (tr( "Select right branch" ));
+	a->setShortcut (Qt::Key_Right);
     connect( a, SIGNAL( activated() ), this, SLOT( editRightBranch() ) );
-    a = new QAction( tr( "Select first branch" ),tr( "Select first branch" ), Key_Home, this, "firstBranch" );
+    a = new QAction( tr( "Select first branch" ), this);
+	a->setStatusTip (tr( "Select first branch" ));
+	a->setShortcut (Qt::Key_Home );
 	a->setEnabled (false);
     a->addTo ( menu );
+	actionListBranches.append(a);
 	actionEditSelectFirst=a;
     connect( a, SIGNAL( activated() ), this, SLOT( editFirstBranch() ) );
-    a = new QAction( tr( "Select last branch" ),tr( "Select last branch" ), Key_End, this, "lastBranch" );
+    a = new QAction( tr( "Select last branch" ),this);
+	a->setStatusTip (tr( "Select last branch" ));
+	a->setShortcut ( Qt::Key_End );
     connect( a, SIGNAL( activated() ), this, SLOT( editLastBranch() ) );
 	a->setEnabled (false);
     a->addTo ( menu );
+	actionListBranches.append(a);
 	actionEditSelectLast=a;
 
-    a = new QAction( tr( "Add Image" ),tr( "Add Image" ), 0, this, "loadImage" );
+    a = new QAction( tr( "Add Image" )+QString("..."), this);
+	a->setStatusTip (tr( "Add Image" ));
     connect( a, SIGNAL( activated() ), this, SLOT( editLoadImage() ) );
 	actionEditLoadImage=a;
+
 }
 
 // Format Actions
 void Main::setupFormatActions()
 {
-    QPopupMenu *menu = new QPopupMenu( this );
-    menuBar()->insertItem( tr( "&Format" ), menu );
+    Q3PopupMenu *menu = new Q3PopupMenu( this );
+    menuBar()->insertItem( tr( "F&ormat" ), menu );
 
-    QToolBar *tb = new QToolBar( this );
+    Q3ToolBar *tb = new Q3ToolBar( this );
     QAction *a;
     QPixmap pix( 16,16);
-    pix.fill (black);
-    actionFormatColor= new QAction( tr( "Set Color" ), pix, tr( "Set &Color" ), 0, this, "formatColor" );
-    connect( actionFormatColor, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
-    actionFormatColor->addTo( tb );
-    actionFormatColor->addTo( menu );
-    a= new QAction( tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ), QPixmap(formatcolorpicker_xpm), tr( "Pic&k color" ), CTRL + Key_K, this, "pickColor" );
+    pix.fill (Qt::black);
+    a= new QAction(pix, tr( "Set &Color" )+QString("..."), this);
+	a->setStatusTip ( tr( "Set Color" ));
+    connect( a, SIGNAL( activated() ), this, SLOT( formatSelectColor() ) );
+    a->addTo( tb );
+    a->addTo( menu );
+	actionFormatColor=a;
+    a= new QAction( QPixmap(iconPath+"formatcolorpicker.png"), tr( "Pic&k color" ), this);
+	a->setStatusTip (tr( "Pick color\nHint: You can pick a color from another branch and color using CTRL+Left Button" ) );
+	a->setShortcut (Qt::CTRL + Qt::Key_K );
     connect( a, SIGNAL( activated() ), this, SLOT( formatPickColor() ) );
 	a->setEnabled (false);
     a->addTo( tb );
     a->addTo( menu );
+	actionListBranches.append(a);
 	actionFormatPickColor=a;
-    a= new QAction( tr( "Color branch" ), QPixmap(formatcoloritem_xpm), tr( "Color &branch" ), CTRL + Key_I, this, "colorItem" );
+
+    a= new QAction(QPixmap(iconPath+"formatcoloritem.png"), tr( "Color &branch" ), this);
+	a->setStatusTip ( tr( "Color branch" ) );
+	a->setShortcut (Qt::CTRL + Qt::Key_I);
     connect( a, SIGNAL( activated() ), this, SLOT( formatColorItem() ) );
 	a->setEnabled (false);
     a->addTo( tb );
     a->addTo( menu );
+	actionListBranches.append(a);
 	actionFormatColorBranch=a;
-    a= new QAction( tr( "Color Subtree" ), QPixmap(formatcolorbranch_xpm), tr( "Color sub&tree" ), CTRL + Key_T, this, "colorBranch" );
+
+    a= new QAction(QPixmap(iconPath+"formatcolorbranch.png"), tr( "Color sub&tree" ), this);
+	a->setStatusTip ( tr( "Color Subtree" ));
+	a->setShortcut (Qt::CTRL + Qt::Key_T);
     connect( a, SIGNAL( activated() ), this, SLOT( formatColorBranch() ) );
 	a->setEnabled (false);
     a->addTo( menu );
     a->addTo( tb );
+	actionListBranches.append(a);
 	actionFormatColorSubtree=a;
 
     menu->insertSeparator();
-	actionGroupFormatLinkStyles=new QActionGroup ( this, "formatLinkStyles");
+	actionGroupFormatLinkStyles=new Q3ActionGroup ( this, "formatLinkStyles");
 	actionGroupFormatLinkStyles->setExclusive (true);
-    a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
+    a= new QAction( tr( "Linkstyle Line" ), actionGroupFormatLinkStyles);
+	a->setStatusTip (tr( "Line" ));
 	a->setToggleAction(true);
     connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleLine() ) );
 	actionFormatLinkStyleLine=a;
-    a= new QAction( tr( "Line" ), QPixmap(), tr( "Linkstyle Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
+    a= new QAction( tr( "Linkstyle Parabel" ), actionGroupFormatLinkStyles);
+	a->setStatusTip (tr( "Line" ));
 	a->setToggleAction(true);
     connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStyleParabel() ) );
 	actionFormatLinkStyleParabel=a;
-    a= new QAction( tr( "PolyLine" ), QPixmap(), tr( "Linkstyle Thick Line" ), 0, actionGroupFormatLinkStyles, "formatLinkStyleLine" );
+    a= new QAction( tr( "Linkstyle Thick Line" ), actionGroupFormatLinkStyles );
+	a->setStatusTip (tr( "PolyLine" ));
 	a->setToggleAction(true);
     connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyLine() ) );
 	actionFormatLinkStylePolyLine=a;
-    a= new QAction( tr( "PolyParabel" ), QPixmap(), tr( "Linkstyle Thick Parabel" ), 0, actionGroupFormatLinkStyles, "formatLinkStylePolyParabel" );
+    a= new QAction( tr( "Linkstyle Thick Parabel" ), actionGroupFormatLinkStyles);
+	a->setStatusTip (tr( "PolyParabel" ) );
 	a->setToggleAction(true);
     connect( a, SIGNAL( activated() ), this, SLOT( formatLinkStylePolyParabel() ) );
 	actionFormatLinkStylePolyParabel=a;
 	actionGroupFormatLinkStyles->addTo (menu);
 	
-	actionGroupFormatFrameTypes=new QActionGroup ( this, "formatFrameTypes");
+	actionGroupFormatFrameTypes=new Q3ActionGroup ( this, "formatFrameTypes");
 	actionGroupFormatFrameTypes->setExclusive (true);
-    a = new QAction( tr( "No Frame" ),tr( "No Frame" ), 0, actionGroupFormatFrameTypes, "frameNone" );
+    a = new QAction( tr( "No Frame" ), actionGroupFormatFrameTypes );
+	a->setStatusTip (tr("No Frame"));
 	a->setToggleAction(true);
     connect( a, SIGNAL( activated() ), this, SLOT( formatFrameNone() ) );
 	actionFormatFrameNone=a;
-    a = new QAction( tr( "Rectangle" ),tr( "Rectangle" ), 0, actionGroupFormatFrameTypes, "frameRectangle" );
+    a = new QAction( tr( "Rectangle" ), actionGroupFormatFrameTypes);
+	a->setStatusTip (tr( "Rectangle" ));
 	a->setToggleAction(true);
     connect( a, SIGNAL( activated() ), this, SLOT( formatFrameRectangle() ) );
 	actionFormatFrameRectangle=a;
 
+    a = new QAction( tr( "Include images vertically" ),  actionFormatIncludeImagesVer);
+	a->setStatusTip ( tr ("Include top and bottom position of images into branch"));
+	a->setToggleAction(true);
+    connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesVer() ) );
+	actionFormatIncludeImagesVer=a;
+
+    a = new QAction( tr( "Include images horizontally" ),  actionFormatIncludeImagesHor );
+	a->setStatusTip ( tr ("Include left and right position of images into branch"));
+	a->setToggleAction(true);
+    connect( a, SIGNAL( activated() ), this, SLOT( formatIncludeImagesHor() ) );
+	actionFormatIncludeImagesHor=a;
+
+    a = new QAction( tr( "Hide link if object is not selected" ), actionFormatHideLinkUnselected);
+	a->setStatusTip (tr( "Hide link" ));
+	a->setToggleAction(true);
+    connect( a, SIGNAL( activated() ), this, SLOT( formatHideLinkUnselected() ) );
+	actionFormatHideLinkUnselected=a;
+
     menu->insertSeparator();
-    a= new QAction( tr( "Use same color for links and headings" ), QPixmap(), tr( "&Use color of heading for link" ), 0, this, "formatLinkColorHint" );
+    a= new QAction( tr( "&Use color of heading for link" ),  this);
+	a->setStatusTip (tr( "Use same color for links and headings" ));
 	a->setToggleAction(true);
     connect( a, SIGNAL( activated() ), this, SLOT( formatToggleLinkColorHint() ) );
 	a->addTo( menu );
 	actionFormatLinkColorHint=a;
-    pix.fill (white);
-    actionFormatLinkColor= new QAction( tr( "Set Link Color" ), pix, tr( "Set &Link Color" ), 0, this, "formatLinkColor" );
-    connect( actionFormatLinkColor, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
-    actionFormatLinkColor->addTo( menu );
-    actionFormatBackColor= new QAction( tr( "Set Background Color" ), pix, tr( "Set &Background Color" ), 0, this, "formatBackColor" );
-    connect( actionFormatBackColor, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
-    actionFormatBackColor->addTo( menu );
+
+    pix.fill (Qt::white);
+    a= new QAction( pix, tr( "Set &Link Color"+QString("...") ), this  );
+	a->setStatusTip (tr( "Set Link Color" ));
+    a->addTo( menu );
+    connect( a, SIGNAL( activated() ), this, SLOT( formatSelectLinkColor() ) );
+    actionFormatLinkColor=a;
+
+    a= new QAction( pix, tr( "Set &Background Color" )+QString("..."), this );
+	a->setStatusTip (tr( "Set Background Color" ));
+    a->addTo( menu );
+    connect( a, SIGNAL( activated() ), this, SLOT( formatSelectBackColor() ) );
+    actionFormatBackColor=a;
 }
 
 // View Actions
 void Main::setupViewActions()
 {
-    QToolBar *tb = new QToolBar( this );
+    Q3ToolBar *tb = new Q3ToolBar( this );
     tb->setLabel( "View Actions" );
-    QPopupMenu *menu = new QPopupMenu( this );
+    Q3PopupMenu *menu = new Q3PopupMenu( this );
     menuBar()->insertItem( tr( "&View" ), menu );
 
     QAction *a;
-    a = new QAction( tr( "Zoom reset" ), QPixmap(viewzoomreset_xpm), tr( "reset Zoom" ), 0, this, "zoomReset" );
-    connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
+    a = new QAction(QPixmap(iconPath+"viewmag-reset.png"), tr( "reset Zoom" ), this);
+	a->setStatusTip ( tr( "Zoom reset" ) );
+	a->setShortcut (Qt::CTRL + Qt::Key_0 );
     a->addTo( tb );
     a->addTo( menu );
-    a = new QAction( tr( "Zoom in" ), QPixmap(viewzoomin_xpm), tr( "Zoom in" ), CTRL + Key_Plus, this, "zoomIn" );
-    connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
+    connect( a, SIGNAL( activated() ), this, SLOT(viewZoomReset() ) );
+	
+    a = new QAction( QPixmap(iconPath+"viewmag+.png"), tr( "Zoom in" ), this);
+	a->setStatusTip (tr( "Zoom in" ));
+	a->setShortcut (Qt::CTRL + Qt::Key_Plus);
     a->addTo( tb );
     a->addTo( menu );
-    a = new QAction( tr( "Zoom out" ), QPixmap(viewzoomout_xpm), tr( "Zoom out" ), CTRL + Key_Minus, this, "zoomOut" );
-    connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
+    connect( a, SIGNAL( activated() ), this, SLOT(viewZoomIn() ) );
+	
+    a = new QAction( QPixmap(iconPath+"viewmag-.png"), tr( "Zoom out" ), this);
+	a->setStatusTip (tr( "Zoom out" ));
+	a->setShortcut (Qt::CTRL + Qt::Key_Minus );
     a->addTo( tb );
     a->addTo( menu );
-    a = new QAction( tr( "Toggle Note Editor" ), QPixmap(flag_note_xpm), tr( "Toggle Note Editor" ), CTRL + Key_E , this, "noteEditor" );
-    connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
+    connect( a, SIGNAL( activated() ), this, SLOT( viewZoomOut() ) );
+
+
+    a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor" ),this);
+	a->setStatusTip ( tr( "Show Note Editor" ));
+	a->setShortcut ( Qt::CTRL + Qt::Key_E );
 	a->setToggleAction(true);
 	if (textEditor->showWithMain())
 		a->setOn(true);
@@ -666,102 +942,348 @@
 		a->setOn(false);
     a->addTo( tb );
     a->addTo( menu );
+    connect( a, SIGNAL( activated() ), this, SLOT(windowToggleNoteEditor() ) );
 	actionViewToggleNoteEditor=a;
-    a = new QAction( tr( "&Next Window" ), QPixmap(), tr( "Next Window" ), ALT + Key_N , this, "nextWindow" );
+
+    a = new QAction(  tr( "Show history window" ),this );
+	a->setStatusTip ( tr( "Show history window" ));
+	a->setShortcut ( Qt::CTRL + Qt::Key_H  );
+	a->setToggleAction(false);
+    a->addTo( menu );
+    connect( a, SIGNAL( activated() ), this, SLOT(windowToggleHistory() ) );
+	actionViewToggleHistoryWindow=a;
+
+    a = new QAction(tr( "Next Window" ), this);
+	a->setStatusTip ( tr( "&Next Window" ) );
+	a->setShortcut (Qt::ALT + Qt::Key_N );
+    a->addTo( menu );
     connect( a, SIGNAL( activated() ), this, SLOT(windowNextEditor() ) );
+
+    a = new QAction (tr( "Previous Window" ), this );
+	a->setStatusTip (tr( "&Previous Window" ));
+	a->setShortcut (Qt::ALT + Qt::Key_P );
     a->addTo( menu );
-    a = new QAction( tr( "&Previous Window" ), QPixmap(), tr( "Previous Window" ), ALT + Key_P , this, "previousWindow" );
     connect( a, SIGNAL( activated() ), this, SLOT(windowPreviousEditor() ) );
-    a->addTo( menu );
+}
+
+// Mode Actions
+void Main::setupModeActions()
+{
+    //QPopupMenu *menu = new QPopupMenu( this );
+    //menuBar()->insertItem( tr( "&Mode (using modifiers)" ), menu );
+
+    Q3ToolBar *tb = new Q3ToolBar( this );
+    tb->setLabel( tr ("Modes when using modifiers") );
+    QAction *a;
+	actionGroupModModes=new Q3ActionGroup ( this, "formatLinkStyles");
+	actionGroupModModes->setExclusive (true);
+    a= new QAction( QPixmap(iconPath+"modecolor.png"), tr( "Use modifier to color branches" ), actionGroupModModes);
+	a->setShortcut (Qt::Key_J);
+    a->setStatusTip ( tr( "Use modifier to color branches" ));
+	a->setToggleAction(true);
+	a->addTo (tb);
+	a->setOn(true);
+	actionModModeColor=a;
+	
+    a= new QAction( QPixmap(iconPath+"modecopy.png"), tr( "Use modifier to copy" ), actionGroupModModes );
+	a->setShortcut( Qt::Key_K); 
+    a->setStatusTip( tr( "Use modifier to copy" ));
+	a->setToggleAction(true);
+	a->addTo (tb);
+	actionModModeCopy=a;
+
+    a= new QAction(QPixmap(iconPath+"modelink.png"), tr( "Use modifier to draw xLinks" ), actionGroupModModes );
+	a->setShortcut (Qt::Key_L);
+    a->setStatusTip( tr( "Use modifier to draw xLinks" ));
+	a->setToggleAction(true);
+	a->addTo (tb);
+	actionModModeLink=a;
 }
 
 // Flag Actions
 void Main::setupFlagActions()
 {
+	// Create System Flags
+	systemFlagsDefault = new FlagRowObj ();
+	systemFlagsDefault->setVisibility (false);
+	systemFlagsDefault->setName ("systemFlagsDef");
+
+	FlagObj *fo = new FlagObj ();
+	fo->load(QPixmap(flagsPath+"flag-note.png"));
+	fo->setName("note");
+	fo->setToolTip(tr("Note","Systemflag"));
+	systemFlagsDefault->addFlag (fo);	// makes deep copy
+
+	fo->load(QPixmap(flagsPath+"flag-url.png"));
+	fo->setName("url");
+	fo->setToolTip(tr("WWW Document (external)","Systemflag"));
+	systemFlagsDefault->addFlag (fo);
+	
+	fo->load(QPixmap(flagsPath+"flag-vymlink.png"));
+	fo->setName("vymLink");
+	fo->setToolTip(tr("Link to another vym map","Systemflag"));
+	systemFlagsDefault->addFlag (fo);	
+
+	fo->load(QPixmap(flagsPath+"flag-scrolled-right.png"));
+	fo->setName("scrolledright");
+	fo->setToolTip(tr("subtree is scrolled","Systemflag"));
+	systemFlagsDefault->addFlag (fo);
+	
+	fo->load(QPixmap(flagsPath+"flag-tmpUnscrolled-right.png"));
+	fo->setName("tmpUnscrolledright");
+	fo->setToolTip(tr("subtree is temporary scrolled","Systemflag"));
+	systemFlagsDefault->addFlag (fo);
+
+	fo->load(QPixmap(flagsPath+"flag-hideexport.png"));
+	fo->setName("hideInExport");
+	fo->setToolTip(tr("Hide object in exported maps","Systemflag"));
+	systemFlagsDefault->addFlag (fo);
+
+	// Create Standard Flags
+	standardFlagsDefault = new FlagRowObj ();
+	standardFlagsDefault->setVisibility (false);
+	standardFlagsDefault->setName ("standardFlagsDef");
+
+	fo->load(QPixmap(flagsPath+"flag-exclamationmark.png"));
+	fo->setName ("exclamationmark");
+	fo->setGroup("standard-mark");
+	fo->setToolTip(tr("Take care!","Standardflag"));
+	standardFlagsDefault->addFlag (fo);	// makes deep copy
+	
+	fo->load(QPixmap(flagsPath+"flag-questionmark.png"));
+	fo->setName("questionmark");
+	fo->setGroup("standard-mark");
+	fo->setToolTip(tr("Really?","Standardflag"));
+	standardFlagsDefault->addFlag (fo);	
+
+	fo->load(QPixmap(flagsPath+"flag-hook-green.png"));
+	fo->setName("hook-green");
+	fo->setGroup("standard-hook");
+	fo->setToolTip(tr("ok!","Standardflag"));
+	standardFlagsDefault->addFlag (fo);	
+
+	fo->load(QPixmap(flagsPath+"flag-cross-red.png"));
+	fo->setName("cross-red");
+	fo->setGroup("standard-hook");
+	fo->setToolTip(tr("Not ok!","Standardflag"));
+	standardFlagsDefault->addFlag (fo);	
+
+	fo->load(QPixmap(flagsPath+"flag-stopsign.png"));
+	fo->setName("stopsign");
+	fo->setToolTip(tr("This won't work!","Standardflag"));
+	standardFlagsDefault->addFlag (fo);	
+
+	fo->load(QPixmap(flagsPath+"flag-smiley-good.png"));
+	fo->setName("smiley-good");
+	fo->setGroup("standard-smiley");
+	fo->setToolTip(tr("Good","Standardflag"));
+	standardFlagsDefault->addFlag (fo);	
+
+	fo->load(QPixmap(flagsPath+"flag-smiley-sad.png"));
+	fo->setName("smiley-sad");
+	fo->setGroup("standard-smiley");
+	fo->setToolTip(tr("Bad","Standardflag"));
+	standardFlagsDefault->addFlag (fo);	
+
+	fo->load(QPixmap(flagsPath+"flag-smiley-omg.png"));
+	// Original omg.png (in KDE emoticons)
+	fo->setName("smiley-omg");
+	fo->setGroup("standard-smiley");
+	fo->setToolTip(tr("Oh no!","Standardflag"));
+	standardFlagsDefault->addFlag (fo);	
+
+	fo->load(QPixmap(flagsPath+"flag-kalarm.png"));
+	fo->setName("clock");
+	fo->setToolTip(tr("Time critical","Standardflag"));
+	standardFlagsDefault->addFlag (fo);	
+
+	fo->load(QPixmap(flagsPath+"flag-phone.png"));
+	fo->setName("phone");
+	fo->setToolTip(tr("Call...","Standardflag"));
+	standardFlagsDefault->addFlag (fo);	
+
+	fo->load(QPixmap(flagsPath+"flag-lamp.png"));
+	fo->setName("lamp");
+	fo->setToolTip(tr("Idea!","Standardflag"));
+	standardFlagsDefault->addFlag (fo);	
+
+	fo->load(QPixmap(flagsPath+"flag-arrow-up.png"));
+	fo->setName("arrow-up");
+	fo->setGroup("standard-arrow");
+	fo->setToolTip(tr("Important","Standardflag"));
+	standardFlagsDefault->addFlag (fo);	
+
+	fo->load(QPixmap(flagsPath+"flag-arrow-down.png"));
+	fo->setName("arrow-down");
+	fo->setGroup("standard-arrow");
+	fo->setToolTip(tr("Unimportant","Standardflag"));
+	standardFlagsDefault->addFlag (fo);	
+
+	fo->load(QPixmap(flagsPath+"flag-arrow-2up.png"));
+	fo->setName("2arrow-up");
+	fo->setGroup("standard-arrow");
+	fo->setToolTip(tr("Very important!","Standardflag"));
+	standardFlagsDefault->addFlag (fo);	
+
+	fo->load(QPixmap(flagsPath+"flag-arrow-2down.png"));
+	fo->setName("2arrow-down");
+	fo->setGroup("standard-arrow");
+	fo->setToolTip(tr("Very unimportant!","Standardflag"));
+	standardFlagsDefault->addFlag (fo);	
+
+	fo->load(QPixmap(flagsPath+"flag-thumb-up.png"));
+	fo->setName("thumb-up");
+	fo->setGroup("standard-thumb");
+	fo->setToolTip(tr("I like this","Standardflag"));
+	standardFlagsDefault->addFlag (fo);	
+
+	fo->load(QPixmap(flagsPath+"flag-thumb-down.png"));
+	fo->setName("thumb-down");
+	fo->setGroup("standard-thumb");
+	fo->setToolTip(tr("I like this","Standardflag"));
+	fo->setToolTip(tr("I do not like this","Standardflag"));
+	standardFlagsDefault->addFlag (fo);	
+	
+	fo->load(QPixmap(flagsPath+"flag-rose.png"));
+	fo->setName("rose");
+	fo->setToolTip(tr("Rose","Standardflag"));
+	standardFlagsDefault->addFlag (fo);	
+
+	fo->load(QPixmap(flagsPath+"flag-heart.png"));
+	fo->setName("heart");
+	fo->setToolTip(tr("I just love... ","Standardflag"));
+	standardFlagsDefault->addFlag (fo);	
+
+	fo->load(QPixmap(flagsPath+"flag-present.png"));
+	fo->setName("present");
+	fo->setToolTip(tr("Surprise!","Standardflag"));
+	standardFlagsDefault->addFlag (fo);	
+
+	fo->load(QPixmap(flagsPath+"flag-flash.png"));
+	fo->setName("flash");
+	fo->setToolTip(tr("Dangerous","Standardflag"));
+	standardFlagsDefault->addFlag (fo);	
+	
+	fo->load(QPixmap(flagsPath+"flag-info.png"));
+	// Original: xsldbg_output.png
+	fo->setName("info");
+	fo->setToolTip(tr("Info","Standardflag"));
+	standardFlagsDefault->addFlag (fo);	
+
+	fo->load(QPixmap(flagsPath+"flag-lifebelt.png"));
+	// Original khelpcenter.png
+	fo->setName("lifebelt");
+	fo->setToolTip(tr("This will help","Standardflag"));
+	standardFlagsDefault->addFlag (fo);	
+
+	delete (fo);
+
 	standardFlagsDefault->makeToolbar(this, "Standard Flags");
 }
 
 // Settings Actions
 void Main::setupSettingsActions()
 {
-    QPopupMenu *menu = new QPopupMenu( this );
+    Q3PopupMenu *menu = new Q3PopupMenu( this );
     menuBar()->insertItem( tr( "&Settings" ), menu );
 
 	QAction *a;
 
 
-    a = new QAction( tr( "Set application to open pdf files" ), QPixmap(), tr( "Set application to open pdf files" ), 0, this, "setPDF" );
+    a = new QAction( tr( "Set application to open pdf files"), this);
+    a->setStatusTip ( tr( "Set application to open pdf files"));
     connect( a, SIGNAL( activated() ), this, SLOT( settingsPDF() ) );
     a->addTo( menu );
 
-    a = new QAction( tr( "Set application to open an URL" ), QPixmap(), tr( "Set application to open an URL" ), 0, this, "setURL" );
+    a = new QAction( tr( "Set application to open external links"), this);
+    a->setStatusTip( tr( "Set application to open external links"));
     connect( a, SIGNAL( activated() ), this, SLOT( settingsURL() ) );
     a->addTo( menu );
 
     menu->insertSeparator();
-    a = new QAction( tr( "Edit branch after adding it" ), QPixmap(), tr( "Edit branch after adding it" ), 0, this, "autoedit" );
+    a = new QAction( tr( "Edit branch after adding it" ), this );
+    a->setStatusTip( tr( "Edit branch after adding it" ));
 	a->setToggleAction(true);
 	a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoedit",true) );
     a->addTo( menu );
 	actionSettingsAutoedit=a;
 
-    a= new QAction( tr( "Select branch after adding it" ), QPixmap(), tr( "Select branch after adding it" ), 0, this, "autoselectheading" );
+    a= new QAction( tr( "Select branch after adding it" ), this );
+    a->setStatusTip( tr( "Select branch after adding it" ));
 	a->setToggleAction(true);
 	a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselect",false) );
     a->addTo( menu );
 	actionSettingsAutoselectHeading=a;
 	
-    a= new QAction( tr( "Select heading before editing" ), QPixmap(), tr( "Select existing heading" ), 0, this, "autoselectexistingtext" );
+    a= new QAction(tr( "Select existing heading" ), this);
+    a->setStatusTip( tr( "Select heading before editing" ));
 	a->setToggleAction(true);
 	a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/autoselectexistingtext",true) );
     a->addTo( menu );
 	actionSettingsAutoselectText=a;
 	
-    a= new QAction( tr( "Enable pasting into new branch" ), QPixmap(), tr( "Enable pasting into new branch" ), 0, this, "pastenewheading" );
+    a= new QAction(tr( "pasting into new branch" ), this );
+    a->setStatusTip( tr( "Pasting into new branch" ));
 	a->setToggleAction(true);
 	a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/newheadingisempty",true) );
     a->addTo( menu );
 	actionSettingsPasteNewHeading=a;
 	
-    a= new QAction( tr( "Enable Delete key for deleting branches" ), QPixmap(), tr( "Enable Delete key" ), 0, this, "delkey" );
+    a= new QAction( tr( "Delete key" ), this);
+    a->setStatusTip( tr( "Delete key for deleting branches" ));
 	a->setToggleAction(true);
 	a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useDelKey",false) );
     a->addTo( menu );
+    connect( a, SIGNAL( activated() ), this, SLOT( settingsToggleDelKey() ) );
 	actionSettingsUseDelKey=a;
+
+    a= new QAction( tr( "Exclusive flags" ), this);
+    a->setStatusTip( tr( "Use exclusive flags in flag toolbars" ));
+	a->setToggleAction(true);
+	a->setOn ( settings.readBoolEntry ("/vym/mapeditor/editmode/useFlagGroups",true) );
+    a->addTo( menu );
+	actionSettingsUseFlagGroups=a;
+	
+    a= new QAction( tr( "Use hide flags" ), this);
+    a->setStatusTip( tr( "Use hide flag during exports " ));
+	a->setToggleAction(true);
+	a->setOn ( settings.readBoolEntry ("/vym/export/useHideExport",true) );
+    a->addTo( menu );
+	actionSettingsUseHideExport=a;
 }
 
 // Test Actions
 void Main::setupTestActions()
 {
-    QPopupMenu *menu = new QPopupMenu( this );
+    Q3PopupMenu *menu = new Q3PopupMenu( this );
     menuBar()->insertItem( tr( "&Test" ), menu );
 
     QAction *a;
-    a = new QAction( tr( "Test Flag" ), QPixmap(), tr( "test flag" ), 0, this, "flag" );
+    a = new QAction( tr( "test flag" ), this);
+    a->setStatusTip( tr( "Call test function" ));
     connect( a, SIGNAL( activated() ), this, SLOT( testFunction() ) );
     a->addTo( menu );
-
-	a = new QAction( tr( "Show Clipboard" ), QPixmap(), tr( "Show clipboard" ), 0, this, "clipboard" );
-    connect( a, SIGNAL( activated() ), this, SLOT( testShowClipboard() ) );
-    a->addTo( menu );
 }
 
 // Help Actions
 void Main::setupHelpActions()
 {
-    QPopupMenu *menu = new QPopupMenu( this );
+    Q3PopupMenu *menu = new Q3PopupMenu( this );
     menuBar()->insertItem( tr( "&Help" ), menu );
 
     QAction *a;
-    a = new QAction( tr( "Open VYM Documentation (pdf)" ), QPixmap(), tr( "Open VYM Documentation (pdf) " ), 0, this, "about" );
+    a = new QAction(  tr( "Open VYM Documentation (pdf) " ), this );
+    a->setStatusTip( tr( "Open VYM Documentation (pdf)" ));
     connect( a, SIGNAL( activated() ), this, SLOT( helpDoc() ) );
     a->addTo( menu );
 
-    a = new QAction( tr( "Information about VYM" ), QPixmap(), tr( "About VYM" ), 0, this, "about" );
+    a = new QAction( tr( "About VYM" ), this);
+    a->setStatusTip( tr( "About VYM")+" "__VYM);
     connect( a, SIGNAL( activated() ), this, SLOT( helpAbout() ) );
     a->addTo( menu );
 
-    a = new QAction( tr( "Information about QT toolkit" ), QPixmap(), tr( "About QT" ), 0, this, "about" );
+    a = new QAction( tr( "About QT" ), this);
+    a->setStatusTip( tr( "Information about QT toolkit" ));
     connect( a, SIGNAL( activated() ), this, SLOT( helpAboutQT() ) );
     a->addTo( menu );
 }
@@ -772,44 +1294,89 @@
 	QAction*a;
 
 	// Context Menu for branch or mapcenter
-	branchContextMenu =new QPopupMenu (this);
-	actionEditAddBranch->addTo ( branchContextMenu );
-	actionEditAddBranchAbove->addTo ( branchContextMenu );
-	actionEditAddBranchBelow->addTo ( branchContextMenu );
+	branchContextMenu =new Q3PopupMenu (this);
+
+		// Submenu "Add"
+		branchAddContextMenu =new Q3PopupMenu (this);
+		actionEditPaste->addTo ( branchAddContextMenu );
+		actionEditAddBranch->addTo ( branchAddContextMenu );
+		actionEditAddBranchHere->addTo ( branchAddContextMenu );
+		actionEditAddBranchAbove->addTo ( branchAddContextMenu );
+		actionEditAddBranchBelow->addTo ( branchAddContextMenu );
+		branchAddContextMenu->insertSeparator();	
+		actionEditLoadImage->addTo( branchAddContextMenu );
+		branchAddContextMenu->insertSeparator();	
+		actionEditImportAdd->addTo ( branchAddContextMenu );
+		actionEditImportReplace->addTo ( branchAddContextMenu );
+
+		// Submenu "Remove"
+		branchRemoveContextMenu =new Q3PopupMenu (this);
+		actionEditCut->addTo ( branchRemoveContextMenu );
+		actionEditDelete->addTo ( branchRemoveContextMenu );
+		actionEditRemoveBranchKeepChilds->addTo( branchRemoveContextMenu );
+		actionEditRemoveChilds->addTo( branchRemoveContextMenu );
+		
+	branchContextMenu->insertItem (tr("Add"),branchAddContextMenu);	
+	branchContextMenu->insertItem (tr("Remove"),branchRemoveContextMenu);	
+
 	actionEditSaveBranch->addTo( branchContextMenu );
-	branchContextMenu->insertSeparator();	
-	actionEditImportAdd->addTo ( branchContextMenu );
-	actionEditImportReplace->addTo ( branchContextMenu );
+
 	branchContextMenu->insertSeparator();	
 	actionEditOpenURL->addTo ( branchContextMenu );
+	actionEditOpenURLTab->addTo ( branchContextMenu );
 	actionEditURL->addTo ( branchContextMenu );
 	actionEditHeading2URL->addTo ( branchContextMenu );
+	actionEditBugzilla2URL->addTo( branchContextMenu );
     if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) 
-		actionEditBugzilla2URL->addTo( branchContextMenu );
+	{
+		actionEditFATE2URL->addTo( branchContextMenu );
+	}	
 	branchContextMenu->insertSeparator();	
 	actionEditOpenVymLink->addTo ( branchContextMenu );
 	actionEditVymLink->addTo ( branchContextMenu );
 	actionEditDeleteVymLink->addTo ( branchContextMenu );
-	branchContextMenu->insertSeparator();	
-	actionEditLoadImage->addTo( branchContextMenu );
-	branchContextMenu->insertSeparator();	
-	actionEditCopy->addTo( branchContextMenu );
-	actionEditCut->addTo( branchContextMenu );
-	actionEditPaste->addTo( branchContextMenu );
+	
 	branchContextMenu->insertSeparator();	
 	actionGroupFormatFrameTypes->addTo( branchContextMenu );
 
+	branchContextMenu->insertSeparator();	
+	actionFormatIncludeImagesVer->addTo( branchContextMenu );
+	actionFormatIncludeImagesHor->addTo( branchContextMenu );
+	actionFormatHideLinkUnselected->addTo( branchContextMenu );
+
+	// Context Menu for links in a branch menu
+	// This will be populated "on demand" in MapEditor::updateActions
+	branchContextMenu->insertSeparator();	
+	branchLinksContextMenu =new Q3PopupMenu (this);
+	branchLinksContextMenuDup =new Q3PopupMenu (this);
+	branchContextMenu->insertItem (tr("Edit XLink"),branchLinksContextMenuDup);
+	connect( branchLinksContextMenuDup, SIGNAL( activated(int) ), this, SLOT( editEditXLink(int ) ) );
+
+	branchContextMenu->insertItem (tr("Goto XLink"),branchLinksContextMenu);
+	connect( branchLinksContextMenu, SIGNAL( activated(int) ), this, SLOT( editFollowXLink(int ) ) );
+	
 	// Context menu for floatimage
-	floatimageContextMenu =new QPopupMenu (this);
-	saveImageFormatMenu=new QPopupMenu (this);
-	exportImageFormatMenu=new QPopupMenu (this);
+	floatimageContextMenu =new Q3PopupMenu (this);
+	saveImageFormatMenu=new Q3PopupMenu (this);
+	exportImageFormatMenu=new Q3PopupMenu (this);
 
-	QStrList fmt = QImage::outputFormats();
+/* FIXME strange error
+    foreach (QByteArray format, QImageWriter::supportedImageFormats()) 
+	{
+        QString text = tr("%1...").arg(QString(format).toUpper());
+		saveImageFormatMenu->insertItem( text );
+		exportImageFormatMenu->insertItem( text );
+    }
+*/
+
+/* FIXME  not needed any longer
+	Q3StrList fmt = QImageWriter::supportedImageFormats();
 	for (const char* f = fmt.first(); f; f = fmt.next()) 
 	{
 		saveImageFormatMenu->insertItem( f );
 		exportImageFormatMenu->insertItem( f );
 	}	
+*/	
 	connect( saveImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( editSaveImage(int ) ) );
 	connect( exportImageFormatMenu, SIGNAL( activated(int) ), this, SLOT( fileExportImage(int ) ) );
 	floatimageContextMenu->insertItem( tr("Save image"),saveImageFormatMenu );
@@ -819,39 +1386,48 @@
 	actionEditCut->addTo( floatimageContextMenu );
 
 	floatimageContextMenu->insertSeparator();	
-    a = new QAction( tr( "Use for Export" ), QPixmap(), tr( "Use for Export"), 0, this, "useForExport" );
-	a->setToggleAction(true);
-    connect( a, SIGNAL( activated() ), this, SLOT( editToggleFloatExport() ) );
-    a->addTo( floatimageContextMenu);
-	actionEditToggleFloatExport=a;
+	actionFormatHideLinkUnselected->addTo( floatimageContextMenu );
 
+	exportMenu->insertItem ( tr("Export as")+" Image",exportImageFormatMenu);
 
+	a = new QAction( "Open Office"+QString("..."), this);
+	a->setStatusTip( tr( "Export in Open Document Format used e.g. in Open Office " ));
+	connect( a, SIGNAL( activated() ), this, SLOT( fileExportOOPresentation() ) );
+	a->addTo (exportMenu);
 
-	// Context menu for exports
-	exportMenu->insertItem ( tr("Export map as image"),exportImageFormatMenu);
-
-    a = new QAction( tr( "Export as ASCII (still experimental)" ), QPixmap(), tr( "Export (ASCII)" ), 0, this, "exportASCII" );
-    connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
+	a = new QAction(  "Webpage (XHTML)...",this );
+	a->setShortcut (Qt::ALT + Qt::Key_X);
+	a->setStatusTip ( tr( "Export as")+" webpage (XHTML)");
+    connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
     a->addTo( exportMenu );
 
-	a = new QAction( tr( "Export XML" ), QPixmap(), tr( "Export XML" ),  0, this, "exportXML" );
+    a = new QAction( "Text (ASCII)...", this);
+	a->setStatusTip ( tr( "Export as")+" ASCII"+" "+tr("(still experimental)" ));
+    connect( a, SIGNAL( activated() ), this, SLOT( fileExportASCII() ) );
+	a->addTo( exportMenu );
+
+	a = new QAction( tr("KDE Bookmarks"), this);
+	a->setStatusTip( tr( "Export as")+" "+tr("KDE Bookmarks" ));
+	connect( a, SIGNAL( activated() ), this, SLOT( fileExportKDEBookmarks() ) );
+	a->addTo (exportMenu);
+
+    a = new QAction( "Taskjuggler...", this );
+    a->setStatusTip( tr( "Export as")+" Taskjuggler"+" "+tr("(still experimental)" ));
+    connect( a, SIGNAL( activated() ), this, SLOT( fileExportTaskjuggler() ) );
+	a->addTo( exportMenu );
+
+    a = new QAction( "LaTeX...", this);
+    a->setStatusTip( tr( "Export as")+" LaTeX"+" "+tr("(still experimental)" ));
+    connect( a, SIGNAL( activated() ), this, SLOT( fileExportLaTeX() ) );
+	a->addTo( exportMenu );
+
+	a = new QAction( "XML..." , this );
+	a->setStatusTip (tr( "Export as")+" XML");
     connect( a, SIGNAL( activated() ), this, SLOT( fileExportXML() ) );
     a->addTo( exportMenu );
 	
-    if (settings.readBoolEntry( "/vym/mainwindow/showTestMenu",false)) 
-	{
-		a = new QAction( tr( "Export HTML" ), QPixmap(), tr( "Export HTML" ), 0, this, "exportHTML" );
-		connect( a, SIGNAL( activated() ), this, SLOT( fileExportHTML() ) );
-		a->addTo( exportMenu );
-	}
-
-	a = new QAction( tr( "Export XHTML" ), QPixmap(), tr( "Export XHTML" ), ALT + Key_X, this, "exportXHTML" );
-    connect( a, SIGNAL( activated() ), this, SLOT( fileExportXHTML() ) );
-    a->addTo( exportMenu );
-
-	
 	// Context menu for canvas
-	canvasContextMenu =new QPopupMenu (this);
+	canvasContextMenu =new Q3PopupMenu (this);
 	actionEditMapInfo->addTo( canvasContextMenu );
 	canvasContextMenu->insertSeparator();	
 	actionGroupFormatLinkStyles->addTo( canvasContextMenu );
@@ -910,7 +1486,7 @@
 
 void Main::showEvent (QShowEvent * )
 {
-	if (textEditor->showWithMain()) textEditor->show();
+	if (textEditor->showWithMain()) textEditor->showNormal();
 }
 
 bool Main::reallyWriteDirectory(const QString &dir)
@@ -920,9 +1496,8 @@
 	if (eList.first() =="..") eList.pop_front();	// remove "."
 	if (!eList.isEmpty())
 	{
-		QMessageBox mb( "VYM",
-			tr("The directory ") + dir + 
-			tr(" is not empty. Do you risk to overwrite its contents?"),
+		QMessageBox mb( __VYM,
+			tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?").arg(dir),
 		QMessageBox::Warning,
 		QMessageBox::Yes ,
 		QMessageBox::Cancel | QMessageBox::Default,
@@ -945,9 +1520,9 @@
 
 QString Main::browseDirectory (const QString &caption)
 {
-	QFileDialog fd(this,caption);
-	fd.setMode (QFileDialog::DirectoryOnly);
-	fd.setCaption("VYM - "+caption);
+	Q3FileDialog fd(this,caption);
+	fd.setMode (Q3FileDialog::DirectoryOnly);
+	fd.setCaption(__VYM " - "+caption);
 	fd.show();
 	
 	if ( fd.exec() == QDialog::Accepted )
@@ -968,7 +1543,7 @@
 void Main::newView() 
 {
     // Open a new view... have it delete when closed.
-    Main *m = new Main(0, 0, WDestructiveClose);
+    Main *m = new Main(0, 0, Qt::WDestructiveClose);
     qApp->setMainWidget(m);
     m->show();
     qApp->setMainWidget(0);
@@ -995,18 +1570,17 @@
 void Main::fileNew()
 {
 	QString fn="unnamed";
-	MapEditor* medit = new MapEditor (tabWidget, true);
+	MapEditor* medit = new MapEditor ( NULL,true);
 	tabWidget->addTab (medit,fn);
 	tabWidget->showPage(medit);
 	medit->viewport()->setFocus();
+	// For the very first map we do not have flagrows yet...
 	medit->select("mc:");
 }
 
-void Main::fileLoad(QString fn, const LoadMode &lmode)
+ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode)
 {
-	// Error codes
-	enum errorCode {success,aborted};
-	errorCode err=success;
+	ErrorCode err=success;
 	
 	// fn is usually the archive, mapfile the file after uncompressing
 	QString mapfile;
@@ -1026,15 +1600,15 @@
 			if (me->getFilePath() == fn)
 			{
 				// Already there, ask for confirmation
-				QMessageBox mb( "VYM",
-					tr("The map ") + fn + tr ("\n is already opened."
+				QMessageBox mb( __VYM,
+					tr("The map %1\nis already opened."
 					"Opening the same map in multiple editors may lead \n"
 					"to confusion when finishing working with vym."
-					"Do you want to"),
+					"Do you want to").arg(fn),
 					QMessageBox::Warning,
 					QMessageBox::Yes | QMessageBox::Default,
 					QMessageBox::Cancel | QMessageBox::Escape,
-					QMessageBox::QMessageBox::NoButton);
+					QMessageBox::NoButton);
 				mb.setButtonText( QMessageBox::Yes, tr("Open anyway") );
 				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
 				switch( mb.exec() ) 
@@ -1045,7 +1619,7 @@
 						break;
 					case QMessageBox::Cancel:
 						// do nothing
-						return;
+						return aborted;
 						break;
 				}
 			}
@@ -1074,13 +1648,12 @@
 		// from command line
 		if (!QFile(fn).exists() )
 		{
-			QMessageBox mb( "VYM",
-				tr("The map") + fn + 
-				tr(" does not exist.\n Do you want to create a new one?"),
+			QMessageBox mb( __VYM,
+				tr("This map does not exist:\n  %1\nDo you want to create a new one?").arg(fn),
 				QMessageBox::Question,
 				QMessageBox::Yes ,
 				QMessageBox::Cancel | QMessageBox::Default,
-				QMessageBox::QMessageBox::NoButton );
+				QMessageBox::NoButton );
 
 			mb.setButtonText( QMessageBox::Yes, tr("Create"));
 			mb.setButtonText( QMessageBox::No, tr("Cancel"));
@@ -1092,13 +1665,13 @@
 					tabWidget->setTabLabel (currentMapEditor(),
 						currentMapEditor()->getFileName() );
 					statusBar()->message( "Created " + fn , statusbarTime );
-					return;
+					return success;
 						
 				case QMessageBox::Cancel:
 					// don't create new map
 					statusBar()->message( "Loading " + fn + " failed!", statusbarTime );
 					fileCloseMap();
-					return;
+					return aborted;
 			}
 		}	
 
@@ -1112,130 +1685,101 @@
 		QString tmpMapDir=mkdtemp(tmpdir1);
 
 		// Try to unzip file
-		Process *zipProc=new Process ();
-		zipProc->clearArguments();
-		zipProc->setWorkingDirectory (QDir(tmpMapDir));
-		zipProc->addArgument ("unzip");
-		zipProc->addArgument (fn );
-		zipProc->addArgument ("-d");
-		zipProc->addArgument (tmpMapDir);
-
-		if (!zipProc->start() )
+		err=unzipDir (tmpMapDir,fn);
+		if (err==nozip)
 		{
-			QMessageBox::critical( 0, tr( "Critical Load Error" ),
-						   tr("Couldn't start unzip to decompress data."));
-			err=aborted;
-			
+			mapfile=fn;
+			me->setZipped(false);
 		} else
 		{
-			zipProc->waitFinished();
-			if (!zipProc->normalExit() )
+			me->setZipped(true);
+			
+			// Look for mapname.xml
+			mapfile= fn.left(fn.findRev(".",-1,true));
+			mapfile=mapfile.section( '/', -1 );
+			QFile file( tmpMapDir + "/" + mapfile + ".xml");
+			if (!file.exists() )
 			{
-				QMessageBox::critical( 0, tr( "Critical Load Error" ),
-							   tr("unzip didn't exit normally") +
-							   zipProc->getErrout() );
-				err=aborted;
-			} else
-			{
-				if (zipProc->exitStatus()>0)
+				// mapname.xml does not exist, well, 
+				// maybe some renamed the mapname.vym file...
+				// Try to find any .xml in the toplevel 
+				// directory of the .vym file
+				QStringList flist=QDir (tmpMapDir).entryList("*.xml");
+				if (flist.count()==1) 
 				{
-					if (zipProc->exitStatus()==9)
-					{
-						// no zipped file, but maybe .xml or old version? Try again.
-						mapfile=fn;
-						me->setZipped(false);
-					}	
-					else	
-					{
-						QMessageBox::critical( 0, tr( "Critical Load Error" ),
-									   QString("unzip exit code:  %1").arg(zipProc->exitStatus() ) +
-									   zipProc->getErrout() );
-						err=aborted;
-					}
+					// Only one entry, take this one
+					mapfile=tmpMapDir + "/"+flist.first();
 				} else
-				{	// Uncompressing was successfull,
-					// load from uncompressed temporary directory
-
-					me->setZipped(true);
-
+				{
+					for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) 
+						*it=tmpMapDir + "/" + *it;
+					// TODO Multiple entries, load all (but only the first one into this ME)
+					//mainWindow->fileLoadFromTmp (flist);
+					//returnCode=1;	// Silently forget this attempt to load
+					qWarning ("MainWindow::load (fn)  multimap found...");
+				}	
 					
-					// Look for mapname.xml
-					mapfile= fn.left(fn.findRev(".",-1,true));
-					mapfile=mapfile.section( '/', -1 );
-					QFile file( tmpMapDir + "/" + mapfile + ".xml");
-					if (!file.exists() )
-					{
-						// mapname.xml does not exist, well, 
-						// maybe some renamed the mapname.vym file...
-						// Try to find any .xml in the toplevel 
-						// directory of the .vym file
-						QStringList flist=QDir (tmpMapDir).entryList("*.xml");
-						if (flist.count()==1) 
-						{
-							// Only one entry, take this one
-							mapfile=tmpMapDir + "/"+flist.first();
-						} else
-						{
-							for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) 
-								*it=tmpMapDir + "/" + *it;
-							// FIXME	
-							// Multiple entries, load all (but only the first one into this ME)
-							//mainWindow->fileLoadFromTmp (flist);
-							//returnCode=1;	// Silently forget this attempt to load
-							qWarning ("MainWindow::load (fn)  multimap found...");
-						}	
-							
-						if (flist.isEmpty() )
-						{
-							QMessageBox::critical( 0, tr( "Critical Load Error" ),
-									   tr("Couldn't find a map (*.xml) in .vym archive.\n"));
-							err=aborted;				   
-						}	
-					} //file doesn't exist	
-					else
-						mapfile=file.name();
-				} // Uncompressing successfull
-			}
+				if (flist.isEmpty() )
+				{
+					QMessageBox::critical( 0, tr( "Critical Load Error" ),
+							   tr("Couldn't find a map (*.xml) in .vym archive.\n"));
+					err=aborted;				   
+				}	
+			} //file doesn't exist	
+			else
+				mapfile=file.name();
 		}
 
-		// Finally load map into mapEditor
-		me->setFilePath (mapfile,fn);
-		if (me->load(mapfile,lmode))
-			err=aborted;
+		if (err!=aborted)
+		{
+			// Save existing filename in case  we import
+			QString fn_org=me->getFilePath();
 
-		// Delete tmpDir
-		system ( "rm -rf "+tmpMapDir);
+			// Finally load map into mapEditor
+			me->setFilePath (mapfile,fn);
+			err=me->load(mapfile,lmode);
 
-		// Check for errors
-		if (err==success) 
+			// Restore old (maybe empty) filepath, if this is an import
+			if (lmode!=NewMap)
+				me->setFilePath (fn_org);
+		}	
+
+		// Finally check for errors and go home
+		if (err==aborted) 
+		{
+			if (lmode==NewMap) fileCloseMap();
+			statusBar()->message( "Could not load " + fn, statusbarTime );
+		} else 
 		{
 			if (lmode==NewMap)
 			{
 				me->setFilePath (fn);
 				tabWidget->changeTab(tabWidget->page(tabIndex), me->getFileName());
-				lastMaps.prepend(me->getFilePath() );
-				setupLastMapsMenu();
+				if (fn.left(9)!="/tmp/vym-")
+				{
+					// Only append to lastMaps if not loaded from a tmpDir
+					// e.g. imported bookmarks are in a tmpDir
+					lastMaps.prepend(me->getFilePath() );
+					setupLastMapsMenu();
+				}
 				actionFilePrint->setEnabled (true);
 			}	
 			statusBar()->message( "Loaded " + fn, statusbarTime );
-			return;
-		} else 
-		{
-			if (lmode==NewMap)
-				fileCloseMap();
 		}	
 
-
+		// Delete tmpDir
+		removeDir (QDir(tmpMapDir));
 	}
-	statusBar()->message( "Could not load " + fn, statusbarTime );
+	return err;
 }
 
 
 void Main::fileLoad(const LoadMode &lmode)
 {
-	QFileDialog *fd=new QFileDialog( this);
+	Q3FileDialog *fd=new Q3FileDialog( this);
 	if (!lastFileDir.isEmpty()) 
 		fd->setDir (lastFileDir);
+	fd->setMode (Q3FileDialog::ExistingFiles);
 	fd->addFilter ("XML (*.xml)");
 	fd->addFilter ("VYM map (*.vym *.vyp)");
 	switch (lmode)
@@ -1256,9 +1800,16 @@
 	if ( fd->exec() == QDialog::Accepted )
 	{
 		lastFileDir=fd->dirPath();
-        fn = fd->selectedFile();
-		fileLoad(fn, lmode);				   
+	    QStringList flist = fd->selectedFiles();
+		QStringList::Iterator it = flist.begin();
+		while( it != flist.end() ) 
+		{
+			fn = *it;
+			fileLoad(*it, lmode);				   
+			++it;
+		}
 	}
+	delete (fd);
 }
 
 void Main::fileLoad()
@@ -1268,7 +1819,7 @@
 
 void Main::fileLoadLast(int i)
 {
-	fileLoad(*lastMaps.at(lastMapsMenu->indexOf (i) ),NewMap);			   
+	fileLoad(QString(*lastMaps.at(lastMapsMenu->indexOf (i)) ),NewMap);			   
 }
 
 void Main::fileSave(const SaveMode &savemode)
@@ -1277,16 +1828,16 @@
 	QString tmpMapDir;
 	
 	// Error codes
-	enum errorCode {success,aborted};
-	errorCode err=success;
+	ErrorCode err=success;
 	
 	QString safeFilePath;
 
 	bool saveZipped=currentMapEditor()->saveZipped();
 
-	if (currentMapEditor())
+	MapEditor *	me=currentMapEditor();
+	if (me)
 	{
-		QString fn=currentMapEditor()->getFilePath();
+		QString fn=me->getFilePath();
 		// filename=unnamed, filepath="" in constructor...
 		if ( !fn.isEmpty() ) 
 		{	
@@ -1302,12 +1853,11 @@
 			// Look, if we should zip the data:
 			if (!saveZipped)
 			{
-				QMessageBox mb( "VYM",
-					tr("The map ") + fn + 
-					tr ("\ndid not use the compressed "
+				QMessageBox mb( __VYM,
+					tr("The map %1\ndid not use the compressed "
 					"vym file format.\nWriting it uncompressed will also write images \n"
 					"and flags and thus may overwrite files in the "
-					"given directory\n\nDo you want to write the map"),
+					"given directory\n\nDo you want to write the map").arg(fn),
 					QMessageBox::Warning,
 					QMessageBox::Yes | QMessageBox::Default,
 					QMessageBox::No ,
@@ -1337,57 +1887,22 @@
 				char tmpdir1[]="/tmp/vym-XXXXXX";	
 				tmpMapDir=mkdtemp(tmpdir1);
 			
-				safeFilePath=currentMapEditor()->getFilePath();
-				currentMapEditor()->setFilePath (tmpMapDir+"/"+
-					currentMapEditor()->getMapName()+ ".xml",
+				safeFilePath=me->getFilePath();
+				me->setFilePath (tmpMapDir+"/"+
+					me->getMapName()+ ".xml",
 					safeFilePath);
-				currentMapEditor()->save (savemode);
-				currentMapEditor()->setFilePath (safeFilePath);
+				me->save (savemode);
+				me->setFilePath (safeFilePath);
 				
-				// zip the temporary directory
-				Process *zipProc=new Process ();
-				zipProc->clearArguments();
-				zipProc->setWorkingDirectory (QDir(tmpMapDir));
-				zipProc->addArgument ("zip");
-				zipProc->addArgument ("-r");
-				zipProc->addArgument (fn);
-				zipProc->addArgument (".");
-
-				if (!zipProc->start() )
-				{	
-					// zip could not be started
-					QMessageBox::critical( 0, tr( "Critical Save Error" ),
-								   tr("Couldn't start zip to compress data."));
-					err=aborted;
-				} else
-				{
-					// zip could be started
-					zipProc->waitFinished();
-					if (!zipProc->normalExit() )
-					{
-						QMessageBox::critical( 0, tr( "Critical Save Error" ),
-									   tr("zip didn't exit normally")+
-									   "\n" + zipProc->getErrout());
-						err=aborted;
-					} else
-					{
-						if (zipProc->exitStatus()>0)
-						{
-							QMessageBox::critical( 0, tr( "Critical Save Error" ),
-									   QString("zip exit code:  %1").arg(zipProc->exitStatus() )+
-									   "\n" + zipProc->getErrout() );
-							err=aborted;
-						}
-					}
-				}	// zip could be started
+				zipDir (tmpMapDir,fn);
 			} // save zipped
 			else
 			{
 				// Save unzipped. 
-				safeFilePath=currentMapEditor()->getFilePath();
-				currentMapEditor()->setFilePath (fn, safeFilePath);
-				currentMapEditor()->save (savemode);
-				currentMapEditor()->setFilePath (safeFilePath);
+				safeFilePath=me->getFilePath();
+				me->setFilePath (fn, safeFilePath);
+				me->save (savemode);
+				me->setFilePath (safeFilePath);
 			} // save zipped 	
 		} // filepath available
 		else
@@ -1399,19 +1914,20 @@
 		}
     }
 
-	if (currentMapEditor()->saveZipped())
-	{
+	if (saveZipped && !tmpMapDir.isEmpty())
 		// Delete tmpDir
-		system ( "rm -rf "+ tmpMapDir );
-	} 
+		removeDir (QDir(tmpMapDir));
 
 	if (err==success)
+	{
 		statusBar()->message( 
-			tr("Saved")+" " + currentMapEditor()->getFilePath(), 
+			tr("Saved  %1").arg(me->getFilePath()), 
 			statusbarTime );
-	else		
+		lastMaps.prepend(me->getFilePath() );
+		setupLastMapsMenu();
+	} else		
 		statusBar()->message( 
-			tr("Couldn't save")+" " + currentMapEditor()->getFilePath(), 
+			tr("Couldn't save ").arg(me->getFilePath()), 
 			statusbarTime );
 }
 
@@ -1422,26 +1938,25 @@
 
 void Main::fileSaveAs(const SaveMode& savemode)
 {
-	QString tmpMapDir;
 	QString fn;
 
 	if (currentMapEditor())
 	{
 		if (savemode==CompleteMap)
-			fn = QFileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
+			fn = Q3FileDialog::getSaveFileName( QString::null, "VYM map (*.vym)", this );
 		else		
-			fn = QFileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
+			fn = Q3FileDialog::getSaveFileName( QString::null, "VYM part of map (*.vyp)", this );
 		if ( !fn.isEmpty() ) 
 		{
 			// Check for existing file
 			if (QFile (fn).exists())
 			{
-				QMessageBox mb( "VYM",
-					tr("The file ") + fn + tr ("\nexists already. Do you want to"),
+				QMessageBox mb( __VYM,
+					tr("The file %1\nexists already. Do you want to").arg(fn),
 					QMessageBox::Warning,
 					QMessageBox::Yes | QMessageBox::Default,
 					QMessageBox::Cancel | QMessageBox::Escape,
-					QMessageBox::QMessageBox::NoButton);
+					QMessageBox::NoButton);
 				mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
 				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
 				switch( mb.exec() ) 
@@ -1477,8 +1992,9 @@
 			fileSave(savemode);
 
 			// Set name of tab
-			tabWidget->setTabLabel (currentMapEditor(),
-				currentMapEditor()->getFileName() );
+			if (savemode==CompleteMap)
+				tabWidget->setTabLabel (currentMapEditor(),
+					currentMapEditor()->getFileName() );
 			return;
 		} 
 	}
@@ -1489,6 +2005,73 @@
 	fileSaveAs (CompleteMap);
 }
 
+void Main::fileImportKDEBookmarks()
+{
+	ImportKDEBookmarks im;
+	im.transform();
+	if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
+		currentMapEditor()->setFilePath ("");
+}
+
+void Main::fileImportFirefoxBookmarks()
+{
+	Q3FileDialog *fd=new Q3FileDialog( this);
+	fd->setDir (vymBaseDir.homeDirPath()+"/.mozilla/firefox");
+	fd->setMode (Q3FileDialog::ExistingFiles);
+	fd->addFilter ("Firefox "+tr("Bookmarks")+" (*.html)");
+	fd->setCaption(tr("Import")+" "+"Firefox "+tr("Bookmarks"));
+	fd->show();
+
+	if ( fd->exec() == QDialog::Accepted )
+	{
+		ImportFirefoxBookmarks im;
+	    QStringList flist = fd->selectedFiles();
+		QStringList::Iterator it = flist.begin();
+		while( it != flist.end() ) 
+		{
+			im.setFile (*it);
+			if (im.transform() && 
+				success==fileLoad (im.getTransformedFile(),NewMap) && 
+				currentMapEditor() )
+				currentMapEditor()->setFilePath ("");
+			++it;
+		}
+	}
+	delete (fd);
+}
+
+void Main::fileImportMM()
+{
+	ImportMM im;
+
+	Q3FileDialog *fd=new Q3FileDialog( this);
+	if (!lastFileDir.isEmpty()) 
+		fd->setDir (lastFileDir);
+	fd->setMode (Q3FileDialog::ExistingFiles);
+	fd->addFilter ("Mind Manager (*.mmap)");
+	fd->setCaption(tr("Import")+" "+"Mind Manager");
+	fd->show();
+
+	if ( fd->exec() == QDialog::Accepted )
+	{
+		lastFileDir=fd->dirPath();
+	    QStringList flist = fd->selectedFiles();
+		QStringList::Iterator it = flist.begin();
+		while( it != flist.end() ) 
+		{
+			im.setFile (*it);
+			if (im.transform() && 
+				success==fileLoad (im.getTransformedFile(),NewMap) && 
+				currentMapEditor() )
+				currentMapEditor()->setFilePath ("");
+
+			++it;
+		}
+	}
+	delete (fd);
+
+}
+
 void Main::fileImportDir()
 {
 	if (currentMapEditor())
@@ -1505,32 +2088,16 @@
 	}	
 }
 
-void Main::fileExportHTML()
-{
-	if (currentMapEditor())
-	{
-		ExportHTMLDialog dia(this);
-		
-		if (dia.exec()==QDialog::Accepted)
-		{
-			QString dir=dia.getDir();
-			if (reallyWriteDirectory(dir) )
-			{
-				currentMapEditor()->exportXML (dia.getDir() );
-				dia.doExport(currentMapEditor()->getMapName() );
-			}	
-		}
-	}	
-}
 
 void Main::fileExportXHTML()
 {
+	MapEditor *me=currentMapEditor();
 	QString dir;
-	if (currentMapEditor())
+	if (me)
 	{
 		ExportXHTMLDialog dia(this);
-		dia.setFilePath (currentMapEditor()->getFilePath() );
-		dia.setMapName (currentMapEditor()->getMapName() );
+		dia.setFilePath (me->getFilePath() );
+		dia.setMapName (me->getMapName() );
 		dia.readSettings();
 		
 		if (dia.exec()==QDialog::Accepted)
@@ -1546,10 +2113,10 @@
 
 			if (ok)
 			{
-				currentMapEditor()->exportXML (dia.getDir() );
-				dia.doExport(currentMapEditor()->getMapName() );
+				me->exportXML (dia.getDir() );
+				dia.doExport(me->getMapName() );
 				if (dia.hasChanged())
-					currentMapEditor()->setChanged();
+					me->setChanged();
 			}	
 		}
 	}	
@@ -1557,23 +2124,103 @@
 
 void Main::fileExportImage(int item)
 {
-	if (currentMapEditor())
+	MapEditor *me=currentMapEditor();
+	if (me)
 	{
-		QString fn = QFileDialog::getSaveFileName( QString::null, "Image  (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
+		QString fn = Q3FileDialog::getSaveFileName( QString::null, "Image  (*.bmp *.jpg *.pbm *.pgm *.png *.ppm *xbm *.xpm)",
 							   this );
 		if ( !fn.isEmpty() ) 
-		{
-			currentMapEditor()->exportImage(fn,item);
-		} else {
-			statusBar()->message( tr("Couldn't save") + fn, statusbarTime );
-		}
+			me->exportImage(fn,item);
+		else 
+			statusBar()->message( tr("Couldn't save %1").arg(fn), statusbarTime );
+		
 	}
 }
 
 void Main::fileExportASCII()
 {
-	if (currentMapEditor())
-		currentMapEditor()->exportASCII();	
+	MapEditor *me=currentMapEditor();
+	if (me)
+	{
+		ExportASCII ex;
+		ex.setMapCenter(me->getMapCenter());
+		ex.addFilter ("TXT (*.txt)");
+		ex.setCaption(__VYM " -" +tr("Export as ASCII")+" "+tr("(still experimental)"));
+		if (ex.execDialog() ) 
+		{
+			me->setExportMode(true);
+			ex.doExport();
+			me->setExportMode(false);
+		}
+	}
+}
+
+void Main::fileExportLaTeX()
+{
+	MapEditor *me=currentMapEditor();
+	if (me)
+	{
+		ExportLaTeX ex;
+		ex.setMapCenter(me->getMapCenter());
+		ex.addFilter ("Tex (*.tex)");
+		ex.setCaption(__VYM " -" +tr("Export as LaTeX")+" "+tr("(still experimental)"));
+		if (ex.execDialog() ) 
+		{
+			me->setExportMode(true);
+			ex.doExport();
+			me->setExportMode(false);
+		}
+	}
+}
+
+void Main::fileExportKDEBookmarks()
+{
+	ExportKDEBookmarks ex;
+	MapEditor *me=currentMapEditor();
+	if (me)
+	{
+		ex.setMapCenter (me->getMapCenter() );
+		ex.doExport();
+	}	
+}
+
+void Main::fileExportTaskjuggler()
+{
+	ExportTaskjuggler ex;
+	MapEditor *me=currentMapEditor();
+	if (me)
+	{
+		ex.setMapCenter (me->getMapCenter() );
+		ex.setCaption ( __VYM " - "+tr("Export to")+" Taskjuggler"+tr("(still experimental)"));
+		ex.addFilter ("Taskjuggler (*.tjp)");
+		if (ex.execDialog() ) 
+		{
+			me->setExportMode(true);
+			ex.doExport();
+			me->setExportMode(false);
+		}
+	}	
+}
+
+void Main::fileExportOOPresentation()
+{
+	ExportOOFileDialog *fd=new ExportOOFileDialog( this,__VYM " - "+tr("Export to")+" Open Office");
+	// FIXME add extra info in dialog
+	//ImagePreview *p =new ImagePreview (fd);
+	//fd->setContentsPreviewEnabled( TRUE );
+	//fd->setContentsPreview( p, p );
+	//fd->setPreviewMode( QFileDialog::Contents );
+	fd->setCaption(__VYM " - " +tr("Export to")+" Open Office");
+	//fd->setDir (lastImageDir);
+	fd->show();
+
+	if ( fd->exec() == QDialog::Accepted )
+	{
+		QString fn=fd->selectedFile();
+		//lastImageDir=fn.left(fn.findRev ("/"));
+		if (currentMapEditor())
+			currentMapEditor()->exportOOPresentation(fn,fd->selectedConfig());	
+	}
 }
 
 void Main::fileCloseMap()
@@ -1582,9 +2229,8 @@
 	{
 		if (currentMapEditor()->hasChanged())
 		{
-			QMessageBox mb( "VYM",
-				tr("The map ") + currentMapEditor()->getFileName() +
-				tr(" has been modified but not saved yet. Do you want to"),
+			QMessageBox mb( __VYM,
+				tr("The map %1 has been modified but not saved yet. Do you want to").arg(currentMapEditor()->getFileName()),
 				QMessageBox::Warning,
 				QMessageBox::Yes | QMessageBox::Default,
 				QMessageBox::No,
@@ -1632,7 +2278,7 @@
 		if (me->isUnsaved())
 		{
 			tabWidget->setCurrentPage(i);
-			QMessageBox mb( "VYM",
+			QMessageBox mb( __VYM,
 				tr("This map is not saved yet. Do you want to"),
 				QMessageBox::Warning,
 				QMessageBox::Yes | QMessageBox::Default,
@@ -1641,12 +2287,6 @@
 			mb.setButtonText( QMessageBox::Yes, tr("Save map") );
 			mb.setButtonText( QMessageBox::No, tr("Discard changes") );
 			mb.show();
-			// Call undocumented function: setActiveWindow is only
-			// possible, if widget is visible. This depends on
-			// windowmanager...
-#if defined(Q_OS_LINUX)
-			qt_wait_for_window_manager( this);
-#endif			
 			mb.setActiveWindow();
 			switch( mb.exec() ) {
 				case QMessageBox::Yes:
@@ -1671,8 +2311,10 @@
 		currentMapEditor()->undo();
 }
 
-void Main::editRedo()	    // TODO
+void Main::editRedo()	   
 {
+	if (currentMapEditor())
+		currentMapEditor()->redo();
 }
 
 void Main::editCopy()
@@ -1697,13 +2339,6 @@
 {
 	findWindow->popup();
 	findWindow->raise();
-
-	// Call undocumented function: setActiveWindow is only
-	// possible, if widget is visible. This depends on
-	// windowmanager...
-#if defined(Q_OS_LINUX)
-	qt_wait_for_window_manager( this);
-#endif	
 	findWindow->setActiveWindow();
 }
 
@@ -1717,8 +2352,7 @@
 	} else
 	{
 		QMessageBox::information( findWindow, tr( "VYM -Information:" ),
-							   tr("No matches found for ")+
-							   "'<b>"+s+"</b>'");
+							   tr("No matches found for \"%1\"").arg(s));
 	}	
 }
 
@@ -1729,8 +2363,70 @@
 
 void Main::editOpenURL()
 {
+	// Open new browser
 	if (currentMapEditor())
-	    currentMapEditor()->openURL();
+	{	
+	    QString url=currentMapEditor()->getURL();
+		if (url=="") return;
+		QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
+		procBrowser = new Q3Process( this );
+
+		procBrowser->addArgument( browser);
+		procBrowser->addArgument( url);
+
+		if ( !procBrowser->start() ) 
+		{
+			// try to set path to browser
+			QMessageBox::warning(0, 
+				tr("Warning"),
+				tr("Couldn't find a viewer to open %1.\n").arg(url)+
+				tr("Please use Settings->")+tr("Set application to open an URL"));
+			settingsURL() ; 
+		}	
+	}	
+}
+void Main::editOpenURLTab()
+{
+	if (currentMapEditor())
+	{	
+	    QString url=currentMapEditor()->getURL();
+		if (url=="") return;
+		QString browser=settings.readEntry("/vym/mainwindow/readerURL" );
+		if (procBrowser && procBrowser->isRunning())
+		{
+			if (browser.contains("konqueror"))
+			{
+				// Try to open new tab in existing konqueror started previously by vym
+				Q3Process *p=new Q3Process (this);
+				p->addArgument ("dcop");
+				p->addArgument (QString("konqueror-%1").arg(procBrowser->processIdentifier()));
+				p->addArgument ("konqueror-mainwindow#1");
+				p->addArgument ("newTab");
+				p->addArgument (url);
+				if ( !p->start() ) 
+					// try to set browser
+					QMessageBox::warning(0, 
+						tr("Warning"),
+						tr("Couldn't start %1 to open a new tab in %2.").arg("dcop").arg("konqueror"));
+				return;		
+			} else if (browser.contains ("firefox") || browser.contains ("mozilla") )
+			{
+				// Try to open new tab in firefox
+				Q3Process *p=new Q3Process (this);
+				p->addArgument (browser);
+				p->addArgument ("-remote");
+				p->addArgument (QString("openurl(%1,new-tab)").arg(url));
+				if ( !p->start() ) 
+					// try to set browser
+					QMessageBox::warning(0, 
+						tr("Warning"),
+						tr("Couldn't start %1 to open a new tab").arg(browser));
+				return;		
+			}
+		}
+		// Open new browser
+		editOpenURL();
+	}	
 }
 
 void Main::editURL()
@@ -1751,6 +2447,12 @@
 	    currentMapEditor()->editBugzilla2URL();
 }
 
+void Main::editFATE2URL()
+{
+	if (currentMapEditor())
+	    currentMapEditor()->editFATE2URL();
+}
+
 void Main::editOpenVymLink()
 {
 	// Get current path to map
@@ -1776,7 +2478,7 @@
 		{
 			if (!QFile(currentVymLink).exists() )
 				QMessageBox::critical( 0, tr( "Critical Error" ),
-				   tr("Couldn't open map " +currentVymLink)+".");
+				   tr("Couldn't open map %1").arg(currentVymLink));
 			else
 			{
 				fileLoad (currentVymLink, NewMap);
@@ -1800,6 +2502,12 @@
 		currentMapEditor()->deleteVymLink();	
 }
 
+void Main::editToggleHideExport()
+{
+	if (currentMapEditor())
+		currentMapEditor()->toggleHideExport();	
+}
+
 void Main::editMapInfo()
 {
 	if (currentMapEditor())
@@ -1846,6 +2554,12 @@
 		currentMapEditor()->addNewBranch(0);
 }
 
+void Main::editNewBranchHere()
+{
+	if (currentMapEditor())
+		currentMapEditor()->addNewBranchHere();
+}
+
 void Main::editNewBranchAbove()
 {
 	if (currentMapEditor())
@@ -1873,9 +2587,21 @@
 	fileSaveAs (PartOfMap);
 }
 
+void Main::editRemoveBranchKeepChilds()
+{
+	if (currentMapEditor())
+		currentMapEditor()->removeBranchKeepChilds();
+}
+
+void Main::editRemoveChilds()
+{
+	if (currentMapEditor())
+		currentMapEditor()->removeChilds();
+}
+
 void Main::editDeleteSelection()
 {
-	if (currentMapEditor())
+	if (currentMapEditor() && actionSettingsUseDelKey->isOn())
 		currentMapEditor()->deleteSelection();
 }
 
@@ -1927,10 +2653,16 @@
 		currentMapEditor()->saveFloatImage(item);
 }
 
-void Main::editToggleFloatExport()
+void Main::editFollowXLink(int item)
 {
 	if (currentMapEditor())
-		currentMapEditor()->toggleFloatExport();
+		currentMapEditor()->followXLink(branchLinksContextMenu->indexOf(item));
+}
+
+void Main::editEditXLink(int item)
+{
+	if (currentMapEditor())
+		currentMapEditor()->editXLink(branchLinksContextMenuDup->indexOf(item));
 }
 
 void Main::formatSelectColor()
@@ -2022,11 +2754,29 @@
 		currentMapEditor()->setFrame(Rectangle);
 }
 
+void Main::formatIncludeImagesVer()
+{
+	if (currentMapEditor())
+		currentMapEditor()->setIncludeImagesVer(actionFormatIncludeImagesVer->isOn());
+}
+
+void Main::formatIncludeImagesHor()
+{
+	if (currentMapEditor())
+		currentMapEditor()->setIncludeImagesHor(actionFormatIncludeImagesHor->isOn());
+}
+
+void Main::formatHideLinkUnselected()
+{
+	if (currentMapEditor())
+		currentMapEditor()->setHideLinkUnselected(actionFormatHideLinkUnselected->isOn());
+}
+
 void Main::viewZoomReset()
 {
 	if (currentMapEditor())
 	{
-		QWMatrix m;
+		QMatrix m;
 		m.reset();
 		currentMapEditor()->setWorldMatrix( m );
 		currentMapEditor()->setViewCenter();
@@ -2038,7 +2788,7 @@
 {
 	if (currentMapEditor())
 	{
-		QWMatrix m = currentMapEditor()->worldMatrix();
+		QMatrix m = currentMapEditor()->worldMatrix();
 		m.scale( 1.25, 1.25 );
 		currentMapEditor()->setWorldMatrix( m );
 		currentMapEditor()->setViewCenter();
@@ -2050,19 +2800,28 @@
 {
 	if (currentMapEditor())
 	{
-		QWMatrix m = currentMapEditor()->worldMatrix();
+		QMatrix m = currentMapEditor()->worldMatrix();
 		m.scale( 0.8, 0.8 );
 		currentMapEditor()->setWorldMatrix( m );
 		currentMapEditor()->setViewCenter();
 		currentMapEditor()->adjustCanvasSize();
 	}	
 }
+
+void Main::modModeColor()
+{
+}
+
+void Main::modModeLink()
+{
+}
+
 bool Main::settingsPDF()
 {
 	// Default browser is set in constructor
 	bool ok;
 	QString text = QInputDialog::getText(
-		"VYM", tr("Enter path for pdf reader:"), QLineEdit::Normal,
+		"VYM", tr("Set application to open PDF files")+":", QLineEdit::Normal,
 		settings.readEntry("/vym/mainwindow/readerPDF"), &ok, this );
 	if (ok)
 		settings.writeEntry ("/vym/mainwindow/readerPDF",text);
@@ -2075,7 +2834,7 @@
 	// Default browser is set in constructor
 	bool ok;
 	QString text = QInputDialog::getText(
-		"VYM", tr("Enter path for application to open an URL:"), QLineEdit::Normal,
+		"VYM", tr("Set application to open an URL")+":", QLineEdit::Normal,
 		settings.readEntry("/vym/mainwindow/readerURL")
 		, &ok, this );
 	if (ok)
@@ -2083,6 +2842,17 @@
 	return ok;
 }
 
+void Main::settingsToggleDelKey()
+{
+	if (actionSettingsUseDelKey->isOn())
+	{
+		actionEditDelete->setAccel (QKeySequence (Qt::Key_Delete));
+	} else
+	{
+		actionEditDelete->setAccel (QKeySequence (""));
+	}
+}
+
 void Main::windowToggleNoteEditor()
 {
 	if (textEditor->showWithMain() )
@@ -2091,6 +2861,18 @@
 		windowShowNoteEditor();
 }
 
+void Main::windowToggleHistory()
+{
+	if (currentMapEditor())
+		currentMapEditor()->toggleHistoryWindow();
+}
+
+void Main::updateNoteFlag()
+{
+	if (currentMapEditor())
+		currentMapEditor()->updateNoteFlag();
+}
+
 void Main::windowShowNoteEditor()
 {
 	textEditor->setShowWithMain(true);
@@ -2124,20 +2906,18 @@
 
 void Main::testFunction()
 {
-	//textEditor->stackUnder(this);
 	currentMapEditor()->testFunction();
 }
 
-void Main::testShowClipboard()
-{
-	clipboardME->show();
-}
-
 void Main::helpDoc()
 {
 	QString docpath;
-	// default path in SUSE LINUX
-	docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
+	#if defined(Q_OS_MACX)
+		docpath="./vym.app/Contents/vym.pdf";
+	#else
+		// default path in SUSE LINUX
+		docpath="/usr/share/doc/packages/vym/doc/vym.pdf";
+	#endif
 
 	if (!QFile (docpath).exists() )
 	{
@@ -2149,11 +2929,16 @@
 			docpath="doc/tex/vym.pdf";
 			if (!QFile (docpath).exists() )
 			{
-				QMessageBox::critical(0, 
-				tr("Critcal error"),
-				tr("Couldn't find the documentation\n"
-				"vym.pdf in various places."));
-				return;
+				// Try yet another one for Knoppix
+				docpath="/usr/share/doc/packages/vym/vym.pdf";
+				if (!QFile (docpath).exists() )
+				{
+					QMessageBox::critical(0, 
+					tr("Critcal error"),
+					tr("Couldn't find the documentation\n"
+					"vym.pdf in various places."));
+					return;
+				}	
 			}	
 		}
 	}
@@ -2166,10 +2951,11 @@
 	if ( !pdfProc->start() ) 
 	{
 		// error handling
-		QMessageBox::critical(0, 
-		tr("Critcal error"),
-		tr("Couldn't find a viewer to read vym.pdf.\n"
-		"Please use Settings->")+tr("Set application to open pdf files"));
+		QMessageBox::warning(0, 
+			tr("Warning"),
+			tr("Couldn't find a viewer to open %1.\n").arg("vym.pdf")+
+			tr("Please use Settings->")+tr("Set application to open PDF files"));
+		settingsPDF();	
 		return;
 	}
 }
@@ -2177,33 +2963,11 @@
 
 void Main::helpAbout()
 {
-    static QMessageBox* about = new QMessageBox( "VYM",
-			"<h3>VYM - View Your Mind </h3>"
-			"<p> A tool to put the things you have got in your mind into a map.</p>"
-			"<ul>"
-				"<li> (c) by Uwe Drechsel (vym@InSilmaril.de)</li>"
-				"<li> vym is released under the GPL (Gnu General Public License)"
-				", with one exception (see the file \"LICENSE\"which "
-				"comes with vym). This exception is needed to build vym with QT libraries for proprietary operating systems.</li>"
-				"<li> Project homepage <a href=\"http:/www.InSilmaril.de/vym\">"
-    					"http:/www.InSilmaril.de/vym</a></li>"
-			"<li> Credits " 
-				"<ul>"
-					"<li>Thomas Schraitle for the stylesheet  used for XHTML-export </li>"
-					"<li>Clemens Kraus for stylesheets and script used for HTML-export "
-					"<a href=\"http://www.clemens-kraus.de\">(www.clemens-kraus.de)</a></li>"
-					"<li>Alexander Johannesen for providing stylesheets from his xsiteable project " 
-					"<a href=\"http://www.shelter.nu/xsiteable/xsiteable.html\">(www.shelter.nu/xsiteable/xsiteable.html)</a>. </li>"
-					"<li>Ken Wimer and Olaf Hering for Mac support</li>"
-				"</ul>"
-			"</li>"
-			"<li> Version "  __VYM_VERSION__  "</li>"
-				"<li> Build date "  __BUILD_DATE__"</li>"
-			"</ul>", QMessageBox::Information, 1, 0, 0, this, 0, FALSE );
-    about->setButtonText( 1, "Dismiss" );
-    about->setMinimumSize(QSize(300,300));
-	about->setIconPixmap (QPixmap(vym_logo_xpm));
-    about->show();
+	AboutDialog ad;
+	ad.setName ("aboutwindow");
+	ad.setMinimumSize(500,500);
+	ad.resize (QSize (500,500));
+	ad.exec();
 }
 
 void Main::helpAboutQT()
diff -r 9eb7767c2dfa -r 608f976aa7bb mainwindow.h
--- a/mainwindow.h	Sun Jan 30 12:58:47 2005 +0000
+++ b/mainwindow.h	Tue Jun 06 14:58:11 2006 +0000
@@ -1,28 +1,33 @@
 #ifndef MAINWINDOW_H 
 #define MAINWINDOW_H
 
-#include <qpopupmenu.h>
-#include <qmainwindow.h>
-#include <qtextedit.h>
-#include <qintdict.h>
-#include <qcanvas.h>
+#include <q3popupmenu.h>
+#include <q3mainwindow.h>
+#include <q3textedit.h>
+#include <q3intdict.h>
+#include <q3canvas.h>
 #include <qlineedit.h>
 #include <qaction.h>
 #include <qcursor.h>
 #include <qtabwidget.h>
 #include <qmap.h>
+//Added by qt3to4:
+#include <QCloseEvent>
+#include <QShowEvent>
+#include <QHideEvent>
 
+#include "file.h"
+#include "findwindow.h"
+#include "mapeditor.h"
+#include "texteditor.h"
 #include "xml.h"
-#include "texteditor.h"
-#include "mapeditor.h"
-#include "findwindow.h"
 
-class Main : public QMainWindow 
+class Main : public Q3MainWindow 
 {
     Q_OBJECT
 
 public:
-    Main(QWidget* parent=0, const char* name=0, WFlags f=0);
+    Main(QWidget* parent=0, const char* name=0, Qt::WFlags f=0);
     ~Main();
 	void loadCmdLine();
 	void statusMessage (const QString &);
@@ -38,6 +43,7 @@
     void setupEditActions();
     void setupFormatActions();
     void setupViewActions();
+    void setupModeActions();
     void setupWindowActions();
     void setupFlagActions();
     void setupSettingsActions();
@@ -55,7 +61,7 @@
     void newView();
 	void editorChanged(QWidget*);
 
-    void fileLoad(QString ,const LoadMode &);
+    ErrorCode fileLoad(QString ,const LoadMode &);
     void fileLoad(const LoadMode &);
     void fileLoad();
 	void fileLoadLast(int);
@@ -63,12 +69,18 @@
     void fileSave();
     void fileSaveAs(const SaveMode &);
     void fileSaveAs();
+    void fileImportKDEBookmarks();
+    void fileImportFirefoxBookmarks();
+    void fileImportMM();
     void fileImportDir();
     void fileExportXML();
-    void fileExportHTML();
     void fileExportXHTML();
     void fileExportImage(int);
     void fileExportASCII();
+    void fileExportLaTeX();
+    void fileExportKDEBookmarks();
+    void fileExportTaskjuggler();
+    void fileExportOOPresentation();
     void fileCloseMap();
     void filePrint();
     void fileExitVYM();
@@ -83,15 +95,18 @@
 	void editFindChanged();
 public slots:
 	void editOpenURL();
+	void editOpenURLTab();
 private slots:
 	void editURL();
 	void editHeading2URL();
 	void editBugzilla2URL();
+	void editFATE2URL();
 	void editVymLink();
 public slots:
 	void editOpenVymLink();
 private slots:
 	void editDeleteVymLink();
+	void editToggleHideExport();
 	void editMapInfo();
     void editMoveUp();	
     void editMoveDown();	
@@ -99,11 +114,14 @@
     void editUnScrollAll();
     void editHeading();
     void editNewBranch();
+    void editNewBranchHere();
     void editNewBranchAbove();
     void editNewBranchBelow();
     void editImportAdd();
     void editImportReplace();
     void editSaveBranch();
+    void editRemoveBranchKeepChilds();
+    void editRemoveChilds();
     void editDeleteSelection();
     void editUpperBranch();
     void editLowerBranch();
@@ -113,7 +131,8 @@
     void editLastBranch();
     void editLoadImage();
     void editSaveImage(int);
-    void editToggleFloatExport();
+    void editFollowXLink (int);
+    void editEditXLink (int);
 
     void formatSelectColor();
     void formatPickColor();
@@ -129,16 +148,26 @@
     void formatToggleLinkColorHint();
 	void formatFrameNone();
 	void formatFrameRectangle();
+	void formatIncludeImagesVer();
+	void formatIncludeImagesHor();
+	void formatHideLinkUnselected();
 
     void viewZoomReset();
     void viewZoomIn();
     void viewZoomOut();
 
+	void modModeColor();
+	void modModeLink();
+
 public slots:
 	bool settingsPDF();
 	bool settingsURL();
+	void settingsToggleDelKey();
 
 	void windowToggleNoteEditor();
+	void windowToggleHistory();
+	void updateNoteFlag();
+
 private slots:
 	void windowNextEditor();
 	void windowPreviousEditor();
@@ -148,19 +177,19 @@
 	void standardFlagChanged();
 
     void testFunction();
-    void testShowClipboard();
 
     void helpDoc();
     void helpAbout();
     void helpAboutQT();
 
 private:
-    QCanvas* canvas;
+// not needed?    QCanvas* canvas;
 	QTabWidget *tabWidget;
 	FindWindow *findWindow;
 	QStringList lastMaps;
 	int maxLastMaps;
 	QString lastFileDir;
+	Q3Process *procBrowser;
 };
 
 
diff -r 9eb7767c2dfa -r 608f976aa7bb mapcenterobj.cpp
--- a/mapcenterobj.cpp	Sun Jan 30 12:58:47 2005 +0000
+++ b/mapcenterobj.cpp	Tue Jun 06 14:58:11 2006 +0000
@@ -13,7 +13,7 @@
     init();
 }
 
-MapCenterObj::MapCenterObj(QCanvas* c) : BranchObj (c)
+MapCenterObj::MapCenterObj(Q3Canvas* c) : BranchObj (c)
 {
 //    cout << "Const MapCenterObj   canvas="<<c<<"\n";
     init();
@@ -27,26 +27,18 @@
 void MapCenterObj::clear() 
 {
 	BranchObj::clear();
-    init();
 }
 
 void MapCenterObj::init () 
 {
+	BranchObj::init();
     orientation=OrientUndef;
-    absPos=QPoint (canvas->width()/2, canvas->height()/2);
 
 	// FIXME this should be done in TextObj later...
-	QFont font ("Sans Serif,16,-1,5,50,0,0,0,0,0");		
-	heading->setFont(font);
-
-	branch.setAutoDelete (TRUE);
-	floatimage.setAutoDelete (TRUE);
-
-	move (absPos.x(), absPos.y() );
+	//QFont font ("Sans Serif,16,-1,5,50,0,0,0,0,0");		
+	//heading->setFont(font);
 	depth=0;
-
-	scrolled=false;
-	tmpUnscrolled=false;
+	setDefAttr(MovedBranch);
 
 	frame->setFrameType (Rectangle);
 }
@@ -54,13 +46,11 @@
 void MapCenterObj::move (double x, double y)
 {
 	BranchObj::move(x,y);
-	positionBBox();
 }
 
 void MapCenterObj::moveBy (double x, double y)
 {
 	BranchObj::moveBy(x,y);
-	positionBBox();
 }
 
 void MapCenterObj::moveAll (double x, double y)
@@ -77,16 +67,13 @@
 {
 	// Move myself
 	moveBy(dx,dy);
-
-	positionBBox();
 }
 
 void MapCenterObj::updateLink()
 {
 	// set childPos to middle of MapCenterObj
-	childPos=QPoint(
-		absPos.x() + QSize(getSize() ).width()/2, 
-		absPos.y() + QSize(getSize() ).height()/2);
+	childPos.setX( clickBox.topLeft().x() + (int)(clickBox.width())/2 );
+	childPos.setY( clickBox.topLeft().y() + (int)(clickBox.height())/2 );
 	parPos=childPos;		
 	BranchObj *b;
 	for (b=branch.first(); b; b=branch.next() )
@@ -102,19 +89,15 @@
 	for (bo=branch.first(); bo; bo=branch.next() )
 	{	
 		lmo = bo->findMapObj(p, excludeLMO);
-		
-		if (lmo!= NULL) 
-		{
-			return lmo;
-		}	
+		if (lmo!= NULL) return lmo;
 	}
 	// is p in MapCenter?
-	if (inBBox (p) && (this != excludeLMO) ) return this;
+	if (inBox (p) && (this != excludeLMO) ) return this;
 
 	// Search float images
 	FloatImageObj *foi;
 	for (foi=floatimage.first(); foi; foi=floatimage.next() )
-		if (foi->inBBox(p) && (foi != excludeLMO) && foi->getParObj()!= excludeLMO) return foi;
+		if (foi->inBox(p) && (foi != excludeLMO) && foi->getParObj()!= excludeLMO) return foi;
 
 	// nothing found
 	return NULL;
@@ -131,13 +114,21 @@
 		attribut("x2",QString().setNum(absPos.x()+width()-offset.x(),10)) +
 		attribut("y2",QString().setNum(absPos.y()+height()-offset.y(),10));
 	
+	// Providing an ID for a branch makes export to XHTML easier
+	QString idAttr;
+	if (countXLinks()>0)
+		idAttr=attribut ("id",getSelectString());
+	else
+		idAttr="";
+
+	QString linkAttr=getLinkAttr();
+
     s=beginElement ("mapcenter" 
-		+attribut("absPosX",QString().setNum(absPos.x(),10))
-		+attribut("absPosY",QString().setNum(absPos.y(),10))
+		+getOrnAttr() 
 		+attribut("frameType",frame->getFrameTypeName()) 
 		+areaAttr 
-		);
-		
+		+idAttr 
+		+getIncludeImageAttr() );
     incIndent();
     if (heading->getColor()!=QColor("black"))
 		a=attribut ("textColor",QColor(heading->getColor()).name() );
@@ -149,23 +140,25 @@
 	s+=standardFlags->saveToDir(tmpdir+"/flags", "/standardFlag-", verbose);
     s=s+valueElement("heading", getHeading(),a);
 
-	// Reset the counters before saving
-	FloatImageObj (canvas).resetSaveCounter();
-
 	// add link to file in s
 	if (!note.isEmpty() )
 		s+=note.saveToDir();
 	
-	// Save FloatImages
-	FloatImageObj *fio;
-	for (fio=floatimage.first(); fio; fio=floatimage.next() )
-		s+=fio->saveToDir (tmpdir,prefix);
-
 	// Save branches
     BranchObj *bo;
     for (bo=branch.first(); bo; bo=branch.next() )
 		s+=bo->saveToDir(tmpdir,prefix, offset);
 
+	// Save FloatImages
+	FloatImageObj *fio;
+	for (fio=floatimage.first(); fio; fio=floatimage.next() )
+		s+=fio->saveToDir (tmpdir,prefix,offset);
+
+	// Save XLinks
+	XLinkObj *xlo;
+    for (xlo=xlink.first(); xlo; xlo=xlink.next() )
+		s+=xlo->saveToDir();
+
     decIndent();
     s+=endElement   ("mapcenter");
     return s;
@@ -184,9 +177,9 @@
 	QString s2=version.section (".",1,1);
 	QString s3=version.section (".",2,2);
 	bool ok;
-	int vv1 =QString(__VYM_VERSION__).section (".",0,0).toInt(&ok,10);
-	int vv2 =QString(__VYM_VERSION__).section (".",1,1).toInt(&ok,10);
-	int vv3 =QString(__VYM_VERSION__).section (".",2,2).toInt(&ok,10);
+	int vv1 =QString(__VYM_VERSION).section (".",0,0).toInt(&ok,10);
+	int vv2 =QString(__VYM_VERSION).section (".",1,1).toInt(&ok,10);
+	int vv3 =QString(__VYM_VERSION).section (".",2,2).toInt(&ok,10);
 	int mv1=0;
 	int mv2=0;
 	int mv3=0;
@@ -233,3 +226,4 @@
 {
 	return QDate::currentDate().toString ("yyyy-MM-dd");
 }
+
diff -r 9eb7767c2dfa -r 608f976aa7bb mapcenterobj.h
--- a/mapcenterobj.h	Sun Jan 30 12:58:47 2005 +0000
+++ b/mapcenterobj.h	Tue Jun 06 14:58:11 2006 +0000
@@ -1,14 +1,18 @@
 #ifndef MAPCENTEROBJ_H
 #define MAPCENTEROBJ_H
 
+
+#include <QDate>
+
 #include "branchobj.h"
+#include "xlinkobj.h"
 #include "version.h"
 
 /////////////////////////////////////////////////////////////////////////////
 class MapCenterObj:public BranchObj {
 public:
     MapCenterObj ();
-    MapCenterObj (QCanvas*);
+    MapCenterObj (Q3Canvas*);
     ~MapCenterObj ();
     void clear();
     void init();
diff -r 9eb7767c2dfa -r 608f976aa7bb mapeditor.cpp
--- a/mapeditor.cpp	Sun Jan 30 12:58:47 2005 +0000
+++ b/mapeditor.cpp	Tue Jun 06 14:58:11 2006 +0000
@@ -4,61 +4,63 @@
 #include <qmessagebox.h>
 #include <qapplication.h>
 #include <qpainter.h>
-#include <qpopupmenu.h>
+#include <q3popupmenu.h>
 #include <qprinter.h>
-#include <qpaintdevicemetrics.h>
+#include <q3paintdevicemetrics.h>
 #include <qfile.h>
-#include <qfiledialog.h>
+#include <q3filedialog.h>
 #include <qdir.h>
 #include <qcolor.h>
 #include <qcolordialog.h>
 #include <qbitmap.h>
-#include <qprocess.h>
+#include <q3process.h>
 #include <qinputdialog.h>
+#include <q3dragobject.h>
+#include <q3urloperator.h>
+#include <q3networkprotocol.h>
+#include <qregexp.h>
+//Added by qt3to4:
+#include <QResizeEvent>
+#include <QContextMenuEvent>
+#include <Q3StrList>
+#include <QPixmap>
+#include <QMouseEvent>
+#include <QDragEnterEvent>
+#include <QTextStream>
+#include <QDropEvent>
+#include <Q3ActionGroup>
+#include <Q3PtrList>
 
 #include <iostream>
-#include <stdlib.h>
+#include <cstdlib>
 #include <typeinfo>
 
 #include "version.h"
 
+#include "api.h"
+#include "editxlinkdialog.h"
+#include "exports.h"
+#include "extrainfodialog.h"
+#include "file.h"
+#include "linkablemapobj.h"
+#include "mainwindow.h"
+#include "misc.h"
+#include "settings.h"
+#include "texteditor.h"
+#include "warningdialog.h"
 #include "xml.h"
-#include "texteditor.h"
-#include "linkablemapobj.h"
-#include "exports.h"
-#include "misc.h"
-#include "mainwindow.h"
-#include "extrainfodialog.h"
-#include "settings.h"
-
-#include "icons/flag-note.xpm"
-#include "icons/flag-url.xpm"
-#include "icons/flag-vymlink.xpm"	
-#include "icons/flag-scrolled-right.xpm"
-#include "icons/flag-tmpUnscrolled-right.xpm"
-#include "icons/flag-questionmark.xpm"
-#include "icons/flag-exclamationmark.xpm"
-#include "icons/flag-hook-green.xpm"
-#include "icons/flag-cross-red.xpm"
-#include "icons/flag-stopsign.xpm"
-#include "icons/flag-smiley-good.xpm"
-#include "icons/flag-smiley-sad.xpm"
-#include "icons/flag-clock.xpm"
-#include "icons/flag-lamp.xpm"
-#include "icons/flag-arrow-up.xpm"
-#include "icons/flag-arrow-down.xpm"
-#include "icons/flag-thumb-up.xpm"
-#include "icons/flag-thumb-down.xpm"
-#include "icons/flag-heart.xpm"
-#include "icons/flag-flash.xpm"
-#include "icons/flag-lifebelt.xpm"
+
 
 extern TextEditor *textEditor;
 extern int statusbarTime;
 extern Main *mainWindow;
+extern QString tmpVymDir;
+extern QString clipboardDir;
+extern bool clipboardEmpty;
 extern FlagRowObj *systemFlagsDefault;
 extern FlagRowObj *standardFlagsDefault;
-extern MapEditor *clipboardME;
+
+extern Q3PtrList <QAction> actionListBranches;
 
 extern QAction *actionFileSave;
 extern QAction *actionEditUndo;
@@ -69,24 +71,28 @@
 extern QAction *actionEditMoveDown;
 extern QAction *actionEditToggleScroll;
 extern QAction *actionEditOpenURL;
+extern QAction *actionEditOpenURLTab;
 extern QAction *actionEditURL;
 extern QAction *actionEditHeading2URL;
 extern QAction *actionEditBugzilla2URL;
+extern QAction *actionEditFATE2URL;
 extern QAction *actionEditOpenVymLink;
 extern QAction *actionEditVymLink;
 extern QAction *actionEditDeleteVymLink;
+extern QAction *actionEditToggleHideExport;
 extern QAction *actionEditHeading;
 extern QAction *actionEditDelete;
 extern QAction *actionEditAddBranch;
 extern QAction *actionEditAddBranchAbove;
 extern QAction *actionEditAddBranchBelow;
+extern QAction *actionEditRemoveBranchHere;
+extern QAction *actionEditRemoveChilds;
 extern QAction *actionEditImportAdd;
 extern QAction *actionEditImportReplace;
 extern QAction *actionEditSaveBranch;
 extern QAction *actionEditSelectFirst;
 extern QAction *actionEditSelectLast;
 extern QAction *actionEditLoadImage;
-extern QAction *actionEditToggleFloatExport;
 
 extern QAction* actionFormatPickColor;
 extern QAction* actionFormatColorBranch;
@@ -95,11 +101,19 @@
 extern QAction *actionFormatBackColor;
 extern QAction *actionFormatLinkColor;
 
-extern QActionGroup *actionGroupFormatFrameTypes;
+extern Q3ActionGroup* actionGroupModModes;
+extern QAction* actionModModeColor;
+extern QAction* actionModModeLink;
+extern QAction* actionModModeCopy;
+
+extern Q3ActionGroup *actionGroupFormatFrameTypes;
 extern QAction *actionFormatFrameNone;
 extern QAction *actionFormatFrameRectangle;
 
-extern QActionGroup *actionGroupFormatLinkStyles;
+extern Q3ActionGroup *actionGroupFormatLinkStyles;
+extern QAction *actionFormatIncludeImagesVer;
+extern QAction *actionFormatIncludeImagesHor;
+extern QAction *actionFormatHideLinkUnselected;
 extern QAction *actionFormatLinkStyleLine;
 extern QAction *actionFormatLinkStyleParabel;
 extern QAction *actionFormatLinkStylePolyLine;
@@ -111,213 +125,98 @@
 extern QAction *actionSettingsAutoselectHeading;
 extern QAction *actionSettingsAutoselectText;
 extern QAction *actionSettingsPasteNewHeading;
-
-extern QPopupMenu *branchContextMenu;
-extern QPopupMenu *floatimageContextMenu;
-extern QPopupMenu *saveImageFormatMenu;
-extern QPopupMenu *exportImageFormatMenu;
-extern QPopupMenu *canvasContextMenu;
+extern QAction *actionSettingsUseFlagGroups;
+
+extern Q3PopupMenu *branchContextMenu;
+extern Q3PopupMenu *branchLinksContextMenu;
+extern Q3PopupMenu *branchLinksContextMenuDup;
+extern Q3PopupMenu *floatimageContextMenu;
+extern Q3PopupMenu *saveImageFormatMenu;
+extern Q3PopupMenu *exportImageFormatMenu;
+extern Q3PopupMenu *canvasContextMenu;
 
 extern Settings settings;
 
+extern QString iconPath;
+extern QDir vymBaseDir;
+
+int MapEditor::mapNum=0;	// make instance
 
 ///////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////
 MapEditor::MapEditor(
-	QWidget* parent, bool interactive, const char* name, WFlags f) :
-    QCanvasView(parent,name,f)
+	QWidget* parent, bool interactive, const char* name, Qt::WFlags f) :
+  Q3CanvasView(parent,name,f), urlOperator(0), imageBuffer(0)
 {
 	//cout << "Constructor ME "<<this<<endl;
-
-    mapCanvas = new QCanvas(1000,800);
+	mapNum++;
+
+    viewport()->setAcceptDrops(true);
+
+    mapCanvas = new Q3Canvas(1000,800);
 	mapCanvas->setAdvancePeriod(30);
+	mapCanvas->setBackgroundColor (Qt::white);
 
     setCanvas (mapCanvas);
 	
-	setVScrollBarMode ( QScrollView::AlwaysOn );
-	setHScrollBarMode ( QScrollView::AlwaysOn );
-
-	// Now create the _global_ system flags _once_:
-	// (Later all OrnamentedObj copy from this 
-	// and set their own canvas)
-	if (!systemFlagsDefault)
-	{
-		systemFlagsDefault = new FlagRowObj (mapCanvas);
-		systemFlagsDefault->setVisibility (false);
-		systemFlagsDefault->setName ("systemFlagsDef");
-
-		FlagObj *fo = new FlagObj (mapCanvas);
-		fo->load(QPixmap(flag_note_xpm));
-		fo->setName("note");
-		fo->setToolTip(tr("Note"));
-		systemFlagsDefault->addFlag (fo);	// makes deep copy
-
-		fo->load(QPixmap(flag_url_xpm));
-		fo->setName("url");
-		fo->setToolTip(tr("WWW Document (external)"));
-		systemFlagsDefault->addFlag (fo);
-		
-		fo->load(QPixmap(flag_vymlink_xpm));
-		fo->setName("vymLink");
-		fo->setToolTip(tr("Link to another vym map"));
-		systemFlagsDefault->addFlag (fo);	
-
-		fo->load(QPixmap(flag_scrolled_right_xpm));
-		fo->setName("scrolledright");
-		fo->setToolTip(tr("subtree is scrolled"));
-		systemFlagsDefault->addFlag (fo);
-		
-		fo->load(QPixmap(flag_tmpUnscrolled_right_xpm));
-		fo->setName("tmpUnscrolledright");
-		fo->setToolTip(tr("subtree is temporary scrolled"));
-		systemFlagsDefault->addFlag (fo);
-		delete (fo);
-	}
-	if (!standardFlagsDefault)
-	{
-		standardFlagsDefault = new FlagRowObj (mapCanvas);
-		standardFlagsDefault->setVisibility (false);
-		standardFlagsDefault->setName ("standardFlagsDef");
-
-		FlagObj *fo = new FlagObj (mapCanvas);
-		fo->load(QPixmap(flag_exclamationmark_xpm));
-		fo->setName("exclamationmark");
-		fo->setToolTip(tr("Take care!"));
-		standardFlagsDefault->addFlag (fo);	// makes deep copy
-		
-		fo->load(QPixmap(flag_questionmark_xpm));
-		fo->setName("questionmark");
-		fo->setToolTip(tr("Really?"));
-		standardFlagsDefault->addFlag (fo);	
-
-		fo->load(QPixmap(flag_hook_green_xpm));
-		fo->setName("hook-green");
-		fo->setToolTip(tr("ok!"));
-		standardFlagsDefault->addFlag (fo);	
-
-		fo->load(QPixmap(flag_cross_red_xpm));
-		fo->setName("cross-red");
-		fo->setToolTip(tr("Not ok!"));
-		standardFlagsDefault->addFlag (fo);	
-
-		fo->load(QPixmap(flag_stopsign_xpm));
-		fo->setName("stopsign");
-		fo->setToolTip(tr("This won't work!"));
-		standardFlagsDefault->addFlag (fo);	
-
-		fo->load(QPixmap(flag_smiley_good_xpm));
-		fo->setName("smiley-good");
-		fo->setToolTip(tr("Good"));
-		standardFlagsDefault->addFlag (fo);	
-
-		fo->load(QPixmap(flag_smiley_sad_xpm));
-		fo->setName("smiley-sad");
-		fo->setToolTip(tr("Bad"));
-		standardFlagsDefault->addFlag (fo);	
-
-		fo->load(QPixmap(flag_clock_xpm));
-		fo->setName("clock");
-		fo->setToolTip(tr("Time critical"));
-		standardFlagsDefault->addFlag (fo);	
-
-		fo->load(QPixmap(flag_lamp_xpm));
-		fo->setName("lamp");
-		fo->setToolTip(tr("Idea!"));
-		standardFlagsDefault->addFlag (fo);	
-
-		fo->load(QPixmap(flag_arrow_up_xpm));
-		fo->setName("arrow-up");
-		fo->setToolTip(tr("Important"));
-		standardFlagsDefault->addFlag (fo);	
-
-		fo->load(QPixmap(flag_arrow_down_xpm));
-		fo->setName("arrow-down");
-		fo->setToolTip(tr("Unimportant"));
-		standardFlagsDefault->addFlag (fo);	
-
-		fo->load(QPixmap(flag_thumb_up_xpm));
-		fo->setName("thumb-up");
-		fo->setToolTip(tr("I like this"));
-		standardFlagsDefault->addFlag (fo);	
-
-		fo->load(QPixmap(flag_thumb_down_xpm));
-		fo->setName("thumb-down");
-		fo->setToolTip(tr("I do not like this"));
-		standardFlagsDefault->addFlag (fo);	
-		
-		fo->load(QPixmap(flag_heart_xpm));
-		fo->setName("heart");
-		fo->setToolTip(tr("I just love... "));
-		standardFlagsDefault->addFlag (fo);	
-
-		fo->load(QPixmap(flag_flash_xpm));
-		fo->setName("flash");
-		fo->setToolTip(tr("Dangerous"));
-		standardFlagsDefault->addFlag (fo);	
-		
-		fo->load(QPixmap(flag_lifebelt_xpm));
-		fo->setName("lifebelt");
-		fo->setToolTip(tr("This will help"));
-		standardFlagsDefault->addFlag (fo);	
-		delete (fo);
-
-	}
-	
+	// Always show scroll bars (automatic would flicker sometimes)
+	setVScrollBarMode ( Q3ScrollView::AlwaysOn );
+	setHScrollBarMode ( Q3ScrollView::AlwaysOn );
+
     mapCenter = new MapCenterObj(mapCanvas);
     mapCenter->setVisibility (true);
 	mapCenter->setMapEditor (this);
-	mapCenter->setHeading (tr("New Map"));
+	mapCenter->setHeading (tr("New Map","Heading of mapcenter in new map"));
+	mapCenter->move(mapCanvas->width()/2-mapCenter->width()/2,mapCanvas->height()/2-mapCenter->height()/2);
 
     printer=NULL;
 
     lineedit = new QLineEdit(this, "lineedit"  );
-    connect( lineedit, SIGNAL( returnPressed() ), SLOT( finishedLineEditNoSave() ) );
+    connect( lineedit, SIGNAL( returnPressed() ), SLOT( finishedLineEdit() ) );
     lineedit->hide();
 
-    actColor=black; setColor (actColor);
-	deflinkcolor=QColor (0,0,255);
+    actColor=Qt::black; setColor (actColor);
+	defLinkColor=QColor (0,0,255);
+	defXLinkColor=QColor (180,180,180);
 	linkcolorhint=DefaultColor;
 	linkstyle=StylePolyParabel;
-	mapCanvas->setBackgroundColor (white);
 
 	// Create bitmap cursors, patform dependant
 	#if defined(Q_OS_MACX)
-		#include "icons/cursorhandopen16.xpm"
-		#include "icons/cursorcolorpicker16.xpm"
-		QBitmap cb( 16, 16, chandopen, TRUE );
-		QBitmap cm( 16, 16, chandopenmask, TRUE );
-		handOpenCursor=QCursor ( cb, cm );		
+		handOpenCursor=QCursor ( QPixmap(iconPath+"cursorhandopen16.png") );		
 		// set hot spot to tip of picker			
-		pickColorCursor=QCursor ( cursorcolorpicker_xpm, 1,15 ); 
+		pickColorCursor=QCursor ( QPixmap (iconPath+"cursorcolorpicker16.png"), 1,15 ); 
 	#else
-		#include "icons/cursorhandopen.xpm"
-		#include "icons/cursorcolorpicker.xpm"
-
-		QBitmap cb( 32, 32, chandopen, TRUE );
-		QBitmap cm( 32, 32, chandopenmask, TRUE );
-		handOpenCursor=QCursor ( cb, cm );		
+		handOpenCursor=QCursor (QPixmap(iconPath+"cursorhandopen16.png"));		
 		// set hot spot to tip of picker			
-		pickColorCursor=QCursor ( cursorcolorpicker_xpm, 5,27 ); 
+		pickColorCursor=QCursor ( QPixmap(iconPath+"cursorcolorpicker.png"), 5,27 ); 
 	#endif
 
-
 	pickingColor=false;
+	drawingLink=false;
+	copyingObj=false;
 
     editingBO=NULL;
     selection=NULL;
     selectionLast=NULL;
     movingObj=NULL;
 
+	defXLinkWidth=1;
+	defXLinkColor=QColor (230,230,230);
+
     mapChanged=false;
 	mapDefault=true;
 	mapUnsaved=false;
-	undoSelection=NULL;
 	
 	zipped=true;
 	filePath="";
-	fileName="unnamed";
+	fileName=tr("unnamed");
 	mapName="";
 
+	undosTotal=settings.readNumEntry("/vym/mapeditor/undoLevels",50);
+	undosAvail=0;	
+	undoNum=0;
+	
 	// Initialize find routine
 	itFind=NULL;				
 	EOFind=false;
@@ -325,7 +224,11 @@
 	printFrame=true;
 	printFooter=true;
 
-	blockreposition=false;
+	blockReposition=false;
+	blockSaveState=false;
+
+	hidemode=HideNone;
+
 	isInteractive=interactive;
 	if (isInteractive)
 		// Create temporary files
@@ -334,13 +237,22 @@
 	// Initially set movingCentre
 	updateViewCenter();
 
+	// For testing purposes create history window
+	historyWindow = new ShowTextDialog (this);
+	historyWindow->setCaption (fileName);
+
 	mapCenter->reposition();	//	for positioning heading
 }
 
 MapEditor::~MapEditor()
 {
+  if (imageBuffer) delete imageBuffer;
+  if (urlOperator) {
+    urlOperator->stop();
+    delete urlOperator;
+  }
+
 	//cout <<"Destructor MapEditor\n";
-	if (isInteractive) delTmpDirs();
 
 	// Save Settings
 	//settings.writeEntry( "/vym/mapeditor/editmode/autoselect",  );
@@ -362,7 +274,7 @@
     return mapCenter;
 }
 
-QCanvas* MapEditor::getCanvas()
+Q3Canvas* MapEditor::getCanvas()
 {
     return mapCanvas;
 }
@@ -420,6 +332,7 @@
 		{
 			mapCenter->moveAllBy(dx,dy);
 			mapCenter->reposition();
+//			mapCenter->positionBBox();	// To move float
 
 			// scroll the view (in order to not move map on screen)
 			scrollBy (dx,dy);
@@ -427,45 +340,44 @@
 	}
 }
 
-bool MapEditor::blockReposition()
+bool MapEditor::isRepositionBlocked()
 {
-	return blockreposition;
+	return blockReposition;
+}
+
+QString MapEditor::getName (LinkableMapObj *lmo)
+{
+	QString s;
+	if (!lmo) return QString("Error: NULL has no name!");
+
+	if ((typeid(*lmo) == typeid(BranchObj) ||
+				      typeid(*lmo) == typeid(MapCenterObj))) 
+	{
+		
+		s=(((BranchObj*)lmo)->getHeading());
+		if (s=="") s="unnamed";
+		return QString("branch (<font color=\"#0000ff\">%1</font>)").arg(s);
+	}	
+	if ((typeid(*lmo) == typeid(FloatImageObj) ))
+		return QString ("floatimage [<font color=\"#0000ff\">%1</font>]").arg(((FloatImageObj*)lmo)->getOriginalFilename());
+	return QString("Unknown type has no name!");
 }
 
 void MapEditor::makeTmpDirs()
 {
 	// Create unique temporary directories
-	char tmpdir[]="/tmp/vym-XXXXXX";	
-	bakMapDir=mkdtemp(tmpdir);
-	makeSubDirs(bakMapDir);
-	// FIXME set permissions
-	// and maybe use QT method for portability
+	tmpMapDir=tmpVymDir+QString("/mapeditor-%1").arg(mapNum);
+	QDir d;
+	d.mkdir (tmpMapDir,true);
 }
 
-void MapEditor::delTmpDirs()
+QString MapEditor::saveToDir(const QString &tmpdir, const QString &prefix, bool writeflags, const QPoint &offset, LinkableMapObj *saveSelection)
 {
-	//FIXME delete tmp directory, better use QT methods here:
-	system ( "rm -rf "+ bakMapDir );
-}
-
-
-void MapEditor::makeSubDirs(const QString &s)
-{
-	QDir d(s);
-	d.mkdir ("images");	
-	d.mkdir ("flags");	
-}
-
-
-QString MapEditor::saveToDir(const QString &tmpdir, const QString &prefix, bool writeflags, const QPoint &offset, SaveMode savemode)
-{
-	// tmpdir		temporary directory to which data will be writte
+	// tmpdir		temporary directory to which data will be written
 	// prefix		mapname, which will be appended to images etc.
 	// writeflags	Only write flags for "real" save of map, not undo
 	// offset		offset of bbox of whole map in canvas. 
 	//				Needed for XML export
-	// completeMap	if false, only vympart will be written, without
-	//				mapcenter
 	
 	// Save Header
 	QString ls;
@@ -490,14 +402,16 @@
 	if (linkcolorhint==HeadingColor) 
 		colhint=attribut("linkColorHint","HeadingColor");
 
-	QString mapAttr=attribut("version",__VYM_VERSION__);
-	if (savemode==CompleteMap)
+	QString mapAttr=attribut("version",__VYM_VERSION);
+	if (!saveSelection)
 		mapAttr+= attribut("author",mapCenter->getAuthor()) +
 				  attribut("comment",mapCenter->getComment()) +
 			      attribut("date",mapCenter->getDate()) +
 		          attribut("backgroundColor", mapCanvas->backgroundColor().name() ) +
 		          attribut("linkStyle", ls ) +
-		          attribut("linkColor", deflinkcolor.name() ) +
+		          attribut("linkColor", defLinkColor.name() ) +
+		          attribut("defXLinkColor", defXLinkColor.name() ) +
+		          attribut("defXLinkWidth", QString().setNum(defXLinkWidth,10) ) +
 		          colhint; 
 	s+=beginElement("vymmap",mapAttr);
 	incIndent();
@@ -505,21 +419,29 @@
 	// Find the used flags while traversing the tree
 	standardFlagsDefault->resetUsedCounter();
 	
+	// Reset the counters before saving
+	FloatImageObj (mapCanvas).resetSaveCounter();
+
 	// Build xml recursivly
-	if (savemode==CompleteMap)
+	if (!saveSelection)
 		s+=mapCenter->saveToDir(tmpdir,prefix,writeflags,offset);
 	else
 	{
-		if ( undoSelection &&
-			typeid(*undoSelection) == typeid(BranchObj) )
-			s+=((BranchObj*)(undoSelection))->saveToDir(tmpdir,prefix,offset);
+		if ( typeid(*saveSelection) == typeid(BranchObj) )
+			s+=((BranchObj*)(saveSelection))->saveToDir(tmpdir,prefix,offset);
+		else if ( typeid(*saveSelection) == typeid(FloatImageObj) )
+			s+=((FloatImageObj*)(saveSelection))->saveToDir(tmpdir,prefix,offset);
+			
+		else if (selection && typeid(*selection)==typeid(BranchObj))
+				// This is used if selected branch is saved from mainwindow
+				s+=((BranchObj*)selection)->saveToDir(tmpdir,prefix,offset);
 	}
 
 	// Save local settings
 	s+=settings.getXMLData (destPath);
 
 	// Save selection
-	if (selection) 
+	if (selection && !saveSelection ) 
 		s+=valueElement("select",selection->getSelectString());
 
 	decIndent();
@@ -527,37 +449,240 @@
 
 	if (writeflags)
 		standardFlagsDefault->saveToDir (tmpdir+"/flags/","",writeflags);
-	
 	return s;
 }
 
-void MapEditor::saveState()
+void MapEditor::saveState(const QString &comment)
 {
-	saveState (CompleteMap,NULL);
+	// Save complete map
+	saveState (CompleteMap,"",NULL,"",NULL, comment);
 }
 
-void MapEditor::saveState(const SaveMode &mode, LinkableMapObj *part)
+void MapEditor::saveState(LinkableMapObj *undoSel, const QString &comment)
 {
-	// all binary data is saved in bakMapDir (created in Constructor)
-	// the xml data itself is kept in memory in backupXML
-	// 
-	// For faster write/read of data, a part of the map can be
-	// written. Then the undoSelection will mark, which part of the
-	// map should be replaced if an undo is wanted later.
-
-	if (mode==PartOfMap && part && (typeid(*part) == typeid (BranchObj) ) ) 
+	// save the given part of the map 
+	saveState (PartOfMap,"",undoSel,"",NULL, comment);
+}
+
+void MapEditor::saveState(const QString &uc, const QString &rc, const QString &comment)
+{
+	// selection does not change during action,
+	// so just save commands for undo and redo
+	LinkableMapObj *unsel;
+	if (selection)
+		unsel=selection;
+	else
+		unsel=NULL;
+	saveState (UndoCommand,uc,unsel,rc,unsel, comment);
+}
+
+void MapEditor::saveState(const QString & uncom, LinkableMapObj *unsel, const QString &comment) 
+{
+	saveState (UndoCommand,uncom,unsel,"FIXME-redoCom",NULL, comment);
+}
+
+void MapEditor::saveState(const SaveMode &savemode, const QString &undoCom, LinkableMapObj *undoSel, const QString &redoCom, LinkableMapObj *redoSel, const QString &comment)
+{
+	// Main saveState
+
+	if (blockSaveState) return;
+
+	/* TODO remove after testing
+	cout << "ME::saveState()  begin\n"<<endl;
+	cout << "    undosTotal="<<undosTotal<<endl;
+	cout << "    undosAvail="<<undosAvail<<endl;
+	cout << "       undoNum="<<undoNum<<endl;
+	cout << "    ---------------------------"<<endl;
+	*/
+
+	historyWindow->append (comment);
+	
+	setChanged();
+
+	// Find out current undo directory
+	if (undosAvail<undosTotal) undosAvail++;
+	undoNum++;
+	if (undoNum>undosTotal) undoNum=1;
+	
+	QString backupXML;
+	QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(undoNum));
+	QString bakMapPath=QDir::convertSeparators(bakMapDir+"/map.xml");
+
+	// Create bakMapDir if not available
+	QDir d(bakMapDir);
+	if (!d.exists()) 
+		makeSubDirs (bakMapDir);
+
+	// Save current selection 
+	QString redoSelection="";
+	if (redoSel)
+		redoSelection=redoSel->getSelectString();
+
+	// Save the object, which should be undone
+	QString undoSelection="";
+	if (undoSel)
+		undoSelection=undoSel->getSelectString();
+		
+	// Save depending on how much needs to be saved	
+	QString undoCommand="";
+	if (savemode==UndoCommand)
 	{
-		// Writing a vympart only is useful for BranchObj
-		undoSelection=part;
-		backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),PartOfMap);
-	} else	
+		undoCommand=undoCom;
+		backupXML="";
+	}	
+	else if (savemode==PartOfMap && undoSel)
 	{
-		undoSelection=NULL;
-		backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),CompleteMap);
+		undoCommand="undoPart (\""+ undoSelection+"\",\""+bakMapPath+"\")";
+		backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),undoSel);
+	} else
+	{
+		undoCommand="undoMap (\""+bakMapPath+"\")";
+		backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),NULL);
+		undoSelection="";
+	}
+	if (!backupXML.isEmpty())
+		// Write XML Data to disk
+		saveStringToDisk (QString(bakMapPath),backupXML);
+
+	SimpleSettings set;
+	set.setEntry (QString("undoCommand"),undoCommand);
+	set.setEntry (QString("undoSelection"),undoSelection);
+	set.setEntry (QString("redoCommand"),redoCom);
+	set.setEntry (QString("redoSelection"),redoSelection);
+	set.setEntry (QString("comment"),comment);
+	set.writeSettings(QString(bakMapDir+"/commands"));
+
+	/* TODO remove after testing
+	cout << "          into="<< bakMapDir<<endl;
+	cout << "    undosAvail="<<undosAvail<<endl;
+	cout << "       undoNum="<<undoNum<<endl;
+	cout << "    ---------------------------"<<endl;
+	cout << "    comment="<<comment<<endl;
+	cout << "    ---------------------------"<<endl;
+	cout << "    undoCom="<<undoCommand<<endl;
+	cout << "    undoSel="<<undoSelection<<endl;
+	cout << "    ---------------------------"<<endl;
+	cout << "    redoCom="<<redoCom<<endl;
+	cout << "    redoSel="<<redoSelection<<endl;
+	cout << "    ---------------------------"<<endl<<endl;
+	*/
+}
+
+void MapEditor::parseAtom(const QString &atom)
+{
+	API api;
+	QString s,t;
+	int x,y;
+	bool ok;
+
+	// Split string s into command and parameters
+	api.parseCommand (atom);
+	QString com=api.command();
+	
+	// External commands
+	if (com=="moveBranchUp")
+		moveBranchUp();
+	else if (com=="moveBranchDown")
+		moveBranchDown();
+	else if (com=="move")
+	{
+		if (api.checkParamCount(2) && selection )
+		{	
+			x=api.parInt (ok,0);
+			if (ok)
+			{
+				y=api.parInt (ok,1);
+				if (ok) move (x,y);
+			}
+		}	
+	}
+	else if (com=="linkBranchToPos")
+	{
+		if (selection && typeid(*selection) == typeid(BranchObj) ) 
+		{
+			if (api.checkParamCount(4))
+			{
+				s=api.parString(ok,0);
+				LinkableMapObj *dst=mapCenter->findObjBySelect (s);
+				if (dst)
+				{	
+					if (typeid(*dst) == typeid(BranchObj) ) 
+					{
+						// Get number in parent
+						x=api.parInt (ok,1);
+						if (ok)
+							((BranchObj*)selection)->moveBranchTo ((BranchObj*)(dst),x);
+					} else if (typeid(*dst) == typeid(MapCenterObj) ) 
+					{
+						((BranchObj*)selection)->moveBranchTo ((BranchObj*)(dst),-1);
+						// Get coordinates of mainbranch
+						x=api.parInt (ok,2);
+						if (ok)
+						{
+							y=api.parInt (ok,3);
+							if (ok) ((BranchObj*)selection)->move (x,y);
+						}
+					}	
+				}	
+			}
+		}
+	} else if (com=="setHeading")
+	{
+		if (api.checkParamCount(1))
+		{
+			s=api.parString (ok,0);
+			if (ok) setHeading (s);
+		}	
+	} else if (com=="setURL")
+	{
+		if (api.checkParamCount(1))
+		{
+			s=api.parString (ok,0);
+			if (ok) setURL(s);
+		}	
+	} else if (com=="setVymLink")
+	{
+		if (api.checkParamCount(1))
+		{
+			s=api.parString (ok,0);
+			if (ok) setVymLink(s);
+		}	
+	}
+	// Internal commands, used for undo etc.	
+	else if (com==QString("undoMap"))
+	{
+		if (api.checkParamCount(1))
+			undoXML("",api.parString (ok,0));
+	} else if (com==QString("undoPart"))
+	{
+		if (api.checkParamCount(2))
+		{
+			s=api.parString (ok,0);
+			t=api.parString (ok,1);
+			undoXML(s,t);	
+		}
+	} else if (com=="select")
+		if (api.checkParamCount(1))
+		{
+			s=api.parString(ok,0);
+			if (ok) select (s);
+		}	
+	else
+	{
+		api.setError ("Unknown command in: "+atom);
+		cout << "ME::parse   api should have error now...\n";
+	}
+
+	// Any errors?
+	if (api.error())
+	{
+		qWarning("MapEditor::parseAtom: Error!");
+		qWarning(api.errorDesc());
 	}	
 }
 
-void MapEditor::finishedLineEditNoSave()
+
+void MapEditor::finishedLineEdit()
 {
 	// This is called by finishedLineEdit or any MapEditor method,
 	// which wants to assure, that lineedits finish, before e.g. a branch is 
@@ -569,6 +694,7 @@
 
     if (editingBO!=NULL) 
 	{
+		saveState("setHeading (\""+editingBO->getHeading()+"\")",editingBO, QString("Set heading of %1 to \"%2\"").arg(getName(editingBO)).arg(lineedit->text()) );
 		editingBO->setHeading(lineedit->text() );
 		editingBO=NULL;
 		lineedit->releaseKeyboard();
@@ -580,6 +706,14 @@
     }		
 }
 
+void MapEditor::toggleHistoryWindow()
+{
+	if (historyWindow->isVisible())
+		historyWindow->hide();
+	else	
+		historyWindow->show();
+}
+
 
 bool MapEditor::isDefault()
 {
@@ -609,7 +743,7 @@
 void MapEditor::closeMap()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	// Unselect before disabling the toolbar actions
 	if (selection) selection->unselect();
@@ -627,20 +761,31 @@
 
 void MapEditor::setFilePath(QString fname, QString destname)
 {
-	filePath=fname;
-	fileName=fname;
-	destPath=destname;
-
-	// If fname is not an absolute path, complete it
-	filePath=QDir(fname).absPath();
-	fileDir=filePath.left (1+filePath.findRev ("/"));
-
-	// Set short name, too. Search from behind:
-	int i=fileName.findRev("/");
-	if (i>=0) fileName=fileName.remove (0,i+1);
-
-	// Forget the .vym (or .xml) for name of map
-	mapName=fileName.left(fileName.findRev(".",-1,true) );
+	if (fname.isEmpty() || fname=="")
+	{
+		filePath="";
+		fileName="";
+		destPath="";
+	} else
+	{
+		filePath=fname;		// becomes absolute path
+		fileName=fname;		// gets stripped of path
+		destPath=destname;	// needed for vymlinks
+
+		// If fname is not an absolute path, complete it
+		filePath=QDir(fname).absPath();
+		fileDir=filePath.left (1+filePath.findRev ("/"));
+
+		// Set short name, too. Search from behind:
+		int i=fileName.findRev("/");
+		if (i>=0) fileName=fileName.remove (0,i+1);
+
+		// Forget the .vym (or .xml) for name of map
+		mapName=fileName.left(fileName.findRev(".",-1,true) );
+
+		// Adjust history window
+		historyWindow->setCaption (fileName);
+	}
 }
 
 QString MapEditor::getFilePath()
@@ -663,12 +808,12 @@
 	return destPath;
 }
 
-int MapEditor::load (QString &fname, const LoadMode &lmode)
+ErrorCode MapEditor::load (QString fname, LoadMode lmode)
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
-
-	int returnCode=0;
+	if (lineedit) finishedLineEdit();
+
+	ErrorCode err=success;
 
 	if (lmode==NewMap)
 	{
@@ -679,8 +824,7 @@
 		// (map state is set later at end of load...)
 	} else
 	{
-		setChanged();
-		saveState(PartOfMap,selection);
+		saveState(selection,"Load map");
 	}	
 	
     
@@ -693,19 +837,22 @@
 	{
 		QMessageBox::critical( 0, tr( "Critical Parse Error" ),
 				   tr("Couldn't open map " +fname)+".");
-		returnCode=1;	
+		err=aborted;	
 	} else
 	{
-		blockreposition=true;
+		blockReposition=true;
 		QXmlInputSource source( file);
 		QXmlSimpleReader reader;
 		reader.setContentHandler( &handler );
 		reader.setErrorHandler( &handler );
 		handler.setMapEditor( this );
 		handler.setTmpDir (filePath.left(filePath.findRev("/",-1)));	// needed to load files with rel. path
+		handler.setInputFile (file.name());
 		handler.setLoadMode (lmode);
+		blockSaveState=true;
 		bool ok = reader.parse( source );
-		blockreposition=false;
+		blockReposition=false;
+		blockSaveState=false;
 		file.close();
 		if ( ok ) 
 		{
@@ -727,16 +874,19 @@
 		}	
 	}	
 	updateActions();
-	return returnCode;
+	return err;
 }
 
 int MapEditor::save (const SaveMode &savemode)
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	int returnCode=0;
 
+	// The SaveMode UndoCommand is not supported here
+	if (savemode==UndoCommand) return 1;
+
 	// Create mapName and fileDir
 	makeSubDirs (fileDir);
 	QString fname;
@@ -748,32 +898,14 @@
 		fname=fileName;
 
 
-	// Check if fname is writeable
-	QFile file( fileDir+fname);
-	if (!file.open( IO_WriteOnly ) ) 
-	{
-		QMessageBox::critical( 0, tr( "Critical Save Error" ),
-					   tr("Couldn't write to ") +fileDir+fname);
+	QString saveFile;
+	if (savemode==CompleteMap || selection==NULL)
+		saveFile=saveToDir (fileDir,mapName+"-",true,QPoint(),NULL);
+	else	
+		saveFile=saveToDir (fileDir,mapName+"-",true,QPoint(),selection);
+
+	if (!saveStringToDisk(fileDir+fname,saveFile))
 		return 1;
-	}	
-	file.close();
-
-	QString saveFile;
-	saveFile=saveToDir (fileDir,mapName+"-",true,QPoint(),savemode);
-
-	file.setName ( fileDir  + fname);
-	if ( !file.open( IO_WriteOnly ) )
-	{
-		// This should neverever happen
-		QMessageBox::critical(0, tr("Critcal save error"),"MapEditor::save() Couldn't open "+file.name());
-		return 1;
-	}	
-
-	// Write it finally, and write in UTF8, no matter what 
-	QTextStream ts( &file );
-	ts.setEncoding (QTextStream::UnicodeUTF8);
-	ts << saveFile;
-	file.close();
 
 	if (returnCode==0)
 	{
@@ -798,12 +930,13 @@
 void MapEditor::print()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	if ( !printer ) 
 	{
 		printer = new QPrinter;
 		printer->setColorMode (QPrinter::Color);
+		printer->setPrinterName (settings.readEntry("/vym/mainwindow/printerName",printer->printerName()));
 	}
 
 	QRect totalBBox=mapCenter->getTotalBBox();
@@ -840,50 +973,56 @@
 		// e.g. (0,50,700,700) is upper part on A4
 		// see also /usr/lib/qt3/doc/html/coordsys.html
 
-		QPaintDeviceMetrics metrics (printer);
+		Q3PaintDeviceMetrics metrics (printer);
 
 		double paperAspect = (double)metrics.width()   / (double)metrics.height();
 		double   mapAspect = (double)totalBBox.width() / (double)totalBBox.height();
 
-		QRect mapRect=mapCenter->getTotalBBox();
-		QCanvasRectangle *frame=NULL;
-		QCanvasText *footerFN=NULL;
-		QCanvasText *footerDate=NULL;
+		QRect mapRect=totalBBox;
+		Q3CanvasRectangle *frame=NULL;
+		Q3CanvasText *footerFN=NULL;
+		Q3CanvasText *footerDate=NULL;
 		if (printFrame || printFooter)
 		{
 			
 			if (printFrame) 
 			{
 				// Print frame around map
-				mapRect.setRect (mapRect.x()-10, mapRect.y()-10, 
-					mapRect.width()+20, mapRect.height()+20);
-				frame=new QCanvasRectangle (mapRect,mapCanvas);
-				frame->setBrush (QColor(white));
-				frame->setPen (QColor(black));
+				mapRect.setRect (totalBBox.x()-10, totalBBox.y()-10, 
+					totalBBox.width()+20, totalBBox.height()+20);
+				frame=new Q3CanvasRectangle (mapRect,mapCanvas);
+				frame->setBrush (QColor(Qt::white));
+				frame->setPen (QColor(Qt::black));
 				frame->setZ(0);
 				frame->show();    
 			}		
+			/* TODO remove after testing 
+			QCanvasLine *l=new QCanvasLine (mapCanvas);
+			l->setPoints (0,0,mapRect.width(),mapRect.height());
+			l->setPen (QPen(QColor(black), 1));
+			l->setZ (200);
+			l->show();
+			*/
+
 			if (printFooter) 
 			{
 				// Print footer below map
 				QFont font;		
 				font.setPointSize(10);
-				footerFN=new QCanvasText (mapCanvas);
+				footerFN=new Q3CanvasText (mapCanvas);
 				footerFN->setText ("VYM - " + fileName);
 				footerFN->setFont(font);
 				footerFN->move (mapRect.x(), mapRect.y() + mapRect.height() );
 				footerFN->setZ(Z_TEXT);
 				footerFN->show();    
-				footerDate=new QCanvasText (mapCanvas);
+				footerDate=new Q3CanvasText (mapCanvas);
 				footerDate->setText (QDate::currentDate().toString(Qt::TextDate));
 				footerDate->setFont(font);
 				footerDate->move (mapRect.x()+mapRect.width()-footerDate->boundingRect().width(), mapRect.y() + mapRect.height() );
 				footerDate->setZ(Z_TEXT);
 				footerDate->show();    
-				mapRect.setRect (mapRect.x(), mapRect.y(), 
-					mapRect.width(), mapRect.height()+20);
 			}
-			pp.setWindow (mapRect.x(), mapRect.y(), mapRect.width(), mapRect.height());
+			pp.setWindow (mapRect.x(), mapRect.y(), mapRect.width(), mapRect.height()+20);
 		}	else	
 		{
 			pp.setWindow (mapRect);
@@ -915,6 +1054,9 @@
 			selection=oldselection;
 			selection->select();
 		}	
+
+		// Save settings in vymrc
+		settings.writeEntry("/vym/mainwindow/printerName",printer->printerName());
 	}
 }
 
@@ -947,86 +1089,84 @@
 	return pix;
 }
 
+void MapEditor::setHideTmpMode (HideTmpMode mode)
+{
+	hidemode=mode;
+	mapCenter->setHideTmp (hidemode);
+	mapCenter->reposition();
+	adjustCanvasSize();
+	canvas()->update();
+}
+
+HideTmpMode MapEditor::getHideTmpMode()
+{
+	return hidemode;
+}
+
 void MapEditor::exportImage(QString fn)
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
-
+	if (lineedit) finishedLineEdit();
+
+	setExportMode (true);
 	QPixmap pix (getPixmap());
 	pix.save(fn, "PNG");
+	setExportMode (false);
+}
+
+void MapEditor::setExportMode (bool b)
+{
+	// should be called before and after exports
+	// depending on the settings
+	if (b && settings.value("/vym/export/useHideExport","yes")=="yes")
+		setHideTmpMode (HideExport);
+	else	
+		setHideTmpMode (HideNone);
 }
 
 void MapEditor::exportImage(QString fn, int item)
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
-
+	if (lineedit) finishedLineEdit();
+
+	setExportMode (true);
 	QPixmap pix (getPixmap());
 	pix.save(fn, exportImageFormatMenu->text(item) );
+	setExportMode (false);
 }
 
-void MapEditor::exportASCII()
+void MapEditor::exportOOPresentation(const QString &fn, const QString &cf)
 {
-	// FIXME still experimental
-	QFileDialog *fd=new QFileDialog( this, tr("VYM - Export (ASCII)"));
-	fd->addFilter ("TXT (*.txt)");
-	fd->setCaption("VYM - Export (ASCII) (still experimental)");
-	fd->setMode( QFileDialog::AnyFile );
-	fd->show();
-
-	if ( fd->exec() == QDialog::Accepted )
+	ExportOO ex;
+	ex.setFile (fn);
+	ex.setMapCenter(mapCenter);
+	if (ex.setConfigFile(cf)) 
 	{
-		if (QFile (fd->selectedFile()).exists() )
-		{
-			QMessageBox mb( "VYM",
-				tr("The file ") + fd->selectedFile() + 
-				tr(" exists already. Do you want to overwrite it?"),
-			QMessageBox::Warning,
-			QMessageBox::Yes | QMessageBox::Default,
-			QMessageBox::Cancel | QMessageBox::Escape,
-			QMessageBox::NoButton );
-
-			mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
-			mb.setButtonText( QMessageBox::No, tr("Cancel"));
-			Export ex;
-			switch( mb.exec() ) 
-			{
-				case QMessageBox::Yes:
-					// save 
-					if (!ex.setOutputDir ("out"))
-					{
-						QMessageBox::critical (0,tr("Critical Export Error "),tr("Couldn't create directory ") + "out");
-						return;
-					}
-					break;;
-				case QMessageBox::Cancel:
-					// do nothing
-					return;
-					break;
-			}
-		}
-		Export ex;
-		ex.setPath (fd->selectedFile() );
-		ex.setMapCenter(mapCenter);
-		ex.exportMap();
+		setExportMode (true);
+		ex.exportPresentation();
+		setExportMode (false);
 	}
 }
 
 
+
 void MapEditor::exportXML(const QString &dir)
 {
+	// Hide stuff during export, if settings want this
+	setExportMode (true);
+
 	// Create subdirectories
 	makeSubDirs (dir);
 
 	// write to directory
-	QString saveFile=saveToDir (dir,mapName+"-",true,mapCenter->getTotalBBox().topLeft() ,CompleteMap);
+	QString saveFile=saveToDir (dir,mapName+"-",true,mapCenter->getTotalBBox().topLeft() ,NULL);
 	QFile file;
 
 	file.setName ( dir + "/"+mapName+".xml");
-	if ( !file.open( IO_WriteOnly ) )
+	if ( !file.open( QIODevice::WriteOnly ) )
 	{
 		// This should neverever happen
-		QMessageBox::critical (0,tr("Critical Export Error"),tr("MapEditor::exportXML couldn't open ")+file.name());
+		QMessageBox::critical (0,tr("Critical Export Error"),tr("MapEditor::exportXML couldn't open %1").arg(file.name()));
 		return;
 	}	
 
@@ -1038,6 +1178,8 @@
 
 	// Now write image, too
 	exportImage (dir+"/images/"+mapName+".png");
+
+	setExportMode (false);
 }
 
 void MapEditor::clear()
@@ -1051,240 +1193,264 @@
 	mapCenter->clear();
 }
 
+void MapEditor::copy()
+{
+	// Finish open lineEdits
+	if (lineedit) finishedLineEdit();
+
+	if (selection) 
+	{
+		// write to directory
+		QString clipfile="part";
+		QString saveFile=saveToDir (fileDir,clipfile+"-",true,QPoint(),selection);
+		QFile file;
+
+		file.setName ( clipboardDir + "/"+clipfile+".xml");
+		if ( !file.open( QIODevice::WriteOnly ) )
+		{
+			// This should neverever happen
+			QMessageBox::critical (0,tr("Critical Export Error"),tr("MapEditor::exportXML couldn't open %1").arg(file.name()));
+			return;
+		}	
+
+		// Write it finally, and write in UTF8, no matter what 
+		QTextStream ts( &file );
+		ts.setEncoding (QTextStream::UnicodeUTF8);
+		ts << saveFile;
+		file.close();
+
+		clipboardEmpty=false;
+		updateActions();
+	}	    
+}
+
+void MapEditor::redo()
+{
+	// Finish open lineEdits
+	if (lineedit) finishedLineEdit();
+
+	blockSaveState=true;
+	
+	// Find out current undo directory
+	QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(undoNum));
+
+	// Restore variables
+	QString undoCommand;
+	QString undoSelection;
+	QString redoCommand;
+	QString redoSelection;
+	SimpleSettings set;
+	set.readSettings(QString(bakMapDir+"/commands"));
+	undoCommand=set.readEntry ("undoCommand");
+	undoSelection=set.readEntry ("undoSelection");
+	redoCommand=set.readEntry ("redoCommand");
+	redoSelection=set.readEntry ("redoSelection");
+
+	// select  object before redo
+	if (!redoSelection.isEmpty())
+		select (redoSelection);
+
+/* TODO remove testing
+	cout << "ME::redo() begin\n";
+	cout << "    undosTotal="<<undosTotal<<endl;
+	cout << "    undosAvail="<<undosAvail<<endl;
+	cout << "       undoNum="<<undoNum<<endl;
+	cout << "    ---------------------------"<<endl;
+	cout << "    undoCom="<<undoCommand<<endl;
+	cout << "    undoSel="<<undoSelection<<endl;
+	cout << "    ---------------------------"<<endl;
+	cout << "    redoCom="<<redoCommand<<endl;
+	cout << "    redoSel="<<redoSelection<<endl;
+	cout << "    ---------------------------"<<endl;
+*/
+	parseAtom (undoCommand);
+	mapCenter->reposition();
+
+	//if (!redoSelection.isEmpty())
+	//	select (redoSelection);
+
+	undosAvail--;
+	if (undosAvail<1)
+		// Undo not longer available now
+		actionEditUndo->setEnabled (false);
+	else	
+		undoNum--; if (undoNum<1) undoNum=undosTotal;
+
+	blockSaveState=false;
+/* TODO remove testing
+	cout << "ME::redo() end\n";
+	cout << "    undosAvail="<<undosAvail<<endl;
+	cout << "       undoNum="<<undoNum<<endl;
+	cout << "    ---------------------------"<<endl<<endl;
+*/	
+}
+
 void MapEditor::undo()
 {
-	QDir d;
-	d.setPath(bakMapDir);
+	// Finish open lineEdits
+	if (lineedit) finishedLineEdit();
+
+	blockSaveState=true;
+	
+	// Find out current undo directory
+	QString bakMapDir=QDir::convertSeparators (QString(tmpMapDir+"/undo-%1").arg(undoNum));
+
+	// Restore variables
+	QString undoCommand;
+	QString undoSelection;
+	QString redoCommand;
+	QString redoSelection;
+	SimpleSettings set;
+	set.readSettings(QString(bakMapDir+"/commands"));
+	undoCommand=  set.readEntry ("undoCommand");
+	undoSelection=set.readEntry ("undoSelection");
+	redoCommand=  set.readEntry ("redoCommand");
+	redoSelection=set.readEntry ("redoSelection");
+
+	// select  object before undo
+	if (!undoSelection.isEmpty())
+		select (undoSelection);
+
+/* TODO testing
+	cout << "ME::undo() begin\n";
+	cout << "    undosTotal="<<undosTotal<<endl;
+	cout << "    undosAvail="<<undosAvail<<endl;
+	cout << "       undoNum="<<undoNum<<endl;
+	cout << "    ---------------------------"<<endl;
+	cout << "    undoCom="<<undoCommand<<endl;
+	cout << "    undoSel="<<undoSelection<<endl;
+	cout << "    ---------------------------"<<endl;
+	cout << "    redoCom="<<redoCommand<<endl;
+	cout << "    redoSel="<<redoSelection<<endl;
+	cout << "    ---------------------------"<<endl;
+*/	
+	parseAtom (undoCommand);
+	mapCenter->reposition();
+
+	//if (!redoSelection.isEmpty())
+	//	select (redoSelection);
+
+	undosAvail--;
+	if (undosAvail<1)
+		// Undo not longer available now
+		actionEditUndo->setEnabled (false);
+	else	
+		undoNum--; if (undoNum<1) undoNum=undosTotal;
+
+	blockSaveState=false;
+/* TODO remove testing
+	cout << "ME::undo() end\n";
+	cout << "    undosAvail="<<undosAvail<<endl;
+	cout << "       undoNum="<<undoNum<<endl;
+	cout << "    ---------------------------"<<endl<<endl;
+*/
+}
+
+void MapEditor::undoXML(const QString &undoSel, const QString &bakMapPath)
+{
+	QString bakMapDir=bakMapPath.left(bakMapPath.findRev("/"));
+	QDir d(bakMapDir);
+	QFile file (bakMapPath);
+
 	if (d.exists() )
 	{
-		// Finish open lineEdits
-		if (lineedit) finishedLineEditNoSave();
-
-		if (selection) 
-		{
-			selection->unselect();
-			selection=NULL;
-		}	
-		
+		// We need to parse saved XML data
 		mapBuilderHandler handler;
-		QXmlInputSource source;
-		source.setData(backupXML);
+		QXmlInputSource source( file);
 		QXmlSimpleReader reader;
 		reader.setContentHandler( &handler );
 		reader.setErrorHandler( &handler );
 		handler.setMapEditor( this );
 		handler.setTmpDir ( bakMapDir );	// needed to load files with rel. path
-		if (undoSelection)
+		if (undoSel.isEmpty())
 		{
-			selection=undoSelection;
-			selection->select();
-			handler.setLoadMode (ImportReplace);
-
+			unselect();
+			mapCenter->clear();
+			handler.setLoadMode (NewMap);
 		} else	
 		{
-			mapCenter->clear();
-			handler.setLoadMode (NewMap);
+			select (undoSel);
+			handler.setLoadMode (ImportReplace);
 		}	
-		blockreposition=true;
+		blockReposition=true;
 		bool ok = reader.parse( source );
-		blockreposition=false;
-		if ( ok ) 
-			mapCenter->reposition();
-			
-		else 
+		blockReposition=false;
+		if (! ok ) 
 		{	
 			// This should never ever happen
 			QMessageBox::critical( 0, tr( "Critical Parse Error by reading backupFile" ),
-								   tr( handler.errorProtocol() )+" in "+backupXML );
+								   tr( handler.errorProtocol() )+" in "+bakMapDir );
 		}
-		// Undo not longer available now
-		actionEditUndo->setEnabled (false);
-		undoSelection=false;
-		mapChanged=false;
-		return;
 	} else	
 	{
 		QMessageBox::critical( 0, tr( "Critical Error" ),
-			"Temporary directory " +bakMapDir + 
-			tr (" used for undo is gone. \n"
+			tr("Temporary directory %1 used for undo is gone. \n"
 			"I will create a new one, but at the moment no undo is available.\n"
 			"Maybe you want to reload your original data.\n\n"
-			"Sorry for any inconveniences.") );
+			"Sorry for any inconveniences.").arg(bakMapDir) );
 		makeTmpDirs();	
 	}							
 }
 
-void MapEditor::copy()
+void MapEditor::pasteNoSave()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
-
-	if (selection) 
-	{
-		if (typeid(*selection) == typeid(BranchObj) ) 
-		{
-			BranchObj* to;
-			BranchObj* from;
-			clipboardME->clear();
-			clipboardME->getMapCenter()->addBranch();
-			to=clipboardME->getMapCenter()->getLastBranch();
-			if (to) 
-			{
-				from=(BranchObj*)(selection);
-				to->copy(from);
-
-				// keep position relative to parent
-				to->move2RelPos ( from->getRelPos());
-
-				// select data in clipboard
-				clipboardME->select ("bo:0");
-
-				// repositioning makes testing nicer,
-				// but is not needed usually:
-				if (clipboardME->isVisible())
-				{
-					clipboardME->getMapCenter()->reposition();  
-				}	
-				else
-					clipboardME->hide();
-			}
-		}    
-		if (typeid(*selection) == typeid(FloatImageObj) ) 
-		{
-			FloatImageObj* to;
-			FloatImageObj* from;
-			clipboardME->clear();
-			clipboardME->getMapCenter()->addFloatImage();
-			to=clipboardME->getMapCenter()->getLastFloatImage();
-			if (to) 
-			{
-				from=(FloatImageObj*)(selection);
-				to->copy(from);
-
-				// select data in clipboard
-				clipboardME->select ("fi:0");
-
-				// repositioning makes testing nicer,
-				// but is not needed usually:
-				if (clipboardME->isVisible())
-				{
-					clipboardME->getMapCenter()->reposition();  
-				}	
-				else
-					clipboardME->hide();
-			}
-		}    
-	}	    
-}
-
-LinkableMapObj* MapEditor::pasteNoSave()
-{
-	return pasteAtNoSave (-1);
-}
-
-LinkableMapObj* MapEditor::pasteAtNoSave(int pos)
-{
-	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
-
-	LinkableMapObj *fromLMO=clipboardME->getSelection();
-	LinkableMapObj *returnLMO=NULL;
-
-	if (selection && fromLMO) 
-	{
-
-		if (typeid(*fromLMO) == typeid(BranchObj) ) 
-		{
-			if (typeid(*selection) == typeid(MapCenterObj)) 
-			{
-				returnLMO=mapCenter->addBranch( (BranchObj*)(fromLMO) );
-				((BranchObj*)(returnLMO))->move2RelPos(normalise(fromLMO->getRelPos() ) );
-			}     
-			if (typeid(*selection) == typeid(BranchObj)) 
-				if (pos<0)
-					returnLMO=((BranchObj*)(selection))->addBranch((BranchObj*)(fromLMO) );
-				else
-				{
-					BranchObj *par=(BranchObj*)(selection->getParObj());
-					if (par) returnLMO=par->insertBranch((BranchObj*)(fromLMO),pos );
-				}	
-		}
-		
-		if (typeid(*fromLMO) == typeid(FloatImageObj) &&
-			(typeid(*selection) == typeid (BranchObj) || 
-			 typeid(*selection)==typeid(MapCenterObj)) )
-			returnLMO=((BranchObj*) (selection))->addFloatImage ((FloatImageObj*)(fromLMO));
-		
-	}	    
-	return returnLMO;
+	if (lineedit) finishedLineEdit();
+
+	load (clipboardDir+"/part.xml",ImportAdd);
 }
 
 void MapEditor::cutNoSave()
 {
-	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
-
-	BranchObj* bo;
-	BranchObj* par; 
-	if (selection != NULL) {
-		if (typeid(*selection) == typeid(BranchObj) ) 
-		{
-			bo=(BranchObj*)(selection);
-			par=(BranchObj*)(bo->getParObj());
-			bo->unselect();
-			selection=NULL;
-			par->removeBranch(bo);
-			selection=par;
-			selection->select();
-		}
-		if (typeid(*selection) == typeid(FloatImageObj) ) 
-		{
-			FloatImageObj* fio=(FloatImageObj*)(selection);
-			par=(BranchObj*)(fio->getParObj());
-			fio->unselect();
-			selection=NULL;
-			par->removeFloatImage(fio);
-			selection=par;
-			selection->select();
-		}
-	}	    
+	copy();
+	deleteSelection();
 }
 
 void MapEditor::paste()
 {   
-	setChanged();
-	saveState(PartOfMap,selection);
-	pasteNoSave();
-	mapCenter->reposition();
-	adjustCanvasSize();
+	if (selection && (typeid(*selection) == typeid(BranchObj) ||
+				      typeid(*selection) == typeid(MapCenterObj))) 
+	{
+		saveState(selection,QString("Paste to %1").arg( getName(selection)));
+		pasteNoSave();
+		mapCenter->reposition();
+		adjustCanvasSize();
+	}
 }
 
 void MapEditor::cut()
 {
-	setChanged();
-	saveState(PartOfMap,selection->getParObj());
+	saveState(selection->getParObj(),QString("Cut %1").arg(getName(selection)));
 	copy();
 	cutNoSave();
 	mapCenter->reposition();
 	adjustCanvasSize();
 }
 
+void MapEditor::move(const int &x, const int &y)
+{
+	// TODO no saveState, because this is only internal at undo so far
+	if (selection) selection->move(x,y);
+	if (typeid(*selection) == typeid(FloatImageObj))
+		((FloatImageObj*)selection)->setRelPos();
+}
+
 void MapEditor::moveBranchUp()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	BranchObj* bo;
 	BranchObj* par;
 	if (typeid(*selection) == typeid(BranchObj)  ) 
 	{
-		setChanged();
-		saveState(PartOfMap,selection->getParObj());
-		bo=(BranchObj*)(selection);
+		bo=(BranchObj*)selection;
+		if (!bo->canMoveBranchUp()) return;
 		par=(BranchObj*)(bo->getParObj());
 		selection->unselect();
 		selection=par->moveBranchUp (bo);
 		selection->select();
+		saveState("moveBranchDown ()",bo,QString("Move up %1").arg(getName(bo)));
 		mapCenter->reposition();
 		ensureSelectionVisible();
 	}
@@ -1293,19 +1459,19 @@
 void MapEditor::moveBranchDown()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	BranchObj* bo;
 	BranchObj* par;
 	if (typeid(*selection) == typeid(BranchObj)  ) 
 	{
-		setChanged();
-		saveState(PartOfMap,selection->getParObj());
-		bo=(BranchObj*)(selection);
+		bo=(BranchObj*)selection;
+		if (!bo->canMoveBranchDown()) return;
 		par=(BranchObj*)(bo->getParObj());
 		selection->unselect(); 
 		selection=par->moveBranchDown(bo);
 		selection->select();
+		saveState("moveBranchUp ()",bo,QString("Move down %1").arg(getName(bo)));
 		mapCenter->reposition();
 		ensureSelectionVisible();
 	}	
@@ -1314,46 +1480,82 @@
 void MapEditor::editHeading()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	if (selection  &&  
 		 (typeid(*selection) == typeid(BranchObj) || 
 		  typeid(*selection) == typeid(MapCenterObj) ) ) 
 	{
-		setChanged();
-		saveState(PartOfMap,selection);
+		editingBO=(BranchObj*)selection;
 
 		ensureSelectionVisible();
-		BranchObj *bo=(BranchObj*)(selection);
-		editingBO=(BranchObj*)(selection);
-		QPoint p = worldMatrix().map(QPoint (bo->x(),bo->y()));
+		QPoint p = worldMatrix().map(QPoint (editingBO->x(),editingBO->y()));
 		lineedit->setGeometry(p.x()-contentsX(),p.y()-contentsY(),200,25);
-		QString s=bo->getHeading();
+		QString s=editingBO->getHeading();
 		lineedit->setText(s);
 		lineedit->setCursorPosition(1);
 		if (actionSettingsAutoselectText->isOn() && !s.isEmpty() && actionSettingsPasteNewHeading->isOn() )
 			lineedit->selectAll();
 		lineedit->show();
-
 		lineedit->grabKeyboard();
 		lineedit->setFocus();
 	}				
 }
 
-
-void MapEditor::addNewBranch(int pos)
+void MapEditor::setHeading(const QString &s)
 {
-	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
-
+	// Internal function, no saveState needed
 	if (selection  &&  
 		 (typeid(*selection) == typeid(BranchObj) || 
 		  typeid(*selection) == typeid(MapCenterObj) ) ) 
 	{
-		setChanged();
-		saveState(PartOfMap,selection);
-
-		BranchObj* bo1 = (BranchObj*) (selection);
+		((BranchObj*)selection)->setHeading(s);
+		mapCenter->reposition();
+		adjustCanvasSize();
+		ensureSelectionVisible();
+	}
+}
+
+void MapEditor::setURL (const QString &s)
+{
+	// Internal function, no saveState needed
+	if (selection  &&  
+		 (typeid(*selection) == typeid(BranchObj) || 
+		  typeid(*selection) == typeid(MapCenterObj) ) ) 
+	{
+		((BranchObj*)selection)->setURL(s);
+		mapCenter->reposition();
+		adjustCanvasSize();
+		ensureSelectionVisible();
+	}
+}
+
+void MapEditor::setVymLink (const QString &s)
+{
+	// Internal function, no saveState needed
+	if (selection  &&  
+		 (typeid(*selection) == typeid(BranchObj) || 
+		  typeid(*selection) == typeid(MapCenterObj) ) ) 
+	{
+		((BranchObj*)selection)->setVymLink(s);
+		mapCenter->reposition();
+		adjustCanvasSize();
+		ensureSelectionVisible();
+	}
+}
+
+void MapEditor::addNewBranch(int pos)
+{
+	// Finish open lineEdits
+	if (lineedit) finishedLineEdit();
+
+	if (selection  &&  
+		 (typeid(*selection) == typeid(BranchObj) || 
+		  typeid(*selection) == typeid(MapCenterObj) ) ) 
+	{
+		BranchObj* bo1 = (BranchObj*) selection;
+		saveState(selection, QString("Add new branch to %1").arg(getName(bo1)));	//TODO undoCommand
+
 		bool wasScrolled=false;
 		BranchObj *newbo=NULL;
 		if (pos==0)
@@ -1391,7 +1593,7 @@
 			selection->select();
 			if (actionSettingsPasteNewHeading->isOn() )
 			{
-				BranchObj *bo2= (BranchObj*)(selection);
+				BranchObj *bo2= (BranchObj*)selection;
 				bo2->setHeading("");
 			}	
 			if (actionSettingsAutoedit->isOn() )
@@ -1407,18 +1609,74 @@
 	}	
 }
 
+
+void MapEditor::addNewBranchHere()
+{
+	// Finish open lineEdits
+	if (lineedit) finishedLineEdit();
+
+	if (selection  &&  
+		 (typeid(*selection) == typeid(BranchObj) ) )
+	{
+		BranchObj* bo1 = (BranchObj*) selection;
+		saveState(selection, QString("Add new branch here").arg(getName(bo1)));
+
+		bool wasScrolled=false;
+		BranchObj *newbo=NULL;
+		BranchObj *parbo=(BranchObj*)(selection->getParObj());
+		if (parbo)
+		{
+			// add below selection
+			newbo=parbo->insertBranch(bo1->getNum()+1);
+		} 
+
+		LinkableMapObj *oldselection=selection;
+		((BranchObj*)selection)->moveBranchTo (newbo,-1);
+
+		mapCenter->reposition();
+		adjustCanvasSize();
+		if (actionSettingsAutoedit->isOn() ||
+			actionSettingsAutoselectHeading->isOn() )
+		{
+			selection->unselect();
+			selection=newbo;
+			selection->select();
+			if (actionSettingsPasteNewHeading->isOn() )
+			{
+				BranchObj *bo2= (BranchObj*)selection;
+				bo2->setHeading("");
+			}	
+			if (actionSettingsAutoedit->isOn() )
+				editHeading();
+			if (!actionSettingsAutoselectHeading->isOn()
+				&& !wasScrolled)
+			{
+				selection->unselect();
+				selection=oldselection;
+				selection->select();
+			}
+		}	
+	}	
+}
+
 void MapEditor::deleteSelection()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	if (selection  && typeid(*selection) ==typeid(BranchObj) ) 
 	{
-		setChanged();
-		saveState(PartOfMap,selection->getParObj());
 		BranchObj* bo=dynamic_cast <BranchObj*> (selection);
 		BranchObj* par=(BranchObj*)(bo->getParObj());
 		bo->unselect();
+		if (selection->getDepth()>1)
+			// Normal branch, save parent with childs
+			saveState(par,QString("Delete %1").arg(getName(bo)));
+		else
+			// Mainbranch, save whole map
+			// TODO Better would be to insert mainbranch again at pos
+			// But undoCommand is missing right now
+			saveState(QString("Delete %1").arg(getName(bo)));
 		selection=NULL;
 		par->removeBranch(bo);
 		selection=par;
@@ -1429,10 +1687,9 @@
 	}
 	if (selection  && typeid(*selection) ==typeid(FloatImageObj) ) 
 	{
-		setChanged();
-		saveState(PartOfMap,selection->getParObj());
 		FloatImageObj* fio=dynamic_cast <FloatImageObj*> (selection);
 		BranchObj* par=(BranchObj*)(fio->getParObj());
+		saveState(par, QString("Delete %1").arg(getName(fio)));
 		fio->unselect();
 		selection=NULL;
 		par->removeFloatImage(fio);
@@ -1449,56 +1706,6 @@
 	return selection;
 }
 
-bool MapEditor::select (QString s)
-{
-	LinkableMapObj *lmo=mapCenter;
-	QString part;
-	QString typ;
-	QString num;
-	while (!s.isEmpty() )
-	{
-		part=s.section(",",0,0);
-		typ=part.left (3);
-		num=part.right(part.length() - 3);
-		
-		if (typ=="mc:")
-		{
-			if (num=="")
-				break;
-			else
-				lmo=mapCenter->getBranchNum (num.toUInt());
-		} else
-			if (typ=="bo:")
-				lmo=((BranchObj*)(lmo))->getBranchNum (num.toUInt());
-			else
-				if (typ=="fi:")
-					lmo=((BranchObj*)(lmo))->getFloatImageNum (num.toUInt());
-				
-		
-		
-		if (!lmo) break;
-		
-		if (s.contains(","))
-			s=s.right(s.length() - part.length() -1 );
-		else	
-			break;
-	}
-
-	// Finally select the found object
-	if (lmo)
-	{
-		if (selection) selection->unselect();
-		selection=lmo;
-		selection->select();
-		adjustCanvasSize();
-		ensureSelectionVisible();
-		return true;
-	} else
-		return false;
-	
-	
-}
-
 void MapEditor::unselect()
 {
 	if (selection) 
@@ -1519,6 +1726,37 @@
 	}
 }	
 
+bool MapEditor::select (const QString &s)
+{
+	LinkableMapObj *lmo=mapCenter->findObjBySelect(s);
+
+	// Finally select the found object
+	if (lmo)
+	{
+		if (selection) unselect();
+		selection=lmo;
+		selection->select();
+		adjustCanvasSize();
+		ensureSelectionVisible();
+		return true;
+	} 
+	return false;
+}
+
+void MapEditor::select (LinkableMapObj *lmo)
+{
+	if (lmo && selection != lmo)
+	{
+		// select the MapObj
+		if (selection) selection->unselect();
+		selection=lmo;
+		selection->select();
+			
+		adjustCanvasSize();
+	}
+
+}
+
 void MapEditor::selectNextBranch()
 {
 	// Increase number of branch
@@ -1583,7 +1821,7 @@
 					b=select (s);
 					if (b)
 					{	
-						if ( ((BranchObj*)(selection))->countBranches()>0)
+						if ( ((BranchObj*)selection)->countBranches()>0)
 							s+=",bo:0";
 						else	
 							break;
@@ -1662,8 +1900,8 @@
 				{
 					b=select (s);
 					if (b)
-						if ( ((BranchObj*)(selection))->countBranches()>0)
-							s+=",bo:"+ QString ("%1").arg( ((BranchObj*)(selection))->countBranches()-1 );
+						if ( ((BranchObj*)selection)->countBranches()>0)
+							s+=",bo:"+ QString ("%1").arg( ((BranchObj*)selection)->countBranches()-1 );
 						else	
 							break;
 					else
@@ -1681,7 +1919,7 @@
 void MapEditor::selectUpperBranch()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	if (selection) 
 	{
@@ -1701,7 +1939,7 @@
 void MapEditor::selectLowerBranch()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	if (selection) 
 	{
@@ -1722,7 +1960,7 @@
 void MapEditor::selectLeftBranch()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	BranchObj* bo;
 	BranchObj* par;
@@ -1730,7 +1968,7 @@
 	{
 		if (typeid(*selection) == typeid(MapCenterObj))
 		{
-			par=  (BranchObj*) (selection);
+			par=  (BranchObj*) selection;
 			bo=par->getLastSelectedBranch();
 			if (bo)
 			{
@@ -1766,7 +2004,7 @@
 			{
 				if (typeid(*selection) == typeid(BranchObj) )
 				{
-					bo=((BranchObj*)(selection))->getLastSelectedBranch();
+					bo=((BranchObj*)selection)->getLastSelectedBranch();
 					if (bo) 
 					{
 						selection->unselect();
@@ -1784,7 +2022,7 @@
 void MapEditor::selectRightBranch()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	BranchObj* bo;
 	BranchObj* par;
@@ -1793,7 +2031,7 @@
 	{
 		if (typeid(*selection) == typeid(MapCenterObj))
 		{
-			par=  (BranchObj*) (selection);
+			par=  (BranchObj*) selection;
 			bo=par->getLastSelectedBranch();
 			if (bo)
 			{
@@ -1826,7 +2064,7 @@
 			{
 				if (typeid(*selection) == typeid(BranchObj) )
 				{
-					bo=((BranchObj*)(selection))->getLastSelectedBranch();
+					bo=((BranchObj*)selection)->getLastSelectedBranch();
 					if (bo) 
 					{
 						selection->unselect();
@@ -1844,7 +2082,7 @@
 void MapEditor::selectFirstBranch()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	BranchObj *bo1;
 	BranchObj *bo2;
@@ -1852,7 +2090,7 @@
 	if (selection) {
 		if (typeid(*selection) == typeid(BranchObj))
 		{
-			bo1=  (BranchObj*) (selection);
+			bo1=  (BranchObj*) selection;
 			par=(BranchObj*)(bo1->getParObj());
 			bo2=par->getFirstBranch();
 			if (bo2) {
@@ -1869,7 +2107,7 @@
 void MapEditor::selectLastBranch()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	BranchObj *bo1;
 	BranchObj *bo2;
@@ -1877,7 +2115,7 @@
 	if (selection) {
 		if (typeid(*selection) == typeid(BranchObj))
 		{
-			bo1=  (BranchObj*) (selection);
+			bo1=  (BranchObj*) selection;
 			par=(BranchObj*)(bo1->getParObj());
 			bo2=par->getLastBranch();
 			if (bo2) {
@@ -1899,12 +2137,12 @@
 void MapEditor::selectBackgroundColor()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 
 	QColor col = QColorDialog::getColor( mapCanvas->backgroundColor(), this );
 	if ( !col.isValid() ) return;
 	setBackgroundColor( col );
-	setChanged();
+	saveState(QString("Set background color of map to %1").arg(col.name()));
 }
 
 void MapEditor::setBackgroundColor(QColor c)
@@ -1919,7 +2157,7 @@
 		if (typeid(*selection) == typeid(BranchObj) ||
 			typeid(*selection) == typeid(MapCenterObj))
 		{
-			BranchObj *bo=(BranchObj*)(selection);
+			BranchObj *bo=(BranchObj*)selection;
 			actColor=bo->getColor(); 
 		}    
 	}
@@ -1933,10 +2171,9 @@
 		if (typeid(*selection) == typeid(BranchObj) ||
 			typeid(*selection) == typeid(MapCenterObj))
 		{
-			setChanged();
-			saveState(PartOfMap,selection);
-			BranchObj *bo=(BranchObj*)(selection);
-			bo->setColor(actColor, false); // color links, color childs
+			BranchObj *bo=(BranchObj*)selection;
+			saveState(selection, QString("Set color of %1 to %2").arg(getName(bo)).arg(actColor.name()));	//TODO undoCommand
+			bo->setColor(actColor); // color branch
 		}    
 	}
 }
@@ -1948,10 +2185,9 @@
 		if (typeid(*selection) == typeid(BranchObj) ||
 			typeid(*selection) == typeid(MapCenterObj))
 		{
-			setChanged();
-			saveState(PartOfMap,selection);
-			BranchObj *bo=(BranchObj*)(selection);
-			bo->setColor(actColor, true); // color links, color childs
+			BranchObj *bo=(BranchObj*)selection;
+			saveState(selection, QString ("Set color of %1 and childs to %2").arg(getName(bo)).arg(actColor.name()));	//TODO undoCommand
+			bo->setColorChilds(actColor); // color links, color childs
 		}    
 	}
 }
@@ -1961,9 +2197,15 @@
 {
 	if (selection)
 	{
-		setChanged();
-		saveState(PartOfMap,selection);	
-		((BranchObj*)(selection))->toggleStandardFlag (f);
+		BranchObj *bo=(BranchObj*)selection;
+		QString s;
+		if (bo->isSetStandardFlag(f))
+			s="Unset";
+		else
+			s="Set";
+		saveState(selection, QString("%1 standard flag \"%2\" of %3").arg(s).arg(f).arg(getName(bo)));// TODO undoCommand	
+		bo->toggleStandardFlag (f,actionSettingsUseFlagGroups->isOn());
+		adjustCanvasSize();
 	}	
 }
 
@@ -1995,7 +2237,7 @@
 			{
 				if (selection!=itFind) 
 				{
-					if (selection) ((BranchObj*)(selection))->unselect();
+					if (selection) ((BranchObj*)selection)->unselect();
 					selection=itFind;
 					selection->select();
 					adjustCanvasSize();
@@ -2010,7 +2252,7 @@
 			// Searching in Heading
 			if (searching && itFind->getHeading().contains (s,cs) ) 
 			{
-				if (selection) ((BranchObj*)(selection))->unselect();
+				if (selection) ((BranchObj*)selection)->unselect();
 				selection=itFind;
 				selection->select();
 				adjustCanvasSize();
@@ -2027,7 +2269,7 @@
 	if (!searching)
 	{
 		adjustCanvasSize();
-		return (BranchObj*)(selection);
+		return (BranchObj*)selection;
 	}	else
 		return NULL;
 }
@@ -2038,62 +2280,44 @@
 	EOFind=false;
 }
 
-void MapEditor::openURL()
-{
-	if (selection )
-	{
-		if (typeid(*selection) == typeid(BranchObj) ||
-			typeid(*selection) == typeid(MapCenterObj))
-		{
-			QString url=((BranchObj*)(selection))->getURL();
-
-			QProcess *proc = new QProcess( this );
-
-#if !defined(Q_OS_MACX)
-			proc->addArgument( settings.readEntry("/vym/mainwindow/readerURL","konqueror" ));
-#else			
-			proc->addArgument( settings.readEntry("/vym/mainwindow/readerURL",
-				"/Applications/Safari.app/Contents/MacOS/Safari" ));
-#endif			
-
-			proc->addArgument( url);
-
-			if ( !proc->start() ) 
-				// error handling
-				if (mainWindow->settingsURL() ) 
-					openURL();
-		}	
-	}	
-}
-
 void MapEditor::editURL()
 {
 	if (selection && (typeid(*selection) == typeid(BranchObj) ||
 			typeid(*selection) == typeid(MapCenterObj)) )
 	{		
 		bool ok;
+		BranchObj *bo=(BranchObj*)selection;
 		QString text = QInputDialog::getText(
 				"VYM", tr("Enter URL:"), QLineEdit::Normal,
-				((BranchObj*)(selection))->getURL(), &ok, this );
+				bo->getURL(), &ok, this );
 		if ( ok) 
 		{
 			// user entered something and pressed OK
-			((BranchObj*)(selection))->setURL (text);
+			saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+text+"\")", QString("Set URL of %1 to %21").arg(getName(bo)).arg(text));	
+			bo->setURL (text);
 			updateActions();
-			setChanged();
 		}	
 	}
 }
 
+QString MapEditor::getURL()
+{
+	if (selection && (typeid(*selection) == typeid(BranchObj) ||
+			typeid(*selection) == typeid(MapCenterObj)) )
+		return ((BranchObj*)selection)->getURL();
+	else
+		return "";
+}
+
 void MapEditor::editHeading2URL()
 {
 	if (selection && (typeid(*selection) == typeid(BranchObj) ||
 			typeid(*selection) == typeid(MapCenterObj)) )
 	{		
-		BranchObj *b=(BranchObj*)(selection);
-		b->setURL (b->getHeading());
+		BranchObj *bo=(BranchObj*)selection;
+		saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+bo->getHeading()+"\")",QString("Copy heading of %1 to URL").arg(getName(bo)));	
+		bo->setURL (bo->getHeading());
 		updateActions();
-		setChanged();
 	}
 }	
 
@@ -2102,10 +2326,24 @@
 	if (selection && (typeid(*selection) == typeid(BranchObj) ||
 			typeid(*selection) == typeid(MapCenterObj)) )
 	{		
-		BranchObj *b=(BranchObj*)(selection);
-		b->setURL ("http://bugzilla.suse.de/show_bug.cgi?id="+b->getHeading());
+		BranchObj *bo=(BranchObj*)selection;
+		QString url= "https://bugzilla.novell.com/show_bug.cgi?id="+bo->getHeading();
+		saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")",QString("Use heading of %1 as link to Novell Bugzilla").arg(getName(bo)));	
+		bo->setURL (url);
 		updateActions();
-		setChanged();
+	}
+}	
+
+void MapEditor::editFATE2URL()
+{
+	if (selection && (typeid(*selection) == typeid(BranchObj) ||
+			typeid(*selection) == typeid(MapCenterObj)) )
+	{		
+		BranchObj *bo=(BranchObj*)selection;
+		QString url= "http://keeper.suse.de:8080/webfate/match/id?value=ID"+bo->getHeading();
+		saveState("setURL (\""+bo->getURL()+"\")","setURL (\""+url+"\")",QString("Use heading of %1 as link to FATE").arg(getName(bo)));	
+		bo->setURL (url);
+		updateActions();
 	}
 }	
 
@@ -2114,21 +2352,24 @@
 	if (selection && (typeid(*selection) == typeid(BranchObj) ||
 			typeid(*selection) == typeid(MapCenterObj)) )
 	{		
-		QFileDialog *fd=new QFileDialog( this,tr("VYM - Link to another map"));
+		BranchObj *bo=(BranchObj*)selection;
+		Q3FileDialog *fd=new Q3FileDialog( this,__VYM " - " +tr("Link to another map"));
 		fd->addFilter (QString (tr("vym map") + " (*.vym)"));
-		fd->setCaption(tr("VYM - Link to another map"));
-		if (! ((BranchObj*)(selection))->getVymLink().isEmpty() )
-			fd->setSelection( ((BranchObj*)(selection))->getVymLink() );
+		fd->setCaption(__VYM " - " +tr("Link to another map"));
+		if (! bo->getVymLink().isEmpty() )
+			fd->setSelection( bo->getVymLink() );
 		fd->show();
 
 		QString fn;
 		if ( fd->exec() == QDialog::Accepted )
-			((BranchObj*)(selection))->setVymLink (fd->selectedFile() );
-		updateActions();
-		mapCenter->reposition();
-		adjustCanvasSize();
-		canvas()->update();
-		setChanged();
+		{
+			saveState("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\""+fd->selectedFile()+"\")",QString("Set vymlink of %1 to %2").arg(getName(bo)).arg(fd->selectedFile()));	
+			bo->setVymLink (fd->selectedFile() );
+			updateActions();
+			mapCenter->reposition();
+			adjustCanvasSize();
+			canvas()->update();
+		}
 	}
 }
 
@@ -2137,12 +2378,41 @@
 	if (selection && (typeid(*selection) == typeid(BranchObj) ||
 			typeid(*selection) == typeid(MapCenterObj)) )
 	{		
-		((BranchObj*)(selection))->setVymLink ("" );
+		BranchObj *bo=(BranchObj*)selection;
+		saveState("setVymLink (\""+bo->getVymLink()+"\")","setVymLink (\"\")",QString("Unset vymlink of %1").arg(getName(bo)));	
+		bo->setVymLink ("" );
 		updateActions();
 		mapCenter->reposition();
 		adjustCanvasSize();
 		canvas()->update();
-		setChanged();
+	}
+}
+
+void MapEditor::toggleHideExport()
+{
+	if (selection && (typeid(*selection) == typeid(BranchObj) ||
+			typeid(*selection) == typeid(MapCenterObj)) ||
+			(typeid(*selection)==typeid(FloatImageObj))
+			)
+	{		
+		OrnamentedObj *oo=(OrnamentedObj*)selection;
+		QString s;
+		if (oo->hideInExport())
+		{
+			oo->setHideInExport(false);
+			s="Unset";
+		}	
+		else	
+		{
+			oo->setHideInExport(true);
+			s="Set";
+		}	
+		saveState(QString ("%1 hide export flag of %2").arg(s).arg(getName(selection)));	//TODO undoCommand
+		actionEditToggleHideExport->setOn (oo->hideInExport());	
+		updateActions();
+		mapCenter->reposition();
+		adjustCanvasSize();
+		canvas()->update();
 	}
 }
 
@@ -2151,12 +2421,41 @@
 	if (selection && (typeid(*selection) == typeid(BranchObj) ||
 			typeid(*selection) == typeid(MapCenterObj)) )
 	{		
-		return ((BranchObj*)(selection))->getVymLink();
+		return ((BranchObj*)selection)->getVymLink();
 	}
 	return "";
 	
 }
 
+void MapEditor::removeBranchKeepChilds()
+{
+	if (selection && (typeid(*selection) == typeid(BranchObj) ))
+	{		
+		BranchObj* bo=(BranchObj*)selection;
+		BranchObj* par=(BranchObj*)(bo->getParObj());
+		QString s=QString("Remove %1 and keep its childs").arg(getName(bo));
+		if (bo->getDepth()==1)
+			saveState(s);
+		else	
+			saveState(selection->getParObj(),s);	// TODO undoCommand
+		QString sel=selection->getSelectString();
+		unselect();
+		par->removeBranchHere(bo);
+		mapCenter->reposition();
+		select (sel);
+	}	
+}
+
+void MapEditor::removeChilds()
+{
+	if (selection && (typeid(*selection) == typeid(BranchObj) ))
+	{		
+		saveState(selection->getParObj(), QString("Remove childs of branch %1").arg(getName(selection)));
+		((BranchObj*)selection)->removeChilds();
+		mapCenter->reposition();
+	}	
+}
+
 void MapEditor::editMapInfo()
 {
 	ExtraInfoDialog dia;
@@ -2167,14 +2466,15 @@
 	// Calc some stats
 	QString stats;
     int i=0;
-    QCanvasItemList l=canvas()->allItems();
-    for (QCanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) 
+    Q3CanvasItemList l=canvas()->allItems();
+    for (Q3CanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) 
         i++;
     stats+=QString ("%1 items on canvas\n").arg (i,6);
 
 	uint b=0;
 	uint f=0;
 	uint n=0;
+	uint xl=0;
 	BranchObj *bo;
 	bo=mapCenter->first();
 	while (bo) 
@@ -2182,9 +2482,11 @@
 		if (!bo->getNote().isEmpty() ) n++;
 		f+= bo->countFloatImages();
 		b++;
+		xl+=bo->countXLinks();
 		bo=bo->next();
 	}
     stats+=QString ("%1 branches\n").arg (b-1,6);
+    stats+=QString ("%1 xLinks \n").arg (xl,6);
     stats+=QString ("%1 notes\n").arg (n,6);
     stats+=QString ("%1 images\n").arg (f,6);
 	dia.setStats (stats);
@@ -2192,14 +2494,15 @@
 	// Finally show dialog
 	if (dia.exec() == QDialog::Accepted)
 	{
+		saveState("Edit info about map");	//TODO undoCommand
 		mapCenter->setAuthor (dia.getAuthor() );
 		mapCenter->setComment (dia.getComment() );
-		setChanged();
 	}
 }
 
 void MapEditor::updateActions()
 {
+	QAction *a;
 	if (getLinkColorHint()==HeadingColor) 
 		actionFormatLinkColorHint->setOn(true);
 	else	
@@ -2226,7 +2529,7 @@
 	QPixmap pix( 16, 16 );
     pix.fill( mapCanvas->backgroundColor() );
     actionFormatBackColor->setIconSet( pix );
-    pix.fill( deflinkcolor );
+    pix.fill( defLinkColor );
     actionFormatLinkColor->setIconSet( pix );
 
 	actionEditUndo->setEnabled( mapChanged );
@@ -2237,17 +2540,54 @@
 		if ( (typeid(*selection) == typeid(BranchObj)) || 
 			(typeid(*selection) == typeid(MapCenterObj))  )
 		{
+			BranchObj *bo=(BranchObj*)selection;
+			// Take care of links
+			if (bo->countXLinks()==0)
+			{
+				branchLinksContextMenu->clear();
+				branchLinksContextMenu->insertItem ("No xLink available");
+				branchLinksContextMenuDup->clear();
+				branchLinksContextMenuDup->insertItem ("No xLink available");
+				
+			} else
+			{
+				BranchObj *bot;
+				QString s;
+				branchLinksContextMenu->clear();
+				branchLinksContextMenuDup->clear();
+				for (int i=0; i<=bo->countXLinks();i++)
+				{
+					bot=bo->XLinkTargetAt(i);
+					if (bot)
+					{
+						s=bot->getHeading();
+						if (s.length()>25)
+							s=s.left(25)+"...";
+						branchLinksContextMenu->insertItem (s);
+						branchLinksContextMenuDup->insertItem (s);
+					}	
+				}
+			}
+
 			standardFlagsDefault->setEnabled (true);
 
-			if ( ((BranchObj*)(selection))->getURL().isEmpty() )
+			actionEditToggleScroll->setEnabled (true);
+			if ( bo->isScrolled() )
+				actionEditToggleScroll->setOn(true);
+			else	
+				actionEditToggleScroll->setOn(false);
+
+			if ( bo->getURL().isEmpty() )
+			{
 				actionEditOpenURL->setEnabled (false);
+				actionEditOpenURLTab->setEnabled (false);
+			}	
 			else	
+			{
 				actionEditOpenURL->setEnabled (true);
-			actionEditURL->setEnabled (true);	
-			actionEditHeading2URL->setEnabled (true);	
-			actionEditBugzilla2URL->setEnabled (true);	
-
-			if ( ((BranchObj*)(selection))->getVymLink().isEmpty() )
+				actionEditOpenURLTab->setEnabled (true);
+			}
+			if ( bo->getVymLink().isEmpty() )
 			{
 				actionEditOpenVymLink->setEnabled (false);
 				actionEditDeleteVymLink->setEnabled (false);
@@ -2256,28 +2596,29 @@
 				actionEditOpenVymLink->setEnabled (true);
 				actionEditDeleteVymLink->setEnabled (true);
 			}	
-			actionEditVymLink->setEnabled (true);	
+
+			if (bo->canMoveBranchUp()) 
+				actionEditMoveUp->setEnabled (true);
+			else	
+				actionEditMoveUp->setEnabled (false);
+			if (bo->canMoveBranchDown()) 
+				actionEditMoveDown->setEnabled (true);
+			else	
+				actionEditMoveDown->setEnabled (false);
+
+
+			actionEditToggleHideExport->setEnabled (true);	
+			actionEditToggleHideExport->setOn (bo->hideInExport() );	
 
 			actionEditCopy->setEnabled (true);	
 			actionEditCut->setEnabled (true);	
-			actionEditPaste->setEnabled (true);	
-			actionEditMoveUp->setEnabled (true);	
-			actionEditMoveDown->setEnabled (true);	
-			actionEditToggleScroll->setEnabled (true);	
-			actionEditHeading->setEnabled (true);
+			if (!clipboardEmpty)
+				actionEditPaste->setEnabled (true);	
+			else	
+				actionEditPaste->setEnabled (false);	
+			for (a=actionListBranches.first();a;a=actionListBranches.next())
+				a->setEnabled(true);
 			actionEditDelete->setEnabled (true);
-			actionEditAddBranch->setEnabled (true);
-			actionEditAddBranchAbove->setEnabled (true);
-			actionEditAddBranchBelow->setEnabled (true);
-			actionEditImportAdd->setEnabled (true);
-			actionEditImportReplace->setEnabled (true);
-			actionEditSaveBranch->setEnabled (true);
-			actionEditSelectFirst->setEnabled (true);
-			actionEditSelectLast->setEnabled (true);
-			actionEditToggleFloatExport->setEnabled (false);
-			actionFormatPickColor->setEnabled (true);
-			actionFormatColorBranch->setEnabled (true);
-			actionFormatColorSubtree->setEnabled (true);
 			switch (selection->getFrameType())
 			{
 				case NoFrame: 
@@ -2289,40 +2630,35 @@
 				default:
 					break;
 			}	
+			actionFormatIncludeImagesVer->setOn
+				( ((BranchObj*)selection)->getIncludeImagesVer());
+			actionFormatIncludeImagesHor->setOn
+				( ((BranchObj*)selection)->getIncludeImagesHor());
+			actionFormatHideLinkUnselected->setOn
+				(selection->getHideLinkUnselected());
 		}
 		if ( (typeid(*selection) == typeid(FloatImageObj)) )
 		{
+			FloatObj *fo=(FloatImageObj*)selection;
 			standardFlagsDefault->setEnabled (false);
 
 			actionEditOpenURL->setEnabled (false);
-			actionEditURL->setEnabled (false);	
-			actionEditHeading2URL->setEnabled (false);	
-			actionEditBugzilla2URL->setEnabled (false);	
 			actionEditOpenVymLink->setEnabled (false);
-			actionEditVymLink->setEnabled (false);	
 			actionEditDeleteVymLink->setEnabled (false);	
+			actionEditToggleHideExport->setEnabled (true);	
+			actionEditToggleHideExport->setOn (fo->hideInExport() );	
+
 
 			actionEditCopy->setEnabled (true);
 			actionEditCut->setEnabled (true);	
-			actionEditPaste->setEnabled (false);	//FIXME
-			actionEditMoveUp->setEnabled (false);	
-			actionEditMoveDown->setEnabled (false);	
-			actionEditToggleScroll->setEnabled (false);	
-			actionEditHeading->setEnabled (false);
+			actionEditPaste->setEnabled (false);
+			for (a=actionListBranches.first();a;a=actionListBranches.next())
+				a->setEnabled(false);
 			actionEditDelete->setEnabled (true);
-			actionEditAddBranch->setEnabled (false);
-			actionEditAddBranchAbove->setEnabled (false);
-			actionEditAddBranchBelow->setEnabled (false);
-			actionEditImportAdd->setEnabled (false);
-			actionEditSaveBranch->setEnabled (false);
-			actionEditImportReplace->setEnabled (false);
-			actionEditSelectFirst->setEnabled (false);
-			actionEditSelectLast->setEnabled (false);
-			actionEditToggleFloatExport->setOn
-				( ((FloatImageObj*)(selection))->getFloatExport() );
-			actionFormatPickColor->setEnabled (false);
-			actionFormatColorBranch->setEnabled (false);
-			actionFormatColorSubtree->setEnabled (false);
+			actionFormatHideLinkUnselected->setOn
+				( selection->getHideLinkUnselected());
+			actionEditMoveUp->setEnabled (false);
+			actionEditMoveDown->setEnabled (false);
 		}
 
 	} else
@@ -2332,36 +2668,34 @@
 		actionEditCopy->setEnabled (false);	
 		actionEditCut->setEnabled (false);	
 		actionEditPaste->setEnabled (false);	
-		actionEditMoveUp->setEnabled (false);	
-		actionEditMoveDown->setEnabled (false);	
-		actionEditToggleScroll->setEnabled (false);	
+		for (a=actionListBranches.first();a;a=actionListBranches.next())
+			a->setEnabled(false);
+
+		actionEditToggleScroll->setEnabled (false);
 		actionEditOpenURL->setEnabled (false);
-		actionEditURL->setEnabled (false);	
 		actionEditOpenVymLink->setEnabled (false);
-		actionEditVymLink->setEnabled (false);	
 		actionEditDeleteVymLink->setEnabled (false);	
 		actionEditHeading2URL->setEnabled (false);	
-		actionEditBugzilla2URL->setEnabled (false);	
-		actionEditHeading->setEnabled (false);
 		actionEditDelete->setEnabled (false);
-		actionEditAddBranch->setEnabled (false);
-		actionEditAddBranchAbove->setEnabled (false);
-		actionEditAddBranchBelow->setEnabled (false);
-		actionEditSaveBranch->setEnabled (false);
-		actionEditImportReplace->setEnabled (false);
-		actionEditSelectFirst->setEnabled (false);
-		actionEditSelectLast->setEnabled (false);
-		actionEditToggleFloatExport->setEnabled (false);
-		actionFormatPickColor->setEnabled (false);
-		actionFormatColorBranch->setEnabled (false);
-		actionFormatColorSubtree->setEnabled (false);
+		actionEditMoveUp->setEnabled (false);
+		actionEditMoveDown->setEnabled (false);
+		actionEditToggleHideExport->setEnabled (false);	
 	}	
 }
 
+void MapEditor::updateNoteFlag()
+{
+	if (selection)
+		if ( (typeid(*selection) == typeid(BranchObj)) || 
+			(typeid(*selection) == typeid(MapCenterObj))  )
+			((BranchObj*)selection)->updateNoteFlag();
+}
+
 void MapEditor::setLinkStyle (LinkStyle ls)
 {
 	linkstyle=ls;
 
+	saveState("Set link style");	// TODO undoCommand
 	BranchObj *bo;
 	bo=mapCenter->first();
 	bo=bo->next();
@@ -2370,8 +2704,7 @@
 		bo->setLinkStyle(bo->getDefLinkStyle());
 		bo=bo->next();
 	}
-	//setChanged();
-	//saveState();
+	mapCenter->reposition();
 }
 
 LinkStyle MapEditor::getLinkStyle ()
@@ -2381,7 +2714,7 @@
 
 void MapEditor::setLinkColor(QColor c)
 {
-	deflinkcolor=c;
+	defLinkColor=c;
 	updateActions();
 }
 
@@ -2425,29 +2758,54 @@
 
 QColor MapEditor::getDefLinkColor()
 {
-	return deflinkcolor;
+	return defLinkColor;
+}
+
+void MapEditor::setDefXLinkColor(QColor col)
+{
+	defXLinkColor=col;
+}
+
+QColor MapEditor::getDefXLinkColor()
+{
+	return defXLinkColor;
+}
+
+void MapEditor::setDefXLinkWidth (int w)
+{
+	defXLinkWidth=w;
+}
+
+int MapEditor::getDefXLinkWidth()
+{
+	return defXLinkWidth;
 }
 
 void MapEditor::selectLinkColor()
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
-
-	QColor col = QColorDialog::getColor( deflinkcolor, this );
+	if (lineedit) finishedLineEdit();
+
+	QColor col = QColorDialog::getColor( defLinkColor, this );
 	if ( !col.isValid() ) return;
 	setLinkColor( col );
-	setChanged();
+	saveState(QString("Set link color to %1").arg(col.name()));	//TODO undoCommand
+
 }
 
 void MapEditor::toggleScroll()
 {
 	if (selection && (typeid(*selection) == typeid(BranchObj)) )
 	{
-		BranchObj *bo=((BranchObj*)(selection));
+		BranchObj *bo=((BranchObj*)selection);
 		if (bo->countBranches()==0) return;
 		if (bo->getDepth()==0) return;
-		setChanged();
-		saveState(PartOfMap,selection);
+		QString s;
+		if (bo->isScrolled())
+			s="Unscroll";
+		else	
+			s="Scroll";
+		saveState(selection, QString ("%1 %2").arg(s).arg(getName(bo)));
 		bo->toggleScroll();
 		adjustCanvasSize();
 		canvas()->update();
@@ -2471,33 +2829,42 @@
 		(typeid(*selection) == typeid(BranchObj)) || 
 		(typeid(*selection) == typeid(MapCenterObj))  )
 	{
-		BranchObj *bo=((BranchObj*)(selection));
-
-		QFileDialog *fd=new QFileDialog( this,tr("vym - load image"));
+		BranchObj *bo=((BranchObj*)selection);
+
+		Q3FileDialog *fd=new Q3FileDialog( this);
+		fd->setMode (Q3FileDialog::ExistingFiles);
 		fd->addFilter (QString (tr("Images") + " (*.png *.bmp *.xbm *.jpg *.png *.xpm *.gif *.pnm)"));
 		ImagePreview *p =new ImagePreview (fd);
 		fd->setContentsPreviewEnabled( TRUE );
 		fd->setContentsPreview( p, p );
-		fd->setPreviewMode( QFileDialog::Contents );
-		fd->setCaption(tr("vym - Load image"));
+		fd->setPreviewMode( Q3FileDialog::Contents );
+		fd->setCaption(__VYM " - " +tr("Load image"));
 		fd->setDir (lastImageDir);
 		fd->show();
 
 		QString fn;
 		if ( fd->exec() == QDialog::Accepted )
 		{
-			setChanged();
-			saveState(PartOfMap,selection);
-			QString fn=fd->selectedFile();
+			saveState(selection, QString("Add floatimage to %1").arg(getName(selection)));
 			lastImageDir=fn.left(fn.findRev ("/"));
-			bo->addFloatImage();
-			// FIXME check if load was successful
-			bo->getLastFloatImage()->load(fn);
-			bo->getLastFloatImage()->setOriginalFilename(fn);
+			QStringList flist = fd->selectedFiles();
+			QStringList::Iterator it = flist.begin();
+			while( it != flist.end() ) 
+			{
+				fn = *it;
+				bo->addFloatImage();
+				// TODO check if load was successful
+				bo->getLastFloatImage()->load(*it);
+				bo->getLastFloatImage()->setOriginalFilename(fn);
+				++it;
+			}
+
 			mapCenter->reposition();
 			adjustCanvasSize();
 			canvas()->update();
 		}
+		delete (p);
+		delete (fd);
 	}
 }
 
@@ -2506,10 +2873,10 @@
 	if (selection && 
 		(typeid(*selection) == typeid(FloatImageObj)) )
 	{
-		FloatImageObj *fio=((FloatImageObj*)(selection));
+		FloatImageObj *fio=((FloatImageObj*)selection);
 		const char* fmt = saveImageFormatMenu->text(item);
 
-		QFileDialog *fd=new QFileDialog( this, tr("vym - save image as") + fmt);
+		Q3FileDialog *fd=new Q3FileDialog( this, tr("vym - save image as") + fmt);
 		fd->addFilter ("PNG (*.png)");
 		fd->addFilter ("BMP (*.bmp)");
 		fd->addFilter ("XBM (*.xbm)");
@@ -2518,8 +2885,8 @@
 		fd->addFilter ("GIF (*.gif)");
 		fd->addFilter ("PNM (*.pnm)");
 		fd->addFilter (QString (tr("Images") + " (*.png *.bmp *.xbm *.jpg *.png *.xpm *.gif *.pnm)"));
-		fd->setCaption(tr("vym - Save image as ") + fmt);
-		fd->setMode( QFileDialog::AnyFile );
+		fd->setCaption(__VYM " - " +tr("Save image as %1").arg(fmt));
+		fd->setMode( Q3FileDialog::AnyFile );
 		fd->setSelection (fio->getOriginalFilename());
 		fd->show();
 
@@ -2528,10 +2895,9 @@
 		{
 			if (QFile (fd->selectedFile()).exists() )
 			{
-				QMessageBox mb( "VYM",
-					tr("The file ") + fd->selectedFile() + 
-					tr(" exists already. "
-					"Do you want to overwrite it?"),
+				QMessageBox mb( __VYM,
+					tr("The file %1 exists already.\n"
+					"Do you want to overwrite it?").arg(fd->selectedFile()),
 				QMessageBox::Warning,
 				QMessageBox::Yes | QMessageBox::Default,
 				QMessageBox::Cancel | QMessageBox::Escape,
@@ -2555,17 +2921,6 @@
 	}
 }
 
-void MapEditor::toggleFloatExport()
-{
-	if (selection && 
-		(typeid(*selection) == typeid(FloatImageObj))|| 
-		(typeid(*selection) == typeid(FloatObj)) )
-	{
-		FloatImageObj *fio=((FloatImageObj*)(selection));
-		fio->setFloatExport (actionEditToggleFloatExport->isOn() );
-	}
-}
-
 void MapEditor::setFrame(const FrameType &t)
 {
 	if (selection && 
@@ -2578,6 +2933,33 @@
 	}
 }
 
+void MapEditor::setIncludeImagesVer(bool b)
+{
+	if (selection && 
+		(typeid(*selection) == typeid(BranchObj)) || 
+		(typeid(*selection) == typeid(MapCenterObj))  )
+		((BranchObj*)selection)->setIncludeImagesVer(b);
+		mapCenter->reposition();
+}
+
+void MapEditor::setIncludeImagesHor(bool b)
+{
+	if (selection && 
+		(typeid(*selection) == typeid(BranchObj)) || 
+		(typeid(*selection) == typeid(MapCenterObj))  )
+		((BranchObj*)selection)->setIncludeImagesHor(b);
+		mapCenter->reposition();
+}
+
+void MapEditor::setHideLinkUnselected (bool b)
+{
+	if (selection && 
+		(typeid(*selection) == typeid(BranchObj)) || 
+		(typeid(*selection) == typeid(MapCenterObj))  ||
+		(typeid(*selection) == typeid(FloatImageObj)) )
+		selection->setHideLinkUnselected(b);
+}
+
 void MapEditor::importDir(BranchObj *dst, QDir d)
 {
 	if (selection && 
@@ -2588,41 +2970,42 @@
 		
 		// Traverse directories
 		d.setFilter( QDir::Dirs| QDir::Hidden | QDir::NoSymLinks );
-		const QFileInfoList *dirlist = d.entryInfoList();
-		QFileInfoListIterator itdir( *dirlist );
-		QFileInfo *fi;
-
-		while ( (fi = itdir.current()) != 0 ) 
+		QFileInfoList list = d.entryInfoList();
+		QFileInfo fi;
+
+		for (int i = 0; i < list.size(); ++i) 
 		{
-			if (fi->fileName() != "." && fi->fileName() != ".." )
+			fi=list.at(i);
+			if (fi.fileName() != "." && fi.fileName() != ".." )
 			{
 				dst->addBranch();
 				bo=dst->getLastBranch();
-				bo->setHeading (fi->fileName() );
-				bo->setColor (QColor("blue"),false);
+				bo->setHeading (fi.fileName() );
+				bo->setColor (QColor("blue"));
 				bo->toggleScroll();
-				if ( !d.cd(fi->fileName()) ) 
-					QMessageBox::critical (0,tr("Critical Import Error"),tr("Cannot find the directory"));
+				if ( !d.cd(fi.fileName()) ) 
+					QMessageBox::critical (0,tr("Critical Import Error"),tr("Cannot find the directory %1").arg(fi.fileName()));
 				else 
 				{
+					// Recursively add subdirs
 					importDir (bo,d);
 					d.cdUp();
 				}
 			}	
-			++itdir;
 		}		
 		// Traverse files
 		d.setFilter( QDir::Files| QDir::Hidden | QDir::NoSymLinks );
-		const QFileInfoList *filelist = d.entryInfoList();
-		QFileInfoListIterator itfile( *filelist );
-
-		while ( (fi = itfile.current()) != 0 ) 
+		list = d.entryInfoList();
+
+		for (int i = 0; i < list.size(); ++i) 
 		{
+			fi=list.at(i);
 			dst->addBranch();
 			bo=dst->getLastBranch();
-			bo->setHeading (fi->fileName() );
-			bo->setColor (QColor("black"),false);
-			++itfile;
+			bo->setHeading (fi.fileName() );
+			bo->setColor (QColor("black"));
+			if (fi.fileName().right(4) == ".vym" )
+				bo->setVymLink (fi.filePath());
 		}	
 	}		
 }
@@ -2633,16 +3016,16 @@
 		(typeid(*selection) == typeid(BranchObj)) || 
 		(typeid(*selection) == typeid(MapCenterObj))  )
 	{
-		QFileDialog *fd=new QFileDialog( this,tr("VYM - Choose directory structur to import"));
-		fd->setMode (QFileDialog::DirectoryOnly);
+		Q3FileDialog *fd=new Q3FileDialog( this,__VYM " - " +tr("Choose directory structure to import"));
+		fd->setMode (Q3FileDialog::DirectoryOnly);
 		fd->addFilter (QString (tr("vym map") + " (*.vym)"));
-		fd->setCaption(tr("VYM - Choose directory structur to import"));
+		fd->setCaption(__VYM " - " +tr("Choose directory structure to import"));
 		fd->show();
 
 		QString fn;
 		if ( fd->exec() == QDialog::Accepted )
 		{
-			BranchObj *bo=((BranchObj*)(selection));
+			BranchObj *bo=((BranchObj*)selection);
 			importDir (bo,QDir(fd->selectedFile()) );
 			mapCenter->reposition();
 			adjustCanvasSize();
@@ -2651,20 +3034,119 @@
 	}	
 }
 
+void MapEditor::followXLink(int i)
+{
+	if (selection && 
+		(typeid(*selection) == typeid(BranchObj)) || 
+		(typeid(*selection) == typeid(MapCenterObj))  )
+	{
+		BranchObj *bo=((BranchObj*)selection)->XLinkTargetAt(i);
+		if (bo) 
+		{
+			selection->unselect();
+			selection=bo;
+			selection->select();
+			ensureSelectionVisible();
+		}
+	}
+}
+
+void MapEditor::editXLink(int i)
+{
+	if (selection && 
+		(typeid(*selection) == typeid(BranchObj)) || 
+		(typeid(*selection) == typeid(MapCenterObj))  )
+	{
+		XLinkObj *xlo=((BranchObj*)selection)->XLinkAt(i);
+		if (xlo) 
+		{
+			EditXLinkDialog dia;
+			dia.setXLink (xlo);
+			dia.setSelection(selection);
+			if (dia.exec() == QDialog::Accepted)
+			{
+				if (dia.useSettingsGlobal() )
+				{
+					setDefXLinkColor (xlo->getColor() );
+					setDefXLinkWidth (xlo->getWidth() );
+				}
+				if (dia.deleteXLink())
+					((BranchObj*)selection)->deleteXLinkAt(i);
+				saveState("Edit xLink");	//TODO undoCommand
+			}
+		}	
+	}
+}
+
 void MapEditor::testFunction()
 {
 	cout << "MapEditor::testFunction() called\n";
+
+	mapCenter->positionBBox();
+	return;
+
+	WarningDialog dia;
+	dia.setCancelButton (true);
+	dia.setText("This is a longer \nWarning");
+	dia.setCaption("Warning: Flux problem");
+	dia.setShowAgainName("/vym/warnings/mapeditor");
+	if (dia.exec()==QDialog::Accepted)
+		cout << "accepted!\n";
+	else	
+		cout << "canceled!\n";
+	return;
+
+	QString ub=vymBaseDir.path()+"/scripts/update-bookmarks";
+	Q3Process *proc = new Q3Process( this );
+	proc->addArgument(ub);
+
+	if ( !proc->start() ) 
+	{
+		QMessageBox::warning(0, 
+			tr("Warning"),
+			tr("Couldn't find script %1\nto notifiy Browsers of changed bookmarks.").arg(ub));
+	}	
+
+	
+/*
+	if (hidemode==HideNone)
+	{
+		setHideTmpMode (HideExport);
+		mapCenter->calcBBoxSizeWithChilds();
+		QRect totalBBox=mapCenter->getTotalBBox();
+		QRect 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,mapCanvas);
+		frame->setBrush (QColor(white));
+		frame->setPen (QColor(black));
+		frame->setZ(0);
+		frame->show();    
+	}	
+	else	
+	{
+		setHideTmpMode (HideNone);
+	}	
+	cout <<"  hidemode="<<hidemode<<endl;
+	*/
 }
 
 void MapEditor::ensureSelectionVisible()
 {
-	LinkableMapObj* lmo= dynamic_cast <LinkableMapObj*> (selection);
-	QPoint p;
-	if (selection->getOrientation() == OrientLeftOfCenter)
-		p= worldMatrix().map(QPoint (lmo->x(),lmo->y()));
-	else	
-		p= worldMatrix().map(QPoint (lmo->x()+lmo->width(),lmo->y()+lmo->height()));
-	ensureVisible (p.x(), p.y() );
+	if (selection)
+	{
+		LinkableMapObj* lmo= dynamic_cast <LinkableMapObj*> (selection);
+		QPoint p;
+		if (selection->getOrientation() == OrientLeftOfCenter)
+			p= worldMatrix().map(QPoint (lmo->x(),lmo->y()));
+		else	
+			p= worldMatrix().map(QPoint (lmo->x()+lmo->width(),lmo->y()+lmo->height()));
+		ensureVisible (p.x(), p.y() );
+	}
 
 }
 
@@ -2719,78 +3201,129 @@
 		updateActions();
 		canvasContextMenu->popup(e->globalPos() );
     } 
+	e->accept();
 }
 
 void MapEditor::contentsMousePressEvent(QMouseEvent* e)
 {
+	// Ignore right clicks, these will go to context menus
+	if (e->button() == Qt::RightButton )
+	{
+		e->ignore();
+		return;
+	}
+
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 	
     QPoint p = inverseWorldMatrix().map(e->pos());
     LinkableMapObj* lmo=mapCenter->findMapObj(p, NULL);
 	
-	// Special case: CTRL is pressed, don't select anything
-	if (e->state() & QMouseEvent::ControlButton)
+	e->accept();
+
+	//Take care of clickdesystem flags _or_ modifier modes
+	//
+	if (lmo && (typeid(*lmo)==typeid(BranchObj) ||
+		typeid(*lmo)==typeid(MapCenterObj) ))
 	{
-		pickingColor=true;
-		setCursor (pickColorCursor);
-		return;
+		QString foname=((BranchObj*)lmo)->getSystemFlagName(p);
+		if (!foname.isEmpty())
+		{
+			// systemFlag clicked
+			select (lmo);
+			if (foname=="url") 
+			{
+				if (e->state() & Qt::ControlModifier)
+					mainWindow->editOpenURLTab();
+				else	
+					mainWindow->editOpenURL();
+			}	
+			else if (foname=="vymLink")
+			{
+				mainWindow->editOpenVymLink();
+				// tabWidget may change, better return now
+				// before segfaulting...
+			} else if (foname=="note")
+				mainWindow->windowToggleNoteEditor();
+			else if (foname=="hideInExport")		
+				toggleHideExport();
+			return;	
+		} 
+	} 
+	// No system flag clicked, take care of modmodes
+
+	// Special case: CTRL is pressed
+	if (e->state() & Qt::ControlModifier)
+	{
+		if (actionModModeColor->isOn())
+		{
+				pickingColor=true;
+				setCursor (pickColorCursor);
+				return;
+		} 
+		if (actionModModeLink->isOn())
+		{	
+			BranchObj *bo_begin=NULL;
+			if (lmo)
+				bo_begin=(BranchObj*)(lmo);
+			else	
+				if (selection && 
+					((typeid(*selection) == typeid(BranchObj)) || 
+					(typeid(*selection) == typeid(MapCenterObj)))  )
+				bo_begin=(BranchObj*)selection;
+			if (bo_begin)	
+			{
+				drawingLink=true;
+				linkingObj_src=bo_begin;
+				tmpXLink=new XLinkObj (mapCanvas);
+				tmpXLink->setBegin (bo_begin);
+				tmpXLink->setEnd   (p);
+				tmpXLink->setColor(defXLinkColor);
+				tmpXLink->setWidth(defXLinkWidth);
+				tmpXLink->updateXLink();
+				tmpXLink->setVisibility (true);
+				return;
+			} 
+		}
 	}
-
     if (lmo) 
-	{	// MapObj was found
-		if (selection != lmo)
+	{	
+		select (lmo);
+		// Left Button	    Move Branches
+		if (e->button() == Qt::LeftButton )
 		{
-			// select the MapObj
-			if (selection) selection->unselect();
-			selection=lmo;
-			selection->select();
-				
-			adjustCanvasSize();
-		}
-
-		// Check, if systemFlag clicked
-		if (typeid(*selection)==typeid(BranchObj) ||
-			typeid(*selection)==typeid(MapCenterObj) )
-		{
-			QString foname=((BranchObj*)(selection))->getSystemFlagName(p);
-			if (!foname.isEmpty())
-			{
-				// Do not move, if systemFlag clicked
-				if (foname=="url") 
-					openURL();
-				else
-					if (foname=="vymLink")
-					{
-						mainWindow->editOpenVymLink();
-						// tabWidget may change, better return now
-						// before segfaulting...
-						return;
-					} else
-						if (foname=="note")
-							mainWindow->windowToggleNoteEditor();
-			}			
-		}	
-			
-		// Left Button	    Move Branches
-		if (e->button() == QMouseEvent::LeftButton )
-		{
-			movingObj=selection;	
 			movingObj_start.setX( p.x() - selection->x() );	
 			movingObj_start.setY( p.y() - selection->y() );	
+			movingObj_orgPos.setX (lmo->x() );
+			movingObj_orgPos.setY (lmo->y() );
+
+			// If modMode==copy, then we want to "move" the _new_ object around
+			// then we need the offset from p to the _old_ selection, because of tmp
+			if (actionModModeCopy->isOn() &&
+				e->state() & Qt::ControlModifier)
+			{
+				if (typeid(*selection)==typeid(BranchObj) )
+				{
+					copyingObj=true;
+					mapCenter->addBranch ((BranchObj*)selection);
+					unselect();
+					selection=mapCenter->getLastBranch();
+					selection->select();
+					mapCenter->reposition();
+				}
+			}	
+			movingObj=selection;	
 		} else
 			// Middle Button    Toggle Scroll
 			// (On Mac OS X this won't work, but we still have 
 			// a button in the toolbar)
-			if (e->button() == QMouseEvent::MidButton )
-			{
+			if (e->button() == Qt::MidButton )
 				toggleScroll();
-			} 
 		updateActions();
 	} else 
 	{ // No MapObj found, we are on the Canvas itself
 		// Left Button	    move Pos of CanvasView
-		if (e->button() == QMouseEvent::LeftButton )
+		if (e->button() == Qt::LeftButton )
 		{
 			movingObj=NULL;	// move Content not Obj
 			movingObj_start=e->globalPos();
@@ -2803,14 +3336,19 @@
 
 void MapEditor::contentsMouseMoveEvent(QMouseEvent* e)
 {
+	QPoint p = inverseWorldMatrix().map(e->pos());
+
     // Move the selected MapObj
     if ( selection && movingObj) 
     {	
-		QPoint p = inverseWorldMatrix().map(e->pos());
+		// To avoid jumping of the CanvasView, only 
+		// ensureSelectionVisible, if not tmp linked
+		if (!selection->hasParObjTmp())
+			ensureSelectionVisible ();
 		
-		// Now move the selection, but add relative position (movingObj_start) 
-		// where selection 
-		// was chosen with mousepointer. (This avoids flickering resp. jumping 
+		// Now move the selection, but add relative position 
+		// (movingObj_start) where selection was chosen with 
+		// mousepointer. (This avoids flickering resp. jumping 
 		// of selection back to absPos)
 		
 		LinkableMapObj *lmosel;
@@ -2822,21 +3360,17 @@
 
 		if (typeid(*selection) == typeid(FloatImageObj))
 		{
-			setChanged();
-			saveState();
-			FloatObj *fo=(FloatObj*)(selection);
-			if (fo->getLinkStyle()==StyleUndef) 
-			{
-				fo->setLinkStyle(fo->getDefLinkStyle());
-				fo->setLinkColor(fo->getParObj()->getLinkColor());
-			}	
+			FloatObj *fo=(FloatObj*)selection;
+			saveState(
+				"move "+qpointToString(movingObj_orgPos),fo->getSelectString() ,
+				QString("Move %1").arg(getName(selection)));
 			fo->move   (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );		
 			fo->setRelPos();
 			fo->reposition();
 
 			// Relink float to new mapcenter or branch, if shift is pressed	
 			// Only relink, if selection really has a new parent
-			if ( (e->state() & QMouseEvent::ShiftButton) && lmo &&
+			if ( (e->state() & Qt::ShiftModifier) && lmo &&
 				( (typeid(*lmo)==typeid(BranchObj)) ||
 				  (typeid(*lmo)==typeid(MapCenterObj)) ) &&
 				( lmo != fo->getParObj())  
@@ -2844,6 +3378,7 @@
 			{
 				if (typeid(*fo) == typeid(FloatImageObj)) 
 				{
+					saveState(QString("Relink %1 to %2").arg(getName(fo)).arg(getName(lmo) ) );
 					FloatImageObj *fio=(FloatImageObj*)(fo);
 					((BranchObj*)(lmo))->addFloatImage (fio);
 					fio->unselect();
@@ -2854,18 +3389,13 @@
 					selection=(LinkableMapObj*)(fio);
 					selection->select();
 					movingObj=(MapObj*)(fio);
-					// setLinkStyle calls updateLink, only set it once
-					if (fio->getLinkStyle()!=fio->getDefLinkStyle() ) 
-						fio->setLinkStyle (fio->getDefLinkStyle());
-
 				}	
-				// TODO if (typeid(*selection) == typeid(FloatTextObj))
 			}
 		} else	// selection != a FloatObj
 		{
 			if (lmosel->getDepth()==0)
 			{
-				if (e->state() == (LeftButton | !ShiftButton)) 
+				if (e->state() == Qt::LeftButton && e->modifiers()==Qt::ShiftModifier) 
 					// If mapCenter is moved, move all the rest by default, too.
 					mapCenter->moveAll(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );		
 				else	
@@ -2875,8 +3405,6 @@
 				if (lmosel->getDepth()==1)
 				{
 					// depth==1, mainbranch
-					setChanged();
-					saveState(PartOfMap,lmosel);
 					lmosel->move(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );		
 				} else
 				{
@@ -2884,36 +3412,31 @@
 					if (lmosel->getOrientation() == OrientLeftOfCenter)
 						// Add width of bbox here, otherwise alignRelTo will cause jumping around
 						lmosel->move(p.x() -movingObj_start.x()+lmosel->getBBox().width(), 
-							p.y()-movingObj_start.y() );		
+							p.y()-movingObj_start.y() +lmosel->getTopPad() );		
 					else	
-						lmosel->move(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() );
+						lmosel->move(p.x() -movingObj_start.x(), p.y()-movingObj_start.y() -lmosel->getTopPad());
 				} 
 				// reposition subbranch
 				lmosel->reposition();	
-				ensureSelectionVisible();
+				//ensureSelectionVisible();
 
 				if (lmo && (lmo!=selection) &&  
 					(typeid(*lmo) == typeid(BranchObj) ||
 					(typeid(*lmo) == typeid(MapCenterObj) )
 					) )
 				{
-					if (e->state() & QMouseEvent::ControlButton)
+					if (e->state() & Qt::ControlModifier)
 					{
 						// Special case: CTRL to link below lmo
 						lmosel->setParObjTmp (lmo,p,+1);
 					}
-					else if (e->state() & QMouseEvent::ShiftButton)
+					else if (e->state() & Qt::ShiftModifier)
 						lmosel->setParObjTmp (lmo,p,-1);
 					else
 						lmosel->setParObjTmp (lmo,p,0);
 				} else	
 				{
-					if (lmo &&(lmo==selection))   
-						// Could link to myself (happens sometimes...)
-						lmosel->unsetParObjTmp();
-					if (!lmo)  
-						// no Obj under selection, go back to original Parent
-						lmosel->unsetParObjTmp();
+					lmosel->unsetParObjTmp();
 				}		
 			} // depth>0
 
@@ -2923,8 +3446,15 @@
 		return;
 	} // selection && moving_obj
 		
+	// Draw a link from one branch to another
+	if (drawingLink)
+	{
+		 tmpXLink->setEnd (p);
+		 tmpXLink->updateXLink();
+	}	 
+	
     // Move CanvasView 
-    if (!movingObj && !pickingColor) 
+    if (!movingObj && !pickingColor &&!drawingLink) 
 	{
 		QPoint p=e->globalPos();
 		movingVec.setX(-p.x() + movingObj_start.x() );
@@ -2944,37 +3474,62 @@
 	if (pickingColor)
 	{
 		pickingColor=false;
-		setCursor (ArrowCursor);
+		setCursor (Qt::ArrowCursor);
 		// Check if we are over another branch
 		dst=mapCenter->findMapObj(inverseWorldMatrix().map(e->pos() ), NULL);
 		if (dst && selection) 
 		{	
-			if (e->state() & QMouseEvent::ShiftButton)
+			if (e->state() & Qt::ShiftModifier)
 			{
-				((BranchObj*)(selection))->setColor (((BranchObj*)(dst))->getColor(),false);
-				((BranchObj*)(selection))->setLinkColor ();
+				((BranchObj*)selection)->setColor (((BranchObj*)(dst))->getColor());
+				((BranchObj*)selection)->setLinkColor ();
 			}	
 			else	
 			{
-				((BranchObj*)(selection))->setColor (((BranchObj*)(dst))->getColor(),true);
-				((BranchObj*)(selection))->setLinkColor ();
+				((BranchObj*)selection)->setColorChilds (((BranchObj*)(dst))->getColor());
+				((BranchObj*)selection)->setLinkColor ();
 			}	
 		} 
 		return;
 	}
+
+	// Have we been drawing a link?
+	if (drawingLink)
+	{
+		drawingLink=false;
+		// Check if we are over another branch
+		dst=mapCenter->findMapObj(inverseWorldMatrix().map(e->pos() ), NULL);
+		if (dst && selection) 
+		{	
+			tmpXLink->setEnd ( ((BranchObj*)(dst)) );
+			tmpXLink->updateXLink();
+			tmpXLink->activate();
+			saveState(QString("Activate xLink from %1 to %2").arg(getName(tmpXLink->getBegin())).arg(getName(tmpXLink->getEnd())) );	//TODO undoCommand
+		} else
+		{
+			delete(tmpXLink);
+			tmpXLink=NULL;
+		}
+		return;
+	}
+	
     // Have we been moving something?
     if ( selection && movingObj ) 
     {	
+		// Moved FloatObj? Maybe we need to reposition
+		if(typeid(*selection)==typeid (FloatImageObj))
+		{
+			selection->getParObj()->requestReposition();
+			mapCenter->reposition();
+		}	
+
 		// Check if we are over another branch, but ignore 
 		// any found LMOs, which are FloatObjs
 		dst=mapCenter->findMapObj(inverseWorldMatrix().map(e->pos() ), 
-			((LinkableMapObj*)(selection)) );
-
-		if (dst &&
-		(typeid(*dst)!=typeid(BranchObj)&&typeid(*dst)!=typeid(MapCenterObj))) 
-		{
+			((LinkableMapObj*)selection) );
+
+		if (dst && (typeid(*dst)!=typeid(BranchObj) && typeid(*dst)!=typeid(MapCenterObj))) 
 			dst=NULL;
-		}	
 		
 		// Now check, if we have been moving a branch 
 		if (typeid(*selection) == typeid(BranchObj)  )
@@ -2983,40 +3538,43 @@
 			QPoint savePos=QPoint (selection->x(),selection->y() );
 
 			// Reset the temporary drawn link to the original one
-			((LinkableMapObj*)(selection))->unsetParObjTmp();
-
+			((LinkableMapObj*)selection)->unsetParObjTmp();
+
+
+			copyingObj=false;	
 			if (dst ) 
-			{   
-				setChanged();
-				saveState();
+			{
+				BranchObj* bs=((BranchObj*)selection);
+				QString undoCom="linkBranchToPos (\""+ 
+					(bs->getParObj())->getSelectString()+
+					"\","+
+					QString("%1").arg(bs->getNum())+
+					","+
+					QString ("%1,%2").arg(movingObj_orgPos.x()).arg(movingObj_orgPos.y())+
+					")";
 				// TODO we also could check, if dest and src are on same branch,
 				// then it would be sufficient to saveState of this branch
 
-				// FIXME better introduce BO::move  to speed up and keep IDs
-				copy();			// copy selection to clipboard
-				cutNoSave();	// remove selection here
-
-				selection->unselect();	
-				selection=dst;
 				// Modifiers allow to insert above/below dst
-				if (e->state() & QMouseEvent::ShiftButton)
+				if (e->state() & Qt::ShiftModifier)
 				{
-					selection=pasteAtNoSave (((BranchObj*)(dst))->getNum());
-					if (selection) selection->select();
-				}	
-				else if (e->state() & QMouseEvent::ControlButton)
+					bs->moveBranchTo ( (BranchObj*)(dst->getParObj()), ((BranchObj*)(dst))->getNum());
+				} else 
+				if (e->state() & Qt::ControlModifier)
+			{
+					bs->moveBranchTo ( (BranchObj*)(dst->getParObj()), ((BranchObj*)(dst))->getNum()+1);
+				} else	
 				{
-					selection=pasteAtNoSave (((BranchObj*)(dst))->getNum()+1);
-					if (selection) selection->select();
-				}	
-				else	
-				{
-					selection=pasteNoSave();
-					selection->select();
+					bs->moveBranchTo ((BranchObj*)(dst),-1);
 					if (dst->getDepth()==0) 
-						((BranchObj*)(selection))->move (savePos);
-				}	
-			} 
+						bs->move (savePos);
+				} 
+				saveState (undoCom,bs->getSelectString(),QString("Relink %1 to %2").arg(getName(bs)).arg(getName(dst)) );
+			} else
+				if (selection->getDepth()==1)
+					// If we have moved mainbranch only save endposition
+					saveState("move "+qpointToString(movingObj_orgPos), selection->getSelectString(), QString("Move %1 to %2").arg(getName(selection)).arg(qpointToString(movingObj_orgPos)));
+			
 			// Draw the original link, before selection was moved around
 			mapCenter->reposition();
 		}
@@ -3025,17 +3583,17 @@
 		canvas()->update();
 		movingObj=NULL;		
 	} else 
-	{	// maybe we moved View: set old cursor
-		setCursor (ArrowCursor);
-    }
+		// maybe we moved View: set old cursor
+		setCursor (Qt::ArrowCursor);
+    
 }
 
 void MapEditor::contentsMouseDoubleClickEvent(QMouseEvent* e)
 {
 	// Finish open lineEdits
-	if (lineedit) finishedLineEditNoSave();
+	if (lineedit) finishedLineEdit();
 	
-	if (e->button() == QMouseEvent::LeftButton )
+	if (e->button() == Qt::LeftButton )
 	{
 		QPoint p = inverseWorldMatrix().map(e->pos());
 		LinkableMapObj *lmo=mapCenter->findMapObj(p, NULL);
@@ -3044,8 +3602,6 @@
 			if (selection) selection->unselect();
 			selection=lmo;
 			selection->select();
-			setChanged();
-			saveState(PartOfMap,selection);
 			editHeading();
 		}
 	}
@@ -3053,10 +3609,239 @@
 
 void MapEditor::resizeEvent (QResizeEvent* e)
 {
-	QCanvasView::resizeEvent( e );
-	
-	QString s="";
-	if (!fileName.isEmpty()) s=fileName;
+	Q3CanvasView::resizeEvent( e );
 	adjustCanvasSize();
 }
 
+void MapEditor::contentsDragEnterEvent(QDragEnterEvent *event) 
+{
+
+//  for (unsigned int i=0;event->format(i);i++) // Debug mime type
+//    cerr << event->format(i) << endl;
+
+  if (selection && 
+      (typeid(*selection) == typeid(BranchObj)) || 
+      (typeid(*selection) == typeid(MapCenterObj))) {
+    
+    // If QImageDrag can decode mime type 
+    if (Q3ImageDrag::canDecode(event)) {
+      event->accept();
+      return;
+    }
+    
+    // If image are dragged from firefox 
+    if (event->provides("application/x-moz-file-promise-url") && 
+	event->provides("application/x-moz-nativeimage")) {
+      event->accept(true);
+      return;
+    }
+
+    // If QUriDrag can decode mime type 
+    if (Q3UriDrag::canDecode(event)) {
+      event->accept();
+      return;
+    }
+    
+	// If Uri are dragged from firefox 
+    if (event->provides("_NETSCAPE_URL")){
+      event->accept();
+      return;
+    }
+
+    // If QTextDrag can decode mime type
+    if (Q3TextDrag::canDecode(event)) {
+      event->accept();
+      return;
+    }
+
+  }
+  event->ignore();
+}
+
+bool isUnicode16(const QByteArray &d) 
+{
+  // TODO: make more precise check for unicode 16.
+  // Guess unicode16 if any of second bytes are zero
+  unsigned int length = max(0,d.size()-2)/2;
+  for (unsigned int i = 0; i<length ; i++)
+    if (d.at(i*2+1)==0) return true;
+  return false;
+}
+      
+void MapEditor::contentsDropEvent(QDropEvent *event) 
+{
+	if (selection && 
+      (typeid(*selection) == typeid(BranchObj)) || 
+      (typeid(*selection) == typeid(MapCenterObj))) 
+	{
+		bool update=false;
+		Q3StrList uris;
+		QString heading;
+		if (event->provides("image/png")) 
+		{
+			QPixmap pix;
+			if (Q3ImageDrag::decode(event, pix)) 
+			{
+				addFloatImage(pix);
+				event->accept();
+				update=true;
+			} else
+				event->ignore();
+
+		} else if (event->provides("application/x-moz-file-promise-url") && 
+			 event->provides("application/x-moz-nativeimage")) 
+		{
+			// Contains url to the img src in unicode16
+			QByteArray d = event->encodedData("application/x-moz-file-promise-url");
+			QString url = QString((const QChar*)d.data(),d.size()/2);
+			fetchImage(url);
+			event->accept();
+			update=true;
+		} else if (event->provides ("text/uri-list"))
+		{	// Uris provided e.g. by konqueror
+			Q3UriDrag::decode (event,uris);
+		} else if (event->provides ("_NETSCAPE_URL"))
+		{	// Uris provided by Mozilla
+		  QStringList l = QStringList::split("\n", event->encodedData("_NETSCAPE_URL"));
+		  uris.append(l[0]);
+		  heading = l[1];
+		} else if (event->provides("text/html")) {
+
+		  // Handels text mime types
+		  // Look like firefox allways handle text as unicode16 (2 bytes per char.)
+		  QByteArray d = event->encodedData("text/html");
+		  QString text;
+		  if (isUnicode16(d)) 
+		    text = QString((const QChar*)d.data(),d.size()/2);
+		  else 
+		    text = QString(d);
+
+		  textEditor->setText(text);
+
+		  event->accept();
+		  update=true;
+		} else if (event->provides("text/plain")) {
+		  QByteArray d = event->encodedData("text/plain");
+		  QString text;
+		  if (isUnicode16(d))
+		    text = QString((const QChar*)d.data(),d.size()/2);
+		  else 
+		    text = QString(d);
+
+		  textEditor->setText(text);
+		  
+		  event->accept();
+		  update= true;
+		}
+
+		if (uris.count()>0)
+		{
+			QStringList files;
+			QStringList urls;
+			QString s;
+			BranchObj *bo;
+			for (const char* u=uris.first(); u; u=uris.next())
+			{
+				bo=((BranchObj*)selection)->addBranch();
+				if (bo)
+				{
+					s=Q3UriDrag::uriToLocalFile(u);
+					if (!s.isEmpty()) 
+					{
+                       QString file = QDir::convertSeparators(s);
+                       heading = QFileInfo(file).baseName();
+                       files.append(file);
+                       if (file.endsWith(".vym", false))
+                           bo->setVymLink(file);
+                       else
+                           bo->setURL(u);
+                   } else 
+				   {
+                       urls.append (u);
+                       bo->setURL(u);
+                   }
+
+                   if (!heading.isEmpty())
+                       bo->setHeading(heading);
+                   else
+                       bo->setHeading(u);
+				}
+			}
+			update=true;
+		}
+
+		if (update) 
+		{
+			//FIXME saveState has to be called earlier for each of the drops...
+			saveState("Drop Event");	//TODO undo Command
+			mapCenter->reposition();
+			adjustCanvasSize();
+			canvas()->update();
+		}	
+	}	
+}
+
+void MapEditor::addFloatImage(const QPixmap &img) 
+{
+  if (selection && 
+      (typeid(*selection) == typeid(BranchObj)) || 
+      (typeid(*selection) == typeid(MapCenterObj))  )
+  {
+    BranchObj *bo=((BranchObj*)selection);
+    saveState(selection,QString("Add floatimage to %1").arg(getName(bo)));
+    //QString fn=fd->selectedFile();
+    //lastImageDir=fn.left(fn.findRev ("/"));
+    bo->addFloatImage();
+    // FIXME check if load was successful
+    bo->getLastFloatImage()->load(img);
+    //bo->getLastFloatImage()->setOriginalFilename(fn);
+    mapCenter->reposition();
+    adjustCanvasSize();
+    canvas()->update();
+  }
+}
+
+
+void MapEditor::imageDataFetched(const QByteArray &a, Q3NetworkOperation */*nop*/) 
+{
+  if (!imageBuffer) imageBuffer = new QBuffer();
+  if (!imageBuffer->isOpen()) {
+    imageBuffer->open(QIODevice::WriteOnly | QIODevice::Append);
+  }
+  imageBuffer->at(imageBuffer->at()+imageBuffer->writeBlock(a));
+}
+
+
+void MapEditor::imageDataFinished(Q3NetworkOperation *nop) 
+{
+	if (nop->state()==Q3NetworkProtocol::StDone) {
+		QPixmap img(imageBuffer->buffer());
+		addFloatImage(img);
+	}
+
+	if (imageBuffer) {
+		imageBuffer->close();
+		if (imageBuffer) {
+			imageBuffer->close();
+			delete imageBuffer;
+			imageBuffer = 0;
+		}
+	}
+}
+
+void MapEditor::fetchImage(const QString &url) 
+{
+  if (urlOperator) {
+    urlOperator->stop();
+    disconnect(urlOperator);
+    delete urlOperator;
+  }
+  
+  urlOperator = new Q3UrlOperator(url);
+  connect(urlOperator, SIGNAL(finished(Q3NetworkOperation *)), 
+	  this, SLOT(imageDataFinished(Q3NetworkOperation*)));
+
+  connect(urlOperator, SIGNAL(data(const QByteArray &, Q3NetworkOperation *)),
+	  this, SLOT(imageDataFetched(const QByteArray &, Q3NetworkOperation *)));
+  urlOperator->get();
+}
diff -r 9eb7767c2dfa -r 608f976aa7bb mapeditor.h
--- a/mapeditor.h	Sun Jan 30 12:58:47 2005 +0000
+++ b/mapeditor.h	Tue Jun 06 14:58:11 2006 +0000
@@ -1,43 +1,63 @@
 #ifndef MAPEDITOR_H
 #define MAPEDITOR_H
 
-#include <qcanvas.h>
+#include <q3canvas.h>
 #include <qlineedit.h>
 #include <qcursor.h>
-#include <qfiledialog.h>
+#include <q3filedialog.h>
 #include <qevent.h>
-#include <qprocess.h>
+#include <q3process.h>
+#include <qbuffer.h>
+//Added by qt3to4:
+#include <QContextMenuEvent>
+#include <QDropEvent>
+#include <QResizeEvent>
+#include <QPixmap>
+#include <QMouseEvent>
+#include <QDragEnterEvent>
 
 #include "mapcenterobj.h"
+#include "file.h"
 #include "misc.h"
+#include "showtextdialog.h"
 
-class MapEditor : public QCanvasView , public xmlObj {
+class Q3NetworkOperation;
+class Q3UrlOperator;
+
+class MapEditor : public Q3CanvasView , public xmlObj {
     Q_OBJECT
 
 public:
-    MapEditor(QWidget* parent=0, bool interactive=false, const char* name=0, WFlags f=0);
+    MapEditor(QWidget* parent=0, bool interactive=false, const char* name=0, Qt::WFlags f=0);
 	~MapEditor();
     QColor color();
     QColor backgroundColor();
     MapCenterObj* getMapCenter();
-	QCanvas* getCanvas();
+	Q3Canvas* getCanvas();
 	void adjustCanvasSize();// adjust canvas size to map and scrollview
-	bool blockReposition(); // block while load or undo
+	bool isRepositionBlocked(); // block while load or undo
 	
 private:
+	QString getName(LinkableMapObj*);	// Get e.g. heading or filename
 	void makeTmpDirs();		// create temporary directories
-	void delTmpDirs();		// delete temporary directories
-	void makeSubDirs(const QString&);		
-							// create subdirs in dir
-    QString saveToDir(const QString&,const QString &,bool, const QPoint
-	&,SaveMode);
-    void saveState();		// save actual state to backup
-    void saveState(const SaveMode&, LinkableMapObj *);
+    QString saveToDir(const QString&,const QString &,bool, const QPoint &,LinkableMapObj*);
+    void saveState(const QString &);	// save actual state to backup
+    void saveState(LinkableMapObj *, const QString &);
+    void saveState(const QString &, const QString &, const QString &);
+    void saveState(const QString &, LinkableMapObj *, const QString &);
+    void saveState(const SaveMode&, const QString &, LinkableMapObj *, const QString &, LinkableMapObj *, const QString &);
+    void parseAtom(const QString &);	
 
-private slots:
-    void finishedLineEditNoSave();
+    void addFloatImage(const QPixmap &img);
+
+  private slots:
+    void finishedLineEdit();
+    void fetchImage(const QString &img);
+    void imageDataFetched(const QByteArray &, Q3NetworkOperation *);
+    void imageDataFinished(Q3NetworkOperation *);
 
 public:
+	void toggleHistoryWindow();
 	bool isDefault();		// false, if map was changed once
     bool isUnsaved();		// save necessary
     bool hasChanged();		// undo possible
@@ -49,38 +69,51 @@
 	QString getFileName ();	// e.g. "map.xml"
 	QString getMapName ();	// e.g. "map"
 	QString getDestPath (); // e.g. "/home/tux/map.vym"
-    int load (QString&, const LoadMode &);	// newmap, import/replace selection
+    ErrorCode load (QString, LoadMode );	// newmap, import/replace selection
+public:
     int save(const SaveMode &);	// Save map 
 	void setZipped(bool);		// save map zipped
 	bool saveZipped();			// 1 if file will be saved zipped
     void print();				// print canvas
 private:
     QPixmap getPixmap();
+	void setHideTmpMode (HideTmpMode);	// temporary hide stuff
+	HideTmpMode getHideTmpMode();		// temporary hide stuff
 public:
+	void setExportMode (bool);			// temporary hide stuff during export
     void exportImage (QString fn);		// export as PNG	
     void exportImage (QString fn, int);	// export in given format
-    void exportASCII();
+    void exportOOPresentation(const QString &,const QString &);
     void exportXML(const QString&);		// export to directory
     void clear();		// clear map
+    void copy();		// copy branch to clipboard
+    void redo();		// redo last action
     void undo();		// undo last action
-    void copy();		// copy branch to clipboard
 private:	
-    LinkableMapObj* pasteNoSave();		// paste clipboard to branch
-    LinkableMapObj* pasteAtNoSave(int);	// paste clipboard to branch at position i
+    void undoXML(const QString &, const QString &);
+    void pasteNoSave();		// paste clipboard to branch
     void cutNoSave();	// cut to clipboard
 public:	
     void paste();		// paste clipboard to branch and backup
     void cut();			// cut to clipboard and backup
+    void move(const int &,const int&);
     void moveBranchUp();
     void moveBranchDown();
-    void editHeading();
+    void editHeading();					// Start editing heading 
+private:
+	void setHeading(const QString &);	// Just set the heading for selection
+	void setURL(const QString &);		// Just set the URL for selection
+	void setVymLink(const QString &);	// Set vymLink for selection
+public:	
     void addNewBranch(int);			// pos allows to add above/below selection
+    void addNewBranchHere();		// insert and make selection its
     void deleteSelection();
 	LinkableMapObj* getSelection();	// returns selection
-	bool select(QString );			// Select 
 	void unselect();				// before changing current noteedit
 	void reselect();				// after  changing current noteedit
+	bool select(const QString &);	// Select 
 private:	
+	void select(LinkableMapObj*);	
 	void selectNextBranch();		// Increment number of branch
 	void selectPrevBranch();		// Decrement number of branch
 public:	
@@ -100,15 +133,20 @@
 	virtual void setViewCenter();			// needed for zooming
     BranchObj* findText(QString,bool);		// Find object
     void findReset();						// Reset Find 
-	void openURL();							// open URL in external browser
 	void editURL();							// edit the URL
+	QString getURL();						// returns URL of selection or ""
 	void editHeading2URL();					// copy heading to URL
 	void editBugzilla2URL();				// create URL to Bugzilla
+	void editFATE2URL();					// create URL to FATE
 	void editVymLink();						// edit link to another map
 	void deleteVymLink();					// delete link to another map
 	QString getVymLink();					// return path to map
+	void toggleHideExport();				// toggle the export flag
+	void removeBranchKeepChilds();			// remove but keep childs
+	void removeChilds();					// remove childs
 	void editMapInfo();						// dialog to enter author, ...
 	void updateActions();					// update e.g. format buttons
+	void updateNoteFlag();					// when TextEditor changes
 	void setLinkStyle (LinkStyle);			// Set style of link
 	LinkStyle getLinkStyle ();				// requested in LMO
 	void setLinkColor(QColor);				// default color of links
@@ -116,18 +154,27 @@
 	void setLinkColorHint(LinkColorHint);	// color of links
 	LinkColorHint getLinkColorHint();
 	QColor getDefLinkColor();
+	void setDefXLinkColor(QColor);
+	QColor getDefXLinkColor();
+	void setDefXLinkWidth (int);
+	int getDefXLinkWidth();
 	void toggleLinkColorHint();				// after changing linkStyles
     void selectLinkColor();
     void toggleScroll();
     void unScrollAll();
 	void loadFloatImage ();
 	void saveFloatImage (int);
-	void toggleFloatExport();
 	void setFrame(const FrameType &);
+	void setIncludeImagesVer(bool);
+	void setIncludeImagesHor(bool);
+	void setHideLinkUnselected (bool);
+	bool getHideLinkUnselected ();
 private:	
     void importDir(BranchObj *,QDir);
 public:	
     void importDir();
+	void followXLink (int);
+	void editXLink (int);
     void testFunction();				// FIXME just testing
 
 protected:
@@ -139,8 +186,10 @@
     virtual void contentsMouseDoubleClickEvent(QMouseEvent*);
     virtual void contentsMouseMoveEvent(QMouseEvent*);
 
+    virtual void contentsDragEnterEvent(QDragEnterEvent *event);
+    virtual void contentsDropEvent(QDropEvent *event);
 private:
-    QCanvas* mapCanvas;
+    Q3Canvas* mapCanvas;
     MapCenterObj* mapCenter;
 
 	bool adjustCanvasRequested;	// collect requests until end of user event
@@ -148,17 +197,24 @@
     QLineEdit* lineedit;
 
     QColor actColor;			// actual color
-	QColor deflinkcolor;		// default color for links
+	QColor defLinkColor;		// default color for links
+	QColor defXLinkColor;		// default color for xlinks
+	int defXLinkWidth;			// default width for xlinks
 	LinkColorHint linkcolorhint;// use heading color or own color
 	LinkStyle linkstyle;		// default style for links
 
     QCursor handOpenCursor;		// cursor while moving canvas view
 	QCursor pickColorCursor;	// cursor while picking color 
-	bool pickingColor;			// true while picking Color CTRL-LeftButton
+	bool pickingColor;
+	bool drawingLink;			// true while creating a link
+	bool copyingObj;			// true while creating a link
+	XLinkObj* tmpXLink;
 	
     LinkableMapObj* selection;		// select a LinkableMapObj
     LinkableMapObj* selectionLast;	// last selection 
     MapObj* movingObj;				// moving a MapObj
+	MapObj* linkingObj_src;			// part of a link
+    QPoint movingObj_orgPos;		// org. pos of mouse before move
     QPoint movingObj_start;			// rel. pos of mouse to absPos 
     QPoint movingCont_start;		// inital pos of moving Content or
     QPoint movingVec;				// how far has Content moved
@@ -168,14 +224,12 @@
     bool mapDefault;				// Flag if map is untouched
     bool mapChanged;				// Flag if undo is possible
 	bool mapUnsaved;				// Flag if map should be saved
-    QString backupXML;				// backup (XML) for undo
-	LinkableMapObj* undoSelection;	// replace this LMO with vympart from backup
-									// if != NULL
 
 	bool printFrame;			// Print frame around map
 	bool printFooter;			// Print footer below map
 
 	bool zipped;				// should map be zipped
+static	int mapNum;				// unique number for Editor
 	QString fileName;			// short name of file (for tab)
 	QString filePath;			// path to file which will be saved
 	QString fileDir;			// dir where file is saved
@@ -184,14 +238,27 @@
 	QString lastImageDir;		// save dir for adding images
 
 	bool isInteractive;			// non interactive don't need tmpdirs
-	QString bakMapDir;			// tmp directory with data for undo
-	bool blockreposition;		// block while load or undo
+	QString tmpMapDir;			// tmp directory with data for undo/redo
+	int undosTotal;				// total number of undos 
+	int undoNum;				// current number of bakMapDir to be used 
+	int undosAvail;				// how many actions can currently be undone
+	bool blockReposition;		// block while load or undo
+	bool blockSaveState;		// block while load or undo
 
 	BranchObj* itFind;			// next object in find process
 	bool EOFind;				// true, if search failed
 
 	QPoint exportOffset;		// set before export, used in save
+	HideTmpMode hidemode;			// true while exporting to hide some stuff
+	
     void resizeEvent( QResizeEvent * );
+
+  Q3UrlOperator *urlOperator;
+  QDataStream *imageData;
+  QBuffer *imageBuffer;
+
+	ShowTextDialog *historyWindow;
+
 };
 #endif
 
diff -r 9eb7767c2dfa -r 608f976aa7bb mapobj.cpp
--- a/mapobj.cpp	Sun Jan 30 12:58:47 2005 +0000
+++ b/mapobj.cpp	Tue Jun 06 14:58:11 2006 +0000
@@ -1,17 +1,17 @@
 #include "mapobj.h"
+#include "misc.h"
 
 /////////////////////////////////////////////////////////////////
 // MapObj
 /////////////////////////////////////////////////////////////////
 MapObj::MapObj ()
 {
-	// TODO not used any longer...
-	cout << "Const MapObj (): Please set canvas somehow!!!\n";
-    // canvas=actMapEditor->getCanvas();
+	//qWarning ( "Const MapObj (): Please set canvas somehow!!!");
+	canvas=NULL;
     init ();
 }
 
-MapObj::MapObj (QCanvas* c)
+MapObj::MapObj (Q3Canvas* c)
 {
 //  cout << "Const MapObj\n";
     canvas=c;
@@ -45,7 +45,7 @@
 	bbox.setSize (QSize(other->bbox.width(), other->bbox.height() ) );
 }
 
-QCanvas* MapObj::getCanvas()
+Q3Canvas* MapObj::getCanvas()
 {
 	return canvas;
 }
@@ -70,6 +70,16 @@
     return bbox.height();
 }
 
+QPoint MapObj::getAbsPos() 
+{
+    return absPos;
+}
+
+QString MapObj::getPos()
+{
+	return qpointToString(absPos);
+}
+
 void MapObj::move (double x, double y) 
 {
     int xi=static_cast <int> (x);
@@ -77,18 +87,23 @@
     absPos.setX( xi);
     absPos.setY( yi);
     bbox.moveTopLeft(QPoint(xi,yi));
+    clickBox.moveTopLeft(QPoint(xi,yi));
 }
 
 void MapObj::moveBy (double x, double y) 
 {
-    move (x+absPos.x(),y+absPos.y() );
+	int ix=(int)x;
+	int iy=(int)y;
+    MapObj::move (x+absPos.x(),y+absPos.y() );
+	bbox.moveBy (ix,iy);
+	clickBox.moveBy (ix,iy);
 }
 
-bool MapObj::inBBox(QPoint p)
+bool MapObj::inBox(const QPoint &p)
 {
-    if (p.x() >= bbox.left() && p.x() <= bbox.right()  
-	&& p.y() <= bbox.bottom() && p.y() >= bbox.top() )
-	return true;
+    if (p.x() >= clickBox.left() && p.x() <= clickBox.right()  
+	&& p.y() <= clickBox.bottom() && p.y() >= clickBox.top() )
+		return true;
     return false;	
 }
 
@@ -98,7 +113,9 @@
 }
 
 QRect MapObj::addBBox(QRect r1, QRect r2)
-{
+{	
+	// Find smallest QRect containing given rectangles
+
 	QRect n;
 	// Set left border
 	if (r1.left() <= r2.left() )
@@ -141,3 +158,4 @@
 {
     visible=v;
 }
+
diff -r 9eb7767c2dfa -r 608f976aa7bb mapobj.h
--- a/mapobj.h	Sun Jan 30 12:58:47 2005 +0000
+++ b/mapobj.h	Tue Jun 06 14:58:11 2006 +0000
@@ -1,46 +1,51 @@
 #ifndef MAPOBJ_H
 #define MAPOBJ_H
 
-#include <qcanvas.h>
+#include <q3canvas.h>
 #include <iostream>
 
 #include "misc.h"
 
 using namespace std;
 
-#define Z_BBOX     0
-#define Z_LINK    20
-#define Z_FRAME   50
-#define Z_SELBOX  60
-#define Z_ICON    80
-#define Z_TEXT   100
+#define Z_BBOX      0
+#define Z_XLINK    10
+#define Z_LINK     20
+#define Z_FRAME    50
+#define Z_SELBOX   60
+#define Z_FLOATIMG 65
+#define Z_ICON     80
+#define Z_TEXT    100
 
 class MapObj:public xmlObj {
 public:
     MapObj ();
-    MapObj (QCanvas*);
+    MapObj (Q3Canvas*);
     MapObj (MapObj*);
     virtual ~MapObj ();
     virtual void init ();
     virtual void copy (MapObj*);
-	virtual QCanvas* getCanvas();
+	virtual Q3Canvas* getCanvas();
     virtual int x();
     virtual int y();
 	virtual int width();
 	virtual int height();
+	virtual QPoint getAbsPos();
+	virtual QString getPos();					// Return position as string (x,y)
     virtual void move (double x,double y);      // move to absolute Position
     virtual void moveBy (double x,double y);    // move to relative Position
-    virtual bool inBBox(QPoint);				// Check if Point is in bbox
+    virtual bool inBox(const QPoint&);			// Check if Point is within clickbox
     virtual QRect getBBox();					// returns bounding box
     virtual QRect addBBox(QRect,QRect);			// returns bbox which includes both boxes
     virtual QSize getSize();					// returns size of bounding box
     virtual bool isVisibleObj();
     virtual void setVisibility(bool);
-protected:  
-    QCanvas* canvas;
-    QRect bbox;									// bounding box of MO itself
     virtual void positionBBox()=0;       
 	virtual void calcBBoxSize()=0;
+protected:  
+    Q3Canvas* canvas;
+    QRect bbox;									// bounding box of MO itself
+	QRect clickBox;								// area where mouseclicks are found
     QPoint absPos;							    // Position on canvas
     bool visible;
 };
diff -r 9eb7767c2dfa -r 608f976aa7bb misc.cpp
--- a/misc.cpp	Sun Jan 30 12:58:47 2005 +0000
+++ b/misc.cpp	Tue Jun 06 14:58:11 2006 +0000
@@ -1,14 +1,20 @@
+#include <math.h>
+
 #include <qregexp.h>
 #include <qpoint.h>
-
-#include <math.h>
+#include <stdlib.h>
 
 #include "misc.h"
 
+QString qpointToString (const QPoint &p)
+{
+	return "(" + QString("%1").arg(p.x()) +","+ QString ("%1").arg (p.y()) +")";
+}
 
 ostream &operator<< (ostream &stream, QPoint const &p)
 { 
-    return (stream << "(" << p.x() << "," << p.y() << ")");
+	stream << "("<<p.x()<<","<<p.y()<<")";
+	return stream;
 }
 
 float getAngle(const QPoint &p)
@@ -65,49 +71,6 @@
 	return QPoint ((int) (x),(int) (y));
 }
 
-QString maskPath(QString p)
-{
-	// Change " " to "\ " to enable blanks in filenames
-	p=p.replace(QChar('&'),"\\&");
-	return p.replace(QChar(' '),"\\ ");
-}
-
-QString convertToRel (const QString &src, const QString &dst)
-{
-	QString s=src;
-	QString d=dst;
-	int i;
-	// Find relative path from src to dst
-
-	// Remove the first "/"
-	if (s.section ("/",0,0).isEmpty()) 
-	{
-		s=s.right (s.length()-1);
-		d=d.right (d.length()-1);
-	}
-	
-	// remove identical left parts
-	while (s.section("/",0,0) == d.section("/",0,0) ) 
-	{
-		i=s.find ("/");
-		s=s.right (s.length()-i-1);
-		d=d.right (d.length()-i-1);
-	}
-
-	int srcsep=s.contains("/");
-	int dstsep=d.contains("/");
-	if (srcsep >=  dstsep )
-	{
-		// find path to go up first and then back to dst
-		i=1;
-		while (i<=srcsep) 
-		{
-			d="../"+d;
-			i++;
-		}	
-	}
-	return d;
-}
 
 // returns masked "<" ">" "&"
 QString quotemeta(const QString &s)
@@ -203,36 +166,3 @@
     return s;
 }	
 
-
-
-ImagePreview::ImagePreview (QWidget *parent=0): QLabel (parent)
-{
-}
-
-void ImagePreview::previewUrl( const QUrl &u )
-{
-    QString path = u.path();
-    QPixmap pix( path );
-    if ( pix.isNull() )
-        setText( QObject::tr("This is not an image.") );
-    else
-	{
-		float max_w=300;
-		float max_h=300;
-		float r;
-		if (pix.width()>max_w)
-		{
-			r=max_w / pix.width();
-			pix.resize(lrint(pix.width()*r), lrint(pix.height()*r));
-			// TODO not a resize, but a shrink/enlarge is needed here...
-		}
-		if (pix.height()>max_h)
-		{
-			r=max_h / pix.height();
-			pix.resize(lrint(pix.width()*r), lrint(pix.height()*r));
-			// TODO not a resize, but a shrink/enlarge is needed here...
-		}
-        setPixmap( pix );
-	}	
-}
-
diff -r 9eb7767c2dfa -r 608f976aa7bb options.cpp
--- a/options.cpp	Sun Jan 30 12:58:47 2005 +0000
+++ b/options.cpp	Tue Jun 06 14:58:11 2006 +0000
@@ -86,7 +86,7 @@
 			}
 			if (isFile)
 			{
-				cout << "Error: Unknown argument "<<*itarg<<endl;
+				qWarning("Error: Unknown argument ");
 				return 1;
 			}
 		} else
diff -r 9eb7767c2dfa -r 608f976aa7bb options.h
--- a/options.h	Sun Jan 30 12:58:47 2005 +0000
+++ b/options.h	Tue Jun 06 14:58:11 2006 +0000
@@ -3,6 +3,8 @@
 
 #include <qstring.h>
 #include <qstringlist.h>
+//Added by qt3to4:
+#include <Q3ValueList>
 
 enum OptionType  {SwitchOption,StringOption};
 
@@ -30,7 +32,7 @@
 
 
 
-typedef QValueList <Option> OptionList;
+typedef Q3ValueList <Option> OptionList;
 
 class Options
 {
diff -r 9eb7767c2dfa -r 608f976aa7bb ornamentedobj.cpp
--- a/ornamentedobj.cpp	Sun Jan 30 12:58:47 2005 +0000
+++ b/ornamentedobj.cpp	Tue Jun 06 14:58:11 2006 +0000
@@ -18,7 +18,7 @@
     init ();
 }
 
-OrnamentedObj::OrnamentedObj(QCanvas* c) :LinkableMapObj(c)
+OrnamentedObj::OrnamentedObj(Q3Canvas* c) :LinkableMapObj(c)
 {
 //    cout << "Const OrnamentedObj\n";
     init ();
@@ -54,20 +54,29 @@
 	standardFlags->clone(standardFlagsDefault);
 	standardFlags->setName ("standardFlags");
 
+	hideExport=false;
+	hidden=false;
 
-
+	url="";
+	vymLink="";
+	
 }
 
 void OrnamentedObj::copy (OrnamentedObj* other)
 {
     LinkableMapObj::copy(other);
 	heading->copy(other->heading);
-    setColor   (other->heading->getColor(),false);	
+    setColor   (other->heading->getColor());	
 
 	note.copy (other->note);
 	systemFlags->copy (other->systemFlags);
 	standardFlags->copy (other->standardFlags);
 
+	ornamentsBBox=other->ornamentsBBox;
+
+	hideExport=other->hideExport;
+	url=other->url;
+	vymLink=other->vymLink;
 }
 
 QString OrnamentedObj::getHeading()
@@ -83,27 +92,45 @@
 		LinkableMapObj::setLinkColor (mapEditor->getDefLinkColor());
 }
 
+void OrnamentedObj::setColor (QColor col)
+{
+    heading->setColor(col);
+	setLinkColor();
+}
+
 QColor OrnamentedObj::getColor ()
 {
     return heading->getColor();
 }
 
 
+void OrnamentedObj::positionContents()
+{
+	double d=frame->getBorder()/2;
+	double x=absPos.x();
+	double y=absPos.y();
+
+	double ox,oy;	// Offset due to padding
+
+	ox=leftPad + d;
+	oy=topPad + d;
+	
+	systemFlags-> move (ox +x , oy + y );
+
+	// vertical align heading to bottom
+    heading->move (ox + x + systemFlags->getBBox().width(),
+				   oy + y + ornamentsBBox.height() - heading->getHeight() 
+					);
+	standardFlags->move (ox +x + heading->getWidth() + systemFlags->getBBox().width() , oy + y );
+
+	ornamentsBBox.moveTopLeft ( QPoint ((int)(ox+x),(int)(oy+y)));
+	clickBox.moveTopLeft (QPoint ((int)(ox + x), (int)(oy + y)));
+}
+
 void OrnamentedObj::move (double x, double y)
 {
 	MapObj::move (x,y);
-	double dx=frame->getBorder()/2;  // care for border around object
-	double dy=frame->getBorder()/2;
-	systemFlags-> move (x + dx, y + dy);
-
-	// vertical align heading to bottom
-	int h=max (systemFlags->getBBox().height(), standardFlags->getBBox().height());
-	h=max (h,heading->getHeight());
-    heading->move (x + dx + systemFlags->getBBox().width(),
-					y + dy  + h - heading->getHeight() 
-					);
-	standardFlags->move (x + heading->getWidth() + systemFlags->getBBox().width(), y + dy );				
-
+	positionContents();
 	updateLink();
 	requestReposition();
 }
@@ -138,8 +165,7 @@
 
 void OrnamentedObj::move2RelPos(QPoint p)
 {
-	if (!parObj) return;
-	move (parObj->getChildPos().x() + p.x(), parObj->getChildPos().y() + p.y() );
+	move2RelPos (p.x(),p.y());
 }
 
 void OrnamentedObj::setNote(QString s)
@@ -174,9 +200,72 @@
     return note.getNote();
 }
 
-void OrnamentedObj::toggleStandardFlag(QString f)
+QString OrnamentedObj::getNoteASCII()
 {
-	standardFlags->toggle(f);
+    return note.getNoteASCII();
+}
+
+QString OrnamentedObj::getNoteOpenDoc()
+{
+    return note.getNoteOpenDoc();
+}
+
+void OrnamentedObj::setURL(QString s)
+{
+	url=s;
+	if (!url.isEmpty())
+		systemFlags->activate("url");
+	else	
+		systemFlags->deactivate("url");
+	calcBBoxSize();			// recalculate bbox
+    positionBBox();			// rearrange contents
+	forceReposition();
+}
+
+QString OrnamentedObj::getURL()
+{
+	return url;
+}
+
+void OrnamentedObj::setVymLink(QString s)
+{
+	if (!s.isEmpty())
+	{
+		// We need the relative (from loading) 
+		// or absolute path (from User event)
+		// and build the absolute path.
+		// Note: If we have relative, use path of
+		// current map to build absolute path
+		QDir d(s);
+		if (!d.path().startsWith ("/"))
+		{
+			QString p=mapEditor->getDestPath();
+			int i=p.findRev("/",-1);
+			d.setPath(p.left(i)+"/"+s);
+			d.convertToAbs();
+		}
+		vymLink=d.path();
+		systemFlags->activate("vymLink");
+	}	
+	else	
+	{
+		systemFlags->deactivate("vymLink");
+		vymLink="";
+	}	
+	calcBBoxSize();			// recalculate bbox
+    positionBBox();			// rearrange contents
+	forceReposition();
+}
+
+QString OrnamentedObj::getVymLink()
+{
+	return vymLink;
+}
+
+
+void OrnamentedObj::toggleStandardFlag(QString f, bool exclusive)
+{
+	standardFlags->toggle(f,exclusive);
 	calcBBoxSize();
 	positionBBox();
 	move (absPos.x(), absPos.y() );
@@ -192,20 +281,93 @@
 	forceReposition();
 }
 
+bool OrnamentedObj::isSetStandardFlag (QString f)
+{
+	return standardFlags->isActive(f);
+}
+
 QString OrnamentedObj::getSystemFlagName(const QPoint &p)
 {
 	return systemFlags->getFlagName(p);	
 }
 
+bool OrnamentedObj::isActiveFlag (const QString & fname)
+{
+	if (standardFlags->isActive (fname) ) return true;
+	return false;
+}
+
 void OrnamentedObj::updateNoteFlag()
 {
-	// text in NoteEditor has changed, notify MapEditor 
-	mapEditor->setChanged();
+	if (selected) 
+	{
+		// text in NoteEditor has changed, notify MapEditor 
+		mapEditor->setChanged();
 
-	// save text
-	setNote( textEditor->getText() );
+		// save text
+		setNote( textEditor->getText() );
 	
-	// save font   
-	note.setFontHint (textEditor->getFontHint() );
+		// save font   
+		note.setFontHint (textEditor->getFontHint() );
+	}	
 }
 
+void OrnamentedObj::setHideInExport(bool b)
+{
+	if (parObj)
+	{
+		// Don't allow to MapCenter to be hidden
+		hideExport=b;
+		if (b)
+			systemFlags->activate("hideInExport");
+		else	
+			systemFlags->deactivate("hideInExport");
+		calcBBoxSize();
+		positionBBox();
+		requestReposition();	
+	}
+}	
+
+bool OrnamentedObj::hideInExport()
+{
+	return hideExport;
+}	
+
+bool OrnamentedObj::isHidden()
+{
+	return hidden;
+}	
+
+QString OrnamentedObj::getOrnAttr()
+{
+	QString posAttr;
+
+	if (useRelPos)
+		posAttr=attribut("relPosX",QString().setNum(relPos.x(),10)) +
+                attribut("relPosY",QString().setNum(relPos.y(),10)); 
+	else
+	{
+		if (depth==0 || depth==1) posAttr=
+			attribut("absPosX",QString().setNum(absPos.x(),10)) +
+			attribut("absPosY",QString().setNum(absPos.y(),10)); 
+		else
+			posAttr="";
+	}	
+
+	QString urlAttr;
+	if (!url.isEmpty())
+		urlAttr=attribut ("url",url);
+
+	QString vymLinkAttr;
+	if (!vymLink.isEmpty())
+		vymLinkAttr=attribut ("vymLink",convertToRel(mapEditor->getDestPath(),vymLink) );
+
+	QString hideExpAttr;
+	if (hideExport)
+		hideExpAttr= attribut("hideInExport","true");
+	else	
+		hideExpAttr="";
+
+	return posAttr +urlAttr +vymLinkAttr +getLinkAttr() +hideExpAttr;
+}
+
diff -r 9eb7767c2dfa -r 608f976aa7bb ornamentedobj.h
--- a/ornamentedobj.h	Sun Jan 30 12:58:47 2005 +0000
+++ b/ornamentedobj.h	Tue Jun 06 14:58:11 2006 +0000
@@ -4,23 +4,19 @@
 #include "linkablemapobj.h"
 
 class OrnamentedObj:public LinkableMapObj {
-	Q_OBJECT
 public:	
     OrnamentedObj ();
-    OrnamentedObj (QCanvas*);
+    OrnamentedObj (Q3Canvas*);
     OrnamentedObj (OrnamentedObj*);
     ~OrnamentedObj ();
     virtual void init ();
     virtual void copy (OrnamentedObj*);
 
-    virtual void setHeading (QString s)=0;  // set the heading, pure virtual 
-											// to take care of fontsize
     virtual QString getHeading();			// returns the heading	
 	virtual void setLinkColor();			// sets color according to colorhint, overloaded
-    virtual void setVisibility(bool,int)=0;	// set visibility
-    virtual void setVisibility(bool)=0;	    // set vis. for w
-	virtual void setColor(QColor,bool)=0;		// set the color of text and link
+	virtual void setColor(QColor);			// set the color of text and link
 	QColor getColor ();						// get color of heading
+    virtual void positionContents();
     virtual void move   (double,double);
     virtual void move   (QPoint);
     virtual void moveBy (double,double);
@@ -29,19 +25,35 @@
     virtual void move2RelPos (double,double);
     virtual void setNote(QString);			// set note
     virtual void setNote(NoteObj);			// set note
-    virtual QString getNote();				// returns note	
-	virtual void toggleStandardFlag(QString);
+    virtual QString getNote();				// returns note	(HTML)
+    virtual QString getNoteASCII();			// returns note	(ASCII)
+    virtual QString getNoteOpenDoc();		// returns note	(OpenDoc)
+    virtual void setURL (QString);
+    virtual QString getURL ();
+    virtual void setVymLink (QString);
+    virtual QString getVymLink ();
+
+	virtual void toggleStandardFlag(QString, bool);
 	virtual void activateStandardFlag(QString);
+	virtual bool isSetStandardFlag(QString);
 	virtual QString getSystemFlagName (const QPoint &p);
-
-public slots:
-	void updateNoteFlag();
+	virtual bool isActiveFlag(const QString&);	// check if flag is set
+	virtual void updateNoteFlag();
+	virtual void setHideInExport(bool);		// set export of object (and childs)
+	virtual bool hideInExport();
+	virtual bool isHidden ();
+	virtual QString getOrnAttr();			// get attributes for saveToDir
 
 protected:
     HeadingObj *heading;			// Heading
 	NoteObj note;					// Notes
 	FlagRowObj *systemFlags;		// System Flags
 	FlagRowObj *standardFlags;		// Standard Flags
+	QRect ornamentsBBox;			// bbox of flags and heading
+	QString url;					// url to external doc
+	QString vymLink;				// path to another map
+	bool hideExport;				// hide in exports if set
+	bool hidden;					// true if temporary hidden
 };
 
 #endif
diff -r 9eb7767c2dfa -r 608f976aa7bb process.h
--- a/process.h	Sun Jan 30 12:58:47 2005 +0000
+++ b/process.h	Tue Jun 06 14:58:11 2006 +0000
@@ -1,13 +1,13 @@
 #ifndef PROCESS_H
 #define PROCESS_H
 
-#include <qprocess.h>
+#include <q3process.h>
 #include <qstring.h>
 
 
 using namespace std;
 
-class Process:public QProcess
+class Process:public Q3Process
 {
 	Q_OBJECT
 public:
diff -r 9eb7767c2dfa -r 608f976aa7bb selection.h
--- a/selection.h	Sun Jan 30 12:58:47 2005 +0000
+++ b/selection.h	Tue Jun 06 14:58:11 2006 +0000
@@ -2,7 +2,7 @@
 #define SELECTIONOBJ_H
 
 #include "linkablemapobj.h"
-#include <qptrlist.h>
+#include <q3ptrlist.h>
 
 class Selection 
 {
@@ -20,7 +20,7 @@
 	uint count();
 
 private:
-	QPtrList <LinkableMapObj> selectList;
+	Q3PtrList <LinkableMapObj> selectList;
 };
 #endif
 
diff -r 9eb7767c2dfa -r 608f976aa7bb texteditor.cpp
--- a/texteditor.cpp	Sun Jan 30 12:58:47 2005 +0000
+++ b/texteditor.cpp	Tue Jun 06 14:58:11 2006 +0000
@@ -1,6 +1,6 @@
 #include "texteditor.h"
 
-#include <qcanvas.h>
+#include <q3canvas.h>
 #include <qstatusbar.h>
 #include <qmessagebox.h>
 #include <qaction.h>
@@ -8,68 +8,65 @@
 #include <qpainter.h>
 #include <qprinter.h>
 #include <qfile.h>
-#include <qfiledialog.h>
-#include <qtoolbar.h>
-#include <qpopupmenu.h>
+#include <q3filedialog.h>
+#include <q3toolbar.h>
+#include <q3popupmenu.h>
 #include <qmenubar.h>
-#include <qtextedit.h>
-#include <qaccel.h>
+#include <q3textedit.h>
+#include <q3accel.h>
 #include <qtextstream.h>
-#include <qpaintdevicemetrics.h>
+#include <q3paintdevicemetrics.h>
 #include <qsettings.h>
 #include <qfontdialog.h>
 #include <qmessagebox.h>
 #include <qcolordialog.h>
 #include <qregexp.h>
 #include <qlineedit.h>
-#include <qsimplerichtext.h>
+#include <q3simplerichtext.h>
+//Added by qt3to4:
+#include <Q3ValueList>
+#include <QPixmap>
+#include <Q3ActionGroup>
+#include <QCloseEvent>
 
 #include <iostream>
-#include <stdlib.h>
+#include <cstdlib>
 #include <typeinfo>
 
-#include "icons/fileopen.xpm"
-#include "icons/filesave.xpm"
-#include "icons/fileprint.xpm"
-#include "icons/editundo.xpm"	
-#include "icons/editredo.xpm"	
-#include "icons/editcopy.xpm"
-#include "icons/editcut.xpm"
-#include "icons/editpaste.xpm"
-#include "icons/edittrash.xpm"
-#include "icons/formatfixedfont.xpm"
-#include "icons/formattextbold.xpm"
-#include "icons/formattextitalic.xpm"
-#include "icons/formattextunder.xpm"
-#include "icons/formattextleft.xpm"
-#include "icons/formattextcenter.xpm"
-#include "icons/formattextright.xpm"
-#include "icons/formattextjustify.xpm"
+#include "noteobj.h"
+#include "version.h"
 
-extern QCanvas* actCanvas;
+extern Q3Canvas* actCanvas;
 extern int statusbarTime;
 extern QSettings settings;
 
+extern QAction *actionViewToggleNoteEditor;
+
+extern QString iconPath;
+
 using namespace std;
 
 
 ///////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////
 
+
 TextEditor::TextEditor()
 {
     printer = new QPrinter( QPrinter::HighResolution );
+	printer->setPrinterName (settings.readEntry("/vym/mainwindow/printerName",printer->printerName()));
 
-	// Editor
-    e = new QTextEdit( this, "editor" );
+	// Editor (use MyTextEdit to wrap verticalAlignmentChanged to 
+	//         int argument. see header file)
+    e = new MyTextEdit( this, "editor" );
     e->setFocus();
-	e->setTextFormat(RichText);		// default
+	e->setTextFormat(Qt::RichText);		// default
 	e->setTabStopWidth (20);		// unit is pixel
-	e->setColor (black);
+	e->setColor (Qt::black);
 	connect (e, SIGNAL( textChanged() ), this, SLOT( editorChanged() ) );
     setCentralWidget( e );
     statusBar()->message( "Ready", statusbarTime);
-	setCaption("VYM - Note Editor");
+	setCaption(__VYM " - " +tr ("Note Editor"));
 
 	// Toolbars
 	setupFileActions();
@@ -78,9 +75,9 @@
 	setupSettingsActions();
 	
 	// Various states
-	emptyPaper   = QBrush(gray);
-	filledPaper  = QBrush(white);
-	inactivePaper= QBrush(black);
+	emptyPaper   = QBrush(Qt::gray);
+	filledPaper  = QBrush(Qt::white);
+	inactivePaper= QBrush(Qt::black);
 	setInactive();
 
 	// Load Settings
@@ -112,6 +109,10 @@
 		actionSettingsFonthintDefault->setOn (false);
 		e->setCurrentFont (varFont);
 	}	
+	filenameHint="";
+
+	// Save settings in vymrc
+	settings.writeEntry("/vym/mainwindow/printerName",printer->printerName());
 }
 
 
@@ -204,6 +205,16 @@
 	return filename;
 }
 
+void TextEditor::setFilenameHint(const QString &fnh)
+{
+	filenameHint=fnh;
+}
+
+QString TextEditor::getFilenameHint()
+{
+	return filenameHint;
+}
+
 bool TextEditor::findText(const QString &t, const bool &cs)
 {
 	bool wo=false;	// word matches
@@ -215,13 +226,15 @@
 
 void TextEditor::setupFileActions()
 {
-    QToolBar *tb = new QToolBar( this );
+    Q3ToolBar *tb = new Q3ToolBar( this );
     tb->setLabel( "File Actions" );
-    QPopupMenu *menu = new QPopupMenu( this );
+    Q3PopupMenu *menu = new Q3PopupMenu( this );
     menuBar()->insertItem( tr( "&File" ), menu );
 
     QAction *a;
-    a = new QAction( tr( "Import" ), QPixmap( fileopen_xpm), tr( "&Import..." ), CTRL + Key_O, this, "fileImport" );
+    a = new QAction( QPixmap( iconPath+"fileopen.png"), tr( "&Import..." ),this);
+	a->setStatusTip (tr( "Import" ) );
+	a->setShortcut( Qt::CTRL + Qt::Key_O );
     connect( a, SIGNAL( activated() ), this, SLOT( textLoad() ) );
 	a->setEnabled(false);
     a->addTo( tb );
@@ -229,24 +242,31 @@
 	actionFileLoad=a;
 
     menu->insertSeparator();
-    a = new QAction( tr( "Export Note (HTML)" ), QPixmap( filesave_xpm ), tr( "&Export..." ), CTRL + Key_S, this, "fileSave" );
+    a = new QAction( QPixmap(iconPath+"filesave.png" ), tr( "&Export..." ),this);
+	a->setStatusTip (tr( "Export Note (HTML)" ) );
+	a->setShortcut( Qt::CTRL + Qt::Key_S );
     connect( a, SIGNAL( activated() ), this, SLOT( textSave() ) );
     a->addTo( tb );
     a->addTo( menu );
 	actionFileSave=a;
 	
-    a = new QAction( tr( "Export Note As (HTML) " ), QPixmap(), tr( "Export &As... (HTML)" ), 0, this, "exportHTML" );
+    a = new QAction(  QPixmap(), tr( "Export &As... (HTML)" ), this);
+	a->setStatusTip (tr( "Export Note As (HTML) " ));
     connect( a, SIGNAL( activated() ), this, SLOT( textSaveAs() ) );
     a->addTo( menu );
 	actionFileSaveAs=a;
 
-    a = new QAction( tr( "Export Note As (ASCII) " ), QPixmap(), tr( "Export &As...(ASCII)" ), ALT + Key_X, this, "exportASCII" );
+    a = new QAction(QPixmap(), tr( "Export &As...(ASCII)" ), this);
+	a->setStatusTip ( tr( "Export Note As (ASCII) " ) );
+	a->setShortcut(Qt::ALT + Qt::Key_X );
     connect( a, SIGNAL( activated() ), this, SLOT( textExportAsASCII() ) );
     a->addTo( menu );
 	actionFileSaveAs=a;
 
     menu->insertSeparator();
-    a = new QAction( tr( "Print Note" ), QPixmap( fileprint_xpm ), tr( "&Print..." ), CTRL + Key_P, this, "filePrint" );
+    a = new QAction( QPixmap(iconPath+"fileprint.png" ), tr( "&Print..." ),this);
+	a->setStatusTip (tr( "Print Note" ) );
+	a->setShortcut( Qt::CTRL + Qt::Key_P );
     connect( a, SIGNAL( activated() ), this, SLOT( textPrint() ) );
     a->addTo( tb );
     a->addTo( menu );
@@ -255,60 +275,77 @@
 
 void TextEditor::setupEditActions()
 {
-    QToolBar *tb = new QToolBar( this );
+    Q3ToolBar *tb = new Q3ToolBar( this );
     tb->setLabel( "Edit Actions" );
-    QPopupMenu *menu = new QPopupMenu( this );
+    Q3PopupMenu *menu = new Q3PopupMenu( this );
     menuBar()->insertItem( tr( "&Edit" ), menu );
 
     QAction *a;
-    a = new QAction( tr( "Undo" ), QPixmap(editundo_xpm), tr( "&Undo" ), CTRL + Key_Z, this, "undoEvent" );
+    a = new QAction(QPixmap(iconPath+"undo.png"), tr( "&Undo" ), this );
+	a->setStatusTip ( tr( "Undo" ) );
+	a->setShortcut(Qt::CTRL + Qt::Key_Z );
     connect( a, SIGNAL( activated() ), e, SLOT( undo() ) );
     a->addTo( menu );
     a->addTo( tb);
 	actionEditUndo=a;
 	
-    a = new QAction( tr( "Redo" ), QPixmap( editredo_xpm ), tr( "&Redo" ), CTRL + Key_Y, this, "editRedo" ); 
+    a = new QAction(QPixmap(iconPath+"redo.png" ), tr( "&Redo" ),this); 
+	a->setStatusTip ( tr( "Redo" ) );
+	a->setShortcut( Qt::CTRL + Qt::Key_Y );
     connect( a, SIGNAL( activated() ), e, SLOT( redo() ) );
     a->addTo( tb );
     a->addTo( menu );
 	actionEditRedo=a;
 
     menu->insertSeparator();
-    a = new QAction( tr( "Select and copy all" ), QPixmap(), tr( "Select and copy &all" ), CTRL + Key_A, this, "editcopyall" ); 
+    a = new QAction(QPixmap(), tr( "Select and copy &all" ),this); 
+	a->setStatusTip ( tr( "Select and copy all" ) );
+	a->setShortcut( Qt::CTRL + Qt::Key_A );
     connect( a, SIGNAL( activated() ), this, SLOT( editCopyAll() ) );
     a->addTo( menu );
 
     menu->insertSeparator();
-    a = new QAction( tr( "Copy" ), QPixmap( editcopy_xpm ), tr( "&Copy" ), CTRL + Key_C, this, "editCopy" );
+    a = new QAction(QPixmap(iconPath+"editcopy.png" ), tr( "&Copy" ),this);
+	a->setStatusTip ( tr( "Copy" ) );
+	a->setShortcut( Qt::CTRL + Qt::Key_C );
     connect( a, SIGNAL( activated() ), e, SLOT( copy() ) );
     a->addTo( tb );
     a->addTo( menu );
 	actionEditCopy=a;
 	
-    a = new QAction( tr( "Cut" ), QPixmap( editcut_xpm ), tr( "Cu&t" ), CTRL + Key_X, this, "editCut" );
+    a = new QAction(QPixmap(iconPath+"editcut.png" ), tr( "Cu&t" ),this);
+	a->setStatusTip ( tr( "Cut" ) );
+	a->setShortcut( Qt::CTRL + Qt::Key_X );
     connect( a, SIGNAL( activated() ), e, SLOT( cut() ) );
     a->addTo( tb );
     a->addTo( menu );
 	actionEditCut=a;
 
-    a = new QAction( tr( "Paste" ), QPixmap( editpaste_xpm ), tr( "&Paste" ), CTRL + Key_V, this, "editPaste" );
+    a = new QAction(QPixmap(iconPath+"editpaste.png" ), tr( "&Paste" ),this);
+	a->setStatusTip ( tr( "Paste" ) );
+	a->setShortcut( Qt::CTRL + Qt::Key_V );
     connect( a, SIGNAL( activated() ), e, SLOT( paste() ) );
     a->addTo( tb );
     a->addTo( menu );
 	actionEditPaste=a;
 	
-    a = new QAction( tr( "Delete all" ), QPixmap( edittrash_xpm ), tr( "&Delete All" ), 0, this, "editDeleteAll" );
+    a = new QAction( QPixmap( iconPath+"edittrash.png"), tr( "&Delete All" ), this);
+	a->setStatusTip (tr( "Delete all" ) );
     connect( a, SIGNAL( activated() ), e, SLOT( clear() ) );
     a->addTo( tb );
     a->addTo( menu );
 	actionEditDeleteAll=a;
 
-	a = new QAction( tr( "Convert paragraphs to linebreaks" ), QPixmap(), tr( "&Convert Paragraphs" ), ALT + Key_P, this, "editConvertPar" );
+	a = new QAction(QPixmap(), tr( "&Convert Paragraphs" ),this);
+	a->setStatusTip(tr( "Convert paragraphs to linebreaks" )); 
+	a->setShortcut( Qt::ALT + Qt::Key_P );
     connect( a, SIGNAL( activated() ), this, SLOT( textConvertPar() ) );
     a->addTo( menu );
 	actionEditConvertPar=a;
 
-	a = new QAction( tr( "Join all lines of a paragraph" ), QPixmap(), tr( "&Join lines" ), ALT + Key_J, this, "editJoinLines" );
+	a = new QAction( QPixmap(), tr( "&Join lines" ), this);
+	a->setStatusTip(tr( "Join all lines of a paragraph" ) ); 
+	a->setShortcut(Qt::ALT + Qt::Key_J );
     connect( a, SIGNAL( activated() ), this, SLOT( textJoinLines() ) );
     a->addTo( menu );
 	actionEditJoinLines=a;
@@ -316,14 +353,15 @@
 
 void TextEditor::setupFormatActions()
 {
-    QToolBar *tb = new QToolBar( this );
+    Q3ToolBar *tb = new Q3ToolBar( this );
     tb->setLabel( "Format Actions" );
-    QPopupMenu *menu = new QPopupMenu( this );
-    menuBar()->insertItem( tr( "&Format" ), menu );
+    Q3PopupMenu *menu = new Q3PopupMenu( this );
+    menuBar()->insertItem( tr( "F&ormat" ), menu );
 
     QAction *a;
 
-    a = new QAction( tr( "Toggle font hint for the whole text" ), QPixmap(formatfixedfont_xpm), tr( "&Font hint" ), ALT + Key_I, this, "fontHint" );
+    a = new QAction( QPixmap(iconPath+"formatfixedfont.png"), tr( "&Font hint" ), Qt::ALT + Qt::Key_I, this, "fontHint" );
+	a->setStatusTip (tr( "Toggle font hint for the whole text" ) );
 	a->setToggleAction (true);
 	a->setOn (settings.readBoolEntry ("/vym/noteeditor/fonts/useFixedByDefault",false) );
     connect( a, SIGNAL( activated() ), this, SLOT( toggleFonthint() ) );
@@ -341,8 +379,8 @@
     comboFont->lineEdit()->setText( QApplication::font().family() );
 
     comboSize = new QComboBox( true, tb );
-    QValueList<int> sizes = db.standardSizes();
-    QValueList<int>::Iterator it = sizes.begin();
+    Q3ValueList<int> sizes = db.standardSizes();
+    Q3ValueList<int>::Iterator it = sizes.begin();
     for ( ; it != sizes.end(); ++it )
 	comboSize->insertItem( QString::number( *it ) );
     connect( comboSize, SIGNAL( activated( const QString & ) ),
@@ -353,69 +391,98 @@
 
     QPixmap pix( 16, 16 );
     pix.fill( e->color());
-    actionTextColor = new QAction( pix, tr( "&Color..." ), 0, this, "textColor" );
-    connect( actionTextColor, SIGNAL( activated() ), this, SLOT( textColor() ) );
+    actionTextColor = new QAction( pix, tr( "&Color..." ), this);
     actionTextColor->addTo( tb );
     actionTextColor->addTo( menu );
+    connect( actionTextColor, SIGNAL( activated() ), this, SLOT( textColor() ) );
 
-    actionTextBold = new QAction( QPixmap (formattextbold_xpm), tr( "&Bold" ), CTRL + Key_B, this, "textBold" );
+    actionTextBold = new QAction( QPixmap (iconPath+"text_bold.png"), tr( "&Bold" ), this);
+	actionTextBold->setShortcut(Qt::CTRL + Qt::Key_B );
     connect( actionTextBold, SIGNAL( activated() ), this, SLOT( textBold() ) );
     actionTextBold->addTo( tb );
     actionTextBold->addTo( menu );
     actionTextBold->setToggleAction( true );
-    actionTextItalic = new QAction( QPixmap(formattextitalic_xpm ), tr( "&Italic" ), CTRL + Key_I, this, "textItalic" );
+    actionTextItalic = new QAction( QPixmap(iconPath+"text_italic.png"), tr( "&Italic" ),  this);
+	actionTextItalic->setShortcut(Qt::CTRL + Qt::Key_I);
     connect( actionTextItalic, SIGNAL( activated() ), this, SLOT( textItalic() ) );
     actionTextItalic->addTo( tb );
     actionTextItalic->addTo( menu );
     actionTextItalic->setToggleAction( true );
-    actionTextUnderline = new QAction( QPixmap (formattextunder_xpm ), tr( "&Underline" ), CTRL + Key_U, this, "textUnderline" );
+    actionTextUnderline = new QAction( QPixmap (iconPath+"text_under.png"), tr( "&Underline" ), this);
+	actionTextUnderline->setShortcut(Qt::CTRL + Qt::Key_U );
     connect( actionTextUnderline, SIGNAL( activated() ), this, SLOT( textUnderline() ) );
     actionTextUnderline->addTo( tb );
     actionTextUnderline->addTo( menu );
     actionTextUnderline->setToggleAction( true );
     menu->insertSeparator();
 
-    QActionGroup *grp = new QActionGroup( this );
+    Q3ActionGroup *grp = new Q3ActionGroup( this );
     connect( grp, SIGNAL( selected( QAction* ) ), this, SLOT( textAlign( QAction* ) ) );
 
-    actionAlignLeft = new QAction( QPixmap (formattextleft_xpm ), tr( "&Left" ), CTRL + Key_L, grp, "textLeft" );
+    actionAlignLeft = new QAction( QPixmap (iconPath+"text_left.png"), tr( "&Left" ),grp );
+	actionAlignLeft->setShortcut( Qt::CTRL+Qt::Key_L );
     actionAlignLeft->setToggleAction( true );
-    actionAlignCenter = new QAction( QPixmap (formattextcenter_xpm ), tr( "C&enter" ), CTRL + Key_E, grp, "textCenter" );
+    actionAlignCenter = new QAction( QPixmap (iconPath+"text_center.png"), tr( "C&enter" ),grp);
+    actionAlignCenter->setShortcut(  Qt::CTRL + Qt::Key_E);
     actionAlignCenter->setToggleAction( true );
-    actionAlignRight = new QAction( QPixmap (formattextright_xpm ), tr( "&Right" ), CTRL + Key_R, grp, "textRight" );
+    actionAlignRight = new QAction( QPixmap (iconPath+"text_right.png" ), tr( "&Right" ), grp);
+	actionAlignRight->setShortcut(Qt::CTRL + Qt::Key_R );
     actionAlignRight->setToggleAction( true );
-    actionAlignJustify = new QAction( QPixmap ( formattextjustify_xpm ), tr( "&Justify" ), CTRL + Key_J, grp, "textjustify" );
+    actionAlignJustify = new QAction( QPixmap ( iconPath+"text_block.png"), tr( "&Justify" ), grp );
+	actionAlignJustify->setShortcut(Qt::CTRL + Qt::Key_J );
     actionAlignJustify->setToggleAction( true );
 
     grp->addTo( tb );
     grp->addTo( menu );
 
+    Q3ActionGroup *grp2 = new Q3ActionGroup( this );
+    grp2->setExclusive(false);
+    actionAlignSubScript = new QAction( QPixmap (iconPath+"text_sub.png"), tr( "Subs&cript" ),grp2 );
+	actionAlignSubScript->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_B );
+    actionAlignSubScript->setToggleAction( true );
+    connect(actionAlignSubScript, SIGNAL(activated()), this, SLOT(textVAlign()));
+
+    actionAlignSuperScript = new QAction( QPixmap (iconPath+"text_super.png"), tr( "Su&perscript" ),grp2  );
+	actionAlignSuperScript->setShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_P );
+    actionAlignSuperScript->setToggleAction( true );
+    connect(actionAlignSuperScript, SIGNAL(activated()), this, SLOT(textVAlign()));
+
+    menu->insertSeparator();
+    
+    grp2->addTo(tb);
+    grp2->addTo(menu);
+
     connect( e, SIGNAL( currentFontChanged( const QFont & ) ),
 	     this, SLOT( fontChanged( const QFont & ) ) );
     connect( e, SIGNAL( currentColorChanged( const QColor & ) ),
 	     this, SLOT( colorChanged( const QColor & ) ) );
     connect( e, SIGNAL( currentAlignmentChanged( int ) ),
 	     this, SLOT( alignmentChanged( int ) ) );
+    connect( e, SIGNAL( currentVerticalAlignmentChanged(int)),
+	     this, SLOT( verticalAlignmentChanged(int)));
 
 }
 
 void TextEditor::setupSettingsActions()
 {
-    QPopupMenu *menu = new QPopupMenu( this );
+    Q3PopupMenu *menu = new Q3PopupMenu( this );
     menuBar()->insertItem( tr( "&Settings" ), menu );
 
     QAction *a;
-    a = new QAction( tr( "Set fixed font" ), QPixmap(), tr( "Set &fixed font" ), 0, this, "setFixedFont" );
+    a = new QAction(tr( "Set &fixed font" ), this);
+	a->setStatusTip ( tr( "Set fixed font" ));
     connect( a, SIGNAL( activated() ), this, SLOT( setFixedFont() ) );
     a->addTo( menu );
 	actionSettingsFixedFont=a;
 
-    a = new QAction( tr( "Set variable font" ), QPixmap(), tr( "Set &variable font" ), 0, this, "setvariableFont" );
+    a = new QAction(tr( "Set &variable font" ), this);
+	a->setStatusTip ( tr( "Set variable font" ) );
     connect( a, SIGNAL( activated() ), this, SLOT( setVarFont() ) );
     a->addTo( menu );
 	actionSettingsVarFont=a;
 
-    a = new QAction( tr( "Used fixed font by default" ), QPixmap(), tr( "&fixed font is default" ), 0, this, "fonthintDefault" );
+    a = new QAction(tr( "&fixed font is default" ),  this);
+	a->setStatusTip (tr( "Used fixed font by default" ) );
 	a->setToggleAction (true);
 	// set state later in constructor...
     a->addTo( menu );
@@ -428,7 +495,7 @@
 	{
 		if (e->length()) 
 		{
-			QMessageBox mb( "VYM - Note Editor",
+			QMessageBox mb( __VYM " - " +tr("Note Editor"),
 				"Loading will overwrite the existing note",
 				QMessageBox::Warning,
 				QMessageBox::Yes | QMessageBox::Default,
@@ -442,7 +509,7 @@
 			}
 		} 
 		// Load note
-		QFileDialog *fd=new QFileDialog( this);
+		Q3FileDialog *fd=new Q3FileDialog( this);
 		fd->addFilter ("ASCII texts (*.txt)");
 		fd->addFilter ("VYM notes (*.html)");
 		fd->show();
@@ -453,7 +520,7 @@
 		if ( !fn.isEmpty() )
 		{
 			QFile f( fn );
-			if ( !f.open( IO_ReadOnly ) )
+			if ( !f.open( QIODevice::ReadOnly ) )
 			return;
 
 			QTextStream ts( &f );
@@ -465,11 +532,10 @@
 
 void TextEditor::closeEvent( QCloseEvent* ce )
 {
-    if ( !e->isModified() ) 
-	{
-		ce->accept();	// TextEditor can be reopened with show()
-		return;
-    }
+    ce->accept();	// TextEditor can be reopened with show()
+    actionViewToggleNoteEditor->setOn (false);
+    showwithmain=false;
+    return;
 }
 
 QString TextEditor::getText()
@@ -479,21 +545,15 @@
 
 void TextEditor::editorChanged()
 {
-	// received, when QTextEdit::text() has changed
-	EditorState	oldstate=state;
-
 	if (isEmpty())
 		state=emptyEditor;
 	else
 		state=filledEditor;
 
-	if (state != oldstate)
-	{
 		if (state==emptyEditor)
 			e->setPaper (emptyPaper);
 		else
 			e->setPaper (filledPaper);
-	}
 	// SLOT is LinkableMapObj, which will update systemFlag
 	emit (textHasChanged() );
 }
@@ -501,19 +561,19 @@
 
 void TextEditor::setText(QString t)
 {
-	if ( !QStyleSheet::mightBeRichText( t ) )
-		t = QStyleSheet::convertFromPlainText( t, QStyleSheetItem::WhiteSpaceNormal );
+	if ( !Q3StyleSheet::mightBeRichText( t ) )
+		t = Q3StyleSheet::convertFromPlainText( t, Q3StyleSheetItem::WhiteSpaceNormal );
 	e->setReadOnly(false);
 	e->setText(t);
-	editorChanged();	//not called automagically
+//	editorChanged();	//not called automagically  FIXME or is it?
 
 	enableActions();
 }
 
 void TextEditor::setInactive()
 {
+	state=inactiveEditor;
 	setText("");
-	state=inactiveEditor;
 	e->setPaper (inactivePaper);
 	e->setReadOnly (true);
 
@@ -528,7 +588,7 @@
 
 void TextEditor::textSaveAs()
 {
-    QString fn = QFileDialog::getSaveFileName( QString::null, "VYM Note (HTML) (*.html);;All files (*)",
+    QString fn = Q3FileDialog::getSaveFileName( QString::null, "VYM Note (HTML) (*.html);;All files (*)",
 					       this,"export note dialog",tr("Export Note to single file") );
 
     if ( !fn.isEmpty() ) 
@@ -536,14 +596,14 @@
 		QFile file (fn);
 		if (file.exists())
 		{
-			QMessageBox mb( "VYM",
+			QMessageBox mb( __VYM,
 				tr("The file ") + fn + 
 				tr(" exists already. "
 				"Do you want to overwrite it?"),
 			QMessageBox::Warning,
 			QMessageBox::Yes | QMessageBox::Default,
 			QMessageBox::Cancel | QMessageBox::Escape,
-			QMessageBox::NoButton );
+			Qt::NoButton );
 			mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
 			mb.setButtonText( QMessageBox::No, tr("Cancel"));
 			switch( mb.exec() ) {
@@ -577,7 +637,7 @@
 
     QString text = e->text();
     QFile f( filename );
-    if ( !f.open( IO_WriteOnly ) ) 
+    if ( !f.open( QIODevice::WriteOnly ) ) 
 	{
 		statusBar()->message( QString("Could not write to %1").arg(filename),
 					  statusbarTime );
@@ -659,38 +719,19 @@
 		e->setText(t);
 }
 
-QString TextEditor::textConvertToASCII(const QString &t)
-{
-	QString r=t;
-
-	// convert all "<br*>" to "\n"
-	QRegExp re("<br.*>");
-	re.setMinimal(true);
-	r.replace (re,"\n");
-
-	// convert all "</p>" to "\n"
-	re.setPattern ("/p");
-	r.replace (re,"\n");
-	
-	// remove all remaining tags 
-	re.setPattern ("<.*>");
-	r.replace (re,"");
-
-	// convert "&", "<" and ">"
-	re.setPattern ("&gt;");
-	r.replace (re,">");
-	re.setPattern ("&lt;");
-	r.replace (re,"<");
-	re.setPattern ("&amp;");
-	r.replace (re,"&");
-	return r;
-}
-
 void TextEditor::textExportAsASCII()
 {
-	QString text = textConvertToASCII( e->text());
-    QString fn = QFileDialog::getSaveFileName( QString::null, "VYM Note (ASCII) (*.txt);;All files (*)",
-					       this,"export note dialog",tr("Export Note to single file (ASCII)") );
+	QString text = NoteObj (e->text()).getNoteASCII();
+	QString fn,s;
+	if (!filenameHint.isEmpty())
+	{
+		if (!filenameHint.contains (".txt"))
+			s=filenameHint+".txt";
+		else	
+			s=filenameHint;
+	} else	
+		s=QString::null;
+	fn = Q3FileDialog::getSaveFileName( s, "VYM Note (ASCII) (*.txt);;All files (*)", this,"export note dialog",tr("Export Note to single file (ASCII)") );
 	int ret=-1;
 
     if ( !fn.isEmpty() ) 
@@ -705,7 +746,7 @@
 			QMessageBox::Warning,
 			QMessageBox::Yes | QMessageBox::Default,
 			QMessageBox::Cancel | QMessageBox::Escape,
-			QMessageBox::NoButton );
+			Qt::NoButton );
 			mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
 			mb.setButtonText( QMessageBox::No, tr("Cancel"));
 			ret=mb.exec();
@@ -714,7 +755,7 @@
 			return;
 			
 		// save 
-		if ( !file.open( IO_WriteOnly ) ) 
+		if ( !file.open( QIODevice::WriteOnly ) ) 
 			statusBar()->message( QString("Could not write to %1").arg(filename),
 						  statusbarTime );
 		else
@@ -737,14 +778,14 @@
 		QPainter p( printer );
 		// Check that there is a valid device to print to.
 		if ( !p.device() ) return;
-		QPaintDeviceMetrics metrics( p.device() );
+		Q3PaintDeviceMetrics metrics( p.device() );
 		int dpiy = metrics.logicalDpiY();
 		int margin = (int) ( (2/2.54)*dpiy ); // 2 cm margins
 		QRect body( margin, margin, metrics.width() - 2*margin, metrics.height() - 2*margin );
 		QFont font( e->currentFont() );
 		font.setPointSize( 10 ); // we define 10pt to be a nice base size for printing
 
-		QSimpleRichText richText( e->text(), font,
+		Q3SimpleRichText richText( e->text(), font,
 					  e->context(),
 					  e->styleSheet(),
 					  e->mimeSourceFactory(),
@@ -838,22 +879,34 @@
 	return;
     e->setColor( col );
     QPixmap pix( 16, 16 );
-    pix.fill( black );
+    pix.fill( Qt::black );
     actionTextColor->setIconSet( pix );
 }
 
 void TextEditor::textAlign( QAction *a )
 {
     if ( a == actionAlignLeft )
-	e->setAlignment( AlignLeft );
+	e->setAlignment( Qt::AlignLeft );
     else if ( a == actionAlignCenter )
-	e->setAlignment( AlignHCenter );
+	e->setAlignment( Qt::AlignHCenter );
     else if ( a == actionAlignRight )
-	e->setAlignment( AlignRight );
+	e->setAlignment( Qt::AlignRight );
     else if ( a == actionAlignJustify )
-	e->setAlignment( AlignJustify );
+	e->setAlignment( Qt::AlignJustify );
 }
 
+void TextEditor::textVAlign()
+{
+    if ( sender() == actionAlignSuperScript && actionAlignSuperScript->isOn()) {
+	e->setVerticalAlignment( Q3TextEdit::AlignSuperScript);
+    } else if (sender() == actionAlignSubScript && actionAlignSubScript->isOn()) {
+	e->setVerticalAlignment( Q3TextEdit::AlignSubScript);
+    } else {
+	e->setVerticalAlignment( Q3TextEdit::AlignNormal);
+    }
+}
+
+
 void TextEditor::fontChanged( const QFont &f )
 {
     comboFont->lineEdit()->setText( f.family() );
@@ -872,16 +925,30 @@
 
 void TextEditor::alignmentChanged( int a )
 {
-    if ( ( a == AlignAuto ) || ( a & AlignLeft ))
+    if ( ( a == Qt::AlignLeft ) || ( a & Qt::AlignLeft ))
 	actionAlignLeft->setOn( true );
-    else if ( ( a & AlignHCenter ) )
+    else if ( ( a & Qt::AlignHCenter ) )
 	actionAlignCenter->setOn( true );
-    else if ( ( a & AlignRight ) )
+    else if ( ( a & Qt::AlignRight ) )
 	actionAlignRight->setOn( true );
-    else if ( ( a & AlignJustify ) )
+    else if ( ( a & Qt::AlignJustify ) )
 	actionAlignJustify->setOn( true );
 }
 
+void TextEditor::verticalAlignmentChanged(int a) 
+{
+    if (a == Q3TextEdit::AlignSuperScript ) {
+	actionAlignSuperScript->setOn(true);
+	actionAlignSubScript->setOn(false);
+    } else if (a == Q3TextEdit::AlignSubScript ) {
+	actionAlignSuperScript->setOn(false);
+	actionAlignSubScript->setOn(true);
+    } else {
+	actionAlignSuperScript->setOn(false);
+	actionAlignSubScript->setOn(false);
+    }
+}
+
 
 
 void TextEditor::enableActions()
diff -r 9eb7767c2dfa -r 608f976aa7bb texteditor.h
--- a/texteditor.h	Sun Jan 30 12:58:47 2005 +0000
+++ b/texteditor.h	Tue Jun 06 14:58:11 2006 +0000
@@ -1,16 +1,21 @@
+/* emacs: -*- Mode: C; c-style: "bsd"; c-basic-offset: 4; c-recognize-knr-p: nil; -*- */
 #ifndef TEXTEDITOR_H 
 #define TEXTEDITOR_H
 
-#include <qmainwindow.h>
-#include <qtextedit.h>
+#include <q3mainwindow.h>
+#include <q3textedit.h>
 #include <qaction.h>
 #include <qfontdatabase.h>
 #include <qcombobox.h>
+//Added by qt3to4:
+#include <QCloseEvent>
 
 
 enum EditorState {inactiveEditor,emptyEditor,filledEditor};
 
-class TextEditor : public QMainWindow {
+class MyTextEdit;
+
+class TextEditor : public Q3MainWindow {
     Q_OBJECT
 public:
     TextEditor();
@@ -24,6 +29,8 @@
 	QString getFontHintDefault();
 	void setFilename (const QString&);
 	QString getFilename ();
+	void setFilenameHint (const QString&);
+	QString getFilenameHint ();
 	bool findText(const QString &, const bool &); // find Text 
 
 protected:
@@ -54,7 +61,6 @@
     void textSave();
 	void textConvertPar();
 	void textJoinLines();
-	QString textConvertToASCII(const QString &);
 	void textExportAsASCII();
     void textPrint();
 	void textEditUndo();
@@ -68,17 +74,20 @@
     void textSize( const QString &p );
 	void textColor();
 	void textAlign(QAction*);
+	void textVAlign();
     void fontChanged( const QFont &f );
     void colorChanged( const QColor &c );
     void alignmentChanged( int a );
+    void verticalAlignmentChanged(int a);
 	void enableActions();
 	void disableActions();
 
 private:
     QPrinter *printer;
-    QTextEdit *e;
+    MyTextEdit *e;
 	QPoint lastPos;			// save last position of window
     QString filename;
+    QString filenameHint;
 
 	QBrush emptyPaper;		// setting the background color
 	QBrush filledPaper;		// depending on the state
@@ -115,9 +124,39 @@
 	*actionAlignLeft,
 	*actionAlignCenter,
 	*actionAlignRight,
-	*actionAlignJustify;
+	*actionAlignJustify,
+	*actionAlignSubScript,
+	*actionAlignSuperScript;
+};
 
-
+/* Wraps currentVerticalAlignmentChanged(VerticalAlignment)
+ * to currentVerticalAlignmentChanged(int) 
+ * this way the signal can be used without use of the internal 
+ * VerticalAlignment enum of QTextEdit 
+ * If VerticalAlignment has been a global like the normal alignment there
+ * have been no problems!
+ */
+ 
+class MyTextEdit : public Q3TextEdit 
+{
+    Q_OBJECT;
+ public:
+    MyTextEdit(QWidget *parent, const char *name) : Q3TextEdit(parent, name) {
+	connect(this, 
+		SIGNAL(currentVerticalAlignmentChanged(VerticalAlignment)),
+		this, 
+		SLOT(verticalAlignmentChanged(VerticalAlignment)));
+    }
+    int verticalAlignment() const { return m_verticalAlignment; } 
+ signals:
+    void currentVerticalAlignmentChanged(int a);
+ public slots:
+    void verticalAlignmentChanged(VerticalAlignment a) {
+     m_verticalAlignment = a;
+	emit currentVerticalAlignmentChanged((int)a);
+    }
+ private: 
+ int m_verticalAlignment;
 };
 
 #endif
diff -r 9eb7767c2dfa -r 608f976aa7bb version.h
--- a/version.h	Sun Jan 30 12:58:47 2005 +0000
+++ b/version.h	Tue Jun 06 14:58:11 2006 +0000
@@ -1,7 +1,8 @@
 #ifndef VERSION_H 
 #define VERSION_H
 
-#define __VYM_VERSION__ "1.6.0"
-#define __BUILD_DATE__ "January 4, 2005"
+#define __VYM "VYM"
+#define __VYM_VERSION "1.7.50"
+#define __BUILD_DATE "June 5, 2006"
 
 #endif
diff -r 9eb7767c2dfa -r 608f976aa7bb vym.pro
--- a/vym.pro	Sun Jan 30 12:58:47 2005 +0000
+++ b/vym.pro	Tue Jun 06 14:58:11 2006 +0000
@@ -1,31 +1,15 @@
-TARGET  = vym
-TRANSLATIONS += vym_de.ts
-
 TEMPLATE	= app
 LANGUAGE	= C++
 
 CONFIG	+= qt warn_on release
+QT += qt3support
 
-DESTROOT = /usr
-
-target.path = $${DESTROOT}/bin
-INSTALLS += target
-
-support.files = styles/ scripts/ icons/
-support.path = $${DESTROOT}/share/vym
-INSTALLS += support 
-
-doc.files = doc/*
-doc.path = $${DESTROOT}/share/doc/packages/vym
-INSTALLS += doc
-
-demo.files = demos/
-demo.path = $${DESTROOT}/share/vym
-INSTALLS += demo
-
-
-HEADERS	+= branchobj.h \
+HEADERS	+= aboutdialog.h \
+	api.h \
+	branchobj.h \
+	exportoofiledialog.h \
 	exports.h \
+	file.h \
 	findwindow.h \
 	flagobj.h \
 	flagrowobj.h \
@@ -34,7 +18,9 @@
 	frameobj.h \
 	headingobj.h \
 	imageobj.h \
+	imports.h \
 	linkablemapobj.h \
+	xlinkobj.h \
 	mainwindow.h \
 	mapcenterobj.h \
 	mapeditor.h \
@@ -47,10 +33,16 @@
 	texteditor.h \
 	version.h \
 	xml.h \
+	xsltproc.h \
 	settings.h \
 	options.h
-SOURCES	+= branchobj.cpp \
+
+SOURCES	+= aboutdialog.cpp \
+	api.cpp \
+	branchobj.cpp \
+	exportoofiledialog.cpp \
 	exports.cpp \
+	file.cpp \
 	findwindow.cpp \
 	flagobj.cpp \
 	flagrowobj.cpp \
@@ -59,7 +51,9 @@
 	frameobj.cpp \
 	headingobj.cpp \
 	imageobj.cpp \
+	imports.cpp \
 	linkablemapobj.cpp \
+	xlinkobj.cpp \
 	main.cpp \
 	mainwindow.cpp \
 	mapcenterobj.cpp \
@@ -72,10 +66,44 @@
 	selection.cpp \
 	texteditor.cpp \
 	xml.cpp \
+	xsltproc.cpp \
 	settings.cpp \
 	options.cpp
-FORMS	= exporthtmldialog.ui \
-	exportxhtmldialog.ui \
+
+#The following line was changed from FORMS to FORMS3 by qt3to4
+FORMS3	= exportxhtmldialog.ui \
 	showtextdialog.ui \
-	extrainfodialog.ui
+	extrainfodialog.ui \
+	editxlinkdialog.ui \
+	warningdialog.ui
 
+TARGET  = vym
+TRANSLATIONS += lang/vym_de.ts
+TRANSLATIONS += lang/vym_en.ts
+TRANSLATIONS += lang/vym_es.ts
+TRANSLATIONS += lang/vym_it.ts
+
+
+
+DESTROOT = /usr
+
+target.path = $${DESTROOT}/bin
+INSTALLS += target
+
+support.files = styles/ scripts/ icons/ flags/ lang/
+support.path = $${DESTROOT}/share/vym
+INSTALLS += support 
+
+doc.files = tex/vym.pdf 
+doc.path = $${DESTROOT}/share/doc/packages/vym
+INSTALLS += doc
+
+demo.files = demos/
+demo.path = $${DESTROOT}/share/doc/packages/vym
+INSTALLS += demo
+
+#The following line was inserted by qt3to4
+QT += xml  
+#The following line was inserted by qt3to4
+CONFIG += uic3
+
diff -r 9eb7767c2dfa -r 608f976aa7bb warningdialog.ui.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/warningdialog.ui.h	Tue Jun 06 14:58:11 2006 +0000
@@ -0,0 +1,50 @@
+//Added by qt3to4:
+#include <QPixmap>
+/****************************************************************************
+** ui.h extension file, included from the uic-generated form implementation.
+**
+** If you want to add, delete, or rename functions or slots, use
+** Qt Designer to update this file, preserving your code.
+**
+** You should not define a constructor or destructor in this file.
+** Instead, write your code in functions called init() and destroy().
+** These will automatically be called by the form's constructor and
+** destructor.
+*****************************************************************************/
+
+void WarningDialog::init()
+{
+	warningSign->setPixmap (QPixmap("icons/vym.png"));
+	setCancelButton (false);
+	okButton->setText(tr("Proceed"));
+	showAgainBox->setText (tr("Show this message again"));
+	useShowAgain=false;
+	showAgainBox->hide();
+}
+
+void WarningDialog::setCancelButton (bool b)
+{
+	if (b)
+	{
+		cancelButton->show();
+		cancelButton->setText(tr("Cancel"));
+	} else
+		cancelButton->hide();
+}
+
+void WarningDialog::setShowAgainName (const QString &s)
+{
+	showAgainName=s;
+	useShowAgain=true;
+	showAgainBox->show();
+}
+
+void WarningDialog::setText (const QString &s)
+{
+	textLabel->setText(s);
+}
+
+void WarningDialog::setCaption(const QString &s)
+{
+	QDialog::setCaption("VYM - "+s);
+}
diff -r 9eb7767c2dfa -r 608f976aa7bb xlinkobj.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xlinkobj.cpp	Tue Jun 06 14:58:11 2006 +0000
@@ -0,0 +1,302 @@
+#include "xlinkobj.h"
+#include "branchobj.h"
+#include "mapeditor.h"
+//Added by qt3to4:
+#include <Q3PointArray>
+
+
+/////////////////////////////////////////////////////////////////
+// XLinkObj
+/////////////////////////////////////////////////////////////////
+
+int XLinkObj::arrowSize=10;						// make instances 
+
+XLinkObj::XLinkObj ():MapObj() 
+{
+	//	cout << "Const XLinkObj ()\n";
+	init();
+}
+
+XLinkObj::XLinkObj (Q3Canvas* c):MapObj(c)
+{
+	//	cout << "Const XLinkObj (c)  called from MapCenterObj (c)\n";
+	init();
+}
+
+
+XLinkObj::~XLinkObj ()
+{
+	//	cout << "Destr XLinkObj\n";
+	if (xLinkState!=undefinedXLink)
+		deactivate();
+	delete (line);
+	delete (poly);
+}
+
+
+void XLinkObj::init () 
+{
+	beginBranch=NULL;
+	endBranch=NULL;
+	visBranch=NULL;
+	xLinkState=undefinedXLink;
+
+	color=QColor (180,180,180);
+	line=new Q3CanvasLine (canvas);
+	width=1;
+	line->setPen (QPen(color, width));
+	line->setZ (Z_XLINK);
+
+	poly=new Q3CanvasPolygon (canvas);
+	poly->setBrush( color );
+	poly->setZ (Z_XLINK);
+
+	setVisibility (false);
+}
+
+void XLinkObj::copy (XLinkObj* other)
+{
+	// TODO copy not used yet
+	MapObj::copy (other);
+	setVisibility (other->visible);
+	beginBranch=other->beginBranch;
+	endBranch=other->endBranch;
+	width=other->width;
+}
+
+void XLinkObj::setBegin (BranchObj *bo)
+{
+	if (bo) 
+	{
+		xLinkState=initXLink;
+		beginBranch=bo;
+		beginPos=beginBranch->getChildPos();
+	}	
+}
+
+BranchObj* XLinkObj::getBegin ()
+{
+	return beginBranch;
+}
+
+void XLinkObj::setEnd (BranchObj *bo)
+{
+	if (bo) 
+	{
+		xLinkState=initXLink;
+		endBranch=bo;
+		endPos=endBranch->getChildPos();
+	}		
+}
+
+BranchObj* XLinkObj::getEnd()
+{
+	return endBranch;
+}
+
+void XLinkObj::setWidth (int w)
+{
+	width=w;
+	setColor (color);
+}
+
+int XLinkObj::getWidth()
+{
+	return width;
+}
+
+void XLinkObj::setColor(QColor c)
+{
+	color=c;
+	line->setPen (QPen(color, width));
+	poly->setBrush( color );
+}
+
+QColor XLinkObj::getColor()
+{
+	return color;
+}
+
+void XLinkObj::setEnd (QPoint p)
+{
+	endPos=p;
+}
+
+bool XLinkObj::activate ()
+{
+	if (beginBranch && endBranch)
+	{
+		if (beginBranch==endBranch) return false;
+		xLinkState=activeXLink;
+		beginBranch->addXLink (this);
+		endBranch->addXLink (this);
+		setVisibility ();
+		return true;
+	} else
+		return false;
+}
+
+void XLinkObj::deactivate ()
+{
+	if (beginBranch)
+		beginBranch->removeXLinkRef (this);
+	beginBranch=NULL;	
+	if (endBranch)
+		endBranch->removeXLinkRef (this);
+	endBranch=NULL;	
+	visBranch=NULL;
+	xLinkState=undefinedXLink;
+
+	line->hide();
+}
+
+bool XLinkObj::isUsed()
+{
+	if (beginBranch || endBranch || xLinkState!=undefinedXLink)
+		return true;
+	else
+		return false;
+}
+
+void XLinkObj::updateXLink()
+{
+	QPoint a,b;
+	Q3PointArray pa (3);
+	if (visBranch)
+	{
+		// Only one of the linked branches is visible
+		a=b=visBranch->getChildPos();
+		if (visBranch->getOrientation()==OrientRightOfCenter)
+		{
+			b.setX (b.x()+25);
+			pa.putPoints (0,3,
+				b.x(),b.y(),
+				b.x()-arrowSize,b.y()-arrowSize,
+				b.x()-arrowSize,b.y()+arrowSize
+			);
+			poly->setPoints (pa);
+		} else
+		{
+			b.setX (b.x()-25);
+			pa.putPoints (0,3,
+				b.x(),b.y(),
+				b.x()+arrowSize,b.y()-arrowSize,
+				b.x()+arrowSize,b.y()+arrowSize);
+			poly->setPoints (pa);
+		}	
+	} else
+	{
+		// Both linked branches are visible
+		if (beginBranch)
+			// If a link is just drawn in the editor,
+			// we have already a beginBranch
+			a=beginBranch->getChildPos();
+		else
+			// This shouldn't be reached normally...
+			a=beginPos;
+		if (xLinkState==activeXLink && endBranch)
+			b=endBranch->getChildPos();
+		else
+			b=endPos;
+	}
+
+
+	if (line->startPoint()==a && line->endPoint()==b && !visBranch)
+	{
+		// update is called from both branches, so only
+		// update if something has changed
+		return;
+	}	
+	else
+	{
+		beginPos=a;
+		endPos=b;
+		line->setPen (QPen(color, width));
+		line->setPoints (a.x(), a.y(), b.x(), b.y());
+	}
+}
+
+BranchObj* XLinkObj::otherBranch(BranchObj* thisBranch)
+{
+	if (!beginBranch && !endBranch)
+		return NULL;
+	if (thisBranch==beginBranch)
+		return endBranch;
+	else	
+		return beginBranch;
+}
+
+void XLinkObj::positionBBox()
+{
+}
+
+void XLinkObj::calcBBoxSize()
+{
+}
+
+void XLinkObj::setVisibility (bool b)
+{
+	MapObj::setVisibility (b);
+	if (b)
+	{
+		line->show();
+		if (visBranch) 
+			poly->show();
+		else	
+			poly->hide();
+	}	
+	else
+	{
+		line->hide();
+		poly->hide();
+	}	
+}
+
+void XLinkObj::setVisibility ()
+{
+	if (beginBranch && endBranch)
+	{
+		if(beginBranch->isVisibleObj() && endBranch->isVisibleObj())
+		{	// Both ends are visible
+			visBranch=NULL;
+			setVisibility (true);
+		} else
+		{
+			if(!beginBranch->isVisibleObj() && !endBranch->isVisibleObj())
+			{	//None of the ends is visible
+				visBranch=NULL;
+				setVisibility (false);
+			} else
+			{	// Just one end is visible, draw a symbol that shows
+				// that there is a link to a scrolled branch
+				if (beginBranch->isVisibleObj())
+					visBranch=beginBranch;
+				else
+					visBranch=endBranch;
+				setVisibility (true);
+			}
+		}
+	}
+}
+
+QString XLinkObj::saveToDir ()
+{
+	QString s="";
+	if (beginBranch && endBranch &&xLinkState==activeXLink)
+	{
+		if (beginBranch==endBranch && xLinkState)
+			s="";
+		else
+		{
+			QString colAttr=attribut ("color",color.name());
+			QString widAttr=attribut ("width",QString().setNum(width,10));
+			QString begSelAttr=attribut ("beginBranch",beginBranch->getSelectString());
+			QString endSelAttr=attribut ("endBranch",  endBranch->getSelectString());
+			s=beginElement ("xlink", colAttr +widAttr +begSelAttr +endSelAttr);
+
+			s+=endElement ("xlink");
+		}
+	}
+	return s;
+}
+
diff -r 9eb7767c2dfa -r 608f976aa7bb xlinkobj.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xlinkobj.h	Tue Jun 06 14:58:11 2006 +0000
@@ -0,0 +1,50 @@
+#ifndef XLINKOBJ_H
+#define XLINKOBJ_H
+
+#include "linkablemapobj.h"
+
+enum XLinkState {undefinedXLink,initXLink,activeXLink,deleteXLink};
+
+/////////////////////////////////////////////////////////////////////////////
+class XLinkObj:public MapObj {
+public:
+    XLinkObj ();
+    XLinkObj (Q3Canvas*);
+    ~XLinkObj ();
+    virtual void init ();
+    virtual void copy (XLinkObj*);
+	void setBegin (BranchObj*);
+	BranchObj* getBegin();
+	void setEnd   (BranchObj*);
+	void setEnd   (QPoint);
+	BranchObj* getEnd();
+	void setColor(QColor);
+	QColor getColor();
+	void setWidth (int);
+	int getWidth ();
+	bool activate ();			// Sets pointers in branchObjects
+	void deactivate();			// removes those pointers
+	bool isUsed();				// true, if at least on branch uses it
+	void updateXLink();
+	BranchObj* otherBranch (BranchObj*);
+	void positionBBox();
+	void calcBBoxSize();
+	void setVisibility (bool);
+	void setVisibility ();
+	QString saveToDir ();
+
+private:
+	static int arrowSize;
+	QColor color;
+	int width;
+	Q3CanvasLine *line;
+	Q3CanvasPolygon *poly;
+	BranchObj *beginBranch;
+	BranchObj *endBranch;
+	BranchObj *visBranch;	// the "visible" part of a partially scrolled link
+	XLinkState xLinkState;	// init during drawing or active
+	QPoint beginPos;
+	QPoint   endPos;
+};
+
+#endif
diff -r 9eb7767c2dfa -r 608f976aa7bb xml.cpp
--- a/xml.cpp	Sun Jan 30 12:58:47 2005 +0000
+++ b/xml.cpp	Tue Jun 06 14:58:11 2006 +0000
@@ -2,16 +2,20 @@
 
 #include <qmessagebox.h>
 #include <qcolor.h>
-#include <qstylesheet.h>
+#include <q3stylesheet.h>
+//Added by qt3to4:
+#include <QTextStream>
 #include <iostream>
 
 #include "misc.h"
 #include "settings.h"
+#include "linkablemapobj.h"
 
 #include "version.h"
 
 static BranchObj *lastBranch;
 static FloatObj *lastFloat;
+static OrnamentedObj *lastOO;
 
 extern Settings settings;
 
@@ -47,7 +51,7 @@
                     const QString& eName, const QXmlAttributes& atts ) 
 {
     QColor col;
-//	cout << "startElement <"<<eName<<">  state="<<state <<"  laststate="<<laststate<<endl;
+	//cout << "startElement <"<<eName<<">  state="<<state <<"  laststate="<<laststate<<"   loadMode="<<loadMode<<endl;
     if ( state == StateInit && (eName == "vymmap")  ) 
 	{
         state = StateMap;
@@ -59,7 +63,7 @@
 				   "<h3>Map is newer than VYM</h3>"
 				   "<p>The map you are just trying to load was "
 				   "saved using vym " +atts.value("version")+". "
-				   "The version of this vym is " __VYM_VERSION__
+				   "The version of this vym is " __VYM_VERSION
 				   ". If you run into problems after pressing "
 				   "the ok-button below, updating vym should help.");
 
@@ -105,6 +109,15 @@
 				col.setNamedColor(atts.value("linkColor"));
 				me->setLinkColor(col);
 			}	
+			if (!atts.value( "defXLinkColor").isEmpty() ) 
+			{
+				col.setNamedColor(atts.value("defXLinkColor"));
+				me->setDefXLinkColor(col);
+			}	
+			if (!atts.value( "defXLinkWidth").isEmpty() ) 
+			{
+				me->setDefXLinkWidth(atts.value("defXLinkWidth").toInt ());
+			}	
 		}	
 	} else if ( eName == "select" && state == StateMap ) 
 	{
@@ -129,7 +142,7 @@
 			if (lmo && (typeid(*lmo) == typeid(BranchObj) ) 
 			        || (typeid(*lmo) == typeid(MapCenterObj) ) )
 			{
-				lastBranch=(BranchObj*)(lmo);
+				lastBranch=(BranchObj*)lmo;
 				if (loadMode==ImportAdd)
 				{
 					lastBranch->addBranch();
@@ -149,7 +162,7 @@
 		if (!atts.value( "textColor").isEmpty() ) 
 		{
 			col.setNamedColor(atts.value("textColor"));
-			lastBranch->setColor(col ,false );
+			lastBranch->setColor(col );
 		}	    
 	} else if ( eName == "note" && state == StateMapCenter) 
 	{	// only for backward compatibility (<1.4.6). Use htmlnote now.
@@ -165,26 +178,43 @@
         lastBranch->addFloatImage();
 		lastFloat=lastBranch->getLastFloatImage();
 		if (!readFloatImageAttr(atts)) return false;
-	} else if ( eName == "branch" && state == StateMap) 
+	} else if ( (eName == "branch"||eName=="floatimage") && state == StateMap) 
 	{
 		// This is used in vymparts, which have no mapcenter!
 		isVymPart=true;
-		state=StateBranch;
 		LinkableMapObj* lmo=me->getSelection();
+		if (!lmo)
+		{
+			// If a vym part is _loaded_ (not imported), 
+			// selection==lmo==NULL
+			// Treat it like ImportAdd then...
+			loadMode=ImportAdd;
+			lmo=mc;
+		}	
 		if (lmo && (typeid(*lmo) == typeid(BranchObj) ) 
 				|| (typeid(*lmo) == typeid(MapCenterObj) ) )
 		{
 			lastBranch=(BranchObj*)(lmo);
-			if (loadMode==ImportAdd)
+			if (eName=="branch")
 			{
-				lastBranch->addBranch();
-				lastBranch=lastBranch->getLastBranch();
-			} else
-				lastBranch->clear();
-		} else
-			return false;
-		branchDepth=1;
-		readBranchAttr (atts);
+				state=StateBranch;
+				if (loadMode==ImportAdd)
+				{
+					lastBranch->addBranch();
+					lastBranch=lastBranch->getLastBranch();
+					
+				} else
+					lastBranch->clear();
+				branchDepth=1;
+				readBranchAttr (atts);
+			} else if (eName=="floatimage")
+			{
+				state=StateFloatImage;
+				lastBranch->addFloatImage();
+				lastFloat=lastBranch->getLastFloatImage();
+				if (!readFloatImageAttr(atts)) return false;
+			} else return false;
+		} else return false;
 	} else if ( eName == "branch" && state == StateMapCenter) 
 	{
 		state=StateBranch;
@@ -201,7 +231,7 @@
 		if (!atts.value( "textColor").isEmpty() ) 
 		{
 			col.setNamedColor(atts.value("textColor"));
-			lastBranch->setColor(col ,false );
+			lastBranch->setColor(col );
 		}	    
     } else if ( eName == "note" && state == StateBranch) 
 	{
@@ -220,6 +250,10 @@
         lastBranch->addFloatImage();
 		lastFloat=lastBranch->getLastFloatImage();
 		if (!readFloatImageAttr(atts)) return false;
+    } else if ( eName == "xlink" && state == StateBranch ) 
+	{
+		state=StateBranchXLink;
+		if (!readXLinkAttr (atts)) return false;
     } else if ( eName == "branch" && state == StateBranch ) 
 	{
         lastBranch->addBranch();
@@ -255,6 +289,7 @@
         case StateMapCenterHeading: state=StateMapCenter;  return true;
         case StateMapCenterNote: state=StateMapCenter;  return true;
         case StateMapCenterFloatImage: state=StateMapCenter;  return true;
+        case StateFloatImage: state=StateMap; return true;
         case StateBranch: 
             if (branchDepth>1) 
 			{
@@ -274,6 +309,7 @@
         case StateBranchHeading: state=StateBranch;  return true;
         case StateBranchNote: state=StateBranch; return true;
         case StateBranchFloatImage: state=StateBranch;  return true;
+        case StateBranchXLink: state=StateBranch;  return true;
         case StateHtmlNote: state=laststate; return true;
         case StateHtml: 
 			htmldata+="</"+eName+">";
@@ -349,11 +385,27 @@
 
 bool mapBuilderHandler::fatalError( const QXmlParseException& exception ) 
 {
-    errorProt += QString( "fatal parsing error: %1 in line %2, column %3\n")
+    errorProt += QString( "Fatal parsing error: %1 in line %2, column %3\n")
     .arg( exception.message() )
     .arg( exception.lineNumber() )
     .arg( exception.columnNumber() );
-
+	// Try to read the bogus line
+	errorProt+=QString("File is: %1\n").arg(inputFile);
+	QString s;
+	if (loadStringFromDisk (inputFile,s))
+	{
+		QStringList sl=QStringList::split ("\n",s);
+		int i=1;
+		QStringList::Iterator it = sl.begin();
+		while (i<exception.lineNumber()-1)
+		{
+			it++;
+			i++;
+		}
+		s=*it;
+		s.insert (exception.columnNumber()-1,"<ERROR>");
+		errorProt+=s;
+    }
     return QXmlDefaultHandler::fatalError( exception );
 }
 
@@ -368,6 +420,11 @@
 	tmpDir=tp;
 }
 
+void mapBuilderHandler::setInputFile (QString f)
+{
+	inputFile=f;
+}
+
 void mapBuilderHandler::setLoadMode (const LoadMode &lm)
 {
 	loadMode=lm;
@@ -375,28 +432,65 @@
 
 bool mapBuilderHandler::readBranchAttr (const QXmlAttributes& a)
 {
-	bool okx,oky;
-	int x,y;
-	if (!a.value( "absPosX").isEmpty() && loadMode==NewMap && branchDepth<2) 
-	{
-		if (!a.value( "absPosY").isEmpty() ) 
-		{
-			x=a.value("absPosX").toInt (&okx, 10);
-			y=a.value("absPosY").toInt (&oky, 10);
-			if (okx && oky) 
-				lastBranch->move(x,y);
-			else
-				return false;   // Couldn't read absPos
-		}           
-	}           
+	lastOO=lastBranch;
+	if (!readOOAttr(a)) return false;
+
 	if (!a.value( "scrolled").isEmpty() )
 		lastBranch->toggleScroll();
-	if (!a.value( "url").isEmpty() ) 
-		lastBranch->setURL (a.value ("url"));
-	if (!a.value( "vymLink").isEmpty() ) 
-		lastBranch->setVymLink (a.value ("vymLink"));
 	if (!a.value( "frameType").isEmpty() ) 
 		lastBranch->setFrameType (a.value("frameType"));
+
+	if (!a.value( "incImgV").isEmpty() ) 
+	{	
+		if (a.value("incImgV")=="true")
+			lastBranch->setIncludeImagesVer(true);
+		else	
+			lastBranch->setIncludeImagesVer(false);
+	}	
+	if (!a.value( "incImgH").isEmpty() ) 
+	{	
+		if (a.value("incImgH")=="true")
+			lastBranch->setIncludeImagesHor(true);
+		else	
+			lastBranch->setIncludeImagesHor(false);
+	}	
+	return true;	
+}
+
+bool mapBuilderHandler::readOOAttr (const QXmlAttributes& a)
+{
+	if (lastOO)
+	{
+		bool okx,oky;
+		int x,y;
+		if (!a.value( "absPosX").isEmpty() && loadMode==NewMap && branchDepth<2) 
+		{
+			if (!a.value( "absPosY").isEmpty() ) 
+			{
+				x=a.value("absPosX").toInt (&okx, 10);
+				y=a.value("absPosY").toInt (&oky, 10);
+				if (okx && oky  )
+					lastOO->move(x,y);
+				else
+					return false;   // Couldn't read absPos
+			}           
+		}           
+		if (!a.value( "url").isEmpty() ) 
+			lastOO->setURL (a.value ("url"));
+		if (!a.value( "vymLink").isEmpty() ) 
+			lastOO->setVymLink (a.value ("vymLink"));
+		if (!a.value( "hideInExport").isEmpty() ) 
+			if (a.value("hideInExport")=="true")
+				lastOO->setHideInExport(true);
+
+		if (!a.value( "hideLink").isEmpty()) 
+		{
+			if (a.value ("hideLink") =="true")
+				lastOO->setHideLinkUnselected(true);
+			else	
+				lastOO->setHideLinkUnselected(false);
+		}	
+	}
 	return true;	
 }
 
@@ -411,26 +505,26 @@
 		QFile file (fn);
 		QString s;						// Reading a note
 
-		if ( !file.open( IO_ReadOnly) )
+		if ( !file.open( QIODevice::ReadOnly) )
 		{
 			qWarning ("mapBuilderHandler::readNoteAttr:  Couldn't load "+fn);
 			return false;
 		}	
 		QTextStream stream( &file );
 		QString lines;
-		while ( !stream.eof() ) {
+		while ( !stream.atEnd() ) {
 			lines += stream.readLine()+"\n"; 
 		}
 		file.close();
 		// Convert to richtext
-		if ( !QStyleSheet::mightBeRichText( lines ) )
+		if ( !Q3StyleSheet::mightBeRichText( lines ) )
 		{
 			// Here we are workarounding the QT conversion method:
 			// convertFromPlainText does not generate valid xml, needed
 			// for the parser, but just <p> and <br> without closing tags.
 			// So we have to add those by ourselves
 			//lines=quotemeta (lines);
-			lines = QStyleSheet::convertFromPlainText( lines, QStyleSheetItem::WhiteSpaceNormal );
+			lines = Q3StyleSheet::convertFromPlainText( lines, Q3StyleSheetItem::WhiteSpaceNormal );
 			lines.replace ("<br>","<br />");
 		}	
 
@@ -448,6 +542,10 @@
 
 bool mapBuilderHandler::readFloatImageAttr (const QXmlAttributes& a)
 {
+	lastOO=lastFloat;
+	
+	//if (!readOOAttr(a)) return false;
+
 	if (!a.value( "useOrientation").isEmpty() ) 
 	{
 		if (a.value ("useOrientation") =="true")
@@ -470,8 +568,9 @@
 	}	
 	if (!a.value( "floatExport").isEmpty() ) 
 	{
-		if (a.value ("floatExpofrt") =="true")
-			lastFloat->setFloatExport (true);
+		// Only for compatibility. THis is not used since 1.7.11 
+		if (a.value ("floatExport") =="true")
+			lastFloat->setFloatExport(true);
 		else	
 			lastFloat->setFloatExport (false);
 	}	
@@ -487,15 +586,66 @@
 			x=a.value("relPosX").toInt (&okx, 10);
 			y=a.value("relPosY").toInt (&oky, 10);
 			if (okx && oky) 
-				lastFloat->setRelPos (QPoint (x,y) );
+				
+				{
+					lastFloat->setRelPos (QPoint (x,y) );
+					// make sure floats in mapcenter are repositioned to relative pos
+					if (mc==lastBranch) mc->positionContents();
+				}
 			else
 				// Couldn't read relPos
 				return false;  
 		}           
 	}	
+	
+	if (!readOOAttr(a)) return false;
+
+	if (!a.value ("orgName").isEmpty() )
+	{
+		((FloatImageObj*)(lastFloat))->setOriginalFilename (a.value("orgName"));
+	}
 	return true;
 }
 
+bool mapBuilderHandler::readXLinkAttr (const QXmlAttributes& a)
+{
+	QColor col;
+	bool okx;
+	bool success=false;
+	XLinkObj *xlo=new XLinkObj (mc->getCanvas());
+	if (!a.value( "color").isEmpty() ) 
+	{
+		col.setNamedColor(a.value("color"));
+		xlo->setColor (col);
+	}
+
+	if (!a.value( "width").isEmpty() ) 
+	{
+		xlo->setWidth(a.value ("width").toInt (&okx, 10));
+	}
+
+	if (!a.value( "beginBranch").isEmpty() ) 
+	{
+		if (!a.value( "endBranch").isEmpty() ) 
+		{
+			LinkableMapObj *lmo=mc->findObjBySelect (a.value( "beginBranch"));
+			if (lmo && typeid (*lmo)==typeid (BranchObj))
+			{
+				xlo->setBegin ((BranchObj*)(lmo));
+				lmo=mc->findObjBySelect (a.value( "endBranch"));
+				if (lmo && typeid (*lmo)==typeid (BranchObj))
+				{
+					xlo->setEnd ((BranchObj*)(lmo));
+					xlo->activate();
+				}
+			}
+			success=true; // Not all branches there yet, no error
+		}           
+	}	
+	if (!success) delete (xlo);
+	return success;
+}
+
 bool mapBuilderHandler::readHtmlAttr (const QXmlAttributes& a)
 {
 	for (int i=1; i<=a.count(); i++)