From: Gehad elrobey <[email protected]>

Template HTML files must be overwritten when exporting if already exist.

Signed-off-by: Gehad elrobey <[email protected]>
Signed-off-by: Miika Turkia <[email protected]>
---
 qt-ui/divelogexportdialog.cpp | 24 +++++++++++++-----------
 qt-ui/divelogexportdialog.h   |  5 +++--
 2 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/qt-ui/divelogexportdialog.cpp b/qt-ui/divelogexportdialog.cpp
index 285071c..f92a09e 100644
--- a/qt-ui/divelogexportdialog.cpp
+++ b/qt-ui/divelogexportdialog.cpp
@@ -67,6 +67,14 @@ void DiveLogExportDialog::showExplanation()
        }
 }
 
+void DiveLogExportDialog::copy_and_overwrite(const QString &fileName, const 
QString &newName)
+{
+       QFile file(newName);
+       if (file.exists())
+               file.remove();
+       QFile::copy(fileName, newName);
+}
+
 void DiveLogExportDialog::exportHtmlInit(const QString &filename)
 {
        QFile file(filename);
@@ -87,17 +95,11 @@ void DiveLogExportDialog::exportHtmlInit(const QString 
&filename)
 
        searchPath += QDir::separator();
 
-       QFile::copy(searchPath + "dive_export.html", filename);
-       QFile::copy(searchPath + "list_lib.js", exportFiles + "list_lib.js");
-       QFile::copy(searchPath + "poster.png", exportFiles + "poster.png");
-
-       // Remove theme file if already exist in the export dir
-       QFile theme(exportFiles + "theme.css");
-       if (theme.exists())
-               theme.remove();
-
-       QFile::copy(searchPath + (ui->themeSelection->currentText() == "Light" 
? "light.css" : "sand.css"),
-                   exportFiles + "theme.css");
+       copy_and_overwrite(searchPath + "dive_export.html", filename);
+       copy_and_overwrite(searchPath + "list_lib.js", exportFiles + 
"list_lib.js");
+       copy_and_overwrite(searchPath + "poster.png", exportFiles + 
"poster.png");
+       copy_and_overwrite(searchPath + (ui->themeSelection->currentText() == 
"Light" ? "light.css" : "sand.css"),
+                          exportFiles + "theme.css");
 }
 
 void DiveLogExportDialog::exportHTMLsettings(const QString &filename)
diff --git a/qt-ui/divelogexportdialog.h b/qt-ui/divelogexportdialog.h
index fc1bfd3..390cd39 100644
--- a/qt-ui/divelogexportdialog.h
+++ b/qt-ui/divelogexportdialog.h
@@ -23,8 +23,9 @@ slots:
 private:
        Ui::DiveLogExportDialog *ui;
        void showExplanation();
-       void exportHtmlInit(const QString& filename);
-       void exportHTMLsettings(const QString& filename);
+       void exportHtmlInit(const QString &filename);
+       void exportHTMLsettings(const QString &filename);
+       void copy_and_overwrite(const QString &fileName, const QString 
&newName);
 };
 
 #endif // DIVELOGEXPORTDIALOG_H
-- 
1.9.1

_______________________________________________
subsurface mailing list
[email protected]
http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to