summaryrefslogtreecommitdiffstats
path: root/qt-models/divelistmodel.h
blob: 96f16912a6992a75ad770bf7a91c0f4af23bffa5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#ifndef DIVELISTMODEL_H
#define DIVELISTMODEL_H

#include <QAbstractListModel>
#include "dive.h"

class Dive {
public:
	Dive(dive* d);

	QString date() const;
	void setDate(const QString &date);

	QString location() const;
	void setLocation(const QString &location);

	QString sac() const;
	void setSac(const QString &sac);

	QString gas() const;
	void setGas(const QString &gas);

	QString cylinder() const;
	void setCylinder(const QString &cylinder);

	QString suit() const;
	void setSuit(const QString &suit);

	QString weight() const;
	void setWeight(const QString &weight);

	QString temp() const;
	void setTemp(const QString &temp);

	QString duration() const;
	void setDuration(const QString &duration);

	QString depth() const;
	void setDepth(const QString &depth);

	QString rating() const;
	void setRating(const QString &rating);

	dive *thisDive() const;
	void setThisDive(dive *thisDive);

	QString diveNumber() const;
	void setDiveNumber(const QString &diveNumber);

private:
	QString m_diveNumber;
	QString m_date;
	QString m_rating;
	QString m_depth;
	QString m_duration;
	QString m_temp;
	QString m_weight;
	QString m_suit;
	QString m_cylinder;
	QString m_gas;
	QString m_sac;
	QString m_location;


	dive *m_thisDive;
};

class DiveListModel : public QAbstractListModel
{
	Q_OBJECT
public:

	enum DiveListRoles {
		DiveNumberRole = Qt::UserRole + 1,
		DiveDateRole,
		DiveRatingRole,
		DiveDepthRole,
		DiveDurationRole,
		DiveTemperatureRole,
		DiveWeightRole,
		DiveSuitRole,
		DiveCylinderRole,
		DiveGasRole,
		DiveSacRole,
		DiveLocationRole
	};

	static DiveListModel *instance();
	DiveListModel(QObject *parent = 0);
	void addDive(dive *d);
	int rowCount(const QModelIndex &parent = QModelIndex()) const;
	QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
	QHash<int, QByteArray> roleNames() const;

private:
	QList<Dive> m_dives;
	static DiveListModel *m_instance;
};

#endif // DIVELISTMODEL_H