# HG changeset patch
# User insilmaril
# Date 1182340727 0
# Node ID eacf1b165d2d4b5dcd058aed184b2be386c283d7
# Parent  a4df85cb3fe981760ae78a80b311ecca6cd617eb
Added center function

diff -r a4df85cb3fe9 -r eacf1b165d2d mainwindow.cpp
--- a/mainwindow.cpp	Wed Jun 20 11:58:47 2007 +0000
+++ b/mainwindow.cpp	Wed Jun 20 11:58:47 2007 +0000
@@ -958,6 +958,13 @@
 	viewMenu->addAction (a);
     connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
 
+    a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
+	a->setStatusTip (tr( "Show selection" ));
+	a->setShortcut (Qt::Key_Period);
+    a->addTo( tb );
+	viewMenu->addAction (a);
+    connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
+
 	viewMenu->addSeparator();	
 
     a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
@@ -1652,48 +1659,6 @@
 	if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
 }
 
-bool Main::reallyWriteDirectory(const QString &dir)
-{
-	QStringList eList = QDir(dir).entryList();
-	if (eList.first() ==".")  eList.pop_front();	// remove "."
-	if (eList.first() =="..") eList.pop_front();	// remove "."
-	if (!eList.isEmpty())
-	{
-		QMessageBox mb( vymName,
-			tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?","write directory").arg(dir),
-		QMessageBox::Warning,
-		QMessageBox::Yes ,
-		QMessageBox::Cancel | QMessageBox::Default,
-		QMessageBox::QMessageBox::NoButton );
-
-		mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
-		mb.setButtonText( QMessageBox::No, tr("Cancel"));
-		switch( mb.exec() ) 
-		{
-			case QMessageBox::Yes:
-				// save 
-				return true;
-			case QMessageBox::Cancel:
-				// do nothing
-				return false;
-		}
-	}
-	return true;
-}
-
-QString Main::browseDirectory (const QString &caption)
-{
-	QFileDialog fd(this,caption);
-	fd.setMode (QFileDialog::DirectoryOnly);
-	fd.setCaption(vymName+ " - "+caption);
-	fd.setDir (lastFileDir);
-	fd.show();
-	
-	if ( fd.exec() == QDialog::Accepted )
-		return fd.selectedFile();
-	else
-		return "";
-}
 
 MapEditor* Main::currentMapEditor() const
 {
@@ -2292,14 +2257,10 @@
 		currentMapEditor()->importDir();	
 }
 
-void Main::fileExportXML()	//FIXME not scriptable yet
+void Main::fileExportXML()	
 {
-	if (currentMapEditor())
-	{
-		QString dir=browseDirectory(tr("Export XML to directory"));
-		if (dir !="" && reallyWriteDirectory(dir) )
-			currentMapEditor()->exportXML(dir);
-	}	
+	MapEditor *me=currentMapEditor();
+	if (me) me->exportXML();
 }
 
 
@@ -3186,6 +3147,15 @@
 	}	
 }
 
+void Main::viewCenter()
+{
+	MapEditor *me=currentMapEditor();
+	if (me)
+	{
+		me->ensureSelectionVisible();
+	}	
+}
+
 bool Main::settingsPDF()
 {
 	// Default browser is set in constructor
diff -r a4df85cb3fe9 -r eacf1b165d2d mainwindow.h
--- a/mainwindow.h	Wed Jun 20 11:58:47 2007 +0000
+++ b/mainwindow.h	Wed Jun 20 11:58:47 2007 +0000
@@ -53,8 +53,6 @@
     void setupMacros();
 	void hideEvent (QHideEvent * );
 	void showEvent (QShowEvent * );
-	bool reallyWriteDirectory(const QString&);
-	QString browseDirectory(const QString&);
 	MapEditor* currentMapEditor() const;
     
 private slots:
@@ -166,6 +164,7 @@
     void viewZoomReset();
     void viewZoomIn();
     void viewZoomOut();
+    void viewCenter();
 
 public slots:
 	bool settingsPDF();
@@ -305,6 +304,7 @@
 	QAction *actionViewTogglePropertyWindow;
 	QAction *actionViewToggleAntiAlias;
 	QAction *actionViewToggleSmoothPixmapTransform;
+	QAction* actionViewCenter;
 
 	QAction* actionSettingsAutoEdit;
 	QAction* actionSettingsAutoSelectHeading;
diff -r a4df85cb3fe9 -r eacf1b165d2d mapeditor.cpp
--- a/mapeditor.cpp	Wed Jun 20 11:58:47 2007 +0000
+++ b/mapeditor.cpp	Wed Jun 20 11:58:47 2007 +0000
@@ -719,6 +719,21 @@
 			exportXHTML (fname,false);
 		}
 	/////////////////////////////////////////////////////////////////////
+	} else if (com=="exportXML")
+	{
+		QString fname="";
+		ok=true;
+		if (parser.parCount()>=2)
+			// Hey, we even have a filename
+			fname=parser.parString(ok,1); 
+		if (!ok)
+		{
+			parser.setError (Aborted,"Could not read filename");
+		} else
+		{
+			exportXML (fname,false);
+		}
+	/////////////////////////////////////////////////////////////////////
 	} else if (com=="importDir")
 	{
 		if (xelection.isEmpty())
@@ -1800,6 +1815,7 @@
 			dia.setFilePath (filePath );
 			dia.setMapName (mapName );
 			dia.readSettings();
+			if (dir!="") dia.setDir (dir);
 
 			bool ok=true;
 			
@@ -1829,14 +1845,21 @@
 
 			if (ok)
 			{
-				exportXML (dia.getDir() );
+				exportXML (dia.getDir(),false );
 				dia.doExport(mapName );
 				//if (dia.hasChanged()) setChanged();
 			}
 }
 
-void MapEditor::exportXML(const QString &dir)
+void MapEditor::exportXML(QString dir, bool askForName)
 {
+	if (askForName)
+	{
+		dir=browseDirectory(this,tr("Export XML to directory"));
+		if (dir =="" && !reallyWriteDirectory(dir) )
+		return;
+	}
+
 	// Hide stuff during export, if settings want this
 	setExportMode (true);
 
@@ -4020,9 +4043,6 @@
 
 void MapEditor::testFunction()
 {
-	mainWindow->statusMessage("Biiiiiiiiiiiiiiing!");
-	return;
-
 	BranchObj *bo=xelection.getBranch();
 	if (bo) animObjList.append( bo );
 	
diff -r a4df85cb3fe9 -r eacf1b165d2d mapeditor.h
--- a/mapeditor.h	Wed Jun 20 11:58:47 2007 +0000
+++ b/mapeditor.h	Wed Jun 20 11:58:47 2007 +0000
@@ -151,7 +151,7 @@
     void exportXHTML(const QString& dir="", bool askForName=true);	
 
 	/*! Export as XTML to directory */
-    void exportXML(const QString& dir="");
+    void exportXML(QString dir="", bool askForName=true);
 
     void clear();						//!< Clear map
     void copy();						//!< Copy to clipboard
diff -r a4df85cb3fe9 -r eacf1b165d2d tex/vym.changelog
--- a/tex/vym.changelog	Wed Jun 20 11:58:47 2007 +0000
+++ b/tex/vym.changelog	Wed Jun 20 11:58:47 2007 +0000
@@ -1,3 +1,10 @@
+-------------------------------------------------------------------
+Wed Jun 20 13:52:37 CEST 2007 - uwedr
+
+- Version: 1.8.74
+- Feature: Center on selection with "."
+- Feature: Most important exports can be scripted now
+
 -------------------------------------------------------------------
 Mon Jun 18 17:08:46 CEST 2007 - uwedr
 
diff -r a4df85cb3fe9 -r eacf1b165d2d version.h
--- a/version.h	Wed Jun 20 11:58:47 2007 +0000
+++ b/version.h	Wed Jun 20 11:58:47 2007 +0000
@@ -4,10 +4,10 @@
 #include <QString>
 
 #define __VYM_NAME "VYM"
-#define __VYM_VERSION "1.8.73"
+#define __VYM_VERSION "1.8.74"
 //#define __VYM_CODENAME "Codename: 1.9.0-beta-1"
 #define __VYM_CODENAME "Codename: development version"
-#define __VYM_BUILD_DATE "June 19, 2007"
+#define __VYM_BUILD_DATE "June 20, 2007"
 
 
 bool checkVersion(const QString &);