1.1 --- a/mapeditor.cpp Wed Jun 20 10:51:45 2007 +0000
1.2 +++ b/mapeditor.cpp Wed Jun 20 10:51:45 2007 +0000
1.3 @@ -11,6 +11,7 @@
1.4 #include "parser.h"
1.5 #include "editxlinkdialog.h"
1.6 #include "exports.h"
1.7 +#include "exportxhtmldialog.h"
1.8 #include "extrainfodialog.h"
1.9 #include "file.h"
1.10 #include "linkablemapobj.h"
1.11 @@ -668,57 +669,55 @@
1.12 deleteChilds();
1.13 }
1.14 /////////////////////////////////////////////////////////////////////
1.15 - } else if (com=="export")
1.16 + } else if (com=="exportASCII")
1.17 {
1.18 - /*
1.19 - if (xelection.isEmpty())
1.20 + QString fname="";
1.21 + ok=true;
1.22 + if (parser.parCount()>=2)
1.23 + // Hey, we even have a filename
1.24 + fname=parser.parString(ok,1);
1.25 + if (!ok)
1.26 {
1.27 - parser.setError (Aborted,"Nothing selected");
1.28 - } else if (! selb)
1.29 - {
1.30 - parser.setError (Aborted,"Type of selection is not a branch");
1.31 - } else
1.32 - */
1.33 - if (parser.parCount()==0)
1.34 - {
1.35 - parser.setError (Aborted,"No output format given");
1.36 + parser.setError (Aborted,"Could not read filename");
1.37 } else
1.38 {
1.39 - // At least one parameter, which is the outFormat
1.40 - QString outFormat=parser.parString (ok,0);
1.41 - if (!ok)
1.42 + exportASCII (fname,false);
1.43 + }
1.44 + /////////////////////////////////////////////////////////////////////
1.45 + } else if (com=="exportImage")
1.46 + {
1.47 + QString fname="";
1.48 + ok=true;
1.49 + if (parser.parCount()>=2)
1.50 + // Hey, we even have a filename
1.51 + fname=parser.parString(ok,1);
1.52 + if (!ok)
1.53 + {
1.54 + parser.setError (Aborted,"Could not read filename");
1.55 + } else
1.56 + {
1.57 + QString format="PNG";
1.58 + if (parser.parCount()>2)
1.59 {
1.60 - parser.setError (Aborted,QString("Unknown export type: %1").arg(outFormat));
1.61 - } else
1.62 - {
1.63 - QString fname="";
1.64 - ok=true;
1.65 - if (parser.parCount()>=2)
1.66 - // Hey, we even have a filename
1.67 - fname=parser.parString(ok,1);
1.68 - if (!ok)
1.69 - {
1.70 - parser.setError (Aborted,"Could not read filename");
1.71 - } else
1.72 - {
1.73 - if (outFormat == "ascii")
1.74 - {
1.75 - exportASCII (fname,false);
1.76 - } else if (outFormat == "image")
1.77 - {
1.78 - QString format="PNG";
1.79 - if (parser.parCount()>2)
1.80 - {
1.81 - format=parser.parString(ok,2);
1.82 - }
1.83 - exportImage (fname,false,format);
1.84 - } else
1.85 - {
1.86 - parser.setError (Aborted,QString("Unknown export type: %1").arg(outFormat));
1.87 - }
1.88 - }
1.89 + format=parser.parString(ok,2);
1.90 }
1.91 - }
1.92 + exportImage (fname,false,format);
1.93 + }
1.94 + /////////////////////////////////////////////////////////////////////
1.95 + } else if (com=="exportXHTML")
1.96 + {
1.97 + QString fname="";
1.98 + ok=true;
1.99 + if (parser.parCount()>=2)
1.100 + // Hey, we even have a filename
1.101 + fname=parser.parString(ok,1);
1.102 + if (!ok)
1.103 + {
1.104 + parser.setError (Aborted,"Could not read filename");
1.105 + } else
1.106 + {
1.107 + exportXHTML (fname);
1.108 + }
1.109 /////////////////////////////////////////////////////////////////////
1.110 } else if (com=="importDir")
1.111 {
1.112 @@ -1795,7 +1794,47 @@
1.113 }
1.114 }
1.115
1.116 -
1.117 +void MapEditor::exportXHTML (const QString &dir)
1.118 +{
1.119 + ExportXHTMLDialog dia(this);
1.120 + dia.setFilePath (filePath );
1.121 + dia.setMapName (mapName );
1.122 + dia.readSettings();
1.123 + dia.setDir(dir);
1.124 +
1.125 + bool ok=true;
1.126 +
1.127 + if (dir=="")
1.128 + {
1.129 + if (dia.exec()!=QDialog::Accepted)
1.130 + ok=false;
1.131 + else
1.132 + {
1.133 + QDir d (dia.getDir());
1.134 + // Check, if warnings should be used before overwriting
1.135 + // the output directory
1.136 + if (d.exists() && d.count()>0)
1.137 + {
1.138 + WarningDialog warn;
1.139 + warn.showCancelButton (true);
1.140 + warn.setText(QString(
1.141 + "The directory %1 is not empty.\n"
1.142 + "Do you risk to overwrite some of its contents?").arg(d.path() ));
1.143 + warn.setCaption("Warning: Directory not empty");
1.144 + warn.setShowAgainName("mainwindow/overwrite-dir-xhtml");
1.145 +
1.146 + if (warn.exec()!=QDialog::Accepted) ok=false;
1.147 + }
1.148 + }
1.149 + }
1.150 +
1.151 + if (ok)
1.152 + {
1.153 + exportXML (dia.getDir() );
1.154 + dia.doExport(mapName );
1.155 + //if (dia.hasChanged()) setChanged();
1.156 + }
1.157 +}
1.158
1.159 void MapEditor::exportXML(const QString &dir)
1.160 {
1.161 @@ -1824,7 +1863,7 @@
1.162 file.close();
1.163
1.164 // Now write image, too
1.165 - exportImage (dir+"/images/"+mapName+".png","PNG");
1.166 + exportImage (dir+"/images/"+mapName+".png",false,"PNG");
1.167
1.168 setExportMode (false);
1.169 }