summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qt-ui/maintab.cpp4
-rw-r--r--qt-ui/maintab.h2
-rw-r--r--qt-ui/maintab.ui67
-rw-r--r--qt-ui/models.cpp66
-rw-r--r--qt-ui/models.h18
5 files changed, 149 insertions, 8 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index 545632f75..ab712aeca 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -32,6 +32,7 @@
MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
weightModel(new WeightModel(this)),
cylindersModel(CylindersModel::instance()),
+ extraDataModel(new ExtraDataModel(this)),
editMode(NONE),
divePictureModel(DivePictureModel::instance()),
currentTrip(0),
@@ -47,6 +48,7 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
ui.weights->setModel(weightModel);
ui.photosView->setModel(divePictureModel);
connect(ui.photosView, SIGNAL(photoDoubleClicked(QString)), this, SLOT(photoDoubleClicked(QString)));
+ ui.extraData->setModel(extraDataModel);
closeMessage();
QAction *action = new QAction(tr("Save"), this);
@@ -473,6 +475,7 @@ void MainTab::updateDiveInfo(bool clear)
ui.equipmentTab->setEnabled(true);
cylindersModel->updateDive();
weightModel->updateDive();
+ extraDataModel->updateDive();
taglist_get_tagstring(displayed_dive.tag_list, buf, 1024);
ui.tagWidget->setText(QString(buf));
}
@@ -899,6 +902,7 @@ void MainTab::rejectChanges()
weightModel->changed = false;
cylindersModel->updateDive();
weightModel->updateDive();
+ extraDataModel->updateDive();
}
#undef EDIT_TEXT2
diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h
index 541e3fb79..369dd1723 100644
--- a/qt-ui/maintab.h
+++ b/qt-ui/maintab.h
@@ -17,6 +17,7 @@
class WeightModel;
class CylindersModel;
+class ExtraDataModel;
class QCompleter;
struct Completers {
@@ -94,6 +95,7 @@ private:
Ui::MainTab ui;
WeightModel *weightModel;
CylindersModel *cylindersModel;
+ ExtraDataModel *extraDataModel;
EditMode editMode;
BuddyCompletionModel buddyModel;
DiveMasterCompletionModel diveMasterModel;
diff --git a/qt-ui/maintab.ui b/qt-ui/maintab.ui
index a3b15418e..72c04acc3 100644
--- a/qt-ui/maintab.ui
+++ b/qt-ui/maintab.ui
@@ -37,8 +37,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>662</width>
- <height>642</height>
+ <width>668</width>
+ <height>658</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
@@ -336,8 +336,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>662</width>
- <height>642</height>
+ <width>100</width>
+ <height>30</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_5">
@@ -416,8 +416,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>662</width>
- <height>642</height>
+ <width>668</width>
+ <height>658</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_6">
@@ -745,8 +745,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>662</width>
- <height>642</height>
+ <width>342</width>
+ <height>167</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_7">
@@ -953,6 +953,57 @@
</item>
</layout>
</widget>
+ <widget class="QWidget" name="tab_2">
+ <attribute name="title">
+ <string>Extra data</string>
+ </attribute>
+ <widget class="QLabel" name="label_3">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>20</y>
+ <width>341</width>
+ <height>16</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>Additional data from dive computer</string>
+ </property>
+ </widget>
+ <widget class="QScrollArea" name="scrollArea_5">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>50</y>
+ <width>661</width>
+ <height>641</height>
+ </rect>
+ </property>
+ <property name="widgetResizable">
+ <bool>true</bool>
+ </property>
+ <widget class="QWidget" name="scrollAreaWidgetContents_5">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>659</width>
+ <height>639</height>
+ </rect>
+ </property>
+ <widget class="QTableView" name="extraData">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>641</width>
+ <height>621</height>
+ </rect>
+ </property>
+ </widget>
+ </widget>
+ </widget>
+ </widget>
</widget>
<customwidgets>
<customwidget>
diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp
index 64a5fd540..c48d1e4fc 100644
--- a/qt-ui/models.cpp
+++ b/qt-ui/models.cpp
@@ -2660,3 +2660,69 @@ void MultiFilterSortModel::removeFilterModel(MultiFilterInterface *model)
models.removeAll(model);
disconnect(itemModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(myInvalidate()));
}
+
+ExtraDataModel::ExtraDataModel(QObject *parent) : CleanerTableModel(parent),
+ rows(0)
+{
+ //enum Column {KEY, VALUE};
+ setHeaderDataStrings(QStringList() << tr("Key") << tr("Value"));
+}
+
+void ExtraDataModel::clear()
+{
+ if (rows > 0) {
+ beginRemoveRows(QModelIndex(), 0, rows - 1);
+ endRemoveRows();
+ }
+}
+
+QVariant ExtraDataModel::data(const QModelIndex &index, int role) const
+{
+ QVariant ret;
+ struct extra_data *ed = get_dive_dc(&displayed_dive, dc_number)->extra_data;
+ int i = -1;
+ while (ed && ++i < index.row())
+ ed = ed->next;
+ if (!ed)
+ return ret;
+
+ switch (role) {
+ case Qt::FontRole:
+ ret = defaultModelFont();
+ break;
+ case Qt::TextAlignmentRole:
+ ret = int(Qt::AlignLeft | Qt::AlignVCenter);
+ break;
+ case Qt::DisplayRole:
+ switch (index.column()) {
+ case KEY:
+ ret = QString(ed->key);
+ break;
+ case VALUE:
+ ret = QString(ed->value);
+ break;
+ }
+ break;
+ }
+ return ret;
+}
+
+int ExtraDataModel::rowCount(const QModelIndex &parent) const
+{
+ return rows;
+}
+
+void ExtraDataModel::updateDive()
+{
+ clear();
+ rows = 0;
+ struct extra_data *ed = get_dive_dc(&displayed_dive, dc_number)->extra_data;
+ while (ed) {
+ rows++;
+ ed = ed->next;
+ }
+ if (rows > 0) {
+ beginInsertRows(QModelIndex(), 0, rows - 1);
+ endInsertRows();
+ }
+}
diff --git a/qt-ui/models.h b/qt-ui/models.h
index a78c20be0..8750492a1 100644
--- a/qt-ui/models.h
+++ b/qt-ui/models.h
@@ -165,6 +165,24 @@ private:
int rows;
};
+/* extra data model for additional dive computer data */
+class ExtraDataModel : public CleanerTableModel {
+ Q_OBJECT
+public:
+ enum Column {
+ KEY,
+ VALUE
+ };
+ explicit ExtraDataModel(QObject *parent = 0);
+ /*reimp*/ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
+ /*reimp*/ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+
+ void clear();
+ void updateDive();
+private:
+ int rows;
+};
+
/*! An AbstractItemModel for recording dive trip information such as a list of dives.
*
*/