diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2014-05-20 19:33:32 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-05-21 03:31:43 +0900 |
commit | 7dc642860def420f85ae25548ddfa674e14636d1 (patch) | |
tree | 65f58d09ec8b5293550c124286fecf606bd23e73 /qt-ui | |
parent | 0b6cbe0f79d7707297211850963323eb77d21c20 (diff) | |
download | subsurface-7dc642860def420f85ae25548ddfa674e14636d1.tar.gz |
Implementing export dialog
As our menus are getting many export entries, it is better to create a
single export dialog where user is able to select the export type and
whether to export selected dives or all of them. This should also be
more intuitive than the current way when export from file menu export
all dives and right click menu on divelist exports only selected dives.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/divelistview.cpp | 34 | ||||
-rw-r--r-- | qt-ui/divelistview.h | 4 | ||||
-rw-r--r-- | qt-ui/divelogexportdialog.cpp | 55 | ||||
-rw-r--r-- | qt-ui/divelogexportdialog.h | 25 | ||||
-rw-r--r-- | qt-ui/divelogexportdialog.ui | 208 | ||||
-rw-r--r-- | qt-ui/mainwindow.cpp | 35 | ||||
-rw-r--r-- | qt-ui/mainwindow.h | 5 | ||||
-rw-r--r-- | qt-ui/mainwindow.ui | 32 | ||||
-rw-r--r-- | qt-ui/subsurfacewebservices.cpp | 4 | ||||
-rw-r--r-- | qt-ui/subsurfacewebservices.h | 2 |
10 files changed, 316 insertions, 88 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index 07ce1f001..0e022d1cf 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -9,6 +9,7 @@ #include "modeldelegates.h" #include "mainwindow.h" #include "subsurfacewebservices.h" +#include "divelogexportdialog.h" #include "../display.h" #include "exif.h" #include "../file.h" @@ -775,13 +776,10 @@ void DiveListView::contextMenuEvent(QContextMenuEvent *event) if (amount_selected >= 1) { popup.addAction(tr("renumber dive(s)"), this, SLOT(renumberDives())); popup.addAction(tr("save As"), this, SLOT(saveSelectedDivesAs())); - popup.addAction(tr("export As UDDF"), this, SLOT(exportSelectedDivesAsUDDF())); - popup.addAction(tr("export As CSV"), this, SLOT(exportSelectedDivesAsCSV())); + popup.addAction(tr("export dive log"), this, SLOT(exportDives())); popup.addAction(tr("shift times"), this, SLOT(shiftTimes())); popup.addAction(tr("load images"), this, SLOT(loadImages())); } - if (d) - popup.addAction(tr("upload dive(s) to divelogs.de"), this, SLOT(uploadToDivelogsDE())); // "collapse all" really closes all trips, // "collapse" keeps the trip with the selected dive open QAction *actionTaken = popup.exec(event->globalPos()); @@ -821,29 +819,12 @@ void DiveListView::saveSelectedDivesAs() save_dives_logic(bt.data(), true); } -void DiveListView::exportSelectedDivesAsUDDF() +void DiveListView::exportDives() { - QString filename; - QFileInfo fi(system_default_filename()); - - filename = QFileDialog::getSaveFileName(this, tr("Export UDDF File as"), fi.absolutePath(), - tr("UDDF files (*.uddf *.UDDF)")); - if (!filename.isNull() && !filename.isEmpty()) - export_dives_xslt(filename.toUtf8(), true, "uddf-export.xslt"); -} - -void DiveListView::exportSelectedDivesAsCSV() -{ - QString filename; - QFileInfo fi(system_default_filename()); - - filename = QFileDialog::getSaveFileName(this, tr("Export CSV File as"), fi.absolutePath(), - tr("CSV files (*.csv *.CSV)")); - if (!filename.isNull() && !filename.isEmpty()) - export_dives_xslt(filename.toUtf8(), true, "xml2csv.xslt"); + DiveLogExportDialog *diveLogExport = new DiveLogExportDialog(); + diveLogExport->show(); } - void DiveListView::shiftTimes() { ShiftTimesDialog::instance()->show(); @@ -913,11 +894,6 @@ void DiveListView::loadImages() } } -void DiveListView::uploadToDivelogsDE() -{ - DivelogsDeWebServices::instance()->prepareDivesForUpload(); -} - QString DiveListView::lastUsedImageDir() { QSettings settings; diff --git a/qt-ui/divelistview.h b/qt-ui/divelistview.h index 132d92f1f..fd3a31cb7 100644 --- a/qt-ui/divelistview.h +++ b/qt-ui/divelistview.h @@ -50,11 +50,9 @@ slots: void mergeDives(); void renumberDives(); void saveSelectedDivesAs(); - void exportSelectedDivesAsUDDF(); - void exportSelectedDivesAsCSV(); + void exportDives(); void shiftTimes(); void loadImages(); - void uploadToDivelogsDE(); static QString lastUsedImageDir(); signals: diff --git a/qt-ui/divelogexportdialog.cpp b/qt-ui/divelogexportdialog.cpp new file mode 100644 index 000000000..3ac9638ad --- /dev/null +++ b/qt-ui/divelogexportdialog.cpp @@ -0,0 +1,55 @@ +#include <QFileDialog> +#include <QString> + +#include "mainwindow.h" +#include "divelogexportdialog.h" +#include "ui_divelogexportdialog.h" +#include "subsurfacewebservices.h" +#include "worldmap-save.h" + +DiveLogExportDialog::DiveLogExportDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::DiveLogExportDialog) +{ + ui->setupUi(this); +} + +DiveLogExportDialog::~DiveLogExportDialog() +{ + delete ui; +} + +void DiveLogExportDialog::on_buttonBox_accepted() +{ + QFileInfo fi(system_default_filename()); + QString filename; + QString stylesheet; + + if (ui->exportUDDF->isChecked()) { + stylesheet = "uddf-export.xslt"; + filename = QFileDialog::getSaveFileName(this, tr("Export UDDF File as"), fi.absolutePath(), + tr("UDDF files (*.uddf *.UDDF)")); + } else if (ui->exportCSV->isChecked()) { + stylesheet = "xml2csv.xslt"; + filename = QFileDialog::getSaveFileName(this, tr("Export CSV File as"), fi.absolutePath(), + tr("CSV files (*.csv *.CSV)")); + } else if (ui->exportDivelogs->isChecked()) { + DivelogsDeWebServices::instance()->prepareDivesForUpload(ui->exportSelected->isChecked()); + return; + } else if (ui->exportWorldMap->isChecked()) { + filename = QFileDialog::getSaveFileName(this, tr("Export World Map"), fi.absolutePath(), + tr("HTML files (*.html)")); + if (!filename.isNull() && !filename.isEmpty()) + export_worldmap_HTML(filename.toUtf8().data()); + return; + } else if (ui->exportWorldMap->isChecked()) { + filename = QFileDialog::getSaveFileName(this, tr("Export World Map"), fi.absolutePath(), + tr("HTML files (*.html)")); + if (!filename.isNull() && !filename.isEmpty()) + export_worldmap_HTML(filename.toUtf8().data()); + return; + } + + if (!filename.isNull() && !filename.isEmpty()) + export_dives_xslt(filename.toUtf8(), ui->exportSelected->isChecked(), stylesheet.toStdString().c_str()); +} diff --git a/qt-ui/divelogexportdialog.h b/qt-ui/divelogexportdialog.h new file mode 100644 index 000000000..9e2bed25d --- /dev/null +++ b/qt-ui/divelogexportdialog.h @@ -0,0 +1,25 @@ +#ifndef DIVELOGEXPORTDIALOG_H +#define DIVELOGEXPORTDIALOG_H + +#include <QDialog> + +namespace Ui { +class DiveLogExportDialog; +} + +class DiveLogExportDialog : public QDialog +{ + Q_OBJECT + +public: + explicit DiveLogExportDialog(QWidget *parent = 0); + ~DiveLogExportDialog(); + +private slots: + void on_buttonBox_accepted(); + +private: + Ui::DiveLogExportDialog *ui; +}; + +#endif // DIVELOGEXPORTDIALOG_H diff --git a/qt-ui/divelogexportdialog.ui b/qt-ui/divelogexportdialog.ui new file mode 100644 index 000000000..38e23932b --- /dev/null +++ b/qt-ui/divelogexportdialog.ui @@ -0,0 +1,208 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>DiveLogExportDialog</class> + <widget class="QDialog" name="DiveLogExportDialog"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>300</height> + </rect> + </property> + <property name="windowTitle"> + <string>Dialog</string> + </property> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="geometry"> + <rect> + <x>30</x> + <y>240</y> + <width>341</width> + <height>32</height> + </rect> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + <widget class="QLabel" name="label_3"> + <property name="geometry"> + <rect> + <x>-50</x> + <y>10</y> + <width>497</width> + <height>24</height> + </rect> + </property> + <property name="font"> + <font> + <family>Droid Sans [unknown]</family> + <pointsize>14</pointsize> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="frameShape"> + <enum>QFrame::NoFrame</enum> + </property> + <property name="text"> + <string>Export Dive Log Files</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + <widget class="QGroupBox" name="exportFormat"> + <property name="geometry"> + <rect> + <x>30</x> + <y>100</y> + <width>120</width> + <height>141</height> + </rect> + </property> + <property name="title"> + <string>Export format</string> + </property> + <widget class="QRadioButton" name="exportUDDF"> + <property name="geometry"> + <rect> + <x>0</x> + <y>20</y> + <width>110</width> + <height>24</height> + </rect> + </property> + <property name="text"> + <string>UDDF</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="QRadioButton" name="exportDivelogs"> + <property name="geometry"> + <rect> + <x>0</x> + <y>50</y> + <width>110</width> + <height>24</height> + </rect> + </property> + <property name="text"> + <string>divelogs</string> + </property> + </widget> + <widget class="QRadioButton" name="exportCSV"> + <property name="geometry"> + <rect> + <x>0</x> + <y>80</y> + <width>110</width> + <height>24</height> + </rect> + </property> + <property name="text"> + <string>CSV</string> + </property> + </widget> + <widget class="QRadioButton" name="exportWorldMap"> + <property name="geometry"> + <rect> + <x>0</x> + <y>110</y> + <width>110</width> + <height>24</height> + </rect> + </property> + <property name="text"> + <string>Worldmap</string> + </property> + </widget> + </widget> + <widget class="QGroupBox" name="exportSelection"> + <property name="geometry"> + <rect> + <x>190</x> + <y>100</y> + <width>151</width> + <height>80</height> + </rect> + </property> + <property name="title"> + <string>Selection</string> + </property> + <widget class="QRadioButton" name="exportSelected"> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>10</x> + <y>20</y> + <width>131</width> + <height>24</height> + </rect> + </property> + <property name="text"> + <string>Selected dives</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="QRadioButton" name="exportAll"> + <property name="geometry"> + <rect> + <x>10</x> + <y>50</y> + <width>110</width> + <height>24</height> + </rect> + </property> + <property name="text"> + <string>All dives</string> + </property> + </widget> + </widget> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>DiveLogExportDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>DiveLogExportDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 6ff0a68a4..d70e7b31e 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -43,6 +43,7 @@ #include "printdialog.h" #endif #include "divelogimportdialog.h" +#include "divelogexportdialog.h" #ifndef NO_USERMANUAL #include "usermanual.h" #endif @@ -278,34 +279,6 @@ void MainWindow::updateLastUsedDir(const QString &dir) s.setValue("LastDir", dir); } -void MainWindow::on_actionExportUDDF_triggered() -{ - QFileInfo fi(system_default_filename()); - QString filename = QFileDialog::getSaveFileName(this, tr("Export UDDF File as"), fi.absolutePath(), - tr("UDDF files (*.uddf *.UDDF)")); - if (!filename.isNull() && !filename.isEmpty()) - export_dives_xslt(filename.toUtf8(), false, "uddf-export.xslt"); -} - -void MainWindow::on_actionExport_CSV_triggered() -{ - QFileInfo fi(system_default_filename()); - QString filename = QFileDialog::getSaveFileName(this, tr("Export CSV File as"), fi.absolutePath(), - tr("CSV files (*.csv *.CSV)")); - - if (!filename.isNull() && !filename.isEmpty()) - export_dives_xslt(filename.toUtf8(), false, "xml2csv.xslt"); -} - -void MainWindow::on_actionExportHTMLworldmap_triggered() -{ - QFileInfo fi(system_default_filename()); - QString filename = QFileDialog::getSaveFileName(this, tr("Export World Map"), fi.absolutePath(), - tr("HTML files (*.html)")); - if (!filename.isNull() && !filename.isEmpty()) - export_worldmap_HTML(filename.toUtf8().data()); -} - void MainWindow::on_actionPrint_triggered() { #ifndef NO_PRINTING @@ -1222,3 +1195,9 @@ void MainWindow::on_profScaled_clicked(bool triggered) } #undef TOOLBOX_PREF_PROFILE + +void MainWindow::on_actionExport_triggered() +{ + DiveLogExportDialog *diveLogExport = new DiveLogExportDialog(); + diveLogExport->show(); +} diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index d6775c602..1bde5f0e8 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -90,9 +90,6 @@ slots: void on_actionSave_triggered(); void on_actionSaveAs_triggered(); void on_actionClose_triggered(); - void on_actionExportUDDF_triggered(); - void on_actionExport_CSV_triggered(); - void on_actionExportHTMLworldmap_triggered(); void on_actionPrint_triggered(); void on_actionPreferences_triggered(); void on_actionQuit_triggered(); @@ -146,6 +143,8 @@ slots: void on_profSAC_clicked(bool triggered); void on_profScaled_clicked(bool triggered); + void on_actionExport_triggered(); + protected: void closeEvent(QCloseEvent *); diff --git a/qt-ui/mainwindow.ui b/qt-ui/mainwindow.ui index 072d321fc..8ae8b2422 100644 --- a/qt-ui/mainwindow.ui +++ b/qt-ui/mainwindow.ui @@ -563,7 +563,7 @@ <x>0</x> <y>0</y> <width>1418</width> - <height>25</height> + <height>29</height> </rect> </property> <widget class="QMenu" name="menuFile"> @@ -576,9 +576,7 @@ <addaction name="actionSaveAs"/> <addaction name="separator"/> <addaction name="actionClose"/> - <addaction name="actionExportUDDF"/> - <addaction name="actionExport_CSV"/> - <addaction name="actionExportHTMLworldmap"/> + <addaction name="actionExport"/> <addaction name="actionPrint"/> <addaction name="actionPreferences"/> <addaction name="separator"/> @@ -702,22 +700,6 @@ <string>Ctrl+W</string> </property> </action> - <action name="actionExportUDDF"> - <property name="text"> - <string>Export &UDDF</string> - </property> - <property name="shortcut"> - <string>Ctrl+U</string> - </property> - </action> - <action name="actionExportHTMLworldmap"> - <property name="text"> - <string>Export HTML World Map</string> - </property> - <property name="shortcut"> - <string>Ctrl+H</string> - </property> - </action> <action name="actionPrint"> <property name="text"> <string>&Print</string> @@ -946,9 +928,15 @@ <string>&Check for Updates</string> </property> </action> - <action name="actionExport_CSV"> + <action name="actionExport"> <property name="text"> - <string>Export CSV</string> + <string>Export</string> + </property> + <property name="toolTip"> + <string>Export Dive Logs</string> + </property> + <property name="shortcut"> + <string>Ctrl+E</string> </property> </action> </widget> diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp index 406939e6b..fb4ec2c90 100644 --- a/qt-ui/subsurfacewebservices.cpp +++ b/qt-ui/subsurfacewebservices.cpp @@ -601,11 +601,11 @@ void DivelogsDeWebServices::downloadDives() exec(); } -void DivelogsDeWebServices::prepareDivesForUpload() +void DivelogsDeWebServices::prepareDivesForUpload(bool selected) { /* generate a random filename and create/open that file with zip_open */ QString filename = QDir::tempPath() + "/import-" + QString::number(qrand() % 99999999) + ".dld"; - if (prepare_dives_for_divelogs(filename, true)) { + if (prepare_dives_for_divelogs(filename, selected)) { QFile f(filename); if (f.open(QIODevice::ReadOnly)) { uploadDives((QIODevice *)&f); diff --git a/qt-ui/subsurfacewebservices.h b/qt-ui/subsurfacewebservices.h index 4419b1c6b..a9a67de46 100644 --- a/qt-ui/subsurfacewebservices.h +++ b/qt-ui/subsurfacewebservices.h @@ -71,7 +71,7 @@ class DivelogsDeWebServices : public WebServices { public: static DivelogsDeWebServices *instance(); void downloadDives(); - void prepareDivesForUpload(); + void prepareDivesForUpload(bool selected); private slots: |