2015-06-09 19:20:44 +00:00
|
|
|
#ifndef DIVELISTMODEL_H
|
|
|
|
#define DIVELISTMODEL_H
|
|
|
|
|
|
|
|
#include <QAbstractListModel>
|
2016-01-07 18:01:24 +00:00
|
|
|
|
2015-06-09 19:20:44 +00:00
|
|
|
#include "dive.h"
|
2015-08-18 09:03:30 +00:00
|
|
|
#include "helpers.h"
|
2016-01-07 18:01:24 +00:00
|
|
|
#include "subsurface-qt/DiveObjectHelper.h"
|
2015-06-09 19:20:44 +00:00
|
|
|
|
|
|
|
class DiveListModel : public QAbstractListModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
|
|
|
|
enum DiveListRoles {
|
2016-01-07 18:01:24 +00:00
|
|
|
DiveRole = Qt::UserRole + 1,
|
|
|
|
DiveDateRole
|
2015-06-09 19:20:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static DiveListModel *instance();
|
|
|
|
DiveListModel(QObject *parent = 0);
|
|
|
|
void addDive(dive *d);
|
2016-01-27 19:27:41 +00:00
|
|
|
void insertDive(int i, DiveObjectHelper *newDive);
|
|
|
|
void removeDive(int i);
|
2015-12-08 06:23:09 +00:00
|
|
|
void updateDive(dive *d);
|
2015-11-30 18:09:46 +00:00
|
|
|
void clear();
|
2015-06-09 19:20:44 +00:00
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
|
|
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
|
|
|
QHash<int, QByteArray> roleNames() const;
|
2015-12-27 05:37:18 +00:00
|
|
|
QString startAddDive();
|
2016-01-07 18:01:24 +00:00
|
|
|
Q_INVOKABLE DiveObjectHelper* at(int i);
|
2015-06-09 19:20:44 +00:00
|
|
|
private:
|
2016-01-07 18:01:24 +00:00
|
|
|
QList<DiveObjectHelper*> m_dives;
|
2015-06-09 19:20:44 +00:00
|
|
|
static DiveListModel *m_instance;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // DIVELISTMODEL_H
|