scripted exports (continued)
authorinsilmaril
Wed, 20 Jun 2007 10:51:45 +0000
changeset 517b525fdd445c4
parent 516 263988fee2a7
child 518 07f35022646d
scripted exports (continued)
highlighter.cpp
mainwindow.cpp
mapeditor.cpp
mapeditor.h
     1.1 --- a/highlighter.cpp	Wed Jun 20 10:51:45 2007 +0000
     1.2 +++ b/highlighter.cpp	Wed Jun 20 10:51:45 2007 +0000
     1.3 @@ -47,7 +47,8 @@
     1.4  					<< "\\bdelete\\b" 
     1.5  					<< "\\bdeleteKeepChilds\\b" 
     1.6  					<< "\\bdeleteChilds\\b"
     1.7 -					<< "\\bexport\\b"
     1.8 +					<< "\\bexportASCII\\b"
     1.9 +					<< "\\bexportImage\\b"
    1.10  					<< "\\bimportDir\\b"
    1.11  					<< "\\blinkTo\\b" 
    1.12  					<< "\\bloadImage\\b"
     2.1 --- a/mainwindow.cpp	Wed Jun 20 10:51:45 2007 +0000
     2.2 +++ b/mainwindow.cpp	Wed Jun 20 10:51:45 2007 +0000
     2.3 @@ -8,7 +8,6 @@
     2.4  #include "branchpropwindow.h"
     2.5  #include "exportoofiledialog.h"
     2.6  #include "exports.h"
     2.7 -#include "exportxhtmldialog.h"
     2.8  #include "file.h"
     2.9  #include "flagrowobj.h"
    2.10  #include "historywindow.h"
    2.11 @@ -2293,7 +2292,7 @@
    2.12  		currentMapEditor()->importDir();	
    2.13  }
    2.14  
    2.15 -void Main::fileExportXML()
    2.16 +void Main::fileExportXML()	//FIXME not scriptable yet
    2.17  {
    2.18  	if (currentMapEditor())
    2.19  	{
    2.20 @@ -2304,41 +2303,13 @@
    2.21  }
    2.22  
    2.23  
    2.24 -void Main::fileExportXHTML()
    2.25 +void Main::fileExportXHTML()	
    2.26  {
    2.27  	MapEditor *me=currentMapEditor();
    2.28 -	QString dir;
    2.29 -	if (me)
    2.30 -	{
    2.31 -		ExportXHTMLDialog dia(this);
    2.32 -		dia.setFilePath (me->getFilePath() );
    2.33 -		dia.setMapName (me->getMapName() );
    2.34 -		dia.readSettings();
    2.35 -		
    2.36 -		if (dia.exec()==QDialog::Accepted)
    2.37 -		{
    2.38 -			QString dir=dia.getDir();
    2.39 -			// Check, if warnings should be used before overwriting
    2.40 -			// the output directory
    2.41 -			WarningDialog warn;
    2.42 -			warn.showCancelButton (true);
    2.43 -			warn.setText(QString(
    2.44 -				"The directory %1 is not empty.\n"
    2.45 -				"Do you risk to overwrite some of its contents?").arg(dir));
    2.46 -			warn.setCaption("Warning: Directory not empty");
    2.47 -			warn.setShowAgainName("mainwindow/overwrite-dir-xhtml");
    2.48 -			if (warn.exec()==QDialog::Accepted)
    2.49 -			{
    2.50 -				me->exportXML (dia.getDir() );
    2.51 -				dia.doExport(me->getMapName() );
    2.52 -				if (dia.hasChanged())
    2.53 -					me->setChanged();
    2.54 -			}	
    2.55 -		}
    2.56 -	}	
    2.57 +	if (me) me->exportXHTML();
    2.58  }
    2.59  
    2.60 -void Main::fileExportImage()
    2.61 +void Main::fileExportImage()	
    2.62  {
    2.63  	MapEditor *me=currentMapEditor();
    2.64  	if (me) me->exportImage();
    2.65 @@ -2350,7 +2321,7 @@
    2.66  	if (me) me->exportASCII();
    2.67  }
    2.68  
    2.69 -void Main::fileExportCSV()
    2.70 +void Main::fileExportCSV()	//FIXME not scriptable yet
    2.71  {
    2.72  	MapEditor *me=currentMapEditor();
    2.73  	if (me)
    2.74 @@ -2369,7 +2340,7 @@
    2.75  	}
    2.76  }
    2.77  
    2.78 -void Main::fileExportLaTeX()
    2.79 +void Main::fileExportLaTeX()	//FIXME not scriptable yet
    2.80  {
    2.81  	MapEditor *me=currentMapEditor();
    2.82  	if (me)
    2.83 @@ -2388,7 +2359,7 @@
    2.84  	}
    2.85  }
    2.86  
    2.87 -void Main::fileExportKDEBookmarks()
    2.88 +void Main::fileExportKDEBookmarks()	//FIXME not scriptable yet
    2.89  {
    2.90  	ExportKDEBookmarks ex;
    2.91  	MapEditor *me=currentMapEditor();
    2.92 @@ -2399,7 +2370,7 @@
    2.93  	}	
    2.94  }
    2.95  
    2.96 -void Main::fileExportTaskjuggler()
    2.97 +void Main::fileExportTaskjuggler()	//FIXME not scriptable yet
    2.98  {
    2.99  	ExportTaskjuggler ex;
   2.100  	MapEditor *me=currentMapEditor();
   2.101 @@ -2418,7 +2389,7 @@
   2.102  	}	
   2.103  }
   2.104  
   2.105 -void Main::fileExportOOPresentation()
   2.106 +void Main::fileExportOOPresentation()	//FIXME not scriptable yet
   2.107  {
   2.108  	ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office");
   2.109  	// TODO add preview in dialog
     3.1 --- a/mapeditor.cpp	Wed Jun 20 10:51:45 2007 +0000
     3.2 +++ b/mapeditor.cpp	Wed Jun 20 10:51:45 2007 +0000
     3.3 @@ -11,6 +11,7 @@
     3.4  #include "parser.h"
     3.5  #include "editxlinkdialog.h"
     3.6  #include "exports.h"
     3.7 +#include "exportxhtmldialog.h"
     3.8  #include "extrainfodialog.h"
     3.9  #include "file.h"
    3.10  #include "linkablemapobj.h"
    3.11 @@ -668,57 +669,55 @@
    3.12  			deleteChilds();
    3.13  		}	
    3.14  	/////////////////////////////////////////////////////////////////////
    3.15 -	} else if (com=="export")
    3.16 +	} else if (com=="exportASCII")
    3.17  	{
    3.18 -	/*
    3.19 -		if (xelection.isEmpty())
    3.20 +		QString fname="";
    3.21 +		ok=true;
    3.22 +		if (parser.parCount()>=2)
    3.23 +			// Hey, we even have a filename
    3.24 +			fname=parser.parString(ok,1); 
    3.25 +		if (!ok)
    3.26  		{
    3.27 -			parser.setError (Aborted,"Nothing selected");
    3.28 -		} else if (! selb)
    3.29 -		{
    3.30 -			parser.setError (Aborted,"Type of selection is not a branch");
    3.31 -		} else 
    3.32 -	*/
    3.33 -		if (parser.parCount()==0)
    3.34 -		{	
    3.35 -			parser.setError (Aborted,"No output format given");
    3.36 +			parser.setError (Aborted,"Could not read filename");
    3.37  		} else
    3.38  		{
    3.39 -			// At least one parameter, which is the outFormat
    3.40 -			QString outFormat=parser.parString (ok,0);
    3.41 -			if (!ok)
    3.42 +				exportASCII (fname,false);
    3.43 +		}
    3.44 +	/////////////////////////////////////////////////////////////////////
    3.45 +	} else if (com=="exportImage")
    3.46 +	{
    3.47 +		QString fname="";
    3.48 +		ok=true;
    3.49 +		if (parser.parCount()>=2)
    3.50 +			// Hey, we even have a filename
    3.51 +			fname=parser.parString(ok,1); 
    3.52 +		if (!ok)
    3.53 +		{
    3.54 +			parser.setError (Aborted,"Could not read filename");
    3.55 +		} else
    3.56 +		{
    3.57 +			QString format="PNG";
    3.58 +			if (parser.parCount()>2)
    3.59  			{
    3.60 -				parser.setError (Aborted,QString("Unknown export type: %1").arg(outFormat));
    3.61 -			} else
    3.62 -			{
    3.63 -				QString fname="";
    3.64 -				ok=true;
    3.65 -				if (parser.parCount()>=2)
    3.66 -					// Hey, we even have a filename
    3.67 -					fname=parser.parString(ok,1); 
    3.68 -				if (!ok)
    3.69 -				{
    3.70 -					parser.setError (Aborted,"Could not read filename");
    3.71 -				} else
    3.72 -				{
    3.73 -					if (outFormat == "ascii")
    3.74 -					{
    3.75 -						exportASCII (fname,false);
    3.76 -					} else if (outFormat == "image")
    3.77 -					{
    3.78 -						QString format="PNG";
    3.79 -						if (parser.parCount()>2)
    3.80 -						{
    3.81 -							format=parser.parString(ok,2);
    3.82 -						}
    3.83 -						exportImage (fname,false,format);
    3.84 -					} else
    3.85 -					{
    3.86 -						parser.setError (Aborted,QString("Unknown export type: %1").arg(outFormat));
    3.87 -					}
    3.88 -				}
    3.89 +				format=parser.parString(ok,2);
    3.90  			}
    3.91 -		}	
    3.92 +			exportImage (fname,false,format);
    3.93 +		}
    3.94 +	/////////////////////////////////////////////////////////////////////
    3.95 +	} else if (com=="exportXHTML")
    3.96 +	{
    3.97 +		QString fname="";
    3.98 +		ok=true;
    3.99 +		if (parser.parCount()>=2)
   3.100 +			// Hey, we even have a filename
   3.101 +			fname=parser.parString(ok,1); 
   3.102 +		if (!ok)
   3.103 +		{
   3.104 +			parser.setError (Aborted,"Could not read filename");
   3.105 +		} else
   3.106 +		{
   3.107 +			exportXHTML (fname);
   3.108 +		}
   3.109  	/////////////////////////////////////////////////////////////////////
   3.110  	} else if (com=="importDir")
   3.111  	{
   3.112 @@ -1795,7 +1794,47 @@
   3.113  	}
   3.114  }
   3.115  
   3.116 -
   3.117 +void MapEditor::exportXHTML (const QString &dir)
   3.118 +{
   3.119 +			ExportXHTMLDialog dia(this);
   3.120 +			dia.setFilePath (filePath );
   3.121 +			dia.setMapName (mapName );
   3.122 +			dia.readSettings();
   3.123 +			dia.setDir(dir);
   3.124 +
   3.125 +			bool ok=true;
   3.126 +			
   3.127 +			if (dir=="")
   3.128 +			{
   3.129 +				if (dia.exec()!=QDialog::Accepted) 
   3.130 +					ok=false;
   3.131 +				else	
   3.132 +				{
   3.133 +					QDir d (dia.getDir());
   3.134 +					// Check, if warnings should be used before overwriting
   3.135 +					// the output directory
   3.136 +					if (d.exists() && d.count()>0)
   3.137 +					{
   3.138 +						WarningDialog warn;
   3.139 +						warn.showCancelButton (true);
   3.140 +						warn.setText(QString(
   3.141 +							"The directory %1 is not empty.\n"
   3.142 +							"Do you risk to overwrite some of its contents?").arg(d.path() ));
   3.143 +						warn.setCaption("Warning: Directory not empty");
   3.144 +						warn.setShowAgainName("mainwindow/overwrite-dir-xhtml");
   3.145 +
   3.146 +						if (warn.exec()!=QDialog::Accepted) ok=false;
   3.147 +					}
   3.148 +				}	
   3.149 +			}
   3.150 +
   3.151 +			if (ok)
   3.152 +			{
   3.153 +				exportXML (dia.getDir() );
   3.154 +				dia.doExport(mapName );
   3.155 +				//if (dia.hasChanged()) setChanged();
   3.156 +			}
   3.157 +}
   3.158  
   3.159  void MapEditor::exportXML(const QString &dir)
   3.160  {
   3.161 @@ -1824,7 +1863,7 @@
   3.162  	file.close();
   3.163  
   3.164  	// Now write image, too
   3.165 -	exportImage (dir+"/images/"+mapName+".png","PNG");
   3.166 +	exportImage (dir+"/images/"+mapName+".png",false,"PNG");
   3.167  
   3.168  	setExportMode (false);
   3.169  }
     4.1 --- a/mapeditor.h	Wed Jun 20 10:51:45 2007 +0000
     4.2 +++ b/mapeditor.h	Wed Jun 20 10:51:45 2007 +0000
     4.3 @@ -141,7 +141,8 @@
     4.4  	/*! Save as image */
     4.5      void exportImage (QString fname="",bool askForName=true,QString format="PNG");
     4.6      void exportOOPresentation(const QString &,const QString &);	//!< Export as OpenOfficeOrg presentation
     4.7 -    void exportXML(const QString&);		//!< Export as XML to directory
     4.8 +    void exportXHTML(const QString& dir="");//!< Export as XHTML to directory
     4.9 +    void exportXML(const QString& dir="");	//!< Export as XML to directory
    4.10      void clear();						//!< Clear map
    4.11      void copy();						//!< Copy to clipboard
    4.12      void redo();						//!< Redo last action