First Round.
I still need to make sure nothing is broken with the transition,
TOO much stuff was changed.
I'm pretty sure I broke something
I'm pretty sure the dialog is now awesome.
From 85b6859f1b122412b412c52e3a968f2d8d45a5e5 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 6 Jan 2015 14:12:29 -0200
Subject: [PATCH 01/27] Clean a *lot* of code for a new and improved CSV import
 dialog

This mostly cleans out stuff that is going to be uneeded.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/divelogimportdialog.cpp |  187 +-----
 qt-ui/divelogimportdialog.h   |   20 -
 qt-ui/divelogimportdialog.ui  | 1271 +++--------------------------------------
 3 files changed, 98 insertions(+), 1380 deletions(-)

diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 3318bc9..02fc03e 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -31,53 +31,10 @@ DiveLogImportDialog::DiveLogImportDialog(QStringList *fn, QWidget *parent) : QDi
 	for (int i = 0; !CSVApps[i].name.isNull(); ++i)
 		ui->knownImports->addItem(CSVApps[i].name);
 
-	ui->CSVSeparator->addItem("Tab");
-	ui->CSVSeparator->addItem(",");
-	ui->CSVSeparator->addItem(";");
+	ui->CSVSeparator->addItems( QStringList() << tr("Separator") << tr("Tab") << ";" << ",");
 	ui->knownImports->setCurrentIndex(1);
-	ui->ManualSeparator->addItem("Tab");
-	ui->ManualSeparator->addItem(",");
-	ui->ManualSeparator->addItem(";");
-	ui->knownImports->setCurrentIndex(1);
-
-	connect(ui->CSVDepth, SIGNAL(valueChanged(int)), this, SLOT(unknownImports()));
-	connect(ui->CSVTime, SIGNAL(valueChanged(int)), this, SLOT(unknownImports()));
-	connect(ui->CSVTemperature, SIGNAL(valueChanged(int)), this, SLOT(unknownImports()));
-	connect(ui->temperatureCheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports()));
-	connect(ui->CSVpo2, SIGNAL(valueChanged(int)), this, SLOT(unknownImports()));
-	connect(ui->po2CheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports()));
-	connect(ui->CSVcns, SIGNAL(valueChanged(int)), this, SLOT(unknownImports()));
-	connect(ui->cnsCheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports()));
-	connect(ui->CSVndl, SIGNAL(valueChanged(int)), this, SLOT(unknownImports()));
-	connect(ui->ndlCheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports()));
-	connect(ui->CSVtts, SIGNAL(valueChanged(int)), this, SLOT(unknownImports()));
-	connect(ui->ttsCheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports()));
-	connect(ui->CSVstopdepth, SIGNAL(valueChanged(int)), this, SLOT(unknownImports()));
-	connect(ui->stopdepthCheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports()));
-	connect(ui->CSVpressure, SIGNAL(valueChanged(int)), this, SLOT(unknownImports()));
-	connect(ui->pressureCheckBox, SIGNAL(clicked(bool)), this, SLOT(unknownImports()));
 
 	/* manually import CSV file */
-	connect(ui->DiveNumberCheck, SIGNAL(clicked(bool)), this, SLOT(manualDiveNumber()));
-	connect(ui->DateCheck, SIGNAL(clicked(bool)), this, SLOT(manualDate()));
-	connect(ui->TimeCheck, SIGNAL(clicked(bool)), this, SLOT(manualTime()));
-	connect(ui->LocationCheck, SIGNAL(clicked(bool)), this, SLOT(manualLocation()));
-	connect(ui->GpsCheck, SIGNAL(clicked(bool)), this, SLOT(manualGps()));
-	connect(ui->MaxDepthCheck, SIGNAL(clicked(bool)), this, SLOT(manualMaxDepth()));
-	connect(ui->MeanDepthCheck, SIGNAL(clicked(bool)), this, SLOT(manualMeanDepth()));
-	connect(ui->BuddyCheck, SIGNAL(clicked(bool)), this, SLOT(manualBuddy()));
-	connect(ui->NotesCheck, SIGNAL(clicked(bool)), this, SLOT(manualNotes()));
-	connect(ui->TagsCheck, SIGNAL(clicked(bool)), this, SLOT(manualTags()));
-	connect(ui->WeightCheck, SIGNAL(clicked(bool)), this, SLOT(manualWeight()));
-	connect(ui->DurationCheck, SIGNAL(clicked(bool)), this, SLOT(manualDuration()));
-	connect(ui->CylinderSizeCheck, SIGNAL(clicked(bool)), this, SLOT(manualCylinderSize()));
-	connect(ui->StartPressureCheck, SIGNAL(clicked(bool)), this, SLOT(manualStartPressure()));
-	connect(ui->EndPressureCheck, SIGNAL(clicked(bool)), this, SLOT(manualEndPressure()));
-	connect(ui->O2Check, SIGNAL(clicked(bool)), this, SLOT(manualO2()));
-	connect(ui->HeCheck, SIGNAL(clicked(bool)), this, SLOT(manualHe()));
-	connect(ui->AirTempCheck, SIGNAL(clicked(bool)), this, SLOT(manualAirTemp()));
-	connect(ui->WaterTempCheck, SIGNAL(clicked(bool)), this, SLOT(manualWaterTemp()));
-
 	QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this);
 	connect(close, SIGNAL(activated()), this, SLOT(close()));
 	QShortcut *quit = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this);
@@ -92,11 +49,11 @@ DiveLogImportDialog::~DiveLogImportDialog()
 #define VALUE_IF_CHECKED(x) (ui->x->isEnabled() ? ui->x->value() - 1 : -1)
 void DiveLogImportDialog::on_buttonBox_accepted()
 {
-	if (ui->tabWidget->currentIndex() == 0) {
-		for (int i = 0; i < fileNames.size(); ++i) {
-			if (ui->knownImports->currentText() == QString("Seabear CSV")) {
-				parse_seabear_csv_file(fileNames[i].toUtf8().data(), ui->CSVTime->value() - 1,
-				       ui->CSVDepth->value() - 1, VALUE_IF_CHECKED(CSVTemperature),
+	/*
+	for (int i = 0; i < fileNames.size(); ++i) {
+		if (ui->knownImports->currentText() == QString("Seabear CSV")) {
+			parse_seabear_csv_file(fileNames[i].toUtf8().data(), ui->CSVTime->value() - 1,
+			       ui->CSVDepth->value() - 1, VALUE_IF_CHECKED(CSVTemperature),
 				       VALUE_IF_CHECKED(CSVpo2),
 				       VALUE_IF_CHECKED(CSVcns),
 				       VALUE_IF_CHECKED(CSVndl),
@@ -107,7 +64,7 @@ void DiveLogImportDialog::on_buttonBox_accepted()
 				       specialCSV.contains(ui->knownImports->currentIndex()) ? CSVApps[ui->knownImports->currentIndex()].name.toUtf8().data() : "csv",
 				       ui->CSVUnits->currentIndex());
 
-				/* Seabear CSV stores NDL and TTS in Minutes, not seconds */
+				// Seabear CSV stores NDL and TTS in Minutes, not seconds
 				struct dive *dive = dive_table.dives[dive_table.nr - 1];
 				for(int s_nr = 0 ; s_nr <= dive->dc.samples ; s_nr++) {
 					struct sample *sample = dive->dc.sample + s_nr;
@@ -147,7 +104,7 @@ void DiveLogImportDialog::on_buttonBox_accepted()
 					  VALUE_IF_CHECKED(WaterTemp));
 		}
 	}
-
+*/
 	process_dives(true, false);
 
 	MainWindow::instance()->refreshDisplay();
@@ -159,34 +116,12 @@ void DiveLogImportDialog::on_buttonBox_accepted()
 		ui->CSV->setEnabled(VAL >= 0);\
 		ui->BOX->setChecked(VAL >= 0);\
 		ui->CSV->blockSignals(false); })
+
 void DiveLogImportDialog::on_knownImports_currentIndexChanged(int index)
 {
-	if (specialCSV.contains(index)) {
-		ui->groupBox_3->setEnabled(false);
-	} else {
-		ui->groupBox_3->setEnabled(true);
-	}
 	if (index == 0)
 		return;
 
-	ui->CSVTime->blockSignals(true);
-	ui->CSVDepth->blockSignals(true);
-	ui->CSVTime->setValue(CSVApps[index].time);
-	ui->CSVDepth->setValue(CSVApps[index].depth);
-	ui->CSVTime->blockSignals(false);
-	ui->CSVDepth->blockSignals(false);
-	SET_VALUE_AND_CHECKBOX(CSVTemperature, temperatureCheckBox, CSVApps[index].temperature);
-	SET_VALUE_AND_CHECKBOX(CSVpo2, po2CheckBox, CSVApps[index].po2);
-	SET_VALUE_AND_CHECKBOX(CSVcns, cnsCheckBox, CSVApps[index].cns);
-	SET_VALUE_AND_CHECKBOX(CSVndl, ndlCheckBox, CSVApps[index].ndl);
-	SET_VALUE_AND_CHECKBOX(CSVtts, ttsCheckBox, CSVApps[index].tts);
-	SET_VALUE_AND_CHECKBOX(CSVstopdepth, stopdepthCheckBox, CSVApps[index].stopdepth);
-	SET_VALUE_AND_CHECKBOX(CSVpressure, pressureCheckBox, CSVApps[index].pressure);
-	ui->CSVSeparator->blockSignals(true);
-	int separator_index = ui->CSVSeparator->findText(CSVApps[index].separator);
-	if (separator_index != -1)
-		ui->CSVSeparator->setCurrentIndex(separator_index);
-	ui->CSVSeparator->blockSignals(false);
 }
 
 void DiveLogImportDialog::unknownImports()
@@ -194,107 +129,3 @@ void DiveLogImportDialog::unknownImports()
 	if (!specialCSV.contains(ui->knownImports->currentIndex()))
 		ui->knownImports->setCurrentIndex(0);
 }
-
-#define SET_COLUMN(CHECK, VALUE) ({\
-	if (ui->CHECK->isChecked()) {\
-		ui->VALUE->setEnabled(true);\
-		ui->VALUE->setValue(++column);\
-	} else {\
-		ui->VALUE->setEnabled(false);\
-		--column;}\
-	})
-
-void DiveLogImportDialog::manualDiveNumber()
-{
-	SET_COLUMN(DiveNumberCheck, DiveNumber);
-}
-
-void DiveLogImportDialog::manualDate()
-{
-	SET_COLUMN(DateCheck, Date);
-}
-
-void DiveLogImportDialog::manualTime()
-{
-	SET_COLUMN(TimeCheck, Time);
-}
-
-void DiveLogImportDialog::manualLocation()
-{
-	SET_COLUMN(LocationCheck, Location);
-}
-
-void DiveLogImportDialog::manualGps()
-{
-	SET_COLUMN(GpsCheck, Gps);
-}
-
-void DiveLogImportDialog::manualMaxDepth()
-{
-	SET_COLUMN(MaxDepthCheck, MaxDepth);
-}
-
-void DiveLogImportDialog::manualMeanDepth()
-{
-	SET_COLUMN(MeanDepthCheck, MeanDepth);
-}
-
-void DiveLogImportDialog::manualBuddy()
-{
-	SET_COLUMN(BuddyCheck, Buddy);
-}
-
-void DiveLogImportDialog::manualNotes()
-{
-	SET_COLUMN(NotesCheck, Notes);
-}
-
-void DiveLogImportDialog::manualTags()
-{
-	SET_COLUMN(TagsCheck, Tags);
-}
-
-void DiveLogImportDialog::manualWeight()
-{
-	SET_COLUMN(WeightCheck, Weight);
-}
-
-void DiveLogImportDialog::manualDuration()
-{
-	SET_COLUMN(DurationCheck, Duration);
-}
-
-void DiveLogImportDialog::manualCylinderSize()
-{
-	SET_COLUMN(CylinderSizeCheck, CylinderSize);
-}
-
-void DiveLogImportDialog::manualStartPressure()
-{
-	SET_COLUMN(StartPressureCheck, StartPressure);
-}
-
-void DiveLogImportDialog::manualEndPressure()
-{
-	SET_COLUMN(EndPressureCheck, EndPressure);
-}
-
-void DiveLogImportDialog::manualO2()
-{
-	SET_COLUMN(O2Check, O2);
-}
-
-void DiveLogImportDialog::manualHe()
-{
-	SET_COLUMN(HeCheck, He);
-}
-
-void DiveLogImportDialog::manualAirTemp()
-{
-	SET_COLUMN(AirTempCheck, AirTemp);
-}
-
-void DiveLogImportDialog::manualWaterTemp()
-{
-	SET_COLUMN(WaterTempCheck, WaterTemp);
-}
diff --git a/qt-ui/divelogimportdialog.h b/qt-ui/divelogimportdialog.h
index 36314f7..b2ee4ff 100644
--- a/qt-ui/divelogimportdialog.h
+++ b/qt-ui/divelogimportdialog.h
@@ -23,26 +23,6 @@ slots:
 	void on_knownImports_currentIndexChanged(int index);
 	void unknownImports();
 
-	void manualDiveNumber();
-	void manualDate();
-	void manualTime();
-	void manualLocation();
-	void manualGps();
-	void manualMaxDepth();
-	void manualMeanDepth();
-	void manualBuddy();
-	void manualNotes();
-	void manualTags();
-	void manualWeight();
-	void manualDuration();
-	void manualCylinderSize();
-	void manualStartPressure();
-	void manualEndPressure();
-	void manualO2();
-	void manualHe();
-	void manualAirTemp();
-	void manualWaterTemp();
-
 private:
 	bool selector;
 	QStringList fileNames;
diff --git a/qt-ui/divelogimportdialog.ui b/qt-ui/divelogimportdialog.ui
index 7b4e909..13ee3e9 100644
--- a/qt-ui/divelogimportdialog.ui
+++ b/qt-ui/divelogimportdialog.ui
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>522</width>
-    <height>436</height>
+    <width>709</width>
+    <height>646</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -20,815 +20,103 @@
   </property>
   <layout class="QVBoxLayout" name="verticalLayout">
    <item>
-    <widget class="QTabWidget" name="tabWidget">
-     <property name="currentIndex">
-      <number>0</number>
-     </property>
-     <widget class="QWidget" name="tab">
-      <attribute name="title">
-       <string>CSV options</string>
-      </attribute>
-      <layout class="QGridLayout" name="gridLayout_2">
-       <item row="2" column="1">
-        <widget class="QGroupBox" name="groupBox_7">
-         <property name="title">
-          <string>Units</string>
-         </property>
-         <layout class="QHBoxLayout" name="horizontalLayout_4b">
-          <item>
-           <widget class="QComboBox" name="CSVUnits">
-            <item>
-             <property name="text">
-              <string>Metric</string>
-             </property>
-            </item>
-            <item>
-             <property name="text">
-              <string>Imperial</string>
-             </property>
-            </item>
-           </widget>
-          </item>
-         </layout>
-        </widget>
-       </item>
-       <item row="0" column="1">
-        <widget class="QGroupBox" name="groupBox_2">
-         <property name="title">
-          <string>Field separator</string>
-         </property>
-         <layout class="QHBoxLayout" name="horizontalLayout_2">
-          <item>
-           <widget class="QComboBox" name="CSVSeparator"/>
-          </item>
-         </layout>
-        </widget>
-       </item>
-       <item row="3" column="1">
-        <spacer name="verticalSpacer">
-         <property name="orientation">
-          <enum>Qt::Vertical</enum>
-         </property>
-         <property name="sizeHint" stdset="0">
-          <size>
-           <width>20</width>
-           <height>40</height>
-          </size>
-         </property>
-        </spacer>
-       </item>
-       <item row="0" column="0" rowspan="3">
-        <widget class="QGroupBox" name="groupBox_3">
-         <property name="title">
-          <string>Field configuration</string>
-         </property>
-         <layout class="QGridLayout" name="gridLayout">
-          <item row="3" column="1">
-           <widget class="QSpinBox" name="CSVpo2">
-            <property name="enabled">
-             <bool>false</bool>
-            </property>
-            <property name="minimum">
-             <number>1</number>
-            </property>
-            <property name="value">
-             <number>1</number>
-            </property>
-           </widget>
-          </item>
-          <item row="1" column="1">
-           <widget class="QSpinBox" name="CSVDepth">
-            <property name="minimum">
-             <number>1</number>
-            </property>
-            <property name="value">
-             <number>2</number>
-            </property>
-           </widget>
-          </item>
-          <item row="2" column="1">
-           <widget class="QSpinBox" name="CSVTemperature">
-            <property name="enabled">
-             <bool>false</bool>
-            </property>
-            <property name="minimum">
-             <number>1</number>
-            </property>
-           </widget>
-          </item>
-          <item row="1" column="0">
-           <widget class="QLabel" name="label_2">
-            <property name="text">
-             <string>Depth</string>
-            </property>
-           </widget>
-          </item>
-          <item row="7" column="1">
-           <widget class="QSpinBox" name="CSVstopdepth">
-            <property name="enabled">
-             <bool>false</bool>
-            </property>
-            <property name="minimum">
-             <number>1</number>
-            </property>
-            <property name="value">
-             <number>1</number>
-            </property>
-           </widget>
-          </item>
-          <item row="7" column="0">
-           <widget class="QCheckBox" name="stopdepthCheckBox">
-            <property name="text">
-             <string>Stopdepth</string>
-            </property>
-           </widget>
-          </item>
-          <item row="8" column="1">
-           <widget class="QSpinBox" name="CSVpressure">
-            <property name="enabled">
-             <bool>false</bool>
-            </property>
-            <property name="minimum">
-             <number>1</number>
-            </property>
-            <property name="value">
-             <number>1</number>
-            </property>
-           </widget>
-          </item>
-          <item row="8" column="0">
-           <widget class="QCheckBox" name="pressureCheckBox">
-            <property name="text">
-             <string>Pressure</string>
-            </property>
-           </widget>
-          </item>
-          <item row="3" column="0">
-           <widget class="QCheckBox" name="po2CheckBox">
-            <property name="text">
-             <string>pO₂</string>
-            </property>
-           </widget>
-          </item>
-          <item row="0" column="0">
-           <widget class="QLabel" name="label">
-            <property name="text">
-             <string>Time</string>
-            </property>
-           </widget>
-          </item>
-          <item row="2" column="0">
-           <widget class="QCheckBox" name="temperatureCheckBox">
-            <property name="text">
-             <string>Temp</string>
-            </property>
-           </widget>
-          </item>
-          <item row="0" column="1">
-           <widget class="QSpinBox" name="CSVTime">
-            <property name="minimum">
-             <number>1</number>
-            </property>
-            <property name="value">
-             <number>1</number>
-            </property>
-           </widget>
-          </item>
-          <item row="4" column="1">
-           <widget class="QSpinBox" name="CSVcns">
-            <property name="enabled">
-             <bool>false</bool>
-            </property>
-            <property name="minimum">
-             <number>1</number>
-            </property>
-            <property name="value">
-             <number>1</number>
-            </property>
-           </widget>
-          </item>
-          <item row="5" column="0">
-           <widget class="QCheckBox" name="ndlCheckBox">
-            <property name="text">
-             <string>NDL</string>
-            </property>
-           </widget>
-          </item>
-          <item row="5" column="1">
-           <widget class="QSpinBox" name="CSVndl">
-            <property name="enabled">
-             <bool>false</bool>
-            </property>
-            <property name="minimum">
-             <number>1</number>
-            </property>
-            <property name="value">
-             <number>1</number>
-            </property>
-           </widget>
-          </item>
-          <item row="6" column="0">
-           <widget class="QCheckBox" name="ttsCheckBox">
-            <property name="text">
-             <string>TTS</string>
-            </property>
-           </widget>
-          </item>
-          <item row="6" column="1">
-           <widget class="QSpinBox" name="CSVtts">
-            <property name="enabled">
-             <bool>false</bool>
-            </property>
-            <property name="minimum">
-             <number>1</number>
-            </property>
-            <property name="value">
-             <number>1</number>
-            </property>
-           </widget>
-          </item>
-          <item row="4" column="0">
-           <widget class="QCheckBox" name="cnsCheckBox">
-            <property name="text">
-             <string>Cns</string>
-            </property>
-           </widget>
-          </item>
-         </layout>
-         <zorder>CSVpressure</zorder>
-         <zorder>pressureCheckBox</zorder>
-         <zorder>ndlCheckBox</zorder>
-         <zorder>CSVndl</zorder>
-         <zorder>ttsCheckBox</zorder>
-         <zorder>CSVtts</zorder>
-         <zorder>label</zorder>
-         <zorder>label_2</zorder>
-         <zorder>CSVTime</zorder>
-         <zorder>CSVDepth</zorder>
-         <zorder>temperatureCheckBox</zorder>
-         <zorder>CSVTemperature</zorder>
-         <zorder>po2CheckBox</zorder>
-         <zorder>CSVpo2</zorder>
-         <zorder>cnsCheckBox</zorder>
-         <zorder>CSVcns</zorder>
-         <zorder>stopdepthCheckBox</zorder>
-         <zorder>CSVstopdepth</zorder>
-        </widget>
-       </item>
-       <item row="1" column="1">
-        <widget class="QGroupBox" name="groupBox_4">
-         <property name="title">
-          <string>Pre-configured imports</string>
-         </property>
-         <layout class="QHBoxLayout" name="horizontalLayout_4">
-          <item>
-           <widget class="QComboBox" name="knownImports">
-            <property name="currentIndex">
-             <number>-1</number>
-            </property>
-           </widget>
-          </item>
-         </layout>
-        </widget>
-       </item>
-      </layout>
-     </widget>
-     <widget class="QWidget" name="tab_2">
-      <attribute name="title">
-       <string>Manual dives</string>
-      </attribute>
-      <layout class="QGridLayout" name="gridLayout_4">
-       <item row="3" column="1">
-        <widget class="QGroupBox" name="groupBox_8">
-         <property name="sizePolicy">
-          <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-         <property name="minimumSize">
-          <size>
-           <width>0</width>
-           <height>70</height>
-          </size>
-         </property>
-         <property name="toolTip">
-          <string>Choose day, month and year order for date format. The field separator can be any of the characters .-/.</string>
-         </property>
-         <property name="title">
-          <string>Date format</string>
-         </property>
-         <widget class="QComboBox" name="DateFormat">
-          <property name="geometry">
-           <rect>
-            <x>20</x>
-            <y>40</y>
-            <width>100</width>
-            <height>27</height>
-           </rect>
-          </property>
-          <item>
-           <property name="text">
-            <string>dd.mm.yyyy</string>
-           </property>
-          </item>
-          <item>
-           <property name="text">
-            <string>mm/dd/yyyy</string>
-           </property>
-          </item>
-          <item>
-           <property name="text">
-            <string>yyyy-mm-dd</string>
-           </property>
-          </item>
-         </widget>
-        </widget>
-       </item>
-       <item row="2" column="1">
-        <widget class="QGroupBox" name="groupBox_6">
-         <property name="sizePolicy">
-          <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-         <property name="minimumSize">
-          <size>
-           <width>0</width>
-           <height>70</height>
-          </size>
-         </property>
-         <property name="title">
-          <string>Units</string>
-         </property>
-         <layout class="QHBoxLayout" name="horizontalLayout_5">
-          <item>
-           <widget class="QComboBox" name="Units">
-            <item>
-             <property name="text">
-              <string>Metric</string>
-             </property>
-            </item>
-            <item>
-             <property name="text">
-              <string>Imperial</string>
-             </property>
-            </item>
-           </widget>
-          </item>
-         </layout>
-        </widget>
-       </item>
-       <item row="0" column="0" rowspan="7">
-        <widget class="QGroupBox" name="groupBox">
-         <property name="title">
-          <string>Field configuration</string>
-         </property>
-         <layout class="QGridLayout" name="gridLayout_3">
-          <item row="0" column="0">
-           <widget class="QCheckBox" name="DiveNumberCheck">
-            <property name="text">
-             <string>Dive #</string>
-            </property>
-           </widget>
-          </item>
-          <item row="0" column="1">
-           <widget class="QSpinBox" name="DiveNumber">
-            <property name="enabled">
-             <bool>false</bool>
-            </property>
-            <property name="minimum">
-             <number>1</number>
-            </property>
-           </widget>
-          </item>
-          <item row="0" column="2">
-           <widget class="QCheckBox" name="MaxDepthCheck">
-            <property name="text">
-             <string>Max depth</string>
-            </property>
-           </widget>
-          </item>
-          <item row="0" column="3">
-           <widget class="QSpinBox" name="MaxDepth">
-            <property name="enabled">
-             <bool>false</bool>
-            </property>
-            <property name="minimum">
-             <number>1</number>
-            </property>
-           </widget>
-          </item>
-          <item row="1" column="0">
-           <widget class="QCheckBox" name="DateCheck">
-            <property name="toolTip">
-             <string>Date in dd.mm.yyyy, yyyy-mm-dd or mm/dd/yyyy format</string>
-            </property>
-            <property name="text">
-             <string>Date</string>
-            </property>
-           </widget>
-          </item>
-          <item row="1" column="1">
-           <widget class="QSpinBox" name="Date">
-            <property name="enabled">
-             <bool>false</bool>
-            </property>
-            <property name="toolTip">
-             <string>Date in dd.mm.yyyy, yyyy-mm-dd or mm/dd/yyyy format</string>
-            </property>
-            <property name="minimum">
-             <number>1</number>
-            </property>
-           </widget>
-          </item>
-          <item row="1" column="2">
-           <widget class="QCheckBox" name="MeanDepthCheck">
-            <property name="text">
-             <string>Mean depth</string>
-            </property>
-           </widget>
-          </item>
-          <item row="1" column="3">
-           <widget class="QSpinBox" name="MeanDepth">
-            <property name="enabled">
-             <bool>false</bool>
-            </property>
-            <property name="minimum">
-             <number>1</number>
-            </property>
-           </widget>
-          </item>
-          <item row="2" column="0">
-           <widget class="QCheckBox" name="TimeCheck">
-            <property name="text">
-             <string>Time</string>
-            </property>
-           </widget>
-          </item>
-          <item row="2" column="1">
-           <widget class="QSpinBox" name="Time">
-            <property name="enabled">
-             <bool>false</bool>
-            </property>
-            <property name="minimum">
-             <number>1</number>
-            </property>
-           </widget>
-          </item>
-          <item row="2" column="2">
-           <widget class="QCheckBox" name="BuddyCheck">
-            <property name="text">
-             <string>Buddy</string>
-            </property>
-           </widget>
-          </item>
-          <item row="2" column="3">
-           <widget class="QSpinBox" name="Buddy">
-            <property name="enabled">
-             <bool>false</bool>
-            </property>
-            <property name="minimum">
-             <number>1</number>
-            </property>
-           </widget>
-          </item>
-          <item row="3" column="0">
-           <widget class="QCheckBox" name="DurationCheck">
-            <property name="toolTip">
-             <string>Dive duration in seconds or in min:sec format</string>
-            </property>
-            <property name="text">
-             <string>Duration</string>
-            </property>
-           </widget>
-          </item>
-          <item row="3" column="1">
-           <widget class="QSpinBox" name="Duration">
-            <property name="enabled">
-             <bool>false</bool>
-            </property>
-            <property name="toolTip">
-             <string>Dive duration in seconds or in min:sec format</string>
-            </property>
-            <property name="minimum">
-             <number>1</number>
-            </property>
-           </widget>
-          </item>
-          <item row="3" column="2">
-           <widget class="QCheckBox" name="NotesCheck">
-            <property name="text">
-             <string>Notes</string>
-            </property>
-           </widget>
-          </item>
-          <item row="3" column="3">
-           <widget class="QSpinBox" name="Notes">
-            <property name="enabled">
-             <bool>false</bool>
-            </property>
-            <property name="minimum">
-             <number>1</number>
-            </property>
-           </widget>
-          </item>
-          <item row="4" column="0">
-           <widget class="QCheckBox" name="LocationCheck">
-            <property name="text">
-             <string>Location</string>
-            </property>
-           </widget>
-          </item>
-          <item row="4" column="1">
-           <widget class="QSpinBox" name="Location">
-            <property name="enabled">
-             <bool>false</bool>
-            </property>
-            <property name="minimum">
-             <number>1</number>
-            </property>
-           </widget>
-          </item>
-          <item row="6" column="0">
-           <widget class="QCheckBox" name="WeightCheck">
-            <property name="text">
-             <string>Weight</string>
-            </property>
-           </widget>
-          </item>
-          <item row="6" column="1">
-           <widget class="QSpinBox" name="Weight">
-            <property name="enabled">
-             <bool>false</bool>
-            </property>
-            <property name="minimum">
-             <number>1</number>
-            </property>
-           </widget>
-          </item>
-          <item row="5" column="0">
-           <widget class="QCheckBox" name="GpsCheck">
-            <property name="text">
-             <string>GPS</string>
-            </property>
-           </widget>
-          </item>
-          <item row="5" column="1">
-           <widget class="QSpinBox" name="Gps">
-            <property name="enabled">
-             <bool>false</bool>
-            </property>
-            <property name="minimum">
-             <number>1</number>
-            </property>
-           </widget>
-          </item>
-          <item row="4" column="2">
-           <widget class="QCheckBox" name="TagsCheck">
-            <property name="text">
-             <string>Tags</string>
-            </property>
-           </widget>
-          </item>
-          <item row="4" column="3">
-           <widget class="QSpinBox" name="Tags">
-            <property name="enabled">
-             <bool>false</bool>
-            </property>
-            <property name="minimum">
-             <number>1</number>
-            </property>
-           </widget>
-          </item>
-          <item row="7" column="0">
-           <widget class="QCheckBox" name="CylinderSizeCheck">
-            <property name="text">
-             <string>Cyl size</string>
-            </property>
-           </widget>
-          </item>
-          <item row="7" column="1">
-           <widget class="QSpinBox" name="CylinderSize">
-            <property name="enabled">
-             <bool>false</bool>
-            </property>
-            <property name="minimum">
-             <number>1</number>
-            </property>
-           </widget>
-          </item>
-          <item row="5" column="2">
-           <widget class="QCheckBox" name="AirTempCheck">
-            <property name="text">
-             <string>Air temp</string>
-            </property>
-           </widget>
-          </item>
-          <item row="5" column="3">
-           <widget class="QSpinBox" name="AirTemp">
-            <property name="enabled">
-             <bool>false</bool>
-            </property>
-            <property name="minimum">
-             <number>1</number>
-            </property>
-           </widget>
-          </item>
-          <item row="8" column="0">
-           <widget class="QCheckBox" name="StartPressureCheck">
-            <property name="text">
-             <string>Start Pressure</string>
-            </property>
-           </widget>
-          </item>
-          <item row="8" column="1">
-           <widget class="QSpinBox" name="StartPressure">
-            <property name="enabled">
-             <bool>false</bool>
-            </property>
-            <property name="minimum">
-             <number>1</number>
-            </property>
-           </widget>
-          </item>
-          <item row="6" column="2">
-           <widget class="QCheckBox" name="WaterTempCheck">
-            <property name="text">
-             <string>Water temp</string>
-            </property>
-           </widget>
-          </item>
-          <item row="6" column="3">
-           <widget class="QSpinBox" name="WaterTemp">
-            <property name="enabled">
-             <bool>false</bool>
-            </property>
-            <property name="minimum">
-             <number>1</number>
-            </property>
-           </widget>
-          </item>
-          <item row="9" column="0">
-           <widget class="QCheckBox" name="EndPressureCheck">
-            <property name="text">
-             <string>End Press</string>
-            </property>
-           </widget>
-          </item>
-          <item row="9" column="1">
-           <widget class="QSpinBox" name="EndPressure">
-            <property name="enabled">
-             <bool>false</bool>
-            </property>
-            <property name="minimum">
-             <number>1</number>
-            </property>
-           </widget>
-          </item>
-          <item row="8" column="2">
-           <widget class="QCheckBox" name="O2Check">
-            <property name="text">
-             <string>O₂</string>
-            </property>
-           </widget>
-          </item>
-          <item row="8" column="3">
-           <widget class="QSpinBox" name="O2">
-            <property name="enabled">
-             <bool>false</bool>
-            </property>
-            <property name="minimum">
-             <number>1</number>
-            </property>
-           </widget>
-          </item>
-          <item row="9" column="2">
-           <widget class="QCheckBox" name="HeCheck">
-            <property name="text">
-             <string>He</string>
-            </property>
-           </widget>
-          </item>
-          <item row="9" column="3">
-           <widget class="QSpinBox" name="He">
-            <property name="enabled">
-             <bool>false</bool>
-            </property>
-            <property name="minimum">
-             <number>1</number>
-            </property>
-           </widget>
-          </item>
-         </layout>
-        </widget>
-       </item>
-       <item row="4" column="1">
-        <widget class="QGroupBox" name="groupBox_9">
-         <property name="sizePolicy">
-          <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-         <property name="minimumSize">
-          <size>
-           <width>0</width>
-           <height>70</height>
-          </size>
-         </property>
-         <property name="toolTip">
-          <string>Choose duration format.</string>
-         </property>
-         <property name="title">
-          <string>Duration format</string>
-         </property>
-         <widget class="QComboBox" name="DurationFormat">
-          <property name="geometry">
-           <rect>
-            <x>20</x>
-            <y>40</y>
-            <width>100</width>
-            <height>27</height>
-           </rect>
-          </property>
-          <item>
-           <property name="text">
-            <string>Seconds</string>
-           </property>
-          </item>
-          <item>
-           <property name="text">
-            <string>Minutes</string>
-           </property>
-          </item>
-          <item>
-           <property name="text">
-            <string>Minutes:seconds</string>
-           </property>
-          </item>
-         </widget>
-        </widget>
-       </item>
-       <item row="1" column="1">
-        <widget class="QGroupBox" name="groupBox_5">
-         <property name="sizePolicy">
-          <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-         <property name="minimumSize">
-          <size>
-           <width>0</width>
-           <height>70</height>
-          </size>
-         </property>
-         <property name="title">
-          <string>Field separator</string>
-         </property>
-         <layout class="QHBoxLayout" name="horizontalLayout">
-          <item>
-           <widget class="QComboBox" name="ManualSeparator"/>
-          </item>
-         </layout>
-        </widget>
-       </item>
-      </layout>
-     </widget>
-    </widget>
-   </item>
-   <item>
     <widget class="QWidget" name="horizontalWidget" native="true">
      <layout class="QHBoxLayout" name="horizontalLayout_3">
       <property name="spacing">
        <number>0</number>
       </property>
-      <property name="leftMargin">
-       <number>0</number>
-      </property>
-      <property name="topMargin">
-       <number>0</number>
-      </property>
-      <property name="rightMargin">
-       <number>0</number>
-      </property>
-      <property name="bottomMargin">
+      <property name="margin">
        <number>0</number>
       </property>
       <item>
        <widget class="QWidget" name="verticalWidget" native="true">
         <layout class="QVBoxLayout" name="verticalLayout_2">
-         <property name="topMargin">
-          <number>0</number>
-         </property>
-         <property name="rightMargin">
-          <number>0</number>
-         </property>
-         <property name="bottomMargin">
-          <number>0</number>
-         </property>
+         <item>
+          <layout class="QHBoxLayout" name="horizontalLayout">
+           <item>
+            <widget class="QComboBox" name="knownImports">
+             <property name="currentIndex">
+              <number>-1</number>
+             </property>
+            </widget>
+           </item>
+           <item>
+            <widget class="QComboBox" name="CSVSeparator"/>
+           </item>
+           <item>
+            <widget class="QComboBox" name="DateFormat">
+             <item>
+              <property name="text">
+               <string>dd.mm.yyyy</string>
+              </property>
+             </item>
+             <item>
+              <property name="text">
+               <string>mm/dd/yyyy</string>
+              </property>
+             </item>
+             <item>
+              <property name="text">
+               <string>yyyy-mm-dd</string>
+              </property>
+             </item>
+            </widget>
+           </item>
+           <item>
+            <widget class="QComboBox" name="DurationFormat">
+             <item>
+              <property name="text">
+               <string>Seconds</string>
+              </property>
+             </item>
+             <item>
+              <property name="text">
+               <string>Minutes</string>
+              </property>
+             </item>
+             <item>
+              <property name="text">
+               <string>Minutes:seconds</string>
+              </property>
+             </item>
+            </widget>
+           </item>
+           <item>
+            <widget class="QComboBox" name="CSVUnits">
+             <item>
+              <property name="text">
+               <string>Metric</string>
+              </property>
+             </item>
+             <item>
+              <property name="text">
+               <string>Imperial</string>
+              </property>
+             </item>
+            </widget>
+           </item>
+          </layout>
+         </item>
+         <item>
+          <widget class="QListView" name="avaliableColumns">
+           <property name="maximumSize">
+            <size>
+             <width>16777215</width>
+             <height>150</height>
+            </size>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QLabel" name="label">
+           <property name="text">
+            <string>Drag the tags above to each corresponding column below</string>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <widget class="QTableView" name="tableView"/>
+         </item>
          <item>
           <widget class="QDialogButtonBox" name="buttonBox">
            <property name="orientation">
@@ -848,19 +136,6 @@
   </layout>
  </widget>
  <tabstops>
-  <tabstop>tabWidget</tabstop>
-  <tabstop>CSVTime</tabstop>
-  <tabstop>CSVDepth</tabstop>
-  <tabstop>temperatureCheckBox</tabstop>
-  <tabstop>CSVTemperature</tabstop>
-  <tabstop>po2CheckBox</tabstop>
-  <tabstop>CSVpo2</tabstop>
-  <tabstop>cnsCheckBox</tabstop>
-  <tabstop>CSVcns</tabstop>
-  <tabstop>stopdepthCheckBox</tabstop>
-  <tabstop>CSVstopdepth</tabstop>
-  <tabstop>CSVSeparator</tabstop>
-  <tabstop>knownImports</tabstop>
   <tabstop>buttonBox</tabstop>
  </tabstops>
  <resources/>
@@ -897,373 +172,5 @@
     </hint>
    </hints>
   </connection>
-  <connection>
-   <sender>temperatureCheckBox</sender>
-   <signal>clicked(bool)</signal>
-   <receiver>CSVTemperature</receiver>
-   <slot>setEnabled(bool)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>108</x>
-     <y>169</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>238</x>
-     <y>171</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>po2CheckBox</sender>
-   <signal>clicked(bool)</signal>
-   <receiver>CSVpo2</receiver>
-   <slot>setEnabled(bool)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>108</x>
-     <y>201</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>238</x>
-     <y>203</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>cnsCheckBox</sender>
-   <signal>clicked(bool)</signal>
-   <receiver>CSVcns</receiver>
-   <slot>setEnabled(bool)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>108</x>
-     <y>233</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>238</x>
-     <y>235</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>stopdepthCheckBox</sender>
-   <signal>clicked(bool)</signal>
-   <receiver>CSVstopdepth</receiver>
-   <slot>setEnabled(bool)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>108</x>
-     <y>265</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>238</x>
-     <y>267</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>DiveNumberCheck</sender>
-   <signal>clicked(bool)</signal>
-   <receiver>DiveNumber</receiver>
-   <slot>setEnabled(bool)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>96</x>
-     <y>103</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>176</x>
-     <y>105</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>DateCheck</sender>
-   <signal>clicked(bool)</signal>
-   <receiver>Date</receiver>
-   <slot>setEnabled(bool)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>96</x>
-     <y>135</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>176</x>
-     <y>137</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>TimeCheck</sender>
-   <signal>clicked(bool)</signal>
-   <receiver>Time</receiver>
-   <slot>setEnabled(bool)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>96</x>
-     <y>167</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>176</x>
-     <y>169</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>LocationCheck</sender>
-   <signal>clicked(bool)</signal>
-   <receiver>Location</receiver>
-   <slot>setEnabled(bool)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>96</x>
-     <y>231</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>176</x>
-     <y>233</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>GpsCheck</sender>
-   <signal>clicked(bool)</signal>
-   <receiver>Gps</receiver>
-   <slot>setEnabled(bool)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>96</x>
-     <y>263</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>176</x>
-     <y>265</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>MaxDepthCheck</sender>
-   <signal>clicked(bool)</signal>
-   <receiver>MaxDepth</receiver>
-   <slot>setEnabled(bool)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>185</x>
-     <y>103</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>296</x>
-     <y>105</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>MeanDepthCheck</sender>
-   <signal>clicked(bool)</signal>
-   <receiver>MeanDepth</receiver>
-   <slot>setEnabled(bool)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>185</x>
-     <y>135</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>296</x>
-     <y>137</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>BuddyCheck</sender>
-   <signal>clicked(bool)</signal>
-   <receiver>Buddy</receiver>
-   <slot>setEnabled(bool)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>185</x>
-     <y>167</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>296</x>
-     <y>169</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>NotesCheck</sender>
-   <signal>clicked(bool)</signal>
-   <receiver>Notes</receiver>
-   <slot>setEnabled(bool)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>185</x>
-     <y>199</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>296</x>
-     <y>201</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>TagsCheck</sender>
-   <signal>clicked(bool)</signal>
-   <receiver>Tags</receiver>
-   <slot>setEnabled(bool)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>185</x>
-     <y>263</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>296</x>
-     <y>265</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>WeightCheck</sender>
-   <signal>clicked(bool)</signal>
-   <receiver>Weight</receiver>
-   <slot>setEnabled(bool)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>185</x>
-     <y>231</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>296</x>
-     <y>233</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>DurationCheck</sender>
-   <signal>clicked(bool)</signal>
-   <receiver>Duration</receiver>
-   <slot>setEnabled(bool)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>96</x>
-     <y>199</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>176</x>
-     <y>201</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>CylinderSizeCheck</sender>
-   <signal>clicked(bool)</signal>
-   <receiver>CylinderSize</receiver>
-   <slot>setEnabled(bool)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>20</x>
-     <y>20</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>20</x>
-     <y>20</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>StartPressureCheck</sender>
-   <signal>clicked(bool)</signal>
-   <receiver>StartPressure</receiver>
-   <slot>setEnabled(bool)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>20</x>
-     <y>20</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>20</x>
-     <y>20</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>EndPressureCheck</sender>
-   <signal>clicked(bool)</signal>
-   <receiver>EndPressure</receiver>
-   <slot>setEnabled(bool)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>20</x>
-     <y>20</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>20</x>
-     <y>20</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>O2Check</sender>
-   <signal>clicked(bool)</signal>
-   <receiver>O2</receiver>
-   <slot>setEnabled(bool)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>20</x>
-     <y>20</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>20</x>
-     <y>20</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>HeCheck</sender>
-   <signal>clicked(bool)</signal>
-   <receiver>He</receiver>
-   <slot>setEnabled(bool)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>20</x>
-     <y>20</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>20</x>
-     <y>20</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>AirTempCheck</sender>
-   <signal>clicked(bool)</signal>
-   <receiver>AirTemp</receiver>
-   <slot>setEnabled(bool)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>20</x>
-     <y>20</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>20</x>
-     <y>20</y>
-    </hint>
-   </hints>
-  </connection>
-  <connection>
-   <sender>WaterTempCheck</sender>
-   <signal>clicked(bool)</signal>
-   <receiver>WaterTemp</receiver>
-   <slot>setEnabled(bool)</slot>
-   <hints>
-    <hint type="sourcelabel">
-     <x>20</x>
-     <y>20</y>
-    </hint>
-    <hint type="destinationlabel">
-     <x>20</x>
-     <y>20</y>
-    </hint>
-   </hints>
-  </connection>
  </connections>
 </ui>
-- 
2.2.1

From 687f1544ab8dcb000aaabf3566ee2fe0e85e2a4b Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 6 Jan 2015 14:32:03 -0200
Subject: [PATCH 02/27] Skeleton code for the Model that have the Columns
 Information

Just the skeleton, then start doing stuff.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/divelogimportdialog.cpp | 32 ++++++++++++++++++++++++++++++++
 qt-ui/divelogimportdialog.h   | 14 ++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 02fc03e..69639e2 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -4,6 +4,8 @@
 #include "divelogimportdialog.h"
 #include "mainwindow.h"
 #include "ui_divelogimportdialog.h"
+#include <QAbstractListModel>
+#include <QAbstractTableModel>
 
 const DiveLogImportDialog::CSVAppConfig DiveLogImportDialog::CSVApps[CSVAPPS] = {
 	// time, depth, temperature, po2, cns, ndl, tts, stopdepth, pressure
@@ -16,6 +18,36 @@ const DiveLogImportDialog::CSVAppConfig DiveLogImportDialog::CSVApps[CSVAPPS] =
 	{ NULL, }
 };
 
+ColumnNameProvider::ColumnNameProvider(QObject *parent)
+{
+
+}
+
+bool ColumnNameProvider::insertRows(int row, int count, const QModelIndex &parent)
+{
+
+}
+
+bool ColumnNameProvider::removeRows(int row, int count, const QModelIndex &parent)
+{
+
+}
+
+bool ColumnNameProvider::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+
+}
+
+QVariant ColumnNameProvider::data(const QModelIndex &index, int role) const
+{
+
+}
+
+int ColumnNameProvider::rowCount(const QModelIndex &parent) const
+{
+
+}
+
 DiveLogImportDialog::DiveLogImportDialog(QStringList *fn, QWidget *parent) : QDialog(parent),
 	selector(true),
 	ui(new Ui::DiveLogImportDialog)
diff --git a/qt-ui/divelogimportdialog.h b/qt-ui/divelogimportdialog.h
index b2ee4ff..f658e5d 100644
--- a/qt-ui/divelogimportdialog.h
+++ b/qt-ui/divelogimportdialog.h
@@ -2,6 +2,7 @@
 #define DIVELOGIMPORTDIALOG_H
 
 #include <QDialog>
+#include <QAbstractListModel>
 
 #include "../dive.h"
 #include "../divelist.h"
@@ -10,6 +11,19 @@ namespace Ui {
 	class DiveLogImportDialog;
 }
 
+class ColumnNameProvider : public QAbstractListModel {
+	Q_OBJECT
+public:
+	ColumnNameProvider(QObject *parent);
+	bool insertRows(int row, int count, const QModelIndex &parent);
+	bool removeRows(int row, int count, const QModelIndex &parent);
+	bool setData(const QModelIndex &index, const QVariant &value, int role);
+	QVariant data(const QModelIndex &index, int role) const;
+	int rowCount(const QModelIndex &parent) const;
+private:
+	QStringList columnNames;
+};
+
 class DiveLogImportDialog : public QDialog {
 	Q_OBJECT
 
-- 
2.2.1

From ea96963d4e2e2ff9a34d59076a21607dfadca8f2 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 6 Jan 2015 14:39:56 -0200
Subject: [PATCH 03/27] Added data, row count and the Stringlist that populated
 the model.

I know that there is a QStringListModel, but that doesn't
has add and remove methods, and thus I cannot use it. ;)

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/divelogimportdialog.cpp | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 69639e2..cff3864 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -20,7 +20,9 @@ const DiveLogImportDialog::CSVAppConfig DiveLogImportDialog::CSVApps[CSVAPPS] =
 
 ColumnNameProvider::ColumnNameProvider(QObject *parent)
 {
-
+	columnNames << tr("Dive #") << tr("Date") << tr("Time") << tr("Duration") << tr("Location") << tr("GPS") << tr("Weight") << tr("Cyl size") << tr("Start Pressure")
+		    << tr("End Press") << tr("Max depth") << tr("Mean depth") << tr("Buddy") << tr("Notes") << tr("Tags") << tr("Air temp") << tr("Water temp")
+		    << tr("O₂") << tr("He");
 }
 
 bool ColumnNameProvider::insertRows(int row, int count, const QModelIndex &parent)
@@ -40,12 +42,19 @@ bool ColumnNameProvider::setData(const QModelIndex &index, const QVariant &value
 
 QVariant ColumnNameProvider::data(const QModelIndex &index, int role) const
 {
+	if (!index.isValid())
+		return QVariant();
+
+	if (role != Qt::DisplayRole)
+		return QVariant();
 
+	return QVariant(columnNames[index.row()]);
 }
 
 int ColumnNameProvider::rowCount(const QModelIndex &parent) const
 {
-
+	Q_UNUSED(parent)
+	return columnNames.count();
 }
 
 DiveLogImportDialog::DiveLogImportDialog(QStringList *fn, QWidget *parent) : QDialog(parent),
-- 
2.2.1

From 6c9b58096b176e166ded67131bea3279679efa30 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 6 Jan 2015 14:45:49 -0200
Subject: [PATCH 04/27] Display the list of column names on the ListView

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/divelogimportdialog.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index cff3864..60d74a9 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -18,7 +18,7 @@ const DiveLogImportDialog::CSVAppConfig DiveLogImportDialog::CSVApps[CSVAPPS] =
 	{ NULL, }
 };
 
-ColumnNameProvider::ColumnNameProvider(QObject *parent)
+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")
 		    << tr("End Press") << tr("Max depth") << tr("Mean depth") << tr("Buddy") << tr("Notes") << tr("Tags") << tr("Air temp") << tr("Water temp")
@@ -75,6 +75,9 @@ DiveLogImportDialog::DiveLogImportDialog(QStringList *fn, QWidget *parent) : QDi
 	ui->CSVSeparator->addItems( QStringList() << tr("Separator") << tr("Tab") << ";" << ",");
 	ui->knownImports->setCurrentIndex(1);
 
+	ColumnNameProvider *provider = new ColumnNameProvider(this);
+	ui->avaliableColumns->setModel(provider);
+
 	/* manually import CSV file */
 	QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this);
 	connect(close, SIGNAL(activated()), this, SLOT(close()));
-- 
2.2.1

From 8fc8e2654c475ed147da32790a63063a3696ad39 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 6 Jan 2015 14:47:08 -0200
Subject: [PATCH 05/27] Set the lsit view to IconMode

This is needed so the list of items appear in a grid
like view.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/divelogimportdialog.ui | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/qt-ui/divelogimportdialog.ui b/qt-ui/divelogimportdialog.ui
index 13ee3e9..287d67e 100644
--- a/qt-ui/divelogimportdialog.ui
+++ b/qt-ui/divelogimportdialog.ui
@@ -105,6 +105,9 @@
              <height>150</height>
             </size>
            </property>
+           <property name="viewMode">
+            <enum>QListView::IconMode</enum>
+           </property>
           </widget>
          </item>
          <item>
-- 
2.2.1

From e6214883a9bcd72873def3547b60fcdd3d14ff2c Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 6 Jan 2015 14:54:58 -0200
Subject: [PATCH 06/27] Added class skeleton that will handle the Drag Starts

This class will handle the drag 'n drop "Drag" part.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/divelogimportdialog.cpp | 10 ++++++++++
 qt-ui/divelogimportdialog.h   |  9 +++++++++
 qt-ui/divelogimportdialog.ui  |  9 ++++++++-
 3 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 60d74a9..d3a29ba 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -57,6 +57,16 @@ int ColumnNameProvider::rowCount(const QModelIndex &parent) const
 	return columnNames.count();
 }
 
+ColumnNameView::ColumnNameView(QWidget *parent)
+{
+
+}
+
+void ColumnNameView::mousePressEvent(QMouseEvent *press)
+{
+
+}
+
 DiveLogImportDialog::DiveLogImportDialog(QStringList *fn, QWidget *parent) : QDialog(parent),
 	selector(true),
 	ui(new Ui::DiveLogImportDialog)
diff --git a/qt-ui/divelogimportdialog.h b/qt-ui/divelogimportdialog.h
index f658e5d..9441fa7 100644
--- a/qt-ui/divelogimportdialog.h
+++ b/qt-ui/divelogimportdialog.h
@@ -3,6 +3,7 @@
 
 #include <QDialog>
 #include <QAbstractListModel>
+#include <QListView>
 
 #include "../dive.h"
 #include "../divelist.h"
@@ -24,6 +25,14 @@ private:
 	QStringList columnNames;
 };
 
+class ColumnNameView : public QListView {
+	Q_OBJECT
+public:
+	ColumnNameView(QWidget *parent);
+protected:
+	void mousePressEvent(QMouseEvent *press);
+};
+
 class DiveLogImportDialog : public QDialog {
 	Q_OBJECT
 
diff --git a/qt-ui/divelogimportdialog.ui b/qt-ui/divelogimportdialog.ui
index 287d67e..8cbf9bc 100644
--- a/qt-ui/divelogimportdialog.ui
+++ b/qt-ui/divelogimportdialog.ui
@@ -98,7 +98,7 @@
           </layout>
          </item>
          <item>
-          <widget class="QListView" name="avaliableColumns">
+          <widget class="ColumnNameView" name="avaliableColumns">
            <property name="maximumSize">
             <size>
              <width>16777215</width>
@@ -138,6 +138,13 @@
    </item>
   </layout>
  </widget>
+ <customwidgets>
+  <customwidget>
+   <class>ColumnNameView</class>
+   <extends>QListView</extends>
+   <header>divelogimportdialog.h</header>
+  </customwidget>
+ </customwidgets>
  <tabstops>
   <tabstop>buttonBox</tabstop>
  </tabstops>
-- 
2.2.1

From eb25ebde0c6271a5f520fad9bb797a1fa6ec3078 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 6 Jan 2015 15:03:58 -0200
Subject: [PATCH 07/27] Started to Drag the correct values.

This piece of code starts a drag and moves around data,
it does nothing with it yet.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/divelogimportdialog.cpp | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index d3a29ba..dbb3f60 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -6,7 +6,9 @@
 #include "ui_divelogimportdialog.h"
 #include <QAbstractListModel>
 #include <QAbstractTableModel>
-
+#include <QMouseEvent>
+#include <QDrag>
+#include <QMimeData>
 const DiveLogImportDialog::CSVAppConfig DiveLogImportDialog::CSVApps[CSVAPPS] = {
 	// time, depth, temperature, po2, cns, ndl, tts, stopdepth, pressure
 	{ "", },
@@ -64,7 +66,16 @@ ColumnNameView::ColumnNameView(QWidget *parent)
 
 void ColumnNameView::mousePressEvent(QMouseEvent *press)
 {
+	QModelIndex atClick = indexAt(press->pos());
+	if (!atClick.isValid())
+		return;
 
+	qDebug() << atClick.data();
+	QDrag *drag = new QDrag(this);
+	QMimeData *mimeData = new QMimeData;
+	mimeData->setText(atClick.data().toString());
+	drag->setMimeData(mimeData);
+	drag->exec();
 }
 
 DiveLogImportDialog::DiveLogImportDialog(QStringList *fn, QWidget *parent) : QDialog(parent),
-- 
2.2.1

From 8b017451dce9e213a557258424d3b3f604f6d20a Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 6 Jan 2015 15:14:14 -0200
Subject: [PATCH 08/27] More DragDrop skeletons.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/divelogimportdialog.cpp | 27 +++++++++++++++++++++++++--
 qt-ui/divelogimportdialog.h   |  7 +++++++
 2 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index dbb3f60..9db9106 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -34,7 +34,7 @@ bool ColumnNameProvider::insertRows(int row, int count, const QModelIndex &paren
 
 bool ColumnNameProvider::removeRows(int row, int count, const QModelIndex &parent)
 {
-
+	qDebug() << "Calling";
 }
 
 bool ColumnNameProvider::setData(const QModelIndex &index, const QVariant &value, int role)
@@ -61,7 +61,8 @@ int ColumnNameProvider::rowCount(const QModelIndex &parent) const
 
 ColumnNameView::ColumnNameView(QWidget *parent)
 {
-
+	setAcceptDrops(true);
+	setDragEnabled(true);
 }
 
 void ColumnNameView::mousePressEvent(QMouseEvent *press)
@@ -76,8 +77,30 @@ void ColumnNameView::mousePressEvent(QMouseEvent *press)
 	mimeData->setText(atClick.data().toString());
 	drag->setMimeData(mimeData);
 	drag->exec();
+	currentDraggedIndex = atClick.row();
+}
+
+void ColumnNameView::dragLeaveEvent(QDragLeaveEvent *leave)
+{
+	model()->removeRow(currentDraggedIndex);
+}
+
+void ColumnNameView::dragEnterEvent(QDragEnterEvent *event)
+{
+
 }
 
+void ColumnNameView::dragMoveEvent(QDragMoveEvent *event)
+{
+
+}
+
+void ColumnNameView::dropEvent(QDropEvent *event)
+{
+
+}
+
+
 DiveLogImportDialog::DiveLogImportDialog(QStringList *fn, QWidget *parent) : QDialog(parent),
 	selector(true),
 	ui(new Ui::DiveLogImportDialog)
diff --git a/qt-ui/divelogimportdialog.h b/qt-ui/divelogimportdialog.h
index 9441fa7..efb7f29 100644
--- a/qt-ui/divelogimportdialog.h
+++ b/qt-ui/divelogimportdialog.h
@@ -4,6 +4,7 @@
 #include <QDialog>
 #include <QAbstractListModel>
 #include <QListView>
+#include <QDragLeaveEvent>
 
 #include "../dive.h"
 #include "../divelist.h"
@@ -31,6 +32,12 @@ public:
 	ColumnNameView(QWidget *parent);
 protected:
 	void mousePressEvent(QMouseEvent *press);
+	void dragLeaveEvent(QDragLeaveEvent *leave);
+	void dragEnterEvent(QDragEnterEvent *event);
+	void dragMoveEvent(QDragMoveEvent *event);
+	void dropEvent(QDropEvent *event);
+private:
+	int currentDraggedIndex;
 };
 
 class DiveLogImportDialog : public QDialog {
-- 
2.2.1

From 390cf1e09914430233cd59525d240b3a29e2097a Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 6 Jan 2015 15:26:19 -0200
Subject: [PATCH 09/27] Remove the String from the model while Dragging

We are not correctly readding it yet - be patient.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/divelogimportdialog.cpp | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 9db9106..7e2a2a2 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -34,12 +34,18 @@ bool ColumnNameProvider::insertRows(int row, int count, const QModelIndex &paren
 
 bool ColumnNameProvider::removeRows(int row, int count, const QModelIndex &parent)
 {
-	qDebug() << "Calling";
+	beginRemoveRows(QModelIndex(), row, row);
+	columnNames.removeAt(row);
+	qDebug() << "Removing row" << row;
+	endRemoveRows();
 }
 
 bool ColumnNameProvider::setData(const QModelIndex &index, const QVariant &value, int role)
 {
-
+	if (role == Qt::EditRole) {
+		columnNames[index.row()] = value.toString();
+	}
+	dataChanged(index, index);
 }
 
 QVariant ColumnNameProvider::data(const QModelIndex &index, int role) const
@@ -75,29 +81,35 @@ void ColumnNameView::mousePressEvent(QMouseEvent *press)
 	QDrag *drag = new QDrag(this);
 	QMimeData *mimeData = new QMimeData;
 	mimeData->setText(atClick.data().toString());
+	model()->removeRow(atClick.row());
 	drag->setMimeData(mimeData);
 	drag->exec();
-	currentDraggedIndex = atClick.row();
+
 }
 
 void ColumnNameView::dragLeaveEvent(QDragLeaveEvent *leave)
 {
-	model()->removeRow(currentDraggedIndex);
+
 }
 
 void ColumnNameView::dragEnterEvent(QDragEnterEvent *event)
 {
-
+	event->acceptProposedAction();
 }
 
 void ColumnNameView::dragMoveEvent(QDragMoveEvent *event)
 {
-
+	event->acceptProposedAction();
 }
 
 void ColumnNameView::dropEvent(QDropEvent *event)
 {
-
+	const QMimeData *mimeData = event->mimeData();
+	if (mimeData->hasText()) {
+		model()->insertRow(model()->rowCount());
+		model()->setData(model()->index(model()->rowCount()-1, 0), QVariant(mimeData->text()));
+		qDebug() << "model -> rowcount() " << model()->rowCount();
+	}
 }
 
 
-- 
2.2.1

From 6ea5dc9e9e934bde778c447b479f20b70dd5f02a Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 6 Jan 2015 15:30:59 -0200
Subject: [PATCH 10/27] Readd the string removed upon Drop operation.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/divelogimportdialog.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 7e2a2a2..89065cd 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -29,7 +29,9 @@ ColumnNameProvider::ColumnNameProvider(QObject *parent) : QAbstractListModel(par
 
 bool ColumnNameProvider::insertRows(int row, int count, const QModelIndex &parent)
 {
-
+	beginInsertRows(QModelIndex(), row, row);
+	columnNames.append(QString());
+	endInsertRows();
 }
 
 bool ColumnNameProvider::removeRows(int row, int count, const QModelIndex &parent)
-- 
2.2.1

From 3fbc927bedd0151781e78abba735b63a0d7007c1 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 6 Jan 2015 15:42:50 -0200
Subject: [PATCH 11/27] Show the Pixmap being dragged

This way we know that we got the correct drag thingy.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/divelogimportdialog.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 89065cd..8788db6 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -79,11 +79,16 @@ void ColumnNameView::mousePressEvent(QMouseEvent *press)
 	if (!atClick.isValid())
 		return;
 
-	qDebug() << atClick.data();
+	QRect indexRect = visualRect(atClick);
+	QPixmap pix(indexRect.width(), indexRect.height());
+	pix.fill(QColor(0,0,0,0));
+	render(&pix, QPoint(0, 0),QRegion(indexRect));
+
 	QDrag *drag = new QDrag(this);
 	QMimeData *mimeData = new QMimeData;
 	mimeData->setText(atClick.data().toString());
 	model()->removeRow(atClick.row());
+	drag->setPixmap(pix);
 	drag->setMimeData(mimeData);
 	drag->exec();
 
@@ -110,7 +115,6 @@ void ColumnNameView::dropEvent(QDropEvent *event)
 	if (mimeData->hasText()) {
 		model()->insertRow(model()->rowCount());
 		model()->setData(model()->index(model()->rowCount()-1, 0), QVariant(mimeData->text()));
-		qDebug() << "model -> rowcount() " << model()->rowCount();
 	}
 }
 
-- 
2.2.1

From 778acf5c758bf831a7571c56acab558f55dd3aa2 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 6 Jan 2015 15:56:08 -0200
Subject: [PATCH 12/27] Added Skeleton code for the Table View that will
 Accepts Drops.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/divelogimportdialog.cpp | 25 ++++++++++++++++++++++++-
 qt-ui/divelogimportdialog.h   | 14 ++++++++++++++
 qt-ui/divelogimportdialog.ui  |  7 ++++++-
 3 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 8788db6..338fb1e 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -96,7 +96,6 @@ void ColumnNameView::mousePressEvent(QMouseEvent *press)
 
 void ColumnNameView::dragLeaveEvent(QDragLeaveEvent *leave)
 {
-
 }
 
 void ColumnNameView::dragEnterEvent(QDragEnterEvent *event)
@@ -118,6 +117,30 @@ void ColumnNameView::dropEvent(QDropEvent *event)
 	}
 }
 
+ColumnDropCSVView::ColumnDropCSVView(QWidget *parent)
+{
+
+}
+
+void ColumnDropCSVView::dragLeaveEvent(QDragLeaveEvent *leave)
+{
+
+}
+
+void ColumnDropCSVView::dragEnterEvent(QDragEnterEvent *event)
+{
+
+}
+
+void ColumnDropCSVView::dragMoveEvent(QDragMoveEvent *event)
+{
+
+}
+
+void ColumnDropCSVView::dropEvent(QDropEvent *event)
+{
+
+}
 
 DiveLogImportDialog::DiveLogImportDialog(QStringList *fn, QWidget *parent) : QDialog(parent),
 	selector(true),
diff --git a/qt-ui/divelogimportdialog.h b/qt-ui/divelogimportdialog.h
index efb7f29..ed781a5 100644
--- a/qt-ui/divelogimportdialog.h
+++ b/qt-ui/divelogimportdialog.h
@@ -5,6 +5,7 @@
 #include <QAbstractListModel>
 #include <QListView>
 #include <QDragLeaveEvent>
+#include <QTableView>
 
 #include "../dive.h"
 #include "../divelist.h"
@@ -40,6 +41,19 @@ private:
 	int currentDraggedIndex;
 };
 
+class ColumnDropCSVView : public QTableView {
+	Q_OBJECT
+public:
+	ColumnDropCSVView(QWidget *parent);
+protected:
+	void dragLeaveEvent(QDragLeaveEvent *leave);
+	void dragEnterEvent(QDragEnterEvent *event);
+	void dragMoveEvent(QDragMoveEvent *event);
+	void dropEvent(QDropEvent *event);
+private:
+	QStringList columns;
+};
+
 class DiveLogImportDialog : public QDialog {
 	Q_OBJECT
 
diff --git a/qt-ui/divelogimportdialog.ui b/qt-ui/divelogimportdialog.ui
index 8cbf9bc..881c327 100644
--- a/qt-ui/divelogimportdialog.ui
+++ b/qt-ui/divelogimportdialog.ui
@@ -118,7 +118,7 @@
           </widget>
          </item>
          <item>
-          <widget class="QTableView" name="tableView"/>
+          <widget class="ColumnDropCSVView" name="tableView"/>
          </item>
          <item>
           <widget class="QDialogButtonBox" name="buttonBox">
@@ -144,6 +144,11 @@
    <extends>QListView</extends>
    <header>divelogimportdialog.h</header>
   </customwidget>
+  <customwidget>
+   <class>ColumnDropCSVView</class>
+   <extends>QTableView</extends>
+   <header>divelogimportdialog.h</header>
+  </customwidget>
  </customwidgets>
  <tabstops>
   <tabstop>buttonBox</tabstop>
-- 
2.2.1

From 762becf70479ecb78832e00423508f8e3db2c719 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 6 Jan 2015 16:01:21 -0200
Subject: [PATCH 13/27] Added skeleton code for the model that will have the
 result of Columns

This model will show some columns and the user will
need to provide the correct information for each of them

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/divelogimportdialog.cpp | 25 +++++++++++++++++++++++++
 qt-ui/divelogimportdialog.h   | 14 ++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 338fb1e..ffe91fe 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -142,6 +142,31 @@ void ColumnDropCSVView::dropEvent(QDropEvent *event)
 
 }
 
+ColumnNameResult::ColumnNameResult(QObject *parent)
+{
+
+}
+
+bool ColumnNameResult::setData(const QModelIndex &index, const QVariant &value, int role)
+{
+
+}
+
+QVariant ColumnNameResult::data(const QModelIndex &index, int role) const
+{
+
+}
+
+int ColumnNameResult::rowCount(const QModelIndex &parent) const
+{
+
+}
+
+int ColumnNameResult::columnCount(const QModelIndex &parent) const
+{
+
+}
+
 DiveLogImportDialog::DiveLogImportDialog(QStringList *fn, QWidget *parent) : QDialog(parent),
 	selector(true),
 	ui(new Ui::DiveLogImportDialog)
diff --git a/qt-ui/divelogimportdialog.h b/qt-ui/divelogimportdialog.h
index ed781a5..7c47266 100644
--- a/qt-ui/divelogimportdialog.h
+++ b/qt-ui/divelogimportdialog.h
@@ -6,6 +6,7 @@
 #include <QListView>
 #include <QDragLeaveEvent>
 #include <QTableView>
+#include <QAbstractTableModel>
 
 #include "../dive.h"
 #include "../divelist.h"
@@ -27,6 +28,19 @@ private:
 	QStringList columnNames;
 };
 
+class ColumnNameResult : public QAbstractTableModel {
+	Q_OBJECT
+public:
+	ColumnNameResult(QObject *parent);
+	bool setData(const QModelIndex &index, const QVariant &value, int role);
+	QVariant data(const QModelIndex &index, int role) const;
+	int rowCount(const QModelIndex &parent) const;
+	int columnCount(const QModelIndex &parent) const;
+private:
+	QList<QStringList> columnValues;
+	QStringList columnNames;
+};
+
 class ColumnNameView : public QListView {
 	Q_OBJECT
 public:
-- 
2.2.1

From ff3485fd65530ccb167544d3283f4c73896dd0ce Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 6 Jan 2015 16:05:06 -0200
Subject: [PATCH 14/27] Set the model on the Table View, one more skeleton.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/divelogimportdialog.cpp | 8 ++++++++
 qt-ui/divelogimportdialog.h   | 1 +
 2 files changed, 9 insertions(+)

diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index ffe91fe..5f9d365 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -167,6 +167,11 @@ int ColumnNameResult::columnCount(const QModelIndex &parent) const
 
 }
 
+void ColumnNameResult::setColumnValues(QList<QStringList> columns)
+{
+
+}
+
 DiveLogImportDialog::DiveLogImportDialog(QStringList *fn, QWidget *parent) : QDialog(parent),
 	selector(true),
 	ui(new Ui::DiveLogImportDialog)
@@ -188,6 +193,9 @@ DiveLogImportDialog::DiveLogImportDialog(QStringList *fn, QWidget *parent) : QDi
 	ColumnNameProvider *provider = new ColumnNameProvider(this);
 	ui->avaliableColumns->setModel(provider);
 
+	ColumnNameResult *result = new ColumnNameResult(this);
+	ui->tableView->setModel(result);
+
 	/* manually import CSV file */
 	QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this);
 	connect(close, SIGNAL(activated()), this, SLOT(close()));
diff --git a/qt-ui/divelogimportdialog.h b/qt-ui/divelogimportdialog.h
index 7c47266..06052f5 100644
--- a/qt-ui/divelogimportdialog.h
+++ b/qt-ui/divelogimportdialog.h
@@ -36,6 +36,7 @@ public:
 	QVariant data(const QModelIndex &index, int role) const;
 	int rowCount(const QModelIndex &parent) const;
 	int columnCount(const QModelIndex &parent) const;
+	void setColumnValues(QList<QStringList> columns);
 private:
 	QList<QStringList> columnValues;
 	QStringList columnNames;
-- 
2.2.1

From 1905c439ac9b02431a7b4624865999e256a6ab82 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 6 Jan 2015 16:11:27 -0200
Subject: [PATCH 15/27] Another Skeleton: LoadFileContents,

Also, do not pass QStringLists by pointer, uneeded.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/divelogimportdialog.cpp | 13 +++++++++++--
 qt-ui/divelogimportdialog.h   |  4 ++--
 qt-ui/mainwindow.cpp          |  2 +-
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 5f9d365..41144b8 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -9,6 +9,8 @@
 #include <QMouseEvent>
 #include <QDrag>
 #include <QMimeData>
+#include <QFile>
+
 const DiveLogImportDialog::CSVAppConfig DiveLogImportDialog::CSVApps[CSVAPPS] = {
 	// time, depth, temperature, po2, cns, ndl, tts, stopdepth, pressure
 	{ "", },
@@ -172,12 +174,12 @@ void ColumnNameResult::setColumnValues(QList<QStringList> columns)
 
 }
 
-DiveLogImportDialog::DiveLogImportDialog(QStringList *fn, QWidget *parent) : QDialog(parent),
+DiveLogImportDialog::DiveLogImportDialog(QStringList fn, QWidget *parent) : QDialog(parent),
 	selector(true),
 	ui(new Ui::DiveLogImportDialog)
 {
 	ui->setupUi(this);
-	fileNames = *fn;
+	fileNames = fn;
 	column = 0;
 
 	/* Add indexes of XSLTs requiring special handling to the list */
@@ -196,6 +198,8 @@ DiveLogImportDialog::DiveLogImportDialog(QStringList *fn, QWidget *parent) : QDi
 	ColumnNameResult *result = new ColumnNameResult(this);
 	ui->tableView->setModel(result);
 
+	loadFileContents();
+
 	/* manually import CSV file */
 	QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this);
 	connect(close, SIGNAL(activated()), this, SLOT(close()));
@@ -208,6 +212,11 @@ DiveLogImportDialog::~DiveLogImportDialog()
 	delete ui;
 }
 
+void DiveLogImportDialog::loadFileContents() {
+	QFile f(fileNames.first());
+
+}
+
 #define VALUE_IF_CHECKED(x) (ui->x->isEnabled() ? ui->x->value() - 1 : -1)
 void DiveLogImportDialog::on_buttonBox_accepted()
 {
diff --git a/qt-ui/divelogimportdialog.h b/qt-ui/divelogimportdialog.h
index 06052f5..bca7ecc 100644
--- a/qt-ui/divelogimportdialog.h
+++ b/qt-ui/divelogimportdialog.h
@@ -73,7 +73,7 @@ class DiveLogImportDialog : public QDialog {
 	Q_OBJECT
 
 public:
-	explicit DiveLogImportDialog(QStringList *fn, QWidget *parent = 0);
+	explicit DiveLogImportDialog(QStringList fn, QWidget *parent = 0);
 	~DiveLogImportDialog();
 
 private
@@ -81,7 +81,7 @@ slots:
 	void on_buttonBox_accepted();
 	void on_knownImports_currentIndexChanged(int index);
 	void unknownImports();
-
+	void loadFileContents();
 private:
 	bool selector;
 	QStringList fileNames;
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 2ae9b74..9186b7a 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -1361,7 +1361,7 @@ void MainWindow::on_actionImportDiveLog_triggered()
 	}
 
 	if (csvFiles.size()) {
-		DiveLogImportDialog *diveLogImport = new DiveLogImportDialog(&csvFiles, this);
+		DiveLogImportDialog *diveLogImport = new DiveLogImportDialog(csvFiles, this);
 		diveLogImport->show();
 		process_dives(true, false);
 		refreshDisplay();
-- 
2.2.1

From 25e19ecea2cb78ee653d9e1a62f16fe8a325a68d Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 6 Jan 2015 16:21:50 -0200
Subject: [PATCH 16/27] Implement LoadFileContents

This will get the first 10 lines of data, try to separate
them using the separator specified, and then try to make
things display correctly on the table.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/divelogimportdialog.cpp | 17 ++++++++++++++---
 qt-ui/divelogimportdialog.h   |  1 +
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 41144b8..541485d 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -195,8 +195,8 @@ DiveLogImportDialog::DiveLogImportDialog(QStringList fn, QWidget *parent) : QDia
 	ColumnNameProvider *provider = new ColumnNameProvider(this);
 	ui->avaliableColumns->setModel(provider);
 
-	ColumnNameResult *result = new ColumnNameResult(this);
-	ui->tableView->setModel(result);
+	resultModel = new ColumnNameResult(this);
+	ui->tableView->setModel(resultModel);
 
 	loadFileContents();
 
@@ -214,7 +214,18 @@ DiveLogImportDialog::~DiveLogImportDialog()
 
 void DiveLogImportDialog::loadFileContents() {
 	QFile f(fileNames.first());
-
+	QList<QStringList> fileColumns;
+	QStringList currColumns;
+
+	f.open(QFile::ReadOnly);
+	int rows = 0;
+	while (rows < 10 || !f.atEnd()) {
+		QString currLine = f.readLine();
+		currColumns = currLine.split( ui->CSVSeparator->currentText() );
+		fileColumns.append(currColumns);
+		rows += 1;
+	}
+	resultModel->setColumnValues(fileColumns);
 }
 
 #define VALUE_IF_CHECKED(x) (ui->x->isEnabled() ? ui->x->value() - 1 : -1)
diff --git a/qt-ui/divelogimportdialog.h b/qt-ui/divelogimportdialog.h
index bca7ecc..b5eaa90 100644
--- a/qt-ui/divelogimportdialog.h
+++ b/qt-ui/divelogimportdialog.h
@@ -88,6 +88,7 @@ private:
 	Ui::DiveLogImportDialog *ui;
 	QList<int> specialCSV;
 	int column;
+	ColumnNameResult *resultModel;
 
 	struct CSVAppConfig {
 		QString name;
-- 
2.2.1

From be361b1c26dbea0a46627afb98cd7332d539cab1 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 6 Jan 2015 16:30:59 -0200
Subject: [PATCH 17/27] Added the setColumnValues() method

This method populates the model with a few lines
of the CSV data to help the user to define what
each column is.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/divelogimportdialog.cpp | 26 ++++++++++++++++++++++++--
 qt-ui/divelogimportdialog.h   |  4 ++--
 2 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 541485d..9255362 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -161,17 +161,39 @@ QVariant ColumnNameResult::data(const QModelIndex &index, int role) const
 
 int ColumnNameResult::rowCount(const QModelIndex &parent) const
 {
-
+	Q_UNUSED(parent);
+	return columnValues.count() + 1; // +1 == the header.
 }
 
 int ColumnNameResult::columnCount(const QModelIndex &parent) const
 {
-
+	Q_UNUSED(parent);
+	return columnNames.count();
 }
 
 void ColumnNameResult::setColumnValues(QList<QStringList> columns)
 {
+	if (rowCount() != 1) {
+		beginRemoveRows(QModelIndex(), 1, rowCount()-1);
+		columnValues.clear();
+		endRemoveRows();
+	}
+	if (columnCount() != 0) {
+		beginRemoveColumns(QModelIndex(), 0, columnCount()-1);
+		columnNames.clear();
+		endRemoveColumns();
+	}
+
+	QStringList first = columns.first();
+	beginInsertColumns(QModelIndex(), 0, first.count()-1);
+	for(int i = 0; i < first.count(); i++){
+		columnNames.append(QString());
+	}
+	endInsertColumns();
 
+	beginInsertRows(QModelIndex(), 0, columns.count()-1);
+	columnValues = columns;
+	endInsertRows();
 }
 
 DiveLogImportDialog::DiveLogImportDialog(QStringList fn, QWidget *parent) : QDialog(parent),
diff --git a/qt-ui/divelogimportdialog.h b/qt-ui/divelogimportdialog.h
index b5eaa90..a228390 100644
--- a/qt-ui/divelogimportdialog.h
+++ b/qt-ui/divelogimportdialog.h
@@ -34,8 +34,8 @@ public:
 	ColumnNameResult(QObject *parent);
 	bool setData(const QModelIndex &index, const QVariant &value, int role);
 	QVariant data(const QModelIndex &index, int role) const;
-	int rowCount(const QModelIndex &parent) const;
-	int columnCount(const QModelIndex &parent) const;
+	int rowCount(const QModelIndex &parent = QModelIndex()) const;
+	int columnCount(const QModelIndex &parent = QModelIndex()) const;
 	void setColumnValues(QList<QStringList> columns);
 private:
 	QList<QStringList> columnValues;
-- 
2.2.1

From 6ed7def9b74d79abfa78cef0d25b0b91cd05eb4f Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 6 Jan 2015 16:37:36 -0200
Subject: [PATCH 18/27] Added the Data method

Now we can correctly visualize the file data, and changing
the separator will update on the fly.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/divelogimportdialog.cpp | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 9255362..6f61ac2 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -156,7 +156,15 @@ bool ColumnNameResult::setData(const QModelIndex &index, const QVariant &value,
 
 QVariant ColumnNameResult::data(const QModelIndex &index, int role) const
 {
+	if (!index.isValid())
+		return QVariant();
+	if (role != Qt::DisplayRole)
+		return QVariant();
 
+	if (index.row() == 0) {
+		return (columnNames[index.column()]);
+	}
+	return QVariant(columnValues[index.row() -1][index.column()]);
 }
 
 int ColumnNameResult::rowCount(const QModelIndex &parent) const
@@ -211,7 +219,7 @@ DiveLogImportDialog::DiveLogImportDialog(QStringList fn, QWidget *parent) : QDia
 	for (int i = 0; !CSVApps[i].name.isNull(); ++i)
 		ui->knownImports->addItem(CSVApps[i].name);
 
-	ui->CSVSeparator->addItems( QStringList() << tr("Separator") << tr("Tab") << ";" << ",");
+	ui->CSVSeparator->addItems( QStringList() << tr("Tab") << ";" << ",");
 	ui->knownImports->setCurrentIndex(1);
 
 	ColumnNameProvider *provider = new ColumnNameProvider(this);
@@ -227,6 +235,8 @@ DiveLogImportDialog::DiveLogImportDialog(QStringList fn, QWidget *parent) : QDia
 	connect(close, SIGNAL(activated()), this, SLOT(close()));
 	QShortcut *quit = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this);
 	connect(quit, SIGNAL(activated()), parent, SLOT(close()));
+
+	connect(ui->CSVSeparator, SIGNAL(currentIndexChanged(int)), this, SLOT(loadFileContents()));
 }
 
 DiveLogImportDialog::~DiveLogImportDialog()
@@ -243,7 +253,9 @@ void DiveLogImportDialog::loadFileContents() {
 	int rows = 0;
 	while (rows < 10 || !f.atEnd()) {
 		QString currLine = f.readLine();
-		currColumns = currLine.split( ui->CSVSeparator->currentText() );
+		QString separator = ui->CSVSeparator->currentText() == tr("Tab") ? "\t"
+				: ui->CSVSeparator->currentText();
+		currColumns = currLine.split(separator);
 		fileColumns.append(currColumns);
 		rows += 1;
 	}
-- 
2.2.1

From 006abc122779d4f3a67e91a81293a0038a943cf5 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 6 Jan 2015 16:40:51 -0200
Subject: [PATCH 19/27] Added the setData to the ColumnResult model.

this way the drop target will work when implemented.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/divelogimportdialog.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 6f61ac2..73b2e56 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -151,7 +151,12 @@ ColumnNameResult::ColumnNameResult(QObject *parent)
 
 bool ColumnNameResult::setData(const QModelIndex &index, const QVariant &value, int role)
 {
-
+	if (!index.isValid() || index.row() != 0)
+		return false;
+	if (role == Qt::EditRole) {
+		columnNames[index.column()] = value.toString();
+		dataChanged(index, index);
+	}
 }
 
 QVariant ColumnNameResult::data(const QModelIndex &index, int role) const
-- 
2.2.1

From 870bb719ff66ec7c4f742297fd2264555f5f210d Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 6 Jan 2015 16:41:49 -0200
Subject: [PATCH 20/27] Fixed constructor

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/divelogimportdialog.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 73b2e56..e483cb8 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -144,7 +144,7 @@ void ColumnDropCSVView::dropEvent(QDropEvent *event)
 
 }
 
-ColumnNameResult::ColumnNameResult(QObject *parent)
+ColumnNameResult::ColumnNameResult(QObject *parent) : QAbstractTableModel(parent)
 {
 
 }
-- 
2.2.1

From 1ec6ff3bed9e93410331666ab3fb67110bae8901 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 6 Jan 2015 16:52:15 -0200
Subject: [PATCH 21/27] Implemented most of the drag operation

Only thing missing is the Drop.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/divelogimportdialog.cpp | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index e483cb8..0b6dfb7 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -121,22 +121,25 @@ void ColumnNameView::dropEvent(QDropEvent *event)
 
 ColumnDropCSVView::ColumnDropCSVView(QWidget *parent)
 {
-
+	setAcceptDrops(true);
 }
 
 void ColumnDropCSVView::dragLeaveEvent(QDragLeaveEvent *leave)
 {
-
+	Q_UNUSED(leave);
 }
 
 void ColumnDropCSVView::dragEnterEvent(QDragEnterEvent *event)
 {
-
+	event->acceptProposedAction();
 }
 
 void ColumnDropCSVView::dragMoveEvent(QDragMoveEvent *event)
 {
-
+	QModelIndex curr = indexAt(event->pos());
+	if (!curr.isValid() || curr.row() != 0)
+		return;
+	event->acceptProposedAction();
 }
 
 void ColumnDropCSVView::dropEvent(QDropEvent *event)
-- 
2.2.1

From b3fa6c3c4b633d73823f4ea1be51cdb832b42db3 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 6 Jan 2015 16:54:50 -0200
Subject: [PATCH 22/27] Set data done, Drag & Drop Working.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/divelogimportdialog.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 0b6dfb7..245c240 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -144,7 +144,15 @@ void ColumnDropCSVView::dragMoveEvent(QDragMoveEvent *event)
 
 void ColumnDropCSVView::dropEvent(QDropEvent *event)
 {
+	QModelIndex curr = indexAt(event->pos());
+	if (!curr.isValid() || curr.row() != 0)
+		return;
 
+	event->acceptProposedAction();
+	const QMimeData *mimeData = event->mimeData();
+	if (mimeData->hasText()) {
+		model()->setData(curr, QVariant(mimeData->text()));
+	}
 }
 
 ColumnNameResult::ColumnNameResult(QObject *parent) : QAbstractTableModel(parent)
-- 
2.2.1

From bbb1df5d1050f6c1b0fc9679e2ffc7d4f0fbcb36 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 6 Jan 2015 17:19:08 -0200
Subject: [PATCH 23/27] Readd the string to the avaliable models if drag
 cancelled

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/divelogimportdialog.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 245c240..5392385 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -92,8 +92,11 @@ void ColumnNameView::mousePressEvent(QMouseEvent *press)
 	model()->removeRow(atClick.row());
 	drag->setPixmap(pix);
 	drag->setMimeData(mimeData);
-	drag->exec();
-
+	if (drag->exec() == Qt::IgnoreAction){
+		model()->insertRow(model()->rowCount());
+		QModelIndex idx = model()->index(model()->rowCount()-1, 0);
+		model()->setData(idx, mimeData->text());
+	}
 }
 
 void ColumnNameView::dragLeaveEvent(QDragLeaveEvent *leave)
-- 
2.2.1

From 222e42ffd6e1cd9c4cb354636602b9d968845c3e Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 6 Jan 2015 17:32:29 -0200
Subject: [PATCH 24/27] Do not accept drops from outside of subsurface

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/divelogimportdialog.cpp | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 5392385..16c7139 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -11,6 +11,8 @@
 #include <QMimeData>
 #include <QFile>
 
+static QString subsurface_mimedata = "subsurface/csvcolumns";
+
 const DiveLogImportDialog::CSVAppConfig DiveLogImportDialog::CSVApps[CSVAPPS] = {
 	// time, depth, temperature, po2, cns, ndl, tts, stopdepth, pressure
 	{ "", },
@@ -88,14 +90,14 @@ void ColumnNameView::mousePressEvent(QMouseEvent *press)
 
 	QDrag *drag = new QDrag(this);
 	QMimeData *mimeData = new QMimeData;
-	mimeData->setText(atClick.data().toString());
+	mimeData->setData(subsurface_mimedata, atClick.data().toByteArray());
 	model()->removeRow(atClick.row());
 	drag->setPixmap(pix);
 	drag->setMimeData(mimeData);
 	if (drag->exec() == Qt::IgnoreAction){
 		model()->insertRow(model()->rowCount());
 		QModelIndex idx = model()->index(model()->rowCount()-1, 0);
-		model()->setData(idx, mimeData->text());
+		model()->setData(idx, mimeData->data(subsurface_mimedata));
 	}
 }
 
@@ -105,20 +107,23 @@ void ColumnNameView::dragLeaveEvent(QDragLeaveEvent *leave)
 
 void ColumnNameView::dragEnterEvent(QDragEnterEvent *event)
 {
-	event->acceptProposedAction();
+	if(event->mimeData()->data(subsurface_mimedata).count())
+		event->acceptProposedAction();
 }
 
 void ColumnNameView::dragMoveEvent(QDragMoveEvent *event)
 {
-	event->acceptProposedAction();
+	if (event->mimeData()->data(subsurface_mimedata).count())
+		event->acceptProposedAction();
 }
 
 void ColumnNameView::dropEvent(QDropEvent *event)
 {
 	const QMimeData *mimeData = event->mimeData();
-	if (mimeData->hasText()) {
+	if (mimeData->data(subsurface_mimedata).count()) {
+		QVariant value = QString(mimeData->data(subsurface_mimedata));
 		model()->insertRow(model()->rowCount());
-		model()->setData(model()->index(model()->rowCount()-1, 0), QVariant(mimeData->text()));
+		model()->setData(model()->index(model()->rowCount()-1, 0), value);
 	}
 }
 
@@ -153,8 +158,9 @@ void ColumnDropCSVView::dropEvent(QDropEvent *event)
 
 	event->acceptProposedAction();
 	const QMimeData *mimeData = event->mimeData();
-	if (mimeData->hasText()) {
-		model()->setData(curr, QVariant(mimeData->text()));
+	if (mimeData->data(subsurface_mimedata).count()) {
+		QVariant value = QString(mimeData->data(subsurface_mimedata));
+		model()->setData(curr, value);
 	}
 }
 
-- 
2.2.1

From 68bf0d19b790c8e36a504be7e93a868e325f0a06 Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 6 Jan 2015 17:34:50 -0200
Subject: [PATCH 25/27] Better sizings for the CSV Dialog

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/divelogimportdialog.ui | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/qt-ui/divelogimportdialog.ui b/qt-ui/divelogimportdialog.ui
index 881c327..89f9693 100644
--- a/qt-ui/divelogimportdialog.ui
+++ b/qt-ui/divelogimportdialog.ui
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>709</width>
-    <height>646</height>
+    <width>586</width>
+    <height>434</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -102,7 +102,7 @@
            <property name="maximumSize">
             <size>
              <width>16777215</width>
-             <height>150</height>
+             <height>100</height>
             </size>
            </property>
            <property name="viewMode">
@@ -118,7 +118,14 @@
           </widget>
          </item>
          <item>
-          <widget class="ColumnDropCSVView" name="tableView"/>
+          <widget class="ColumnDropCSVView" name="tableView">
+           <property name="maximumSize">
+            <size>
+             <width>16777215</width>
+             <height>200</height>
+            </size>
+           </property>
+          </widget>
          </item>
          <item>
           <widget class="QDialogButtonBox" name="buttonBox">
-- 
2.2.1

From d63e8a5b9176392b122afe9512730281dc31c29f Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 6 Jan 2015 18:12:48 -0200
Subject: [PATCH 26/27] Port the code that actually parse the CSV to the new
 system.

Change the QWidget based approach to the Model
based approach, using the result QStringList
for finding if we have the depth or the time of
Some specific column.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/divelogimportdialog.cpp | 129 +++++++++++++++++++++---------------------
 qt-ui/divelogimportdialog.h   |   3 +-
 2 files changed, 65 insertions(+), 67 deletions(-)

diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 16c7139..570e862 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -15,7 +15,7 @@ static QString subsurface_mimedata = "subsurface/csvcolumns";
 
 const DiveLogImportDialog::CSVAppConfig DiveLogImportDialog::CSVApps[CSVAPPS] = {
 	// time, depth, temperature, po2, cns, ndl, tts, stopdepth, pressure
-	{ "", },
+	{ "Manual Import", },
 	{ "APD Log Viewer", 1, 2, 16, 7, 18, -1, -1, 19, -1, "Tab" },
 	{ "XP5", 1, 2, 10, -1, -1, -1, -1, -1, -1, "Tab" },
 	{ "SensusCSV", 10, 11, -1, -1, -1, -1, -1, -1, -1, "," },
@@ -204,6 +204,11 @@ int ColumnNameResult::columnCount(const QModelIndex &parent) const
 	return columnNames.count();
 }
 
+QStringList ColumnNameResult::result() const
+{
+	return columnNames;
+}
+
 void ColumnNameResult::setColumnValues(QList<QStringList> columns)
 {
 	if (rowCount() != 1) {
@@ -287,23 +292,26 @@ void DiveLogImportDialog::loadFileContents() {
 	resultModel->setColumnValues(fileColumns);
 }
 
-#define VALUE_IF_CHECKED(x) (ui->x->isEnabled() ? ui->x->value() - 1 : -1)
 void DiveLogImportDialog::on_buttonBox_accepted()
 {
-	/*
-	for (int i = 0; i < fileNames.size(); ++i) {
-		if (ui->knownImports->currentText() == QString("Seabear CSV")) {
-			parse_seabear_csv_file(fileNames[i].toUtf8().data(), ui->CSVTime->value() - 1,
-			       ui->CSVDepth->value() - 1, VALUE_IF_CHECKED(CSVTemperature),
-				       VALUE_IF_CHECKED(CSVpo2),
-				       VALUE_IF_CHECKED(CSVcns),
-				       VALUE_IF_CHECKED(CSVndl),
-				       VALUE_IF_CHECKED(CSVtts),
-				       VALUE_IF_CHECKED(CSVstopdepth),
-				       VALUE_IF_CHECKED(CSVpressure),
-				       ui->CSVSeparator->currentIndex(),
-				       specialCSV.contains(ui->knownImports->currentIndex()) ? CSVApps[ui->knownImports->currentIndex()].name.toUtf8().data() : "csv",
-				       ui->CSVUnits->currentIndex());
+	QStringList r = resultModel->result();
+	if (ui->knownImports->currentText() != "Manual Import") {
+		for (int i = 0; i < fileNames.size(); ++i) {
+			if (ui->knownImports->currentText() == "Seabear CSV") {
+				parse_seabear_csv_file(fileNames[i].toUtf8().data(),
+					r.indexOf(tr("Time")),
+					r.indexOf(tr("Max Depth")),
+					r.indexOf(tr("Water temp")),
+					r.indexOf(tr("PO₂")),
+					r.indexOf(tr("CNS")),
+					r.indexOf(tr("NDL")),
+					r.indexOf(tr("TTS")),
+					r.indexOf(tr("Stopped Depth")),
+					r.indexOf(tr("Pressure")),
+					ui->CSVSeparator->currentIndex(),
+					specialCSV.contains(ui->knownImports->currentIndex()) ? CSVApps[ui->knownImports->currentIndex()].name.toUtf8().data() : "csv",
+					ui->CSVUnits->currentIndex()
+				);
 
 				// Seabear CSV stores NDL and TTS in Minutes, not seconds
 				struct dive *dive = dive_table.dives[dive_table.nr - 1];
@@ -312,61 +320,52 @@ void DiveLogImportDialog::on_buttonBox_accepted()
 					sample->ndl.seconds *= 60;
 					sample->tts.seconds *= 60;
 				}
-			} else
-				parse_csv_file(fileNames[i].toUtf8().data(), ui->CSVTime->value() - 1,
-						ui->CSVDepth->value() - 1, VALUE_IF_CHECKED(CSVTemperature),
-						VALUE_IF_CHECKED(CSVpo2),
-						VALUE_IF_CHECKED(CSVcns),
-						VALUE_IF_CHECKED(CSVndl),
-						VALUE_IF_CHECKED(CSVtts),
-						VALUE_IF_CHECKED(CSVstopdepth),
-						VALUE_IF_CHECKED(CSVpressure),
-						ui->CSVSeparator->currentIndex(),
-						specialCSV.contains(ui->knownImports->currentIndex()) ? CSVApps[ui->knownImports->currentIndex()].name.toUtf8().data() : "csv",
-						ui->CSVUnits->currentIndex());
+			} else {
+				parse_csv_file(fileNames[i].toUtf8().data(),
+					r.indexOf(tr("Time")),
+					r.indexOf(tr("Max Depth")),
+					r.indexOf(tr("Water temp")),
+					r.indexOf(tr("PO₂")),
+					r.indexOf(tr("CNS")),
+					r.indexOf(tr("NDL")),
+					r.indexOf(tr("TTS")),
+					r.indexOf(tr("Stopped Depth")),
+					r.indexOf(tr("Pressure")),
+					ui->CSVSeparator->currentIndex(),
+					specialCSV.contains(ui->knownImports->currentIndex()) ? CSVApps[ui->knownImports->currentIndex()].name.toUtf8().data() : "csv",
+					ui->CSVUnits->currentIndex()
+				);
+			}
 		}
 	} else {
 		for (int i = 0; i < fileNames.size(); ++i) {
 			parse_manual_file(fileNames[i].toUtf8().data(),
-					  ui->ManualSeparator->currentIndex(),
-					  ui->Units->currentIndex(),
-					  ui->DateFormat->currentIndex(),
-					  ui->DurationFormat->currentIndex(),
-					  VALUE_IF_CHECKED(DiveNumber),
-					  VALUE_IF_CHECKED(Date), VALUE_IF_CHECKED(Time),
-					  VALUE_IF_CHECKED(Duration), VALUE_IF_CHECKED(Location),
-					  VALUE_IF_CHECKED(Gps), VALUE_IF_CHECKED(MaxDepth),
-					  VALUE_IF_CHECKED(MeanDepth), VALUE_IF_CHECKED(Buddy),
-					  VALUE_IF_CHECKED(Notes), VALUE_IF_CHECKED(Weight),
-					  VALUE_IF_CHECKED(Tags),
-					  VALUE_IF_CHECKED(CylinderSize), VALUE_IF_CHECKED(StartPressure),
-					  VALUE_IF_CHECKED(EndPressure), VALUE_IF_CHECKED(O2),
-					  VALUE_IF_CHECKED(He), VALUE_IF_CHECKED(AirTemp),
-					  VALUE_IF_CHECKED(WaterTemp));
+				ui->CSVSeparator->currentIndex(),
+				ui->CSVUnits->currentIndex(),
+				ui->DateFormat->currentIndex(),
+				ui->DurationFormat->currentIndex(),
+				r.indexOf(tr("Dive #")),
+				r.indexOf(tr("Date")),
+				r.indexOf(tr("Time")),
+				r.indexOf(tr("Duration")),
+				r.indexOf(tr("Location")),
+				r.indexOf(tr("GPS")),
+				r.indexOf(tr("Max depth")),
+				r.indexOf(tr("Mean depth")),
+				r.indexOf(tr("Buddy")),
+				r.indexOf(tr("Notes")),
+				r.indexOf(tr("Weight")),
+				r.indexOf(tr("Tags")),
+				r.indexOf(tr("Cyl size")),
+				r.indexOf(tr("Start Pressure")),
+				r.indexOf(tr("End Pressure")),
+				r.indexOf(tr("O₂")),
+				r.indexOf(tr("He")),
+				r.indexOf(tr("Air Temp")),
+				r.indexOf(tr("Water Temp"))
+			);
 		}
 	}
-*/
 	process_dives(true, false);
-
 	MainWindow::instance()->refreshDisplay();
 }
-
-#define SET_VALUE_AND_CHECKBOX(CSV, BOX, VAL) ({\
-		ui->CSV->blockSignals(true);\
-		ui->CSV->setValue(VAL);\
-		ui->CSV->setEnabled(VAL >= 0);\
-		ui->BOX->setChecked(VAL >= 0);\
-		ui->CSV->blockSignals(false); })
-
-void DiveLogImportDialog::on_knownImports_currentIndexChanged(int index)
-{
-	if (index == 0)
-		return;
-
-}
-
-void DiveLogImportDialog::unknownImports()
-{
-	if (!specialCSV.contains(ui->knownImports->currentIndex()))
-		ui->knownImports->setCurrentIndex(0);
-}
diff --git a/qt-ui/divelogimportdialog.h b/qt-ui/divelogimportdialog.h
index a228390..7799045 100644
--- a/qt-ui/divelogimportdialog.h
+++ b/qt-ui/divelogimportdialog.h
@@ -37,6 +37,7 @@ public:
 	int rowCount(const QModelIndex &parent = QModelIndex()) const;
 	int columnCount(const QModelIndex &parent = QModelIndex()) const;
 	void setColumnValues(QList<QStringList> columns);
+	QStringList result() const;
 private:
 	QList<QStringList> columnValues;
 	QStringList columnNames;
@@ -79,8 +80,6 @@ public:
 private
 slots:
 	void on_buttonBox_accepted();
-	void on_knownImports_currentIndexChanged(int index);
-	void unknownImports();
 	void loadFileContents();
 private:
 	bool selector;
-- 
2.2.1

From 4270a2d517994cba0ab7b4158f8b1e58aba1486f Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <[email protected]>
Date: Tue, 6 Jan 2015 18:18:19 -0200
Subject: [PATCH 27/27] Remove pesky QDebug that snook In.

Signed-off-by: Tomaz Canabrava <[email protected]>
---
 qt-ui/divelogimportdialog.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp
index 570e862..7e37219 100644
--- a/qt-ui/divelogimportdialog.cpp
+++ b/qt-ui/divelogimportdialog.cpp
@@ -42,7 +42,6 @@ bool ColumnNameProvider::removeRows(int row, int count, const QModelIndex &paren
 {
 	beginRemoveRows(QModelIndex(), row, row);
 	columnNames.removeAt(row);
-	qDebug() << "Removing row" << row;
 	endRemoveRows();
 }
 
-- 
2.2.1

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to