# HG changeset patch # User insilmaril # Date 1182336705 0 # Node ID b525fdd445c42bb83c72e8601180d88485242bec # Parent 263988fee2a78fd6be6495dbf1d579fd1e978c5c scripted exports (continued) diff -r 263988fee2a7 -r b525fdd445c4 highlighter.cpp --- a/highlighter.cpp Wed Jun 20 10:51:45 2007 +0000 +++ b/highlighter.cpp Wed Jun 20 10:51:45 2007 +0000 @@ -47,7 +47,8 @@ << "\\bdelete\\b" << "\\bdeleteKeepChilds\\b" << "\\bdeleteChilds\\b" - << "\\bexport\\b" + << "\\bexportASCII\\b" + << "\\bexportImage\\b" << "\\bimportDir\\b" << "\\blinkTo\\b" << "\\bloadImage\\b" diff -r 263988fee2a7 -r b525fdd445c4 mainwindow.cpp --- a/mainwindow.cpp Wed Jun 20 10:51:45 2007 +0000 +++ b/mainwindow.cpp Wed Jun 20 10:51:45 2007 +0000 @@ -8,7 +8,6 @@ #include "branchpropwindow.h" #include "exportoofiledialog.h" #include "exports.h" -#include "exportxhtmldialog.h" #include "file.h" #include "flagrowobj.h" #include "historywindow.h" @@ -2293,7 +2292,7 @@ currentMapEditor()->importDir(); } -void Main::fileExportXML() +void Main::fileExportXML() //FIXME not scriptable yet { if (currentMapEditor()) { @@ -2304,41 +2303,13 @@ } -void Main::fileExportXHTML() +void Main::fileExportXHTML() { MapEditor *me=currentMapEditor(); - QString dir; - if (me) - { - ExportXHTMLDialog dia(this); - dia.setFilePath (me->getFilePath() ); - dia.setMapName (me->getMapName() ); - dia.readSettings(); - - if (dia.exec()==QDialog::Accepted) - { - QString dir=dia.getDir(); - // Check, if warnings should be used before overwriting - // the output directory - 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(dir)); - warn.setCaption("Warning: Directory not empty"); - warn.setShowAgainName("mainwindow/overwrite-dir-xhtml"); - if (warn.exec()==QDialog::Accepted) - { - me->exportXML (dia.getDir() ); - dia.doExport(me->getMapName() ); - if (dia.hasChanged()) - me->setChanged(); - } - } - } + if (me) me->exportXHTML(); } -void Main::fileExportImage() +void Main::fileExportImage() { MapEditor *me=currentMapEditor(); if (me) me->exportImage(); @@ -2350,7 +2321,7 @@ if (me) me->exportASCII(); } -void Main::fileExportCSV() +void Main::fileExportCSV() //FIXME not scriptable yet { MapEditor *me=currentMapEditor(); if (me) @@ -2369,7 +2340,7 @@ } } -void Main::fileExportLaTeX() +void Main::fileExportLaTeX() //FIXME not scriptable yet { MapEditor *me=currentMapEditor(); if (me) @@ -2388,7 +2359,7 @@ } } -void Main::fileExportKDEBookmarks() +void Main::fileExportKDEBookmarks() //FIXME not scriptable yet { ExportKDEBookmarks ex; MapEditor *me=currentMapEditor(); @@ -2399,7 +2370,7 @@ } } -void Main::fileExportTaskjuggler() +void Main::fileExportTaskjuggler() //FIXME not scriptable yet { ExportTaskjuggler ex; MapEditor *me=currentMapEditor(); @@ -2418,7 +2389,7 @@ } } -void Main::fileExportOOPresentation() +void Main::fileExportOOPresentation() //FIXME not scriptable yet { ExportOOFileDialog *fd=new ExportOOFileDialog( this,vymName+" - "+tr("Export to")+" Open Office"); // TODO add preview in dialog 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); } diff -r 263988fee2a7 -r b525fdd445c4 mapeditor.h --- a/mapeditor.h Wed Jun 20 10:51:45 2007 +0000 +++ b/mapeditor.h Wed Jun 20 10:51:45 2007 +0000 @@ -141,7 +141,8 @@ /*! Save as image */ void exportImage (QString fname="",bool askForName=true,QString format="PNG"); void exportOOPresentation(const QString &,const QString &); //!< Export as OpenOfficeOrg presentation - void exportXML(const QString&); //!< Export as XML to directory + void exportXHTML(const QString& dir="");//!< Export as XHTML to directory + void exportXML(const QString& dir=""); //!< Export as XML to directory void clear(); //!< Clear map void copy(); //!< Copy to clipboard void redo(); //!< Redo last action