mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 21:53:23 +00:00
More information on dive site model
All of dive site information is now exposed to the model Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
324b6182aa
commit
db8b140c52
2 changed files with 24 additions and 6 deletions
|
@ -13,10 +13,15 @@ LocationInformationModel *LocationInformationModel::instance()
|
||||||
return self;
|
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
|
int LocationInformationModel::rowCount(const QModelIndex &parent) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(parent);
|
Q_UNUSED(parent);
|
||||||
|
@ -33,8 +38,20 @@ QVariant LocationInformationModel::data(const QModelIndex &index, int role) cons
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
switch(role) {
|
switch(role) {
|
||||||
case Qt::DisplayRole : return qPrintable(ds->name);
|
case Qt::DisplayRole :
|
||||||
case DIVE_SITE_UUID : return ds->uuid;
|
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();
|
return QVariant();
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
#ifndef DIVELOCATIONMODEL_H
|
#ifndef DIVELOCATIONMODEL_H
|
||||||
#define DIVELOCATIONMODEL_H
|
#define DIVELOCATIONMODEL_H
|
||||||
|
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractTableModel>
|
||||||
#include <QStringListModel>
|
#include <QStringListModel>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
class LocationInformationModel : public QAbstractListModel {
|
class LocationInformationModel : public QAbstractTableModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
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();
|
static LocationInformationModel *instance();
|
||||||
|
int columnCount(const QModelIndex &parent) const;
|
||||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||||
QVariant data(const QModelIndex &index = QModelIndex(), int role = Qt::DisplayRole) const;
|
QVariant data(const QModelIndex &index = QModelIndex(), int role = Qt::DisplayRole) const;
|
||||||
int32_t addDiveSite(const QString& name, int lat = 0, int lon = 0);
|
int32_t addDiveSite(const QString& name, int lat = 0, int lon = 0);
|
||||||
|
|
Loading…
Add table
Reference in a new issue