# HG changeset patch
# User insilmaril
# Date 1204128546 0
# Node ID 3dabc6424d731e93f0c5ba2094f477e0b756825b
# Parent  e524edc45affb2f8717e14263c71453e8fd03e94
autosave fix

diff -r e524edc45aff -r 3dabc6424d73 demos/vym-projectplan.vym
Binary file demos/vym-projectplan.vym has changed
diff -r e524edc45aff -r 3dabc6424d73 mainwindow.cpp
--- a/mainwindow.cpp	Wed Feb 27 16:09:06 2008 +0000
+++ b/mainwindow.cpp	Wed Feb 27 16:09:06 2008 +0000
@@ -1469,18 +1469,15 @@
     a = new QAction( "Test function 1" , this);
     a->setStatusTip( "Call test function 1" );
 	testMenu->addAction (a);
-	//a->setShortcut (Qt::Key_F4 );
     connect( a, SIGNAL( triggered() ), this, SLOT( testFunction1() ) );
 
     a = new QAction( "Test function 2" , this);
     a->setStatusTip( "Call test function 2" );
-	//a->setShortcut (Qt::Key_F4 );
 	testMenu->addAction (a);
     connect( a, SIGNAL( triggered() ), this, SLOT( testFunction2() ) );
 
     a = new QAction( "Command" , this);
     a->setStatusTip( "Enter command to call in editor" );
-	//a->setShortcut (Qt::Key_F5 );
     connect( a, SIGNAL( triggered() ), this, SLOT( testCommand() ) );
 	testMenu->addAction (a);
 }
@@ -1835,70 +1832,14 @@
 		tabWidget->showPage(me);
 		me->viewport()->setFocus();
 
-		// Create temporary directory for packing
-		bool ok;
-		QString tmpZipDir=makeTmpDir (ok,"vym-pack");
-		if (!ok)
-		{
-			QMessageBox::critical( 0, tr( "Critical Load Error" ),
-			   tr("Couldn't create temporary directory before load\n"));
-			return aborted; 
-		}
-
-		// Try to unzip file
-		err=unzipDir (tmpZipDir,fn);
-		if (err==nozip)
-		{
-			mapfile=fn;
-			me->setZipped(false);
-		} else
-		{
-			me->setZipped(true);
-			
-			// Look for mapname.xml
-			mapfile= fn.left(fn.findRev(".",-1,true));
-			mapfile=mapfile.section( '/', -1 );
-			QFile file( tmpZipDir + "/" + mapfile + ".xml");
-			if (!file.exists() )
-			{
-				// mapname.xml does not exist, well, 
-				// maybe someone renamed the mapname.vym file...
-				// Try to find any .xml in the toplevel 
-				// directory of the .vym file
-				QStringList flist=QDir (tmpZipDir).entryList("*.xml");
-				if (flist.count()==1) 
-				{
-					// Only one entry, take this one
-					mapfile=tmpZipDir + "/"+flist.first();
-				} else
-				{
-					for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) 
-						*it=tmpZipDir + "/" + *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...");
-				}	
-					
-				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();
-		}
-
 		if (err!=aborted)
 		{
 			// Save existing filename in case  we import
 			QString fn_org=me->getFilePath();
 
 			// Finally load map into mapEditor
-			me->setFilePath (mapfile,fn);
-			err=me->load(mapfile,lmode,ftype);
+			me->setFilePath (fn);
+			err=me->load(fn,lmode,ftype);
 
 			// Restore old (maybe empty) filepath, if this is an import
 			if (lmode!=NewMap)
@@ -1926,9 +1867,6 @@
 			}	
 			statusBar()->message( "Loaded " + fn, statusbarTime );
 		}	
-
-		// Delete tmpDir
-		removeDir (QDir(tmpZipDir));
 	}
 	return err;
 }
@@ -2000,125 +1938,133 @@
 
 void Main::fileSave(MapEditor *me, const SaveMode &savemode)
 {
+	/* FIXME moved to ME
+	// Error codes
+	ErrorCode err=success;
+
+	QString safeFilePath;
+
+	if (!me) return;
+	bool saveZipped=me->saveZipped();
+
 	// tmp dir for zipping 
 	QString tmpZipDir;
 	
-	// Error codes
-	ErrorCode err=success;
+	*/
 	
-	QString safeFilePath;
-
-	bool saveZipped=me->saveZipped();
-
-	if (me)
-	{
-		QString fn=me->getFilePath();
-		// filename=unnamed, filepath="" in constructor of mapEditor
-		if ( !fn.isEmpty() ) 
-		{	
-			// We have a filepath, go on saving			
-
-			// Look, if we should zip the data:
-			if (!saveZipped)
+
+	if (!me) return;
+
+	// filename=unnamed, filepath="" in constructor of mapEditor
+
+	/* FIXME moved to ME
+	if ( !fn.isEmpty() ) 
+	{	
+		// We have a filepath, go on saving			
+
+		// Look, if we should zip the data:
+		if (!saveZipped)
+		{
+			QMessageBox mb( vymName,
+				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").arg(fn),
+				QMessageBox::Warning,
+				QMessageBox::Yes | QMessageBox::Default,
+				QMessageBox::No ,
+				QMessageBox::Cancel | QMessageBox::Escape);
+			mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
+			mb.setButtonText( QMessageBox::No, tr("uncompressed") );
+			mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
+			switch( mb.exec() ) 
 			{
-				QMessageBox mb( vymName,
-					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").arg(fn),
-					QMessageBox::Warning,
-					QMessageBox::Yes | QMessageBox::Default,
-					QMessageBox::No ,
-					QMessageBox::Cancel | QMessageBox::Escape);
-				mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
-				mb.setButtonText( QMessageBox::No, tr("uncompressed") );
-				mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
-				switch( mb.exec() ) 
+				case QMessageBox::Yes:
+					// save compressed (default file format)
+					saveZipped=true;
+					break;
+				case QMessageBox::No:
+					// save uncompressed
+					saveZipped=false;
+					break;
+				case QMessageBox::Cancel:
+					// do nothing
+					return;
+					break;
+			}
+			me->setZipped (saveZipped);
+		}
+
+		// First backup existing file, we 
+		// don't want to add to old zip archives
+		QFile f(fn);
+		if (f.exists())
+		{
+			if (actionSettingsWriteBackupFile->isOn())
+			{
+				QString bfn(fn + "~");
+				QFile bf(bfn);
+				if (bf.exists() && !bf.remove())
 				{
-					case QMessageBox::Yes:
-						// save compressed (default file format)
-						saveZipped=true;
-						break;
-					case QMessageBox::No:
-						// save uncompressed
-						saveZipped=false;
-						break;
-					case QMessageBox::Cancel:
-						// do nothing
-						return;
-						break;
+					QMessageBox::warning(0, tr("Save Error"),
+										 bfn + tr("\ncould not be removed before saving"));
 				}
-				me->setZipped (saveZipped);
+				else if (!f.rename(bfn))
+				{
+					QMessageBox::warning(0, tr("Save Error"),
+										 fn + tr("\ncould not be renamed before saving"));
+				}
 			}
-
-			// First backup existing file, we 
-			// don't want to add to old zip archives
-			QFile f(fn);
-			if (f.exists())
-            {
-				if (actionSettingsWriteBackupFile->isOn())
-				{
-					QString bfn(fn + "~");
-					QFile bf(bfn);
-					if (bf.exists() && !bf.remove())
-					{
-						QMessageBox::warning(0, tr("Save Error"),
-											 bfn + tr("\ncould not be removed before saving"));
-					}
-					else if (!f.rename(bfn))
-					{
-						QMessageBox::warning(0, tr("Save Error"),
-											 fn + tr("\ncould not be renamed before saving"));
-					}
-				}
-            }
-
-			if (saveZipped)
+		}
+
+		if (saveZipped)
+		{
+			// Create temporary directory for packing
+			bool ok;
+			tmpZipDir=makeTmpDir (ok,"vym-zip");
+			if (!ok)
 			{
-				// Create temporary directory for packing
-				bool ok;
-				tmpZipDir=makeTmpDir (ok,"vym-zip");
-				if (!ok)
-				{
-					QMessageBox::critical( 0, tr( "Critical Load Error" ),
-					   tr("Couldn't create temporary directory before save\n"));
-					return; 
-				}
-
-				safeFilePath=me->getFilePath();
-				me->setFilePath (tmpZipDir+"/"+
-					me->getMapName()+ ".xml",
-					safeFilePath);
-				me->save (savemode);
-				me->setFilePath (safeFilePath);
-				
-				zipDir (tmpZipDir,fn);
-			} // save zipped
-			else
-			{
-				// Save unzipped. 
-				safeFilePath=me->getFilePath();
-				me->setFilePath (fn, safeFilePath);
-				me->save (savemode);
-				me->setFilePath (safeFilePath);
-			} // save zipped 	
-		} // filepath available
+				QMessageBox::critical( 0, tr( "Critical Load Error" ),
+				   tr("Couldn't create temporary directory before save\n"));
+				return; 
+			}
+
+			safeFilePath=me->getFilePath();
+			me->setFilePath (tmpZipDir+"/"+
+				me->getMapName()+ ".xml",
+				safeFilePath);
+			me->save (savemode);
+			me->setFilePath (safeFilePath);
+			
+			zipDir (tmpZipDir,fn);
+		} // save zipped
 		else
 		{
-			// We have  no filepath yet,
-			// call fileSaveAs() now, this will call fileSave() 
-			// again.
-			// First switch to editor
-			tabWidget->setCurrentWidget (me);
-			fileSaveAs(savemode);
-		}
-    }
-
+			// Save unzipped. 
+			safeFilePath=me->getFilePath();
+			me->setFilePath (fn, safeFilePath);
+			me->save (savemode);
+			me->setFilePath (safeFilePath);
+		} // save zipped 	
+	} // filepath available
+	else
+	*/
+	if ( me->getFilePath().isEmpty() ) 
+	{
+		// We have  no filepath yet,
+		// call fileSaveAs() now, this will call fileSave() 
+		// again.
+		// First switch to editor
+		tabWidget->setCurrentWidget (me);
+		fileSaveAs(savemode);
+	}
+
+/* FIXME moved to ME
 	if (saveZipped && !tmpZipDir.isEmpty())
 		// Delete tmpDir
 		removeDir (QDir(tmpZipDir));
-
-	if (err==success)
+*/
+	if (me->save (savemode)==success)
 	{
 		statusBar()->message( 
 			tr("Saved  %1").arg(me->getFilePath()), 
@@ -3438,9 +3384,7 @@
 		tr("QInputDialog::getInteger()"),
 	    tr("Number of seconds before autosave:"), settings.value("/mapeditor/autosave/ms").toInt() / 1000, 10, 10000, 1, &ok);
 	if (ok)
-	{
 		settings.setValue ("/mapeditor/autosave/ms",i * 1000);
-    }	
 }
 
 void Main::settingsWriteBackupFileToggle()
@@ -3801,8 +3745,8 @@
 void Main::testFunction1()
 {
 	if (!currentMapEditor()) return;
-	currentMapEditor()->testFunction1();
-	//editAttribute();
+	//currentMapEditor()->testFunction1();
+	editAttribute();
 }
 
 void Main::testFunction2()
diff -r e524edc45aff -r 3dabc6424d73 mapeditor.cpp
--- a/mapeditor.cpp	Wed Feb 27 16:09:06 2008 +0000
+++ b/mapeditor.cpp	Wed Feb 27 16:09:06 2008 +0000
@@ -145,6 +145,10 @@
 	autosaveTimer=new QTimer (this);
 	connect(autosaveTimer, SIGNAL(timeout()), this, SLOT(autosave()));
 
+	fileChangedTimer=new QTimer (this);
+	fileChangedTimer->start(3000);
+	connect(fileChangedTimer, SIGNAL(timeout()), this, SLOT(fileChanged()));
+
 	// Network
 	netstate=Offline;
 
@@ -185,6 +189,7 @@
 {
 	//cout <<"Destructor MapEditor\n";
 	autosaveTimer->stop();
+	fileChangedTimer->stop();
 
 	// tmpMapDir is in tmpVymDir, so it gets removed automagically when vym closes
 	
@@ -1498,7 +1503,7 @@
 	{
 		filePath=fpath;		// becomes absolute path
 		fileName=fpath;		// gets stripped of path
-		destPath=destname;	// needed for vymlinks
+		destPath=destname;	// needed for vymlinks and during load to reset fileChangedTime
 
 		// If fpath is not an absolute path, complete it
 		filePath=QDir(fpath).absPath();
@@ -1543,7 +1548,8 @@
 	ErrorCode err=success;
 
 	parseBaseHandler *handler;
-	switch (ftype)
+	fileType=ftype;
+	switch (fileType)
 	{
 		case VymMap: handler=new parseVYMHandler; break;
 		case FreemindMap : handler=new parseFreemindHandler; break;
@@ -1575,14 +1581,72 @@
 				QString("Add map %1 to %2").arg(fname).arg(getName(bo)));
 	}	
     
-	QFile file( fname );
+
+	// Create temporary directory for packing
+	bool ok;
+	QString tmpZipDir=makeTmpDir (ok,"vym-pack");
+	if (!ok)
+	{
+		QMessageBox::critical( 0, tr( "Critical Load Error" ),
+		   tr("Couldn't create temporary directory before load\n"));
+		return aborted; 
+	}
+
+	// Try to unzip file
+	err=unzipDir (tmpZipDir,fname);
+	QString xmlfile;
+	if (err==nozip)
+	{
+		xmlfile=fname;
+		zipped=false;
+	} else
+	{
+		zipped=true;
+		
+		// Look for mapname.xml
+		xmlfile= fname.left(fname.findRev(".",-1,true));
+		xmlfile=xmlfile.section( '/', -1 );
+		QFile mfile( tmpZipDir + "/" + xmlfile + ".xml");
+		if (!mfile.exists() )
+		{
+			// mapname.xml does not exist, well, 
+			// maybe someone renamed the mapname.vym file...
+			// Try to find any .xml in the toplevel 
+			// directory of the .vym file
+			QStringList flist=QDir (tmpZipDir).entryList("*.xml");
+			if (flist.count()==1) 
+			{
+				// Only one entry, take this one
+				xmlfile=tmpZipDir + "/"+flist.first();
+			} else
+			{
+				for ( QStringList::Iterator it = flist.begin(); it != flist.end(); ++it ) 
+					*it=tmpZipDir + "/" + *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...");
+			}	
+				
+			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
+			xmlfile=mfile.name();
+	}
+
+	QFile file( xmlfile);
 
 	// I am paranoid: file should exist anyway
 	// according to check in mainwindow.
 	if (!file.exists() )
 	{
 		QMessageBox::critical( 0, tr( "Critical Parse Error" ),
-				   tr("Couldn't open map " +fname)+".");
+				   tr(QString("Couldn't open map %1").arg(file.name())));
 		err=aborted;	
 	} else
 	{
@@ -1607,7 +1671,7 @@
 		file.close();
 		if ( ok ) 
 		{
-			model->reposition();
+			model->reposition();	// FIXME reposition the view instead...
 			xelection.update();
 			if (lmode==NewMap)
 			{
@@ -1616,6 +1680,9 @@
 				mapUnsaved=false;
 				autosaveTimer->stop();
 			}
+
+			// Reset timestamp to check for later updates of file
+			fileChangedTime=QFileInfo (destPath).lastModified();
 		} else 
 		{
 			QMessageBox::critical( 0, tr( "Critical Parse Error" ),
@@ -1625,22 +1692,102 @@
 			// partially read by the parser
 		}	
 	}	
+
+	// Delete tmpDir
+	removeDir (QDir(tmpZipDir));
+
 	updateActions();
 	return err;
 }
 
-int MapEditor::save (const SaveMode &savemode)
-{
+ErrorCode MapEditor::save (const SaveMode &savemode)
+{
+	cout <<"ME::save zipped="<<zipped<<endl;
 	// Create mapName and fileDir
 	makeSubDirs (fileDir);
-	QString fname;
-	if (saveZipped())
+	QString tmpZipDir;
+	QString mapFileName;
+	QString safeFilePath;
+
+	ErrorCode err=success;
+
+	if (zipped)
 		// save as .xml
-		fname=mapName+".xml";
+		mapFileName=mapName+".xml";
 	else
 		// use name given by user, even if he chooses .doc
-		fname=fileName;
-
+		mapFileName=fileName;
+
+	// Look, if we should zip the data:
+	if (!zipped)
+	{
+		QMessageBox mb( vymName,
+			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").arg(filePath),
+			QMessageBox::Warning,
+			QMessageBox::Yes | QMessageBox::Default,
+			QMessageBox::No ,
+			QMessageBox::Cancel | QMessageBox::Escape);
+		mb.setButtonText( QMessageBox::Yes, tr("compressed (vym default)") );
+		mb.setButtonText( QMessageBox::No, tr("uncompressed") );
+		mb.setButtonText( QMessageBox::Cancel, tr("Cancel"));
+		switch( mb.exec() ) 
+		{
+			case QMessageBox::Yes:
+				// save compressed (default file format)
+				zipped=true;
+				break;
+			case QMessageBox::No:
+				// save uncompressed
+				zipped=false;
+				break;
+			case QMessageBox::Cancel:
+				// do nothing
+				return aborted;
+				break;
+		}
+	}
+
+	// First backup existing file, we 
+	// don't want to add to old zip archives
+	QFile f(destPath);
+	if (f.exists())
+	{
+		if ( settings.value ("/mapeditor/writeBackupFile").toBool())
+		{
+			cout << "ME::doing backup...\n";//FIXME
+			QString backupFileName(destPath + "~");
+			QFile backupFile(backupFileName);
+			if (backupFile.exists() && !backupFile.remove())
+			{
+				QMessageBox::warning(0, tr("Save Error"),
+									 tr("%1\ncould not be removed before saving").arg(backupFileName));
+			}
+			else if (!f.rename(backupFileName))
+			{
+				QMessageBox::warning(0, tr("Save Error"),
+									 tr("%1\ncould not be renamed before saving").arg(destPath));
+			}
+		}
+	}
+
+	if (zipped)
+	{
+		// Create temporary directory for packing
+		bool ok;
+		tmpZipDir=makeTmpDir (ok,"vym-zip");
+		if (!ok)
+		{
+			QMessageBox::critical( 0, tr( "Critical Load Error" ),
+			   tr("Couldn't create temporary directory before save\n"));
+			return aborted; 
+		}
+
+		safeFilePath=filePath;
+		setFilePath (tmpZipDir+"/"+ mapName+ ".xml", safeFilePath);
+	} // zipped
 
 	QString saveFile;
 	if (savemode==CompleteMap || xelection.isEmpty())
@@ -1661,11 +1808,27 @@
 		// TODO take care of multiselections
 	}	
 
-	if (!saveStringToDisk(fileDir+fname,saveFile))
-		return 1;
+	if (!saveStringToDisk(fileDir+mapFileName,saveFile))
+	{
+		err=aborted;
+		qWarning ("ME::saveStringToDisk failed!");
+	}
+
+	if (zipped)
+	{
+		// zip
+		if (err==success) err=zipDir (tmpZipDir,destPath);
+
+		// Delete tmpDir
+		removeDir (QDir(tmpZipDir));
+
+		// Restore original filepath outside of tmp zip dir
+		setFilePath (safeFilePath);
+	}
 
 	updateActions();
-	return 0;
+	fileChangedTime=QFileInfo (destPath).lastModified();
+	return err;
 }
 
 void MapEditor::setZipped (bool z)
@@ -3937,7 +4100,7 @@
 				{
 					case QMessageBox::Yes:
 						// save 
-						break;;
+						break;
 					case QMessageBox::Cancel:
 						// do nothing
 						delete (fd);
@@ -5046,13 +5209,65 @@
 
 void MapEditor::autosave()
 {
+	QDateTime now=QDateTime().currentDateTime();
+	/* FIXME debug
+	*/
+	cout << "ME::autosave checking "<<qPrintable(filePath)<<"...\n"; 
+	cout << "fsaved: "<<qPrintable (fileChangedTime.toString())<<endl;
+	cout << "  fnow: "<<qPrintable (QFileInfo(filePath).lastModified().toString())<<endl;
+	cout << "  time: "<<qPrintable (now.toString())<<endl;
 	// Disable autosave, while we have gone back in history
 	int redosAvail=undoSet.readNumEntry (QString("/history/redosAvail"));
 	if (redosAvail>0) return;
 
 
 	if (mapUnsaved &&mapChanged && settings.value ("/mapeditor/autosave/use",true).toBool() )
-		mainWindow->fileSave (this);
+	{
+		if (QFileInfo(filePath).lastModified()<=fileChangedTime) 
+			mainWindow->fileSave (this);
+		else
+			if (debug)
+				cout <<"  ME::autosave  rejected, file on disk is newer than last save.\n"; 
+
+	}	
+}
+
+void MapEditor::fileChanged()
+{
+	// Check if file on disk has changed meanwhile
+	if (!filePath.isEmpty())
+	{
+		QDateTime tmod=QFileInfo (filePath).lastModified();
+		if (tmod>fileChangedTime)
+		{
+			
+			/* FIXME debug message, sometimes there's a glitch in the metrics...
+			cout << "ME::fileChanged()\n" 
+			     << "  last saved:     "<<qPrintable (fileChangedTime.toString())<<endl
+				 << "  last modififed: "<<qPrintable (tmod.toString())<<endl;
+			*/	 
+			// FIXME switch to current mapeditor and finish lineedits...
+			QMessageBox mb( vymName,
+				tr("The file of the map  on disk has changed:\n\n"  
+				   "   %1\n\nDo you want to reload this map with the new file?").arg(filePath),
+				QMessageBox::Question,
+				QMessageBox::Yes ,
+				QMessageBox::Cancel | QMessageBox::Default,
+				QMessageBox::NoButton );
+
+			mb.setButtonText( QMessageBox::Yes, tr("Reload"));
+			mb.setButtonText( QMessageBox::No, tr("Ignore"));
+			switch( mb.exec() ) 
+			{
+				case QMessageBox::Yes:
+					// Reload map
+					load (filePath,NewMap,fileType);
+		        case QMessageBox::Cancel:
+					fileChangedTime=tmod; // allow autosave to overwrite newer file!
+			}
+		}
+	}	
+
 }
 
 
diff -r e524edc45aff -r 3dabc6424d73 mapeditor.h
--- a/mapeditor.h	Wed Feb 27 16:09:06 2008 +0000
+++ b/mapeditor.h	Wed Feb 27 16:09:06 2008 +0000
@@ -164,7 +164,7 @@
     ErrorCode load (QString, const LoadMode &, const FileType& );	// newmap, import/replace selection
 public:
 	/*! \brief Save the map to file */
-    int save(const SaveMode &);	
+    ErrorCode save(const SaveMode &);	
 	void setZipped(bool);		//!< Set or unset compression of map with zip save map zipped
 	bool saveZipped();			//!< True, if file will be saved zipped
     void print();				//!< Print the map
@@ -386,12 +386,15 @@
 	void displayNetworkError (QAbstractSocket::SocketError);
 
 	void autosave ();
+	void fileChanged();
 
 private:
 	State state;				// State of MapEditor
 	QGraphicsScene *mapScene;
 	VymModel *model;					// Vym Map, includding several mapCenters
 	QTimer *autosaveTimer;
+	QTimer *fileChangedTimer;
+	QDateTime fileChangedTime;
 
 	bool adjustCanvasRequested;	// collect requests until end of user event
 	BranchObj *editingBO;		// entering Text into BO
@@ -437,6 +440,7 @@
 
 	bool zipped;				// should map be zipped
 	static	int mapNum;			// unique number for Editor
+	FileType fileType;			// type of file, e.g. vym, freemind...
 	QString fileName;			// short name of file (for tab)
 	QString filePath;			// path to file which will be saved
 	QString fileDir;			// dir where file is saved
diff -r e524edc45aff -r 3dabc6424d73 version.h
--- a/version.h	Wed Feb 27 16:09:06 2008 +0000
+++ b/version.h	Wed Feb 27 16:09:06 2008 +0000
@@ -4,10 +4,10 @@
 #include <QString>
 
 #define __VYM_NAME "VYM"
-#define __VYM_VERSION "1.11.5"
+#define __VYM_VERSION "1.11.6"
 //#define __VYM_CODENAME "Codename: 1.10.0-RC-3"
 #define __VYM_CODENAME "Codename: development version"
-#define __VYM_BUILD_DATE "2008-01-15"
+#define __VYM_BUILD_DATE "2008-02-27"
 
 
 bool checkVersion(const QString &);
diff -r e524edc45aff -r 3dabc6424d73 vym.pro
--- a/vym.pro	Wed Feb 27 16:09:06 2008 +0000
+++ b/vym.pro	Wed Feb 27 16:09:06 2008 +0000
@@ -27,8 +27,9 @@
 	aboutdialog.h \
 	animpoint.h \
 	attribute.h \
+	attributedelegate.h\
+	attributedialog.h \
 	attributewidget.h \
-	attributedialog.h \
 	branchobj.h \
 	branchpropwindow.h\
 	editxlinkdialog.h \
@@ -79,8 +80,9 @@
 	aboutdialog.cpp \
 	animpoint.cpp \
 	attribute.cpp \
+	attributedelegate.cpp \
+	attributedialog.cpp \
 	attributewidget.cpp \
-	attributedialog.cpp \
 	branchobj.cpp \
 	branchpropwindow.cpp \
 	editxlinkdialog.cpp \
diff -r e524edc45aff -r 3dabc6424d73 vymmodel.cpp
--- a/vymmodel.cpp	Wed Feb 27 16:09:06 2008 +0000
+++ b/vymmodel.cpp	Wed Feb 27 16:09:06 2008 +0000
@@ -192,18 +192,6 @@
 // View related
 //////////////////////////////////////////////
 
-	/* FIXME copied from MCO, still needed?
-void VymModel::updateLink()
-{
-	// set childPos to middle of MapCenterObj
-	childPos.setX( clickBox.topLeft().x() + (int)(clickBox.width())/2 );
-	childPos.setY( clickBox.topLeft().y() + (int)(clickBox.height())/2 );
-	parPos=childPos;		
-	for (int i=0; i<branch.size(); ++i)
-		branch.at(i)->updateLink();
-}
-
-*/
 void VymModel::updateRelPositions()
 {
 	for (int i=0; i<mapCenters.count(); i++)
diff -r e524edc45aff -r 3dabc6424d73 xml-vym.cpp
--- a/xml-vym.cpp	Wed Feb 27 16:09:06 2008 +0000
+++ b/xml-vym.cpp	Wed Feb 27 16:09:06 2008 +0000
@@ -144,9 +144,7 @@
 		{	
 			// Really use the found mapcenter as MCO in a new map
 
-			// FIXME not working for multiple mapCenters yet:
-			lastBranch=model->addMapCenter();
-			//lastBranch=model->first();	// avoid empty pointer
+			lastBranch=model->addMapCenter(); 
 		} else
 		{
 			// Treat the found mapcenter as a branch