summaryrefslogtreecommitdiffstats
path: root/qt-models/divelistmodel.h
blob: 68022812c86e8ebfcf9abcd681e82959f19aa708 (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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#ifndef DIVELISTMODEL_H
#define DIVELISTMODEL_H

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

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

	QString dateString() const;
	void setDateString(const QString &date);

	timestamp_t date() const;
	void setDate(const timestamp_t when);

	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 airtemp() const;
	void setAirTemp(const QString &airtemp);

	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);

	QString notes() const;
	void setNotes(const QString &notes);

	QString trip() const;
	void setTrip(const QString &trip);

	QString buddy() const;
	void setBuddy(const QString &buddy);

	QString divemaster() const;
	void setDivemaster(const QString &divemaster);

	QString watertemp() const;
	void setWatertemp(const QString &watertemp);

	QString diveId() const;
	void setDiveId(const QString &diveId);

private:
	void setupDiveTempDetails();

	QString m_diveNumber;
	QString m_trip;
	timestamp_t m_date;
	QString m_dateString;
	QString m_rating;
	QString m_depth;
	QString m_duration;
	QString m_airtemp;
	QString m_watertemp;
	QString m_weight;
	QString m_suit;
	QString m_cylinder;
	QString m_gas;
	QString m_sac;
	QString m_location;
	QString m_notes;
	QString m_buddy;
	QString m_divemaster;
	QString m_diveId;


	dive *m_thisDive;
};

class DiveListModel : public QAbstractListModel
{
	Q_OBJECT
public:

	enum DiveListRoles {
		DiveNumberRole = Qt::UserRole + 1,
		DiveTripRole,
		DiveDateRole,
		DiveDateStringRole,
		DiveRatingRole,
		DiveDepthRole,
		DiveDurationRole,
		DiveWaterTemperatureRole,
		DiveAirTemperatureRole,
		DiveWeightRole,
		DiveSuitRole,
		DiveCylinderRole,
		DiveGasRole,
		DiveSacRole,
		DiveLocationRole,
		DiveNotesRole,
		DiveBuddyRole,
		DiveMasterRole,
		DiveIdRole
	};

	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;
	void startAddDive();
private:
	QList<MobileDive> m_dives;
	static DiveListModel *m_instance;
};

#endif // DIVELISTMODEL_H