1.1 --- a/exports.cpp Thu Feb 25 11:03:52 2010 +0000
1.2 +++ b/exports.cpp Tue Mar 02 13:59:19 2010 +0000
1.3 @@ -484,7 +484,6 @@
1.4 singularDelimiter=": ";
1.5 noSingulars=true;
1.6 frameURLs=true;
1.7 - useMapColors=true;
1.8 cssFileName="vym.css";
1.9 cssOriginalPath=""; // Is set in VymModel, based on default setting in ExportHTMLDialog
1.10
1.11 @@ -506,7 +505,7 @@
1.12 }
1.13 QString col;
1.14 QString id=model->getSelectString(current);
1.15 - if (useMapColors)
1.16 + if (dia.useTextColor)
1.17 col=QString("style='color:%1'").arg(current->getHeadingColor().name());
1.18 QString s=QString("<span class='vym-branch%1' %2 id='%3'>")
1.19 .arg(current->depth())
1.20 @@ -531,7 +530,7 @@
1.21 s+=quotemeta(current->getHeading());
1.22 s+="</span>";
1.23
1.24 - if (vis)
1.25 + if (vis && dia.useImage)
1.26 imageMap+=QString(" <area shape='rect' coords='%1,%2,%3,%4' href='#%5'>\n")
1.27 .arg(hr.left()-offset.x())
1.28 .arg(hr.top()-offset.y())
1.29 @@ -595,9 +594,39 @@
1.30 cssOriginalPath=p;
1.31 }
1.32
1.33 -void ExportHTML::doExport()
1.34 +void ExportHTML::doExport(bool useDialog)
1.35 {
1.36 - //FIXME-1 check for errors// Copy CSS file
1.37 + // Execute dialog
1.38 + dia.setFilePath (model->getFilePath());
1.39 + dia.setMapName (model->getMapName());
1.40 + dia.readSettings();
1.41 + if (useDialog && dia.exec()!=QDialog::Accepted) return;
1.42 +
1.43 + // Check if destination is not empty
1.44 + QDir d=dia.getDir();
1.45 + // Check, if warnings should be used before overwriting
1.46 + // the output directory
1.47 + if (d.exists() && d.count()>0)
1.48 + {
1.49 + WarningDialog warn;
1.50 + warn.showCancelButton (true);
1.51 + warn.setText(QString(
1.52 + "The directory %1 is not empty.\n"
1.53 + "Do you risk to overwrite some of its contents?").arg(d.path() ));
1.54 + warn.setCaption("Warning: Directory not empty");
1.55 + warn.setShowAgainName("mainwindow/export-XML-overwrite-dir");
1.56 +
1.57 + if (warn.exec()!=QDialog::Accepted)
1.58 + {
1.59 + mainWindow->statusMessage(QString(QObject::tr("Export aborted.")));
1.60 + return;
1.61 + }
1.62 + }
1.63 +
1.64 + setFile (d.path()+"/"+model->getMapName()+".html");
1.65 + setCSSPath( dia.getCSSPath() );
1.66 +
1.67 + // Copy CSS file
1.68 QFile css_src (cssOriginalPath);
1.69 QFile css_dst (outDir.path()+"/"+cssFileName);
1.70 if (!css_src.open ( QIODevice::ReadOnly))
1.71 @@ -631,13 +660,19 @@
1.72 QTextStream ts( &file ); // use LANG decoding here...
1.73 ts.setEncoding (QTextStream::UnicodeUTF8); // Force UTF8
1.74
1.75 + // Hide stuff during export
1.76 + model->setExportMode (true);
1.77 +
1.78 // Write header
1.79 ts<<"<html><title>"+model->getMapName()<<"</title><body>";
1.80 ts<<" <link rel='stylesheet' id='css.stylesheet' href='"<<cssFileName<<"' />\n";
1.81
1.82 // Include image
1.83 - ts<<"<center><img src=\""<<model->getMapName()<<".png\" usemap='#imagemap'></center>\n";
1.84 -
1.85 + if (dia.useImage)
1.86 + {
1.87 + ts<<"<center><img src=\""<<model->getMapName()<<".png\" usemap='#imagemap'></center>\n";
1.88 + model->exportImage (d.path()+"/"+model->getMapName()+".png",false,"PNG");
1.89 + }
1.90
1.91 // Main loop over all mapcenters
1.92 QString s;
1.93 @@ -667,6 +702,16 @@
1.94 </table>\n";
1.95 ts<<"</body></html>";
1.96 file.close();
1.97 +
1.98 + if (!dia.postscript.isEmpty())
1.99 + {
1.100 + Process p;
1.101 + p.runScript (dia.postscript,d.path()+"/"+model->getMapName()+".html");
1.102 + }
1.103 +
1.104 +
1.105 + dia.saveSettings();
1.106 + model->setExportMode (true);
1.107 }
1.108
1.109 ////////////////////////////////////////////////////////////////////////