summaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/completionmodels.cpp13
-rw-r--r--qt-models/completionmodels.h6
-rw-r--r--qt-models/divelocationmodel.cpp23
-rw-r--r--qt-models/divelocationmodel.h7
4 files changed, 24 insertions, 25 deletions
diff --git a/qt-models/completionmodels.cpp b/qt-models/completionmodels.cpp
index f2e70afd1..ff2afd997 100644
--- a/qt-models/completionmodels.cpp
+++ b/qt-models/completionmodels.cpp
@@ -42,19 +42,6 @@ CREATE_CSV_UPDATE_METHOD(BuddyCompletionModel, buddy);
CREATE_CSV_UPDATE_METHOD(DiveMasterCompletionModel, divemaster);
CREATE_UPDATE_METHOD(SuitCompletionModel, suit);
-void LocationCompletionModel::updateModel()
-{
- QStringList list;
- struct dive_site *ds;
- int i = 0;
- for_each_dive_site(i, ds) {
- if (!list.contains(ds->name))
- list.append(ds->name);
- }
- std::sort(list.begin(), list.end());
- setStringList(list);
-}
-
void TagCompletionModel::updateModel()
{
if (g_tag_list == NULL)
diff --git a/qt-models/completionmodels.h b/qt-models/completionmodels.h
index 859b8c007..c4dfd2a58 100644
--- a/qt-models/completionmodels.h
+++ b/qt-models/completionmodels.h
@@ -15,12 +15,6 @@ public:
void updateModel();
};
-class LocationCompletionModel : public QStringListModel {
- Q_OBJECT
-public:
- void updateModel();
-};
-
class SuitCompletionModel : public QStringListModel {
Q_OBJECT
public:
diff --git a/qt-models/divelocationmodel.cpp b/qt-models/divelocationmodel.cpp
index 32bccd5e1..3d3c77616 100644
--- a/qt-models/divelocationmodel.cpp
+++ b/qt-models/divelocationmodel.cpp
@@ -13,10 +13,15 @@ LocationInformationModel *LocationInformationModel::instance()
return self;
}
-LocationInformationModel::LocationInformationModel(QObject *obj) : QAbstractListModel(obj), internalRowCount(0)
+LocationInformationModel::LocationInformationModel(QObject *obj) : QAbstractTableModel(obj), internalRowCount(0)
{
}
+int LocationInformationModel::columnCount(const QModelIndex &parent) const
+{
+ return COLUMNS;
+}
+
int LocationInformationModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
@@ -33,8 +38,20 @@ QVariant LocationInformationModel::data(const QModelIndex &index, int role) cons
return QVariant();
switch(role) {
- case Qt::DisplayRole : return qPrintable(ds->name);
- case DIVE_SITE_UUID : return ds->uuid;
+ case Qt::DisplayRole :
+ switch(index.column()) {
+ case UUID: return ds->uuid;
+ case NAME: return ds->name;
+ case LATITUDE: return ds->latitude.udeg;
+ case LONGITUDE: return ds->longitude.udeg;
+ case COORDS: return "TODO";
+ case DESCRIPTION: return ds->description;
+ case NOTES: return ds->name;
+ case TAXONOMY_1: return "TODO";
+ case TAXONOMY_2: return "TODO";
+ case TAXONOMY_3: return "TODO";
+ }
+ break;
}
return QVariant();
diff --git a/qt-models/divelocationmodel.h b/qt-models/divelocationmodel.h
index c7d8c2ed5..8cae3a08a 100644
--- a/qt-models/divelocationmodel.h
+++ b/qt-models/divelocationmodel.h
@@ -1,15 +1,16 @@
#ifndef DIVELOCATIONMODEL_H
#define DIVELOCATIONMODEL_H
-#include <QAbstractListModel>
+#include <QAbstractTableModel>
#include <QStringListModel>
#include <stdint.h>
-class LocationInformationModel : public QAbstractListModel {
+class LocationInformationModel : public QAbstractTableModel {
Q_OBJECT
public:
- enum { DIVE_SITE_UUID = Qt::UserRole+1};
+ enum Columns { UUID, NAME, LATITUDE, LONGITUDE, COORDS, DESCRIPTION, NOTES, TAXONOMY_1, TAXONOMY_2, TAXONOMY_3, COLUMNS};
static LocationInformationModel *instance();
+ int columnCount(const QModelIndex &parent) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index = QModelIndex(), int role = Qt::DisplayRole) const;
int32_t addDiveSite(const QString& name, int lat = 0, int lon = 0);