mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 20:53:23 +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"
|
||||
|
||||
namespace Ui {
|
||||
class CSVImportDialog;
|
||||
class DiveLogImportDialog;
|
||||
}
|
||||
|
||||
class CSVImportDialog : public QDialog
|
||||
class DiveLogImportDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CSVImportDialog(QWidget *parent = 0);
|
||||
~CSVImportDialog();
|
||||
explicit DiveLogImportDialog(QWidget *parent = 0);
|
||||
~DiveLogImportDialog();
|
||||
|
||||
private slots:
|
||||
void on_buttonBox_accepted();
|
||||
|
@ -33,7 +33,7 @@ private:
|
|||
void unknownImports();
|
||||
|
||||
bool selector;
|
||||
Ui::CSVImportDialog *ui;
|
||||
Ui::DiveLogImportDialog *ui;
|
||||
|
||||
struct CSVAppConfig {
|
||||
QString name;
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
#include <QtDebug>
|
||||
#include <QFileDialog>
|
||||
#include "csvimportdialog.h"
|
||||
#include "divelogimportdialog.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"},
|
||||
{"XP5", 1, 2, 10, -1, -1, -1, "Tab"},
|
||||
{NULL,}
|
||||
};
|
||||
|
||||
CSVImportDialog::CSVImportDialog(QWidget *parent) :
|
||||
DiveLogImportDialog::DiveLogImportDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
selector(true),
|
||||
ui(new Ui::CSVImportDialog)
|
||||
ui(new Ui::DiveLogImportDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
|
@ -38,13 +38,13 @@ CSVImportDialog::CSVImportDialog(QWidget *parent) :
|
|||
connect(ui->stopdepthCheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports(bool)));
|
||||
}
|
||||
|
||||
CSVImportDialog::~CSVImportDialog()
|
||||
DiveLogImportDialog::~DiveLogImportDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
#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;
|
||||
|
||||
|
@ -89,7 +89,7 @@ void CSVImportDialog::on_buttonBox_accepted()
|
|||
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(*)"));
|
||||
ui->CSVFile->setText(filename);
|
||||
|
@ -103,7 +103,7 @@ void CSVImportDialog::on_CSVFileSelector_clicked()
|
|||
ui->BOX->setChecked(VAL >= 0);\
|
||||
ui->CSV->blockSignals(false);\
|
||||
})
|
||||
void CSVImportDialog::on_knownImports_currentIndexChanged(int index)
|
||||
void DiveLogImportDialog::on_knownImports_currentIndexChanged(int index)
|
||||
{
|
||||
if (index == 0)
|
||||
return;
|
||||
|
@ -120,27 +120,27 @@ void CSVImportDialog::on_knownImports_currentIndexChanged(int index)
|
|||
SET_VALUE_AND_CHECKBOX(CSVstopdepth, stopdepthCheckBox, CSVApps[index].stopdepth);
|
||||
}
|
||||
|
||||
void CSVImportDialog::unknownImports(bool arg1)
|
||||
void DiveLogImportDialog::unknownImports(bool arg1)
|
||||
{
|
||||
unknownImports();
|
||||
}
|
||||
|
||||
void CSVImportDialog::unknownImports(int arg1)
|
||||
void DiveLogImportDialog::unknownImports(int arg1)
|
||||
{
|
||||
unknownImports();
|
||||
}
|
||||
|
||||
void CSVImportDialog::unknownImports()
|
||||
void DiveLogImportDialog::unknownImports()
|
||||
{
|
||||
ui->knownImports->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void CSVImportDialog::on_CSVFile_textEdited()
|
||||
void DiveLogImportDialog::on_CSVFile_textEdited()
|
||||
{
|
||||
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(*)"));
|
||||
ui->DiveLogFile->setText(fileNames.join(";"));
|
||||
|
@ -150,7 +150,7 @@ void CSVImportDialog::on_DiveLogFileSelector_clicked()
|
|||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
}
|
||||
|
||||
void CSVImportDialog::on_DiveLogFile_editingFinished()
|
||||
void DiveLogImportDialog::on_DiveLogFile_editingFinished()
|
||||
{
|
||||
if (ui->DiveLogFile->text().size())
|
||||
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"?>
|
||||
<ui version="4.0">
|
||||
<class>CSVImportDialog</class>
|
||||
<widget class="QDialog" name="CSVImportDialog">
|
||||
<class>DiveLogImportDialog</class>
|
||||
<widget class="QDialog" name="DiveLogImportDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
|
@ -11,7 +11,7 @@
|
|||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Import CSV file</string>
|
||||
<string>Import dive log file</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset>
|
||||
|
@ -362,7 +362,7 @@
|
|||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>CSVImportDialog</receiver>
|
||||
<receiver>DiveLogImportDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
|
@ -378,7 +378,7 @@
|
|||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>CSVImportDialog</receiver>
|
||||
<receiver>DiveLogImportDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
|
@ -35,7 +35,7 @@
|
|||
#include "diveplanner.h"
|
||||
#include "about.h"
|
||||
#include "printdialog.h"
|
||||
#include "csvimportdialog.h"
|
||||
#include "divelogimportdialog.h"
|
||||
|
||||
static MainWindow* instance = 0;
|
||||
|
||||
|
@ -167,15 +167,6 @@ void MainWindow::on_actionClose_triggered()
|
|||
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()
|
||||
{
|
||||
QSettings settings;
|
||||
|
@ -864,10 +855,10 @@ void MainWindow::loadFiles(const QStringList fileNames)
|
|||
ui.actionAutoGroup->setChecked(autogroup);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionImportCSV_triggered()
|
||||
void MainWindow::on_actionImportDiveLog_triggered()
|
||||
{
|
||||
CSVImportDialog *csvImport = new CSVImportDialog();
|
||||
csvImport->show();
|
||||
DiveLogImportDialog *diveLogImport = new DiveLogImportDialog();
|
||||
diveLogImport->show();
|
||||
process_dives(TRUE, FALSE);
|
||||
refreshDisplay();
|
||||
}
|
||||
|
|
|
@ -62,7 +62,6 @@ private slots:
|
|||
void on_actionSave_triggered();
|
||||
void on_actionSaveAs_triggered();
|
||||
void on_actionClose_triggered();
|
||||
void on_actionImport_triggered();
|
||||
void on_actionExportUDDF_triggered();
|
||||
void on_actionPrint_triggered();
|
||||
void on_actionPreferences_triggered();
|
||||
|
@ -102,7 +101,7 @@ private slots:
|
|||
void current_dive_changed(int divenr);
|
||||
void initialUiSetup();
|
||||
|
||||
void on_actionImportCSV_triggered();
|
||||
void on_actionImportDiveLog_triggered();
|
||||
void linkClickedSlot(QUrl url);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -197,8 +197,7 @@
|
|||
<string>&Import</string>
|
||||
</property>
|
||||
<addaction name="actionDownloadDC"/>
|
||||
<addaction name="actionImport"/>
|
||||
<addaction name="actionImportCSV"/>
|
||||
<addaction name="actionImportDiveLog"/>
|
||||
<addaction name="actionDownloadWeb"/>
|
||||
<addaction name="actionDivelogs_de"/>
|
||||
</widget>
|
||||
|
@ -264,17 +263,6 @@
|
|||
<string>Ctrl+W</string>
|
||||
</property>
|
||||
</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">
|
||||
<property name="text">
|
||||
<string>Export &UDDF</string>
|
||||
|
@ -461,12 +449,15 @@
|
|||
<string>Ctrl+L</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionImportCSV">
|
||||
<action name="actionImportDiveLog">
|
||||
<property name="text">
|
||||
<string>Import CSV</string>
|
||||
<string>Import Files</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Import CS&V</string>
|
||||
<string>Import Files</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+I</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDivelogs_de">
|
||||
|
|
|
@ -54,7 +54,7 @@ HEADERS = \
|
|||
subsurfacestartup.h \
|
||||
uemis.h \
|
||||
webservice.h \
|
||||
qt-ui/csvimportdialog.h \
|
||||
qt-ui/divelogimportdialog.h \
|
||||
qt-ui/tagwidget.h \
|
||||
qt-ui/groupedlineedit.h
|
||||
|
||||
|
@ -103,7 +103,7 @@ SOURCES = \
|
|||
time.c \
|
||||
uemis.c \
|
||||
uemis-downloader.c \
|
||||
qt-ui/csvimportdialog.cpp \
|
||||
qt-ui/divelogimportdialog.cpp \
|
||||
qt-ui/tagwidget.cpp \
|
||||
qt-ui/groupedlineedit.cpp
|
||||
|
||||
|
@ -124,7 +124,7 @@ FORMS = \
|
|||
qt-ui/shifttimes.ui \
|
||||
qt-ui/webservices.ui \
|
||||
qt-ui/tableview.ui \
|
||||
qt-ui/csvimportdialog.ui
|
||||
qt-ui/divelogimportdialog.ui
|
||||
|
||||
RESOURCES = subsurface.qrc
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue