1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
#include <QtDebug>
#include <QFileDialog>
#include "csvimportdialog.h"
#include "mainwindow.h"
#include "ui_csvimportdialog.h"
const CSVImportDialog::CSVAppConfig CSVImportDialog::CSVApps[CSVAPPS] = {
{"", },
{"APD Log Viewer", 0, 1, 15, "Tab"},
{"XP5", 0, 1, 9, "Tab"},
{NULL,}
};
CSVImportDialog::CSVImportDialog(QWidget *parent) :
QDialog(parent),
selector(true),
ui(new Ui::CSVImportDialog)
{
ui->setupUi(this);
for (int i = 0; !CSVApps[i].name.isNull(); ++i)
ui->knownImports->addItem(CSVApps[i].name);
ui->CSVSeparator->addItem("Tab");
ui->knownImports->setCurrentIndex(1);
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
}
CSVImportDialog::~CSVImportDialog()
{
delete ui;
}
void CSVImportDialog::on_buttonBox_accepted()
{
char *error = NULL;
parse_csv_file(ui->CSVFile->text().toUtf8().data(), ui->CSVTime->value(), ui->CSVDepth->value(), ui->CSVTemperature->value(), &error);
if (error != NULL) {
mainWindow()->showError(error);
free(error);
error = NULL;
}
process_dives(TRUE, FALSE);
mainWindow()->refreshDisplay();
}
void CSVImportDialog::on_CSVFileSelector_clicked()
{
QString filename = QFileDialog::getOpenFileName(this, tr("Open CSV Log File"), ".", tr("CSV Files (*.csv)"));
ui->CSVFile->setText(filename);
if (filename.isEmpty())
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
else
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
}
void CSVImportDialog::on_knownImports_currentIndexChanged(int index)
{
if (index == 0)
return;
ui->CSVTime->blockSignals(true);
ui->CSVDepth->blockSignals(true);
ui->CSVTemperature->blockSignals(true);
ui->CSVTime->setValue(CSVApps[index].time);
ui->CSVDepth->setValue(CSVApps[index].depth);
ui->CSVTemperature->setValue(CSVApps[index].temperature);
ui->CSVTime->blockSignals(false);
ui->CSVDepth->blockSignals(false);
ui->CSVTemperature->blockSignals(false);
}
void CSVImportDialog::on_CSVTime_valueChanged(int arg1)
{
unknownImports();
}
void CSVImportDialog::on_CSVDepth_valueChanged(int arg1)
{
unknownImports();
}
void CSVImportDialog::on_CSVTemperature_valueChanged(int arg1)
{
unknownImports();
}
void CSVImportDialog::unknownImports()
{
ui->knownImports->setCurrentIndex(0);
}
void CSVImportDialog::on_CSVFile_textEdited()
{
if (ui->CSVFile->text().isEmpty())
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
else
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
}
|