# HG changeset patch
# User insilmaril
# Date 1237463128 0
# Node ID 54d44ecd609748c18dbcbfc81cd82d2583ddc76b
# Parent  1b4d1ea6ea8cb83f1aaa199f07ce5ef0fa7d942a
ProgressBar during load and more fixes

diff -r 1b4d1ea6ea8c -r 54d44ecd6097 aboutdialog.cpp
--- a/aboutdialog.cpp	Fri Mar 06 15:02:58 2009 +0000
+++ b/aboutdialog.cpp	Thu Mar 19 11:45:28 2009 +0000
@@ -59,6 +59,7 @@
 	"    <li>Brasilian: Amadeu JĂșnior</li>"
 	"    <li>Russion: Anton Olenev</li>"
 	"    <li>Simplified Chinese: Moligaloo</li>"
+	"    <li>Traditional Chinese: Wei-Lun Chao </li>"
 	"  </ul>"
 	"</li>"
 	"<li> Patches"
diff -r 1b4d1ea6ea8c -r 54d44ecd6097 branchobj.cpp
--- a/branchobj.cpp	Fri Mar 06 15:02:58 2009 +0000
+++ b/branchobj.cpp	Thu Mar 19 11:45:28 2009 +0000
@@ -1537,7 +1537,8 @@
 
 void BranchObj::select()	// FIXME try to get rid of this in BO completely
 {
-	// update NoteEditor
+	cout << "BO::select()\n";
+	// update NoteEditor   FIXME do this via VymView::changeSelection
 	textEditor->setText(note.getNote() );
 	QString fnh=note.getFilenameHint();
 	if (fnh!="")
@@ -1550,11 +1551,12 @@
 	// set selected and visible
     LinkableMapObj::select();
 
-    //if (po)	po->setLastSelectedBranch(this);
+    //if (po)	po->setLastSelectedBranch(this);  FIXME needed?
 		
 	// temporary unscroll, if we have scrolled parents somewhere
 	if (parObj) ((BranchObj*)(parObj))->tmpUnscroll();
 
+	/* FIXME moved to vymmodel or vymview...
 	// Show URL and link in statusbar
 	QString status;
 	if (!url.isEmpty()) status+="URL: "+url+"  ";
@@ -1566,6 +1568,7 @@
 
 	// Update actions
 	model->updateActions();
+	*/
 }
 
 void BranchObj::unselect()
diff -r 1b4d1ea6ea8c -r 54d44ecd6097 demos/math.vym
Binary file demos/math.vym has changed
diff -r 1b4d1ea6ea8c -r 54d44ecd6097 demos/vym-projectplan.vym
Binary file demos/vym-projectplan.vym has changed
diff -r 1b4d1ea6ea8c -r 54d44ecd6097 exports.cpp
--- a/exports.cpp	Fri Mar 06 15:02:58 2009 +0000
+++ b/exports.cpp	Thu Mar 19 11:45:28 2009 +0000
@@ -262,11 +262,41 @@
 }
 
 ////////////////////////////////////////////////////////////////////////
-void ExportKDEBookmarks::doExport() 
+void ExportKDE3Bookmarks::doExport() 
 {
 	WarningDialog dia;
 	dia.showCancelButton (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 3"));
+	dia.setShowAgainName("/exports/KDE/overwriteKDEBookmarks");
+	if (dia.exec()==QDialog::Accepted)
+	{
+		model->exportXML(tmpDir.path(),false);
+
+		XSLTProc p;
+		p.setInputFile (tmpDir.path()+"/"+model->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->start( ub);
+		if (!proc->waitForStarted())
+		{
+			QMessageBox::warning(0, 
+				QObject::tr("Warning"),
+				QObject::tr("Couldn't find script %1\nto notifiy Browsers of changed bookmarks.").arg(ub));
+		}	
+	}
+}
+
+////////////////////////////////////////////////////////////////////////
+void ExportKDE4Bookmarks::doExport() 
+{
+	WarningDialog dia;
+	dia.showCancelButton (true);
+	dia.setText(QObject::tr("Exporting the %1 bookmarks will overwrite\nyour existing bookmarks file.").arg("KDE 4"));
 	dia.setCaption(QObject::tr("Warning: Overwriting %1 bookmarks").arg("KDE"));
 	dia.setShowAgainName("/exports/KDE/overwriteKDEBookmarks");
 	if (dia.exec()==QDialog::Accepted)
@@ -275,7 +305,7 @@
 
 		XSLTProc p;
 		p.setInputFile (tmpDir.path()+"/"+model->getMapName()+".xml");
-		p.setOutputFile (tmpDir.home().path()+"/.kde/share/apps/konqueror/bookmarks.xml");
+		p.setOutputFile (tmpDir.home().path()+"/.kde4/share/apps/konqueror/bookmarks.xml");
 		p.setXSLFile (vymBaseDir.path()+"/styles/vym2kdebookmarks.xsl");
 		p.process();
 
diff -r 1b4d1ea6ea8c -r 54d44ecd6097 exports.h
--- a/exports.h	Fri Mar 06 15:02:58 2009 +0000
+++ b/exports.h	Thu Mar 19 11:45:28 2009 +0000
@@ -63,7 +63,14 @@
 };
 
 ///////////////////////////////////////////////////////////////////////
-class ExportKDEBookmarks:public ExportXMLBase
+class ExportKDE3Bookmarks:public ExportXMLBase
+{
+public:
+	virtual void doExport();
+};	
+
+///////////////////////////////////////////////////////////////////////
+class ExportKDE4Bookmarks:public ExportXMLBase
 {
 public:
 	virtual void doExport();
diff -r 1b4d1ea6ea8c -r 54d44ecd6097 flagrowobj.cpp
--- a/flagrowobj.cpp	Fri Mar 06 15:02:58 2009 +0000
+++ b/flagrowobj.cpp	Thu Mar 19 11:45:28 2009 +0000
@@ -295,7 +295,7 @@
 	name=n;
 }
 
-void  FlagRowObj::updateToolbar()
+void  FlagRowObj::updateToolbar()	//FIXME this needs to be changed with VM
 {
 	if (parentRow)
 	{
diff -r 1b4d1ea6ea8c -r 54d44ecd6097 imports.cpp
--- a/imports.cpp	Fri Mar 06 15:02:58 2009 +0000
+++ b/imports.cpp	Thu Mar 19 11:45:28 2009 +0000
@@ -50,7 +50,7 @@
 }
 
 /////////////////////////////////////////////////
-bool ImportKDEBookmarks::transform()
+bool ImportKDE3Bookmarks::transform()
 {
 	transformedFile=tmpDir.path()+"/bookmarks.xml";
 
@@ -63,6 +63,21 @@
 	return true;
 }
 
+/////////////////////////////////////////////////
+bool ImportKDE4Bookmarks::transform()
+{
+	transformedFile=tmpDir.path()+"/bookmarks.xml";
+
+	XSLTProc p;
+	p.setInputFile (tmpDir.home().path()+"/.kde4/share/apps/konqueror/bookmarks.xml");
+	p.setOutputFile (transformedFile);
+	p.setXSLFile (vymBaseDir.path()+"/styles/kdebookmarks2vym.xsl");
+	p.process();
+
+	return true;
+}
+
+
 
 /////////////////////////////////////////////////
 bool ImportFirefoxBookmarks::transform()
diff -r 1b4d1ea6ea8c -r 54d44ecd6097 imports.h
--- a/imports.h	Fri Mar 06 15:02:58 2009 +0000
+++ b/imports.h	Thu Mar 19 11:45:28 2009 +0000
@@ -31,7 +31,13 @@
 };
 
 ///////////////////////////////////////////////////////////////////////
-class ImportKDEBookmarks:public ImportBase
+class ImportKDE3Bookmarks:public ImportBase
+{
+public:
+	bool transform();
+};	
+
+class ImportKDE4Bookmarks:public ImportBase
 {
 public:
 	bool transform();
diff -r 1b4d1ea6ea8c -r 54d44ecd6097 main.cpp
--- a/main.cpp	Fri Mar 06 15:02:58 2009 +0000
+++ b/main.cpp	Thu Mar 19 11:45:28 2009 +0000
@@ -179,6 +179,11 @@
 	m.setIcon (QPixmap (iconPath+"vym-48x48.png"));
 	m.show();
 	m.fileNew();
+
+
+	// Paint Mainwindow first time
+	qApp->processEvents();
+
 	m.loadCmdLine();
 
 	// Run script
diff -r 1b4d1ea6ea8c -r 54d44ecd6097 mainwindow.cpp
--- a/mainwindow.cpp	Fri Mar 06 15:02:58 2009 +0000
+++ b/mainwindow.cpp	Thu Mar 19 11:45:28 2009 +0000
@@ -217,7 +217,12 @@
     if (settings.value( "/mainwindow/showTestMenu",false).toBool()) setupTestActions();
     setupHelpActions();
     
+	// Status bar and progress bar there
     statusBar();
+	progressMax=0;
+	progressBar=new QProgressBar; 
+	progressBar->hide();
+	statusBar()->addPermanentWidget(progressBar);
 
 	restoreState (settings.value("/mainwindow/state",0).toByteArray());
 
@@ -239,7 +244,7 @@
 	settings.setValue( "/version/version", vymVersion );
 	settings.setValue( "/version/builddate", vymBuildDate );
 
-	settings.setValue( "/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
+	settings.setValue( "/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
 	settings.setValue( "/mapeditor/editmode/autoSelectNewBranch",actionSettingsAutoSelectNewBranch->isOn() );
 	settings.setValue( "/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
 	settings.setValue( "/mapeditor/editmode/autoSelectText",actionSettingsAutoSelectText->isOn() );
@@ -254,6 +259,7 @@
 	delete textEditor;
 	delete historyWindow;
 	delete branchPropertyWindow;
+	delete progressBar;
 
 	// Remove temporary directory
 	removeDir (QDir(tmpVymDir));
@@ -280,7 +286,39 @@
 
 void Main::statusMessage(const QString &s)
 {
-	statusBar()->message( s);
+	// Surpress messages while progressbar during 
+	// load is active
+	if (progressMin==progressMax)
+		statusBar()->message( s);
+}
+
+void Main::setProgressMinimum (int min)
+{
+	progressBar->setMinimum(min);
+	progressMin=min;
+}
+
+void Main::setProgressMaximum (int max)
+{
+	progressBar->setMaximum(max);
+	progressMax=max;
+	if (max>0)
+	{
+		statusBar()->addPermanentWidget(progressBar);
+		progressBar->show();
+	}
+}
+
+void Main::setProgressValue (int v)
+{
+	progressBar->setValue (v);
+}
+
+void Main::removeProgressBar()
+{
+	if (progressMax>0)
+		statusBar()->removeWidget(progressBar);
+	progressMax=progressMin=0;
 }
 
 void Main::closeEvent (QCloseEvent* )
@@ -337,10 +375,15 @@
 
 	fileImportMenu = fileMenu->addMenu (tr("Import","File menu"));
 
-	a = new QAction(tr("KDE Bookmarks"), this);
-	a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE bookmarks")));
+	a = new QAction(tr("KDE 3 Bookmarks"), this);
+	a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 3 bookmarks")));
 	a->addTo (fileImportMenu);
-	connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDEBookmarks() ) );
+	connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE3Bookmarks() ) );
+
+	a = new QAction(tr("KDE 4 Bookmarks"), this);
+	a->setStatusTip ( tr( "Import %1","Status tip file menu" ).arg(tr("KDE 4 bookmarks")));
+	a->addTo (fileImportMenu);
+	connect( a, SIGNAL( triggered() ), this, SLOT( fileImportKDE4Bookmarks() ) );
 
     if (settings.value( "/mainwindow/showTestMenu",false).toBool()) 
 	{
@@ -393,9 +436,14 @@
     connect( a, SIGNAL( triggered() ), this, SLOT( fileExportCSV() ) );
 	fileExportMenu->addAction (a);
 
-	a = new QAction( tr("KDE Bookmarks","File menu"), this);
-	a->setStatusTip( tr( "Export as %1").arg(tr("KDE Bookmarks" )));
-	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDEBookmarks() ) );
+	a = new QAction( tr("KDE 3 Bookmarks","File menu"), this);
+	a->setStatusTip( tr( "Export as %1").arg(tr("KDE 3 Bookmarks" )));
+	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE3Bookmarks() ) );
+	fileExportMenu->addAction (a);
+
+	a = new QAction( tr("KDE 4 Bookmarks","File menu"), this);
+	a->setStatusTip( tr( "Export as %1").arg(tr("KDE 4 Bookmarks" )));
+	connect( a, SIGNAL( triggered() ), this, SLOT( fileExportKDE4Bookmarks() ) );
 	fileExportMenu->addAction (a);
 
     a = new QAction( "Taskjuggler...", this );
@@ -1403,7 +1451,7 @@
     a = new QAction( tr( "Autosave","Settings action"), this);
     a->setStatusTip( tr( "Autosave"));
 	a->setToggleAction(true);
-	a->setOn ( settings.value ("/mapeditor/autosave/use",false).toBool());
+	a->setOn ( settings.value ("/mainwindow/autosave/use",false).toBool());
     connect( a, SIGNAL( triggered() ), this, SLOT( settingsAutosaveToggle() ) );
 	settingsMenu->addAction (a);
 	actionSettingsAutosaveToggle=a;
@@ -2065,11 +2113,19 @@
 	fileSaveAs (CompleteMap);
 }
 
-void Main::fileImportKDEBookmarks()
+void Main::fileImportKDE3Bookmarks()
 {
-	ImportKDEBookmarks im;
+	ImportKDE3Bookmarks im;
 	im.transform();
-	if (success==fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
+	if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
+		currentMapEditor()->getModel()->setFilePath ("");
+}
+
+void Main::fileImportKDE4Bookmarks()
+{
+	ImportKDE4Bookmarks im;
+	im.transform();
+	if (aborted!=fileLoad (im.getTransformedFile(),NewMap) && currentMapEditor() )
 		currentMapEditor()->getModel()->setFilePath ("");
 }
 
@@ -2091,7 +2147,7 @@
 		{
 			im.setFile (*it);
 			if (im.transform() && 
-				success==fileLoad (im.getTransformedFile(),NewMap,FreemindMap) && 
+				aborted!=fileLoad (im.getTransformedFile(),NewMap,FreemindMap) && 
 				currentMapEditor() )
 				currentMapEditor()->getModel()->setFilePath ("");
 			++it;
@@ -2229,9 +2285,20 @@
 	}
 }
 
-void Main::fileExportKDEBookmarks()	//FIXME not scriptable yet
+void Main::fileExportKDE3Bookmarks()	//FIXME not scriptable yet
 {
-	ExportKDEBookmarks ex;
+	ExportKDE3Bookmarks ex;
+	VymModel *m=currentModel();
+	if (m)
+	{
+		ex.setModel (m);
+		ex.doExport();
+	}	
+}
+
+void Main::fileExportKDE4Bookmarks()	//FIXME not scriptable yet
+{
+	ExportKDE4Bookmarks ex;
 	VymModel *m=currentModel();
 	if (m)
 	{
@@ -2321,10 +2388,16 @@
 				return;
 			}
 		} 
-		me->close();
 		tabModel.removeAt (tabWidget->currentIndex() );
 		tabWidget->removeTab (tabWidget->currentIndex() );
-        delete me;	// FIXME if event was triggered _in_ ME this causes warning message
+
+		// Remove mapEditor;
+		// Better would be delete (me), but then we could have a Qt error:
+		// "QObject: Do not delete object, 'MapEditor', during its event handler!"
+		// So we only remove data now and call deconstructor when vym closes later
+		// FIXME  this needs to be moved to vymview...   me->clear();
+		// some model->clear is needed to free up memory ...
+
 		updateActions();
 	}
 }
@@ -2792,9 +2865,9 @@
 	dia.setAuthor (m->getAuthor() );
 	dia.setComment(m->getComment() );
 
-/* FIXME no stats at the moment (view dependent...)
 	// Calc some stats
 	QString stats;
+/* FIXME no stats at the moment (view dependent...)
     stats+=tr("%1 items on map\n","Info about map").arg (mapScene->items().size(),6);
 
 	uint b=0;
@@ -2811,13 +2884,13 @@
 		xl+=bo->countXLinks();
 		bo=m->next(bo);
 	}
-    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);
+*/
+    stats+=QString ("%1 branches\n").arg (m->countBranches(),6);
 	dia.setStats (stats);
 
-*/
 	// Finally show dialog
 	if (dia.exec() == QDialog::Accepted)
 	{
@@ -3282,7 +3355,7 @@
 
 void Main::settingsAutosaveToggle()
 {
-	settings.setValue ("/mapeditor/autosave/use",actionSettingsAutosaveToggle->isOn() );
+	settings.setValue ("/mainwindow/autosave/use",actionSettingsAutosaveToggle->isOn() );
 }
 
 void Main::settingsAutosaveTime()
@@ -3291,14 +3364,14 @@
 	int i = QInputDialog::getInteger(
 		this, 
 		tr("QInputDialog::getInteger()"),
-	    tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
+	    tr("Number of seconds before autosave:"), settings.value("/mainwindow/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
 	if (ok)
-		settings.setValue ("/mapeditor/autosave/ms",i * 1000);
+		settings.setValue ("/mainwindow/autosave/ms",i * 1000);
 }
 
 void Main::settingsWriteBackupFileToggle()
 {
-	settings.setValue ("/mapeditor/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
+	settings.setValue ("/mainwindow/writeBackupFile",actionSettingsWriteBackupFile->isOn() );
 }
 
 void Main::settingsToggleAnimation()
diff -r 1b4d1ea6ea8c -r 54d44ecd6097 mainwindow.h
--- a/mainwindow.h	Fri Mar 06 15:02:58 2009 +0000
+++ b/mainwindow.h	Thu Mar 19 11:45:28 2009 +0000
@@ -29,7 +29,17 @@
     Main(QWidget* parent=0, const char* name=0, Qt::WFlags f=0);
     ~Main();
 	void loadCmdLine();
+
+private:
+	QProgressBar *progressBar;
+	int progressMax;
+	int progressMin;
+public:	
 	void statusMessage (const QString &);
+	void setProgressMinimum (int min);
+	void setProgressMaximum (int max);
+	void setProgressValue (int v);
+	void removeProgressBar();
 
 private:
 	VymView* createView (VymModel*);
@@ -77,7 +87,8 @@
 private slots:	
     void fileSaveAs(const SaveMode &);
     void fileSaveAs();
-    void fileImportKDEBookmarks();
+    void fileImportKDE3Bookmarks();
+    void fileImportKDE4Bookmarks();
     void fileImportFirefoxBookmarks();
     void fileImportFreemind();
     void fileImportMM();
@@ -88,7 +99,8 @@
     void fileExportASCII();
     void fileExportCSV();
     void fileExportLaTeX();
-    void fileExportKDEBookmarks();
+    void fileExportKDE3Bookmarks();
+    void fileExportKDE4Bookmarks();
     void fileExportTaskjuggler();
     void fileExportOOPresentation();
     void fileCloseMap();
diff -r 1b4d1ea6ea8c -r 54d44ecd6097 mapeditor.cpp
--- a/mapeditor.cpp	Fri Mar 06 15:02:58 2009 +0000
+++ b/mapeditor.cpp	Thu Mar 19 11:45:28 2009 +0000
@@ -128,10 +128,11 @@
 
 MapEditor::~MapEditor()
 {
-	//cout <<"Destructor MapEditor\n";
-	// tmpMapDir is in tmpVymDir, so it gets removed automagically when vym closes
+	cout <<"Destructor MapEditor for "<<model->getMapName().toStdString()<<endl;
+	// No need to remove tmp files:
+	// tmpMapDir is in tmpVymDir, 
+	// so it gets removed automagically when vym closes
 	
-	//removeDir(QDir(tmpMapDir));	// FIXME check?!?
 	model->unregisterEditor(this);
 }
 
@@ -413,21 +414,21 @@
 		if (model->getSelectedBranch() ) 
 		{
 			// Context Menu on branch or mapcenter
-			model->updateActions();
+			//FIXME model->updateActions(); needed?
 			branchContextMenu->popup(e->globalPos() );
 		} else
 		{
 			if (model->getSelectedFloatImage() )
 			{
 				// Context Menu on floatimage
-				model->updateActions();
+				// model->updateActions(); FIXME needed?
 				floatimageContextMenu->popup(e->globalPos() );
 			}	
 		}	
 	} else 
 	{ // No MapObj found, we are on the Canvas itself
 		// Context Menu on scene
-		model->updateActions();
+		// model->updateActions(); FIXME needed?
 		
 		// Open context menu synchronously to position new mapcenter
 		model->setContextPos (p);
@@ -602,7 +603,7 @@
 			// a button in the toolbar)
 			if (e->button() == Qt::MidButton )
 				model->toggleScroll();
-		model->updateActions();
+		// model->updateActions(); FIXME needed?
 		// FIXME needed? xelection.update();
 	} else 
 	{ // No MapObj found, we are on the scene itself
@@ -946,13 +947,13 @@
 					model->reposition();
 			}
 		}
-		 model->updateSelection();
+		model->updateSelection();  //FIXME needed? at least not after pos of selection has changed...
 		// Finally resize scene, if needed
 		scene()->update();
 		movingObj=NULL;		
 
 		// Just make sure, that actions are still ok,e.g. the move branch up/down buttons...
-		model->updateActions();
+		// model->updateActions(); FIXME neeeded? 
 	} else 
 		// maybe we moved View: set old cursor
 		setCursor (Qt::ArrowCursor);
diff -r 1b4d1ea6ea8c -r 54d44ecd6097 version.h
--- a/version.h	Fri Mar 06 15:02:58 2009 +0000
+++ b/version.h	Thu Mar 19 11:45:28 2009 +0000
@@ -7,7 +7,7 @@
 #define __VYM_VERSION "1.13.0"
 //#define __VYM_CODENAME "Codename: RC-1"
 #define __VYM_CODENAME "Codename: development version"
-#define __VYM_BUILD_DATE "2009-03-06"
+#define __VYM_BUILD_DATE "2009-03-19"
 
 
 bool checkVersion(const QString &);
diff -r 1b4d1ea6ea8c -r 54d44ecd6097 vym.pro
--- a/vym.pro	Fri Mar 06 15:02:58 2009 +0000
+++ b/vym.pro	Thu Mar 19 11:45:28 2009 +0000
@@ -11,6 +11,7 @@
 TRANSLATIONS += lang/vym_fr.ts
 TRANSLATIONS += lang/vym_zh_CN.ts
 TRANSLATIONS += lang/vym_pt_BR.ts
+TRANSLATIONS += lang/vym_zh_TW.ts
 
 # Manifest embedding was suggested by Qt docs somewhere...
 win32: CONFIG += embed_manifest_exe
diff -r 1b4d1ea6ea8c -r 54d44ecd6097 vymmodel.cpp
--- a/vymmodel.cpp	Fri Mar 06 15:02:58 2009 +0000
+++ b/vymmodel.cpp	Thu Mar 19 11:45:28 2009 +0000
@@ -66,7 +66,6 @@
 
 void VymModel::clear() 
 {
-	cout << "VymModel::clear   rows="<<rowCount(index(rootItem))<<endl;	
 	selModel->clearSelection();
 
 	// Remove stuff    
@@ -147,8 +146,6 @@
 
 	hidemode=HideNone;
 
-
-
 	// Network
 	netstate=Offline;
 
@@ -179,6 +176,7 @@
 
 void VymModel::updateActions()	// FIXME  maybe don't update if blockReposition is set
 {
+	cout << "VymModel::updateActions \n";
 	// Tell mainwindow to update states of actions
 	mainWindow->updateActions();
 }
@@ -224,6 +222,7 @@
 		mapAttr+= xml.attribut("author",author) +
 				  xml.attribut("comment",comment) +
 			      xml.attribut("date",getDate()) +
+				  xml.attribut("countBranches", QString().number(countBranches())) +
 		          xml.attribut("backgroundColor", mapScene->backgroundBrush().color().name() ) +
 		          xml.attribut("selectionColor", mapEditor->getSelectionColor().name() ) +
 		          xml.attribut("linkStyle", ls ) +
@@ -889,6 +888,12 @@
 
 void VymModel::autosave()
 {
+	if (filePath=="") 
+	{
+		if (debug)
+			cout << "VymModel::autosave rejected due to missing filePath\n";
+	}
+
 	QDateTime now=QDateTime().currentDateTime();
 
 	// Disable autosave, while we have gone back in history
@@ -899,7 +904,7 @@
 	if (filePath.isEmpty()) return;
 
 
-	if (mapUnsaved &&mapChanged && settings.value ("/autosave/use",true).toBool() )
+	if (mapUnsaved &&mapChanged && settings.value ("/mainwindow/autosave/use",true).toBool() )
 	{
 		if (QFileInfo(filePath).lastModified()<=fileChangedTime) 
 			mainWindow->fileSave (this);
@@ -959,8 +964,12 @@
 
 void VymModel::setChanged()
 {
+	cout << "VM::setChanged()\n";
 	if (!mapChanged)
-		autosaveTimer->start(settings.value("/autosave/ms/",300000).toInt());
+	{
+		autosaveTimer->start(settings.value("/mainwindow/autosave/ms/",300000).toInt());
+		cout <<"   timer started with "<<settings.value("/mainwindow/autosave/ms/",300000).toInt()<<endl;
+	}	
 	mapChanged=true;
 	mapDefault=false;
 	mapUnsaved=true;
@@ -1454,6 +1463,22 @@
 	return QDate::currentDate().toString ("yyyy-MM-dd");
 }
 
+int VymModel::countBranches()	// FIXME Optimize this: use internal counter instead of going through whole map each time...
+{
+	int c=0;
+	TreeItem *cur=NULL;
+	TreeItem *prev=NULL;
+	int d;
+	next(cur,prev,d);
+	while (cur) 
+	{
+		c++;
+		next(cur,prev,d);
+	}
+	return c;
+
+}
+
 void VymModel::setHeading(const QString &s)
 {
 	BranchObj *sel=getSelectedBranch();
@@ -4341,19 +4366,9 @@
 	updateSelection (newsel);
 }
 
-void VymModel::updateSelection(const QItemSelection &)
+void VymModel::updateSelection(const QItemSelection &newsel)
 {
-	QItemSelection newsel=selModel->selection();
-	/*
-	cout << "VM::updateSelection   new=";
-	if (!newsel.indexes().isEmpty() )
-		cout << newsel.indexes().first().row()<<"," << newsel.indexes().first().column();
-	cout << "  old=";
-	if (!oldsel.indexes().isEmpty() )
-		cout << oldsel.indexes().first().row()<<"," << oldsel.indexes().first().column();
-	cout <<endl;
-	*/
-	//emit (selectionChanged(newsel,oldsel));	// FIXME needed?
+	emit (selectionChanged(newsel,newsel));	// needed e.g. to update geometry in editor
 	ensureSelectionVisible();
 	sendSelection();
 }
@@ -4596,9 +4611,6 @@
 		num=QString ("%1").arg(n);
 		s=s+num;
 		
-		cout <<"SP::  s0="<<s.toStdString()<<endl;
-
-
 		// Try to select this one
 		if (n>=0 && select (s)) return;
 
@@ -4634,7 +4646,6 @@
 				s=typ+num;
 			}	
 
-		cout <<"SP::  si="<<s.toStdString()<<endl;
 			if (select(s))
 				// pad to oldDepth, select the last branch for each depth
 				for (i=d;i<oldDepth;i++)
diff -r 1b4d1ea6ea8c -r 54d44ecd6097 vymmodel.h
--- a/vymmodel.h	Fri Mar 06 15:02:58 2009 +0000
+++ b/vymmodel.h	Thu Mar 19 11:45:28 2009 +0000
@@ -229,6 +229,7 @@
 	void setComment (const QString &);
 	QString getComment ();
 	QString getDate();
+	int countBranches();
 
 public:	
 	void setHeading(const QString &);		//!< Set heading of branch	
diff -r 1b4d1ea6ea8c -r 54d44ecd6097 vymview.cpp
--- a/vymview.cpp	Fri Mar 06 15:02:58 2009 +0000
+++ b/vymview.cpp	Thu Mar 19 11:45:28 2009 +0000
@@ -1,6 +1,7 @@
 #include "vymview.h"
 
 #include <iostream>
+using namespace std;
 
 #include "mainwindow.h"
 #include "mapeditor.h"
@@ -8,8 +9,10 @@
 extern Main *mainWindow;
 
 
-VymView::VymView(VymModel *model)
+VymView::VymView(VymModel *m)
 {
+	model=m;
+
 	// Create TreeView
 	treeview=new QTreeView;
 	treeview->setModel ((QAbstractItemModel*)model);
@@ -61,11 +64,28 @@
 }
 
 
-void VymView::changeSelection (const QItemSelection &newSel, const QItemSelection &delSel)
+void VymView::changeSelection (const QItemSelection &, const QItemSelection &)
 {
-	// FIXME Currently this works only from treeview->ME
-	treeview->expandAll();	//FIXME only for testing
+	cout << "VymView::changeSelection (newsel,delsel)\n";
+	//treeview->expandAll();	//FIXME only for testing
 
 	//((VymModel*)treeview->model())->select ();
+
+	// Show URL and link in statusbar
+	QString status;
+	QString s=model->getURL();
+	if (!s.isEmpty() ) status+="URL: "+s+"  ";
+	s=model->getVymLink();
+	if (!s.isEmpty() ) status+="Link: "+s;
+	if (!status.isEmpty() ) mainWindow->statusMessage (status);
+
+/* FIXME, was so far in BranchObj
+	// Update Toolbar
+	//updateFlagsToolbar();
+
+*/
+
+	// Update actions
+	mainWindow->updateActions();
 }
 
diff -r 1b4d1ea6ea8c -r 54d44ecd6097 vymview.h
--- a/vymview.h	Fri Mar 06 15:02:58 2009 +0000
+++ b/vymview.h	Thu Mar 19 11:45:28 2009 +0000
@@ -19,6 +19,7 @@
 	void changeSelection (const QItemSelection &newSel, const QItemSelection &delSel);
 
 private:
+	VymModel *model;
 	QTreeView *treeview;
 	QItemSelectionModel *selModel;
 };
diff -r 1b4d1ea6ea8c -r 54d44ecd6097 xml-vym.cpp
--- a/xml-vym.cpp	Fri Mar 06 15:02:58 2009 +0000
+++ b/xml-vym.cpp	Thu Mar 19 11:45:28 2009 +0000
@@ -9,12 +9,14 @@
 #include "misc.h"
 #include "settings.h"
 #include "linkablemapobj.h"
+#include "mainwindow.h"
 #include "version.h"
 
 static BranchObj *lastBranch;
 static FloatObj *lastFloat;
 static OrnamentedObj *lastOO;
 
+extern Main *mainWindow;
 extern Settings settings;
 extern QString vymVersion;
 
@@ -46,6 +48,7 @@
     if ( state == StateInit && (eName == "vymmap")  ) 
 	{
         state = StateMap;
+		branchesTotal=branchesCurrent=0;
 
 		if (loadMode==NewMap )
 		{
@@ -57,6 +60,23 @@
 				model->setAuthor(atts.value( "author" ) );
 			if (!atts.value( "comment").isEmpty() )
 				model->setComment (atts.value( "comment" ) );
+			if (!atts.value( "countBranches").isEmpty() )
+			{
+				branchesTotal=atts.value("countBranches").toInt();
+				if (branchesTotal>10)
+				{
+					mainWindow->setProgressMinimum (0);
+					mainWindow->setProgressMaximum (branchesTotal);
+					mainWindow->setProgressValue(0);
+				}
+			} else
+			{
+				mainWindow->setProgressMinimum (0);
+				mainWindow->setProgressMaximum (0);
+				mainWindow->setProgressValue(0);
+			}
+
+				
 			if (!atts.value( "backgroundColor").isEmpty() )
 			{
 				col.setNamedColor(atts.value("backgroundColor"));
@@ -264,6 +284,9 @@
 	*/
     switch ( state ) 
 	{
+		case StateMap:
+			mainWindow->removeProgressBar();
+			break;
         case StateBranch: 
 			model->selectParent();
 			lastBranch=model->getSelectedBranch();
@@ -330,6 +353,8 @@
 
 bool parseVYMHandler::readBranchAttr (const QXmlAttributes& a)
 {
+	branchesCurrent++;
+	mainWindow->setProgressValue (branchesCurrent);
 	lastOO=lastBranch;
 	if (!readOOAttr(a)) return false;
 
diff -r 1b4d1ea6ea8c -r 54d44ecd6097 xml-vym.h
--- a/xml-vym.h	Fri Mar 06 15:02:58 2009 +0000
+++ b/xml-vym.h	Thu Mar 19 11:45:28 2009 +0000
@@ -3,7 +3,6 @@
 
 #include "xml-base.h"
 
-
 /*! \brief Parsing VYM maps from XML documents */
 
 class parseVYMHandler  : public parseBaseHandler
@@ -42,8 +41,9 @@
 		StateFloatImage,
 		StateHeading
 	 };
-				 
 
+	 int branchesCurrent;
+	 int branchesTotal;
 
 	State state;			 
 	State laststate;