Added center function
authorinsilmaril
Wed, 20 Jun 2007 11:58:47 +0000
changeset 526eacf1b165d2d
parent 525 a4df85cb3fe9
child 527 f19bbd639726
Added center function
mainwindow.cpp
mainwindow.h
mapeditor.cpp
mapeditor.h
tex/vym.changelog
version.h
     1.1 --- a/mainwindow.cpp	Wed Jun 20 11:58:47 2007 +0000
     1.2 +++ b/mainwindow.cpp	Wed Jun 20 11:58:47 2007 +0000
     1.3 @@ -958,6 +958,13 @@
     1.4  	viewMenu->addAction (a);
     1.5      connect( a, SIGNAL( triggered() ), this, SLOT( viewZoomOut() ) );
     1.6  
     1.7 +    a = new QAction( QPixmap(iconPath+"viewshowsel.png"), tr( "Show selection","View action" ), this);
     1.8 +	a->setStatusTip (tr( "Show selection" ));
     1.9 +	a->setShortcut (Qt::Key_Period);
    1.10 +    a->addTo( tb );
    1.11 +	viewMenu->addAction (a);
    1.12 +    connect( a, SIGNAL( triggered() ), this, SLOT( viewCenter() ) );
    1.13 +
    1.14  	viewMenu->addSeparator();	
    1.15  
    1.16      a = new QAction(QPixmap(flagsPath+"flag-note.png"), tr( "Show Note Editor","View action" ),this);
    1.17 @@ -1652,48 +1659,6 @@
    1.18  	if (actionViewToggleNoteEditor->isOn()) textEditor->showNormal();
    1.19  }
    1.20  
    1.21 -bool Main::reallyWriteDirectory(const QString &dir)
    1.22 -{
    1.23 -	QStringList eList = QDir(dir).entryList();
    1.24 -	if (eList.first() ==".")  eList.pop_front();	// remove "."
    1.25 -	if (eList.first() =="..") eList.pop_front();	// remove "."
    1.26 -	if (!eList.isEmpty())
    1.27 -	{
    1.28 -		QMessageBox mb( vymName,
    1.29 -			tr("The directory %1 is not empty.\nDo you risk to overwrite its contents?","write directory").arg(dir),
    1.30 -		QMessageBox::Warning,
    1.31 -		QMessageBox::Yes ,
    1.32 -		QMessageBox::Cancel | QMessageBox::Default,
    1.33 -		QMessageBox::QMessageBox::NoButton );
    1.34 -
    1.35 -		mb.setButtonText( QMessageBox::Yes, tr("Overwrite") );
    1.36 -		mb.setButtonText( QMessageBox::No, tr("Cancel"));
    1.37 -		switch( mb.exec() ) 
    1.38 -		{
    1.39 -			case QMessageBox::Yes:
    1.40 -				// save 
    1.41 -				return true;
    1.42 -			case QMessageBox::Cancel:
    1.43 -				// do nothing
    1.44 -				return false;
    1.45 -		}
    1.46 -	}
    1.47 -	return true;
    1.48 -}
    1.49 -
    1.50 -QString Main::browseDirectory (const QString &caption)
    1.51 -{
    1.52 -	QFileDialog fd(this,caption);
    1.53 -	fd.setMode (QFileDialog::DirectoryOnly);
    1.54 -	fd.setCaption(vymName+ " - "+caption);
    1.55 -	fd.setDir (lastFileDir);
    1.56 -	fd.show();
    1.57 -	
    1.58 -	if ( fd.exec() == QDialog::Accepted )
    1.59 -		return fd.selectedFile();
    1.60 -	else
    1.61 -		return "";
    1.62 -}
    1.63  
    1.64  MapEditor* Main::currentMapEditor() const
    1.65  {
    1.66 @@ -2292,14 +2257,10 @@
    1.67  		currentMapEditor()->importDir();	
    1.68  }
    1.69  
    1.70 -void Main::fileExportXML()	//FIXME not scriptable yet
    1.71 +void Main::fileExportXML()	
    1.72  {
    1.73 -	if (currentMapEditor())
    1.74 -	{
    1.75 -		QString dir=browseDirectory(tr("Export XML to directory"));
    1.76 -		if (dir !="" && reallyWriteDirectory(dir) )
    1.77 -			currentMapEditor()->exportXML(dir);
    1.78 -	}	
    1.79 +	MapEditor *me=currentMapEditor();
    1.80 +	if (me) me->exportXML();
    1.81  }
    1.82  
    1.83  
    1.84 @@ -3186,6 +3147,15 @@
    1.85  	}	
    1.86  }
    1.87  
    1.88 +void Main::viewCenter()
    1.89 +{
    1.90 +	MapEditor *me=currentMapEditor();
    1.91 +	if (me)
    1.92 +	{
    1.93 +		me->ensureSelectionVisible();
    1.94 +	}	
    1.95 +}
    1.96 +
    1.97  bool Main::settingsPDF()
    1.98  {
    1.99  	// Default browser is set in constructor
     2.1 --- a/mainwindow.h	Wed Jun 20 11:58:47 2007 +0000
     2.2 +++ b/mainwindow.h	Wed Jun 20 11:58:47 2007 +0000
     2.3 @@ -53,8 +53,6 @@
     2.4      void setupMacros();
     2.5  	void hideEvent (QHideEvent * );
     2.6  	void showEvent (QShowEvent * );
     2.7 -	bool reallyWriteDirectory(const QString&);
     2.8 -	QString browseDirectory(const QString&);
     2.9  	MapEditor* currentMapEditor() const;
    2.10      
    2.11  private slots:
    2.12 @@ -166,6 +164,7 @@
    2.13      void viewZoomReset();
    2.14      void viewZoomIn();
    2.15      void viewZoomOut();
    2.16 +    void viewCenter();
    2.17  
    2.18  public slots:
    2.19  	bool settingsPDF();
    2.20 @@ -305,6 +304,7 @@
    2.21  	QAction *actionViewTogglePropertyWindow;
    2.22  	QAction *actionViewToggleAntiAlias;
    2.23  	QAction *actionViewToggleSmoothPixmapTransform;
    2.24 +	QAction* actionViewCenter;
    2.25  
    2.26  	QAction* actionSettingsAutoEdit;
    2.27  	QAction* actionSettingsAutoSelectHeading;
     3.1 --- a/mapeditor.cpp	Wed Jun 20 11:58:47 2007 +0000
     3.2 +++ b/mapeditor.cpp	Wed Jun 20 11:58:47 2007 +0000
     3.3 @@ -719,6 +719,21 @@
     3.4  			exportXHTML (fname,false);
     3.5  		}
     3.6  	/////////////////////////////////////////////////////////////////////
     3.7 +	} else if (com=="exportXML")
     3.8 +	{
     3.9 +		QString fname="";
    3.10 +		ok=true;
    3.11 +		if (parser.parCount()>=2)
    3.12 +			// Hey, we even have a filename
    3.13 +			fname=parser.parString(ok,1); 
    3.14 +		if (!ok)
    3.15 +		{
    3.16 +			parser.setError (Aborted,"Could not read filename");
    3.17 +		} else
    3.18 +		{
    3.19 +			exportXML (fname,false);
    3.20 +		}
    3.21 +	/////////////////////////////////////////////////////////////////////
    3.22  	} else if (com=="importDir")
    3.23  	{
    3.24  		if (xelection.isEmpty())
    3.25 @@ -1800,6 +1815,7 @@
    3.26  			dia.setFilePath (filePath );
    3.27  			dia.setMapName (mapName );
    3.28  			dia.readSettings();
    3.29 +			if (dir!="") dia.setDir (dir);
    3.30  
    3.31  			bool ok=true;
    3.32  			
    3.33 @@ -1829,14 +1845,21 @@
    3.34  
    3.35  			if (ok)
    3.36  			{
    3.37 -				exportXML (dia.getDir() );
    3.38 +				exportXML (dia.getDir(),false );
    3.39  				dia.doExport(mapName );
    3.40  				//if (dia.hasChanged()) setChanged();
    3.41  			}
    3.42  }
    3.43  
    3.44 -void MapEditor::exportXML(const QString &dir)
    3.45 +void MapEditor::exportXML(QString dir, bool askForName)
    3.46  {
    3.47 +	if (askForName)
    3.48 +	{
    3.49 +		dir=browseDirectory(this,tr("Export XML to directory"));
    3.50 +		if (dir =="" && !reallyWriteDirectory(dir) )
    3.51 +		return;
    3.52 +	}
    3.53 +
    3.54  	// Hide stuff during export, if settings want this
    3.55  	setExportMode (true);
    3.56  
    3.57 @@ -4020,9 +4043,6 @@
    3.58  
    3.59  void MapEditor::testFunction()
    3.60  {
    3.61 -	mainWindow->statusMessage("Biiiiiiiiiiiiiiing!");
    3.62 -	return;
    3.63 -
    3.64  	BranchObj *bo=xelection.getBranch();
    3.65  	if (bo) animObjList.append( bo );
    3.66  	
     4.1 --- a/mapeditor.h	Wed Jun 20 11:58:47 2007 +0000
     4.2 +++ b/mapeditor.h	Wed Jun 20 11:58:47 2007 +0000
     4.3 @@ -151,7 +151,7 @@
     4.4      void exportXHTML(const QString& dir="", bool askForName=true);	
     4.5  
     4.6  	/*! Export as XTML to directory */
     4.7 -    void exportXML(const QString& dir="");
     4.8 +    void exportXML(QString dir="", bool askForName=true);
     4.9  
    4.10      void clear();						//!< Clear map
    4.11      void copy();						//!< Copy to clipboard
     5.1 --- a/tex/vym.changelog	Wed Jun 20 11:58:47 2007 +0000
     5.2 +++ b/tex/vym.changelog	Wed Jun 20 11:58:47 2007 +0000
     5.3 @@ -1,3 +1,10 @@
     5.4 +-------------------------------------------------------------------
     5.5 +Wed Jun 20 13:52:37 CEST 2007 - uwedr
     5.6 +
     5.7 +- Version: 1.8.74
     5.8 +- Feature: Center on selection with "."
     5.9 +- Feature: Most important exports can be scripted now
    5.10 +
    5.11  -------------------------------------------------------------------
    5.12  Mon Jun 18 17:08:46 CEST 2007 - uwedr
    5.13  
     6.1 --- a/version.h	Wed Jun 20 11:58:47 2007 +0000
     6.2 +++ b/version.h	Wed Jun 20 11:58:47 2007 +0000
     6.3 @@ -4,10 +4,10 @@
     6.4  #include <QString>
     6.5  
     6.6  #define __VYM_NAME "VYM"
     6.7 -#define __VYM_VERSION "1.8.73"
     6.8 +#define __VYM_VERSION "1.8.74"
     6.9  //#define __VYM_CODENAME "Codename: 1.9.0-beta-1"
    6.10  #define __VYM_CODENAME "Codename: development version"
    6.11 -#define __VYM_BUILD_DATE "June 19, 2007"
    6.12 +#define __VYM_BUILD_DATE "June 20, 2007"
    6.13  
    6.14  
    6.15  bool checkVersion(const QString &);