diff -r 263988fee2a7 -r b525fdd445c4 mapeditor.cpp --- a/mapeditor.cpp Wed Jun 20 10:51:45 2007 +0000 +++ b/mapeditor.cpp Wed Jun 20 10:51:45 2007 +0000 @@ -11,6 +11,7 @@ #include "parser.h" #include "editxlinkdialog.h" #include "exports.h" +#include "exportxhtmldialog.h" #include "extrainfodialog.h" #include "file.h" #include "linkablemapobj.h" @@ -668,57 +669,55 @@ deleteChilds(); } ///////////////////////////////////////////////////////////////////// - } else if (com=="export") + } else if (com=="exportASCII") { - /* - if (xelection.isEmpty()) + QString fname=""; + ok=true; + if (parser.parCount()>=2) + // Hey, we even have a filename + fname=parser.parString(ok,1); + if (!ok) { - parser.setError (Aborted,"Nothing selected"); - } else if (! selb) - { - parser.setError (Aborted,"Type of selection is not a branch"); - } else - */ - if (parser.parCount()==0) - { - parser.setError (Aborted,"No output format given"); + parser.setError (Aborted,"Could not read filename"); } else { - // At least one parameter, which is the outFormat - QString outFormat=parser.parString (ok,0); - if (!ok) + exportASCII (fname,false); + } + ///////////////////////////////////////////////////////////////////// + } else if (com=="exportImage") + { + 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 + { + QString format="PNG"; + if (parser.parCount()>2) { - parser.setError (Aborted,QString("Unknown export type: %1").arg(outFormat)); - } else - { - 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 - { - if (outFormat == "ascii") - { - exportASCII (fname,false); - } else if (outFormat == "image") - { - QString format="PNG"; - if (parser.parCount()>2) - { - format=parser.parString(ok,2); - } - exportImage (fname,false,format); - } else - { - parser.setError (Aborted,QString("Unknown export type: %1").arg(outFormat)); - } - } + format=parser.parString(ok,2); } - } + exportImage (fname,false,format); + } + ///////////////////////////////////////////////////////////////////// + } else if (com=="exportXHTML") + { + 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 + { + exportXHTML (fname); + } ///////////////////////////////////////////////////////////////////// } else if (com=="importDir") { @@ -1795,7 +1794,47 @@ } } - +void MapEditor::exportXHTML (const QString &dir) +{ + ExportXHTMLDialog dia(this); + dia.setFilePath (filePath ); + dia.setMapName (mapName ); + dia.readSettings(); + dia.setDir(dir); + + bool ok=true; + + if (dir=="") + { + if (dia.exec()!=QDialog::Accepted) + ok=false; + else + { + QDir d (dia.getDir()); + // Check, if warnings should be used before overwriting + // the output directory + if (d.exists() && d.count()>0) + { + WarningDialog warn; + warn.showCancelButton (true); + warn.setText(QString( + "The directory %1 is not empty.\n" + "Do you risk to overwrite some of its contents?").arg(d.path() )); + warn.setCaption("Warning: Directory not empty"); + warn.setShowAgainName("mainwindow/overwrite-dir-xhtml"); + + if (warn.exec()!=QDialog::Accepted) ok=false; + } + } + } + + if (ok) + { + exportXML (dia.getDir() ); + dia.doExport(mapName ); + //if (dia.hasChanged()) setChanged(); + } +} void MapEditor::exportXML(const QString &dir) { @@ -1824,7 +1863,7 @@ file.close(); // Now write image, too - exportImage (dir+"/images/"+mapName+".png","PNG"); + exportImage (dir+"/images/"+mapName+".png",false,"PNG"); setExportMode (false); }