summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt1
-rw-r--r--qt-models/divecomputerextradatamodel.cpp70
-rw-r--r--qt-models/divecomputerextradatamodel.h25
-rw-r--r--qt-models/models.cpp66
-rw-r--r--qt-models/models.h19
-rw-r--r--qt-ui/maintab.cpp1
6 files changed, 97 insertions, 85 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9e5f9087a..6487e56d7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -255,6 +255,7 @@ set(SUBSURFACE_MODELS_LIB_SRCS
qt-models/tankinfomodel.cpp
qt-models/weigthsysteminfomodel.cpp
qt-models/weightmodel.cpp
+ qt-models/divecomputerextradatamodel.cpp
qt-models/completionmodels.cpp
)
source_group("Subsurface Models" FILES ${SUBSURFACE_MODELS})
diff --git a/qt-models/divecomputerextradatamodel.cpp b/qt-models/divecomputerextradatamodel.cpp
new file mode 100644
index 000000000..8c0c828e3
--- /dev/null
+++ b/qt-models/divecomputerextradatamodel.cpp
@@ -0,0 +1,70 @@
+#include "divecomputerextradatamodel.h"
+#include "dive.h"
+#include "metrics.h"
+
+
+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-models/divecomputerextradatamodel.h b/qt-models/divecomputerextradatamodel.h
new file mode 100644
index 000000000..5d5edb8c6
--- /dev/null
+++ b/qt-models/divecomputerextradatamodel.h
@@ -0,0 +1,25 @@
+#ifndef DIVECOMPUTEREXTRADATAMODEL_H
+#define DIVECOMPUTEREXTRADATAMODEL_H
+
+#include "cleanertablemodel.h"
+
+/* 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;
+};
+
+#endif
diff --git a/qt-models/models.cpp b/qt-models/models.cpp
index cd62dfc67..15e5d9a00 100644
--- a/qt-models/models.cpp
+++ b/qt-models/models.cpp
@@ -1378,69 +1378,3 @@ int LanguageModel::rowCount(const QModelIndex &parent) const
{
return languages.count();
}
-
-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-models/models.h b/qt-models/models.h
index 31fb2871e..095791694 100644
--- a/qt-models/models.h
+++ b/qt-models/models.h
@@ -21,25 +21,6 @@
#include "../divecomputer.h"
#include "cleanertablemodel.h"
-/* 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.
*
*/
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index c0330fde4..acf2f246a 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -19,6 +19,7 @@
#include "divesitehelpers.h"
#include "cylindermodel.h"
#include "weightmodel.h"
+#include "divecomputerextradatamodel.h"
#if defined(FBSUPPORT)
#include "socialnetworks.h"