diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2015-07-22 18:06:27 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-07-22 11:21:16 -0700 |
commit | 6ab87a7420c5897740d4adfa06aa109fbdaa4280 (patch) | |
tree | 5fcc69291e94bfa344f30dd4ea237372bac65c6e | |
parent | 2d2d890ac709bd005f28ec1ec1ca48a209945cd2 (diff) | |
download | subsurface-6ab87a7420c5897740d4adfa06aa109fbdaa4280.tar.gz |
Clean hard coded values on divelog CSV import
Hard coding the values of known imports is quite awkward if we add
these. Thus switching to use enum and names instead.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | qt-ui/divelogimportdialog.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp index ea783b093..561fb077b 100644 --- a/qt-ui/divelogimportdialog.cpp +++ b/qt-ui/divelogimportdialog.cpp @@ -21,6 +21,15 @@ const DiveLogImportDialog::CSVAppConfig DiveLogImportDialog::CSVApps[CSVAPPS] = { NULL, } }; +static enum { + MANUAL, + APD, + XP5, + SENSUS, + SEABEAR, + SUBSURFACE +} known; + ColumnNameProvider::ColumnNameProvider(QObject *parent) : QAbstractListModel(parent) { columnNames << tr("Dive #") << tr("Date") << tr("Time") << tr("Duration") << tr("Location") << tr("GPS") << tr("Weight") << tr("Cyl. size") << tr("Start pressure") << @@ -437,7 +446,7 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy) } // Special handling for APD Log Viewer - if ((triggeredBy == KNOWNTYPES && value == 1) || (triggeredBy == INITIAL && fileNames.first().endsWith(".apd", Qt::CaseInsensitive))) { + if ((triggeredBy == KNOWNTYPES && value == APD) || (triggeredBy == INITIAL && fileNames.first().endsWith(".apd", Qt::CaseInsensitive))) { apd=true; firstLine = "Sample time\tSample depth\tSample setpoint\t\t\t\tSample pO₂\t\t\t\t\t\t\t\t\tSample temperature\t\tSample CNS\tSample stopdepth"; blockSignals(true); @@ -467,7 +476,7 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy) currColumns = firstLine.split(separator); } } - if (triggeredBy == INITIAL || (triggeredBy == KNOWNTYPES && value == 0) || triggeredBy == SEPARATOR) { + if (triggeredBy == INITIAL || (triggeredBy == KNOWNTYPES && value == MANUAL) || triggeredBy == SEPARATOR) { // now try and guess the columns Q_FOREACH (QString columnText, currColumns) { columnText.replace("\"", ""); @@ -493,9 +502,9 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy) } } } - if (triggeredBy == KNOWNTYPES && value != 0) { + if (triggeredBy == KNOWNTYPES && value != MANUAL) { // an actual known type - if (value == 5) { + if (value == SUBSURFACE) { /* * Subsurface CSV file needs separator detection * as we used to default to comma but switched |