aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2014-06-10 08:02:55 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-12 12:42:35 -0700
commit748198891d380858ef8338fac3279b8eaa13d75a (patch)
tree2380c8e7ff10f6c68a2ade5e0fa5d7b8ee124fe0
parent21be237b0e5608dc506bb0a09dcf8000c5a821ca (diff)
downloadsubsurface-748198891d380858ef8338fac3279b8eaa13d75a.tar.gz
Much needed clean on the HTML export dialog code.
Correct usage of QFile, QString and code cleanup. [Dirk Hohndel: plus whitespace cleanup and removal of qDebug() calls] Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/divelogexportdialog.cpp46
-rw-r--r--qt-ui/divelogexportdialog.h4
2 files changed, 17 insertions, 33 deletions
diff --git a/qt-ui/divelogexportdialog.cpp b/qt-ui/divelogexportdialog.cpp
index 84be70be5..21768c77e 100644
--- a/qt-ui/divelogexportdialog.cpp
+++ b/qt-ui/divelogexportdialog.cpp
@@ -5,6 +5,7 @@
#include <QTextStream>
#include <QSettings>
#include <QDir>
+#include <QDebug>
#include "mainwindow.h"
#include "divelogexportdialog.h"
@@ -15,7 +16,7 @@
#include "helpers.h"
DiveLogExportDialog::DiveLogExportDialog(QWidget *parent) : QDialog(parent),
- ui(new Ui::DiveLogExportDialog)
+ ui(new Ui::DiveLogExportDialog)
{
ui->setupUi(this);
showExplanation();
@@ -66,52 +67,35 @@ void DiveLogExportDialog::showExplanation()
}
}
-void DiveLogExportDialog::exportHtmlInit(QString filename)
+void DiveLogExportDialog::exportHtmlInit(const QString &filename)
{
QDir dir(filename);
if (!dir.exists()) {
- /* I think this will not work as expected on windows */
- QDir::home().mkpath(filename);
+ dir.mkpath(filename);
}
QString json_dive_data = filename + QDir::separator() + "file.json";
- QString json_settings = filename + "/settings.json";
+ QString json_settings = filename + QDir::separator() + "settings.json";
exportHTMLsettings(json_settings);
export_HTML(json_dive_data.toUtf8().data(), ui->exportSelectedDives->isChecked());
QString searchPath = getSubsurfaceDataPath("theme");
if (searchPath.isEmpty())
- return;
+ return;
- QFile *tmpFile;
+ searchPath += QDir::separator();
+ QString dirname = filename + QDir::separator();
- tmpFile = new QFile(searchPath + "/dive_export.html");
- tmpFile->copy(filename + "/dive_export.html");
- delete tmpFile;
-
- tmpFile = new QFile(searchPath + "/list_lib.js");
- tmpFile->copy(filename + "/list_lib.js");
- delete tmpFile;
-
- tmpFile = new QFile(searchPath + "/poster.png");
- tmpFile->copy(filename + "/poster.png");
- delete tmpFile;
-
- tmpFile = new QFile(searchPath + "/index.html");
- tmpFile->copy(filename + "/index.html");
- delete tmpFile;
-
- if (ui->themeSelection->currentText() == "Light") {
- tmpFile = new QFile(searchPath + "/light.css");
- } else {
- tmpFile = new QFile(searchPath + "/sand.css");
- }
- tmpFile->copy(filename + "/theme.css");
- delete tmpFile;
+ QFile::copy(searchPath + "dive_export.html", dirname + "dive_export.html");
+ QFile::copy(searchPath + "list_lib.js", dirname + "list_lib.js");
+ QFile::copy(searchPath + "poster.png", dirname + "poster.png");
+ QFile::copy(searchPath + "index.html", dirname + "index.html");
+ QFile::copy(searchPath + ui->themeSelection->currentText() == "Light" ? "light.css" : "sand.css",
+ filename + "theme.css");
}
-void DiveLogExportDialog::exportHTMLsettings(QString filename)
+void DiveLogExportDialog::exportHTMLsettings(const QString &filename)
{
QSettings settings;
settings.beginGroup("HTML");
diff --git a/qt-ui/divelogexportdialog.h b/qt-ui/divelogexportdialog.h
index 8322fa1d1..fc1bfd335 100644
--- a/qt-ui/divelogexportdialog.h
+++ b/qt-ui/divelogexportdialog.h
@@ -23,8 +23,8 @@ slots:
private:
Ui::DiveLogExportDialog *ui;
void showExplanation();
- void exportHtmlInit(QString filename);
- void exportHTMLsettings(QString filename);
+ void exportHtmlInit(const QString& filename);
+ void exportHTMLsettings(const QString& filename);
};
#endif // DIVELOGEXPORTDIALOG_H