mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Refactoring import to DiveLogImportDialog
Changing the import stuff to DiveLogImport. Now we should have one import function/dialog for importing divelogs instead of multiple menu entries. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
646c6ba58b
commit
b052b790df
8 changed files with 93 additions and 59 deletions
|
@ -7,16 +7,16 @@
|
||||||
#include "../divelist.h"
|
#include "../divelist.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class CSVImportDialog;
|
class DiveLogImportDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
class CSVImportDialog : public QDialog
|
class DiveLogImportDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CSVImportDialog(QWidget *parent = 0);
|
explicit DiveLogImportDialog(QWidget *parent = 0);
|
||||||
~CSVImportDialog();
|
~DiveLogImportDialog();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_buttonBox_accepted();
|
void on_buttonBox_accepted();
|
||||||
|
@ -33,7 +33,7 @@ private:
|
||||||
void unknownImports();
|
void unknownImports();
|
||||||
|
|
||||||
bool selector;
|
bool selector;
|
||||||
Ui::CSVImportDialog *ui;
|
Ui::DiveLogImportDialog *ui;
|
||||||
|
|
||||||
struct CSVAppConfig {
|
struct CSVAppConfig {
|
||||||
QString name;
|
QString name;
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include "csvimportdialog.h"
|
#include "divelogimportdialog.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "ui_csvimportdialog.h"
|
#include "ui_divelogimportdialog.h"
|
||||||
|
|
||||||
const CSVImportDialog::CSVAppConfig CSVImportDialog::CSVApps[CSVAPPS] = {
|
const DiveLogImportDialog::CSVAppConfig DiveLogImportDialog::CSVApps[CSVAPPS] = {
|
||||||
{"", },
|
{"", },
|
||||||
{"APD Log Viewer", 1, 2, 16, 7, 18, 19, "Tab"},
|
{"APD Log Viewer", 1, 2, 16, 7, 18, 19, "Tab"},
|
||||||
{"XP5", 1, 2, 10, -1, -1, -1, "Tab"},
|
{"XP5", 1, 2, 10, -1, -1, -1, "Tab"},
|
||||||
{NULL,}
|
{NULL,}
|
||||||
};
|
};
|
||||||
|
|
||||||
CSVImportDialog::CSVImportDialog(QWidget *parent) :
|
DiveLogImportDialog::DiveLogImportDialog(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
selector(true),
|
selector(true),
|
||||||
ui(new Ui::CSVImportDialog)
|
ui(new Ui::DiveLogImportDialog)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
@ -38,13 +38,13 @@ CSVImportDialog::CSVImportDialog(QWidget *parent) :
|
||||||
connect(ui->stopdepthCheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports(bool)));
|
connect(ui->stopdepthCheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports(bool)));
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVImportDialog::~CSVImportDialog()
|
DiveLogImportDialog::~DiveLogImportDialog()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define VALUE_IF_CHECKED(x) (ui->x->isEnabled() ? ui->x->value() - 1: -1)
|
#define VALUE_IF_CHECKED(x) (ui->x->isEnabled() ? ui->x->value() - 1: -1)
|
||||||
void CSVImportDialog::on_buttonBox_accepted()
|
void DiveLogImportDialog::on_buttonBox_accepted()
|
||||||
{
|
{
|
||||||
char *error = NULL;
|
char *error = NULL;
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ void CSVImportDialog::on_buttonBox_accepted()
|
||||||
mainWindow()->refreshDisplay();
|
mainWindow()->refreshDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVImportDialog::on_CSVFileSelector_clicked()
|
void DiveLogImportDialog::on_CSVFileSelector_clicked()
|
||||||
{
|
{
|
||||||
QString filename = QFileDialog::getOpenFileName(this, tr("Open CSV Log File"), ".", tr("CSV Files (*.csv);;All Files(*)"));
|
QString filename = QFileDialog::getOpenFileName(this, tr("Open CSV Log File"), ".", tr("CSV Files (*.csv);;All Files(*)"));
|
||||||
ui->CSVFile->setText(filename);
|
ui->CSVFile->setText(filename);
|
||||||
|
@ -103,7 +103,7 @@ void CSVImportDialog::on_CSVFileSelector_clicked()
|
||||||
ui->BOX->setChecked(VAL >= 0);\
|
ui->BOX->setChecked(VAL >= 0);\
|
||||||
ui->CSV->blockSignals(false);\
|
ui->CSV->blockSignals(false);\
|
||||||
})
|
})
|
||||||
void CSVImportDialog::on_knownImports_currentIndexChanged(int index)
|
void DiveLogImportDialog::on_knownImports_currentIndexChanged(int index)
|
||||||
{
|
{
|
||||||
if (index == 0)
|
if (index == 0)
|
||||||
return;
|
return;
|
||||||
|
@ -120,27 +120,27 @@ void CSVImportDialog::on_knownImports_currentIndexChanged(int index)
|
||||||
SET_VALUE_AND_CHECKBOX(CSVstopdepth, stopdepthCheckBox, CSVApps[index].stopdepth);
|
SET_VALUE_AND_CHECKBOX(CSVstopdepth, stopdepthCheckBox, CSVApps[index].stopdepth);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVImportDialog::unknownImports(bool arg1)
|
void DiveLogImportDialog::unknownImports(bool arg1)
|
||||||
{
|
{
|
||||||
unknownImports();
|
unknownImports();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVImportDialog::unknownImports(int arg1)
|
void DiveLogImportDialog::unknownImports(int arg1)
|
||||||
{
|
{
|
||||||
unknownImports();
|
unknownImports();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVImportDialog::unknownImports()
|
void DiveLogImportDialog::unknownImports()
|
||||||
{
|
{
|
||||||
ui->knownImports->setCurrentIndex(0);
|
ui->knownImports->setCurrentIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVImportDialog::on_CSVFile_textEdited()
|
void DiveLogImportDialog::on_CSVFile_textEdited()
|
||||||
{
|
{
|
||||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!ui->CSVFile->text().isEmpty());
|
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!ui->CSVFile->text().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVImportDialog::on_DiveLogFileSelector_clicked()
|
void DiveLogImportDialog::on_DiveLogFileSelector_clicked()
|
||||||
{
|
{
|
||||||
QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open Dive Log File"), ".", tr("XML Files (*.xml);;UDDF/UDCF Files(*.uddf *.udcf);;All Files(*)"));
|
QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Open Dive Log File"), ".", tr("XML Files (*.xml);;UDDF/UDCF Files(*.uddf *.udcf);;All Files(*)"));
|
||||||
ui->DiveLogFile->setText(fileNames.join(";"));
|
ui->DiveLogFile->setText(fileNames.join(";"));
|
||||||
|
@ -150,7 +150,7 @@ void CSVImportDialog::on_DiveLogFileSelector_clicked()
|
||||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVImportDialog::on_DiveLogFile_editingFinished()
|
void DiveLogImportDialog::on_DiveLogFile_editingFinished()
|
||||||
{
|
{
|
||||||
if (ui->DiveLogFile->text().size())
|
if (ui->DiveLogFile->text().size())
|
||||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
53
qt-ui/divelogimportdialog.h
Normal file
53
qt-ui/divelogimportdialog.h
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
#ifndef DIVELOGIMPORTDIALOG_H
|
||||||
|
#define DIVELOGIMPORTDIALOG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QModelIndex>
|
||||||
|
#include "../dive.h"
|
||||||
|
#include "../divelist.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class DiveLogImportDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
class DiveLogImportDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DiveLogImportDialog(QWidget *parent = 0);
|
||||||
|
~DiveLogImportDialog();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_buttonBox_accepted();
|
||||||
|
void on_CSVFileSelector_clicked();
|
||||||
|
void on_knownImports_currentIndexChanged(int index);
|
||||||
|
void on_CSVFile_textEdited();
|
||||||
|
void unknownImports(int);
|
||||||
|
void unknownImports(bool);
|
||||||
|
|
||||||
|
void on_DiveLogFileSelector_clicked();
|
||||||
|
void on_DiveLogFile_editingFinished();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void unknownImports();
|
||||||
|
|
||||||
|
bool selector;
|
||||||
|
Ui::DiveLogImportDialog *ui;
|
||||||
|
|
||||||
|
struct CSVAppConfig {
|
||||||
|
QString name;
|
||||||
|
int time;
|
||||||
|
int depth;
|
||||||
|
int temperature;
|
||||||
|
int po2;
|
||||||
|
int cns;
|
||||||
|
int stopdepth;
|
||||||
|
QString separator;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define CSVAPPS 4
|
||||||
|
static const CSVAppConfig CSVApps[CSVAPPS];
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DIVELOGIMPORTDIALOG_H
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>CSVImportDialog</class>
|
<class>DiveLogImportDialog</class>
|
||||||
<widget class="QDialog" name="CSVImportDialog">
|
<widget class="QDialog" name="DiveLogImportDialog">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Import CSV file</string>
|
<string>Import dive log file</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowIcon">
|
<property name="windowIcon">
|
||||||
<iconset>
|
<iconset>
|
||||||
|
@ -362,7 +362,7 @@
|
||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>buttonBox</sender>
|
||||||
<signal>accepted()</signal>
|
<signal>accepted()</signal>
|
||||||
<receiver>CSVImportDialog</receiver>
|
<receiver>DiveLogImportDialog</receiver>
|
||||||
<slot>accept()</slot>
|
<slot>accept()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
|
@ -378,7 +378,7 @@
|
||||||
<connection>
|
<connection>
|
||||||
<sender>buttonBox</sender>
|
<sender>buttonBox</sender>
|
||||||
<signal>rejected()</signal>
|
<signal>rejected()</signal>
|
||||||
<receiver>CSVImportDialog</receiver>
|
<receiver>DiveLogImportDialog</receiver>
|
||||||
<slot>reject()</slot>
|
<slot>reject()</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
|
@ -35,7 +35,7 @@
|
||||||
#include "diveplanner.h"
|
#include "diveplanner.h"
|
||||||
#include "about.h"
|
#include "about.h"
|
||||||
#include "printdialog.h"
|
#include "printdialog.h"
|
||||||
#include "csvimportdialog.h"
|
#include "divelogimportdialog.h"
|
||||||
|
|
||||||
static MainWindow* instance = 0;
|
static MainWindow* instance = 0;
|
||||||
|
|
||||||
|
@ -167,15 +167,6 @@ void MainWindow::on_actionClose_triggered()
|
||||||
clear_events();
|
clear_events();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionImport_triggered()
|
|
||||||
{
|
|
||||||
QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Import Files"), lastUsedDir(), filter());
|
|
||||||
if (!fileNames.size())
|
|
||||||
return; // no selection
|
|
||||||
updateLastUsedDir(QFileInfo(fileNames.at(0)).dir().path());
|
|
||||||
importFiles(fileNames);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString MainWindow::lastUsedDir()
|
QString MainWindow::lastUsedDir()
|
||||||
{
|
{
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
|
@ -864,10 +855,10 @@ void MainWindow::loadFiles(const QStringList fileNames)
|
||||||
ui.actionAutoGroup->setChecked(autogroup);
|
ui.actionAutoGroup->setChecked(autogroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_actionImportCSV_triggered()
|
void MainWindow::on_actionImportDiveLog_triggered()
|
||||||
{
|
{
|
||||||
CSVImportDialog *csvImport = new CSVImportDialog();
|
DiveLogImportDialog *diveLogImport = new DiveLogImportDialog();
|
||||||
csvImport->show();
|
diveLogImport->show();
|
||||||
process_dives(TRUE, FALSE);
|
process_dives(TRUE, FALSE);
|
||||||
refreshDisplay();
|
refreshDisplay();
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,6 @@ private slots:
|
||||||
void on_actionSave_triggered();
|
void on_actionSave_triggered();
|
||||||
void on_actionSaveAs_triggered();
|
void on_actionSaveAs_triggered();
|
||||||
void on_actionClose_triggered();
|
void on_actionClose_triggered();
|
||||||
void on_actionImport_triggered();
|
|
||||||
void on_actionExportUDDF_triggered();
|
void on_actionExportUDDF_triggered();
|
||||||
void on_actionPrint_triggered();
|
void on_actionPrint_triggered();
|
||||||
void on_actionPreferences_triggered();
|
void on_actionPreferences_triggered();
|
||||||
|
@ -102,7 +101,7 @@ private slots:
|
||||||
void current_dive_changed(int divenr);
|
void current_dive_changed(int divenr);
|
||||||
void initialUiSetup();
|
void initialUiSetup();
|
||||||
|
|
||||||
void on_actionImportCSV_triggered();
|
void on_actionImportDiveLog_triggered();
|
||||||
void linkClickedSlot(QUrl url);
|
void linkClickedSlot(QUrl url);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -197,8 +197,7 @@
|
||||||
<string>&Import</string>
|
<string>&Import</string>
|
||||||
</property>
|
</property>
|
||||||
<addaction name="actionDownloadDC"/>
|
<addaction name="actionDownloadDC"/>
|
||||||
<addaction name="actionImport"/>
|
<addaction name="actionImportDiveLog"/>
|
||||||
<addaction name="actionImportCSV"/>
|
|
||||||
<addaction name="actionDownloadWeb"/>
|
<addaction name="actionDownloadWeb"/>
|
||||||
<addaction name="actionDivelogs_de"/>
|
<addaction name="actionDivelogs_de"/>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -264,17 +263,6 @@
|
||||||
<string>Ctrl+W</string>
|
<string>Ctrl+W</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionImport">
|
|
||||||
<property name="text">
|
|
||||||
<string>Import Files</string>
|
|
||||||
</property>
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>Import Files</string>
|
|
||||||
</property>
|
|
||||||
<property name="shortcut">
|
|
||||||
<string>Ctrl+I</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
<action name="actionExportUDDF">
|
<action name="actionExportUDDF">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Export &UDDF</string>
|
<string>Export &UDDF</string>
|
||||||
|
@ -461,12 +449,15 @@
|
||||||
<string>Ctrl+L</string>
|
<string>Ctrl+L</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionImportCSV">
|
<action name="actionImportDiveLog">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Import CSV</string>
|
<string>Import Files</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Import CS&V</string>
|
<string>Import Files</string>
|
||||||
|
</property>
|
||||||
|
<property name="shortcut">
|
||||||
|
<string>Ctrl+I</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionDivelogs_de">
|
<action name="actionDivelogs_de">
|
||||||
|
|
|
@ -54,7 +54,7 @@ HEADERS = \
|
||||||
subsurfacestartup.h \
|
subsurfacestartup.h \
|
||||||
uemis.h \
|
uemis.h \
|
||||||
webservice.h \
|
webservice.h \
|
||||||
qt-ui/csvimportdialog.h \
|
qt-ui/divelogimportdialog.h \
|
||||||
qt-ui/tagwidget.h \
|
qt-ui/tagwidget.h \
|
||||||
qt-ui/groupedlineedit.h
|
qt-ui/groupedlineedit.h
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ SOURCES = \
|
||||||
time.c \
|
time.c \
|
||||||
uemis.c \
|
uemis.c \
|
||||||
uemis-downloader.c \
|
uemis-downloader.c \
|
||||||
qt-ui/csvimportdialog.cpp \
|
qt-ui/divelogimportdialog.cpp \
|
||||||
qt-ui/tagwidget.cpp \
|
qt-ui/tagwidget.cpp \
|
||||||
qt-ui/groupedlineedit.cpp
|
qt-ui/groupedlineedit.cpp
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ FORMS = \
|
||||||
qt-ui/shifttimes.ui \
|
qt-ui/shifttimes.ui \
|
||||||
qt-ui/webservices.ui \
|
qt-ui/webservices.ui \
|
||||||
qt-ui/tableview.ui \
|
qt-ui/tableview.ui \
|
||||||
qt-ui/csvimportdialog.ui
|
qt-ui/divelogimportdialog.ui
|
||||||
|
|
||||||
RESOURCES = subsurface.qrc
|
RESOURCES = subsurface.qrc
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue