mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
21be237b0e
commit
748198891d
2 changed files with 17 additions and 33 deletions
|
|
@ -5,6 +5,7 @@
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "divelogexportdialog.h"
|
#include "divelogexportdialog.h"
|
||||||
|
|
@ -66,16 +67,15 @@ void DiveLogExportDialog::showExplanation()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveLogExportDialog::exportHtmlInit(QString filename)
|
void DiveLogExportDialog::exportHtmlInit(const QString &filename)
|
||||||
{
|
{
|
||||||
QDir dir(filename);
|
QDir dir(filename);
|
||||||
if (!dir.exists()) {
|
if (!dir.exists()) {
|
||||||
/* I think this will not work as expected on windows */
|
dir.mkpath(filename);
|
||||||
QDir::home().mkpath(filename);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString json_dive_data = filename + QDir::separator() + "file.json";
|
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);
|
exportHTMLsettings(json_settings);
|
||||||
export_HTML(json_dive_data.toUtf8().data(), ui->exportSelectedDives->isChecked());
|
export_HTML(json_dive_data.toUtf8().data(), ui->exportSelectedDives->isChecked());
|
||||||
|
|
@ -84,34 +84,18 @@ void DiveLogExportDialog::exportHtmlInit(QString filename)
|
||||||
if (searchPath.isEmpty())
|
if (searchPath.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QFile *tmpFile;
|
searchPath += QDir::separator();
|
||||||
|
QString dirname = filename + QDir::separator();
|
||||||
|
|
||||||
tmpFile = new QFile(searchPath + "/dive_export.html");
|
QFile::copy(searchPath + "dive_export.html", dirname + "dive_export.html");
|
||||||
tmpFile->copy(filename + "/dive_export.html");
|
QFile::copy(searchPath + "list_lib.js", dirname + "list_lib.js");
|
||||||
delete tmpFile;
|
QFile::copy(searchPath + "poster.png", dirname + "poster.png");
|
||||||
|
QFile::copy(searchPath + "index.html", dirname + "index.html");
|
||||||
tmpFile = new QFile(searchPath + "/list_lib.js");
|
QFile::copy(searchPath + ui->themeSelection->currentText() == "Light" ? "light.css" : "sand.css",
|
||||||
tmpFile->copy(filename + "/list_lib.js");
|
filename + "theme.css");
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DiveLogExportDialog::exportHTMLsettings(QString filename)
|
void DiveLogExportDialog::exportHTMLsettings(const QString &filename)
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
settings.beginGroup("HTML");
|
settings.beginGroup("HTML");
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@ slots:
|
||||||
private:
|
private:
|
||||||
Ui::DiveLogExportDialog *ui;
|
Ui::DiveLogExportDialog *ui;
|
||||||
void showExplanation();
|
void showExplanation();
|
||||||
void exportHtmlInit(QString filename);
|
void exportHtmlInit(const QString& filename);
|
||||||
void exportHTMLsettings(QString filename);
|
void exportHTMLsettings(const QString& filename);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DIVELOGEXPORTDIALOG_H
|
#endif // DIVELOGEXPORTDIALOG_H
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue