diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-10-09 12:26:58 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-10-09 21:00:44 -0700 |
commit | d6010b5155e7c1b03d1872eb3ed75c39e070ad55 (patch) | |
tree | fb8a33c76b4e9a4afd0dafebefa16bd55f76c199 /qt-models/divelocationmodel.h | |
parent | 19d651a36b8f5c955ef3e147bbb3efa93028f959 (diff) | |
download | subsurface-d6010b5155e7c1b03d1872eb3ed75c39e070ad55.tar.gz |
Dive locations: factor out common code of models
For increased maintainability, use the same columns, roles and
the same accessor function for both dive-site models.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/divelocationmodel.h')
-rw-r--r-- | qt-models/divelocationmodel.h | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/qt-models/divelocationmodel.h b/qt-models/divelocationmodel.h index 47164d2d4..8dbc8f3e6 100644 --- a/qt-models/divelocationmodel.h +++ b/qt-models/divelocationmodel.h @@ -8,18 +8,21 @@ #include "core/units.h" #include "ssrfsortfilterproxymodel.h" -class QLineEdit; - #define RECENTLY_ADDED_DIVESITE 1 bool filter_same_gps_cb (QAbstractItemModel *m, int sourceRow, const QModelIndex& parent); + class LocationInformationModel : public QAbstractTableModel { Q_OBJECT public: - LocationInformationModel(QObject *obj = 0); + // Common columns, roles and accessor function for all dive-site models. + // Thus, different views can connect to different models. enum Columns { UUID, NAME, LATITUDE, LONGITUDE, COORDS, DESCRIPTION, NOTES, TAXONOMY_1, TAXONOMY_2, TAXONOMY_3, COLUMNS}; enum Roles { UUID_ROLE = Qt::UserRole + 1 }; + static QVariant getDiveSiteData(const struct dive_site *ds, int column, int role); + + LocationInformationModel(QObject *obj = 0); static LocationInformationModel *instance(); int columnCount(const QModelIndex &parent) const; int rowCount(const QModelIndex &parent = QModelIndex()) const; |