mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 21:03:23 +00:00
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>
This commit is contained in:
parent
0b6cbe0f79
commit
7dc642860d
11 changed files with 322 additions and 91 deletions
|
@ -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");
|
||||
DiveLogExportDialog *diveLogExport = new DiveLogExportDialog();
|
||||
diveLogExport->show();
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
void DiveListView::shiftTimes()
|
||||
{
|
||||
ShiftTimesDialog::instance()->show();
|
||||
|
@ -913,11 +894,6 @@ void DiveListView::loadImages()
|
|||
}
|
||||
}
|
||||
|
||||
void DiveListView::uploadToDivelogsDE()
|
||||
{
|
||||
DivelogsDeWebServices::instance()->prepareDivesForUpload();
|
||||
}
|
||||
|
||||
QString DiveListView::lastUsedImageDir()
|
||||
{
|
||||
QSettings settings;
|
||||
|
|
|
@ -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:
|
||||
|
|
55
qt-ui/divelogexportdialog.cpp
Normal file
55
qt-ui/divelogexportdialog.cpp
Normal file
|
@ -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());
|
||||
}
|
25
qt-ui/divelogexportdialog.h
Normal file
25
qt-ui/divelogexportdialog.h
Normal file
|
@ -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
|
208
qt-ui/divelogexportdialog.ui
Normal file
208
qt-ui/divelogexportdialog.ui
Normal file
|
@ -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>
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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 *);
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -71,7 +71,7 @@ class DivelogsDeWebServices : public WebServices {
|
|||
public:
|
||||
static DivelogsDeWebServices *instance();
|
||||
void downloadDives();
|
||||
void prepareDivesForUpload();
|
||||
void prepareDivesForUpload(bool selected);
|
||||
|
||||
private
|
||||
slots:
|
||||
|
|
|
@ -83,7 +83,8 @@ HEADERS = \
|
|||
qt-ui/profile/diveeventitem.h \
|
||||
qt-ui/profile/divetooltipitem.h \
|
||||
qt-ui/profile/ruleritem.h \
|
||||
qt-ui/updatemanager.h
|
||||
qt-ui/updatemanager.h \
|
||||
qt-ui/divelogexportdialog.h
|
||||
|
||||
android: HEADERS -= \
|
||||
qt-ui/usermanual.h \
|
||||
|
@ -157,7 +158,8 @@ SOURCES = \
|
|||
qt-ui/profile/diveeventitem.cpp \
|
||||
qt-ui/profile/divetooltipitem.cpp \
|
||||
qt-ui/profile/ruleritem.cpp \
|
||||
qt-ui/updatemanager.cpp
|
||||
qt-ui/updatemanager.cpp \
|
||||
qt-ui/divelogexportdialog.cpp
|
||||
|
||||
android: SOURCES += android.cpp
|
||||
else: linux*: SOURCES += linux.c
|
||||
|
@ -185,7 +187,8 @@ FORMS = \
|
|||
qt-ui/webservices.ui \
|
||||
qt-ui/tableview.ui \
|
||||
qt-ui/divelogimportdialog.ui \
|
||||
qt-ui/usermanual.ui
|
||||
qt-ui/usermanual.ui \
|
||||
qt-ui/divelogexportdialog.ui
|
||||
|
||||
# Nether usermanual or printing is supported on android right now
|
||||
android: FORMS -= qt-ui/usermanual.ui qt-ui/printoptions.ui
|
||||
|
|
Loading…
Add table
Reference in a new issue