| 
									
										
										
										
											2013-04-13 20:44:02 -07:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * models.h | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * header file for the equipment models of Subsurface | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2013-04-13 10:17:59 -03:00
										 |  |  | #ifndef MODELS_H
 | 
					
						
							|  |  |  | #define MODELS_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <QAbstractTableModel>
 | 
					
						
							| 
									
										
										
										
											2013-05-01 23:51:34 -03:00
										 |  |  | #include <QCoreApplication>
 | 
					
						
							| 
									
										
										
										
											2013-05-23 15:33:20 -03:00
										 |  |  | #include <QStringList>
 | 
					
						
							| 
									
										
										
										
											2013-11-14 17:39:35 -02:00
										 |  |  | #include <QStringListModel>
 | 
					
						
							| 
									
										
										
										
											2013-05-01 23:51:34 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-13 10:17:59 -03:00
										 |  |  | #include "../dive.h"
 | 
					
						
							| 
									
										
										
										
											2013-04-27 12:27:27 -03:00
										 |  |  | #include "../divelist.h"
 | 
					
						
							| 
									
										
										
										
											2013-06-17 15:58:26 -07:00
										 |  |  | #include "../qthelper.h"
 | 
					
						
							| 
									
										
										
										
											2013-05-01 23:51:34 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-16 12:33:27 -03:00
										 |  |  | QFont defaultModelFont(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-11 10:50:40 -03:00
										 |  |  | // Encapsulates Boilerplate.
 | 
					
						
							|  |  |  | class CleanerTableModel : public QAbstractTableModel{ | 
					
						
							|  |  |  | 	Q_OBJECT | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	CleanerTableModel(); | 
					
						
							| 
									
										
										
										
											2013-10-15 04:37:31 -07:00
										 |  |  | 	virtual int columnCount(const QModelIndex& parent = QModelIndex()) const; | 
					
						
							|  |  |  | 	virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; | 
					
						
							| 
									
										
										
										
											2013-10-11 10:50:40 -03:00
										 |  |  | protected: | 
					
						
							|  |  |  | 	void setHeaderDataStrings(const QStringList& headers); | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	QStringList headers; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-15 15:04:35 -03:00
										 |  |  | /* Encapsulates the tank_info global variable
 | 
					
						
							| 
									
										
										
										
											2013-05-14 09:28:30 +02:00
										 |  |  |  * to show on Qt's Model View System.*/ | 
					
						
							| 
									
										
										
										
											2013-10-11 11:42:33 -03:00
										 |  |  | class TankInfoModel : public CleanerTableModel { | 
					
						
							| 
									
										
										
										
											2013-04-15 15:04:35 -03:00
										 |  |  | Q_OBJECT | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2013-05-23 15:33:20 -03:00
										 |  |  | 	static TankInfoModel* instance(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-23 18:40:16 -07:00
										 |  |  | 	enum Column {DESCRIPTION, ML, BAR}; | 
					
						
							| 
									
										
										
										
											2013-04-15 15:04:35 -03:00
										 |  |  | 	TankInfoModel(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/*reimp*/ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; | 
					
						
							|  |  |  | 	/*reimp*/ int rowCount(const QModelIndex& parent = QModelIndex()) const; | 
					
						
							| 
									
										
										
										
											2013-05-23 15:33:20 -03:00
										 |  |  | 	/*reimp*/ bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex()); | 
					
						
							|  |  |  | 	/*reimp*/ bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole); | 
					
						
							| 
									
										
										
										
											2013-06-16 13:28:59 -03:00
										 |  |  | 	const QString& biggerString() const; | 
					
						
							| 
									
										
										
										
											2013-04-15 15:04:35 -03:00
										 |  |  | 	void clear(); | 
					
						
							|  |  |  | 	void update(); | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	int rows; | 
					
						
							| 
									
										
										
										
											2013-06-16 13:28:59 -03:00
										 |  |  | 	QString biggerEntry; | 
					
						
							| 
									
										
										
										
											2013-04-15 15:04:35 -03:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-23 18:40:16 -07:00
										 |  |  | /* Encapsulate ws_info */ | 
					
						
							| 
									
										
										
										
											2013-10-11 11:13:16 -03:00
										 |  |  | class WSInfoModel : public CleanerTableModel { | 
					
						
							| 
									
										
										
										
											2013-05-23 18:40:16 -07:00
										 |  |  | Q_OBJECT | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	static WSInfoModel* instance(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	enum Column {DESCRIPTION, GR}; | 
					
						
							|  |  |  | 	WSInfoModel(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/*reimp*/ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; | 
					
						
							|  |  |  | 	/*reimp*/ int rowCount(const QModelIndex& parent = QModelIndex()) const; | 
					
						
							|  |  |  | 	/*reimp*/ bool insertRows(int row, int count, const QModelIndex& parent = QModelIndex()); | 
					
						
							|  |  |  | 	/*reimp*/ bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole); | 
					
						
							| 
									
										
										
										
											2013-06-16 13:28:59 -03:00
										 |  |  | 	const QString& biggerString() const; | 
					
						
							| 
									
										
										
										
											2013-05-23 18:40:16 -07:00
										 |  |  | 	void clear(); | 
					
						
							|  |  |  | 	void update(); | 
					
						
							| 
									
										
										
										
											2013-09-10 11:42:26 -07:00
										 |  |  | 	void updateInfo(); | 
					
						
							| 
									
										
										
										
											2013-05-23 18:40:16 -07:00
										 |  |  | private: | 
					
						
							|  |  |  | 	int rows; | 
					
						
							| 
									
										
										
										
											2013-06-16 13:28:59 -03:00
										 |  |  | 	QString biggerEntry; | 
					
						
							| 
									
										
										
										
											2013-05-23 18:40:16 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-21 22:12:36 -03:00
										 |  |  | /* Encapsulation of the Cylinder Model, that presents the
 | 
					
						
							|  |  |  |  * Current cylinders that are used on a dive. */ | 
					
						
							| 
									
										
										
										
											2013-10-11 10:50:40 -03:00
										 |  |  | class CylindersModel : public CleanerTableModel { | 
					
						
							| 
									
										
										
										
											2013-04-13 10:17:59 -03:00
										 |  |  | Q_OBJECT | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2013-11-28 09:17:30 -02:00
										 |  |  | 	enum Column {REMOVE, TYPE, SIZE, WORKINGPRESS, START, END, O2, HE, DEPTH, COLUMNS}; | 
					
						
							| 
									
										
										
										
											2013-04-13 10:17:59 -03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	explicit CylindersModel(QObject* parent = 0); | 
					
						
							| 
									
										
										
										
											2013-11-10 07:06:26 +09:00
										 |  |  | 	static CylindersModel *instance(); | 
					
						
							| 
									
										
										
										
											2013-04-13 10:17:59 -03:00
										 |  |  | 	/*reimp*/ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; | 
					
						
							|  |  |  | 	/*reimp*/ int rowCount(const QModelIndex& parent = QModelIndex()) const; | 
					
						
							| 
									
										
										
										
											2013-05-22 12:20:00 -03:00
										 |  |  | 	/*reimp*/ Qt::ItemFlags flags(const QModelIndex& index) const; | 
					
						
							|  |  |  | 	/*reimp*/ bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole); | 
					
						
							| 
									
										
										
										
											2013-04-13 10:17:59 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-23 13:31:46 -07:00
										 |  |  | 	void passInData(const QModelIndex& index, const QVariant& value); | 
					
						
							| 
									
										
										
										
											2013-05-22 14:52:38 -03:00
										 |  |  | 	void add(); | 
					
						
							| 
									
										
										
										
											2013-04-13 10:17:59 -03:00
										 |  |  | 	void clear(); | 
					
						
							|  |  |  | 	void update(); | 
					
						
							| 
									
										
										
										
											2013-05-21 09:33:55 -03:00
										 |  |  | 	void setDive(struct dive *d); | 
					
						
							| 
									
										
										
										
											2013-07-18 10:24:02 -03:00
										 |  |  | 	cylinder_t *cylinderAt(const QModelIndex& index); | 
					
						
							| 
									
										
										
										
											2013-09-25 14:23:51 -03:00
										 |  |  | 	bool changed; | 
					
						
							| 
									
										
										
										
											2013-07-18 10:24:02 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-22 11:00:20 -03:00
										 |  |  | public slots: | 
					
						
							|  |  |  | 	void remove(const QModelIndex& index); | 
					
						
							| 
									
										
										
										
											2013-05-21 09:33:55 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-13 10:17:59 -03:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2013-05-21 09:33:55 -03:00
										 |  |  | 	struct dive *current; | 
					
						
							|  |  |  | 	int rows; | 
					
						
							| 
									
										
										
										
											2013-04-13 10:17:59 -03:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-21 22:12:36 -03:00
										 |  |  | /* Encapsulation of the Weight Model, that represents
 | 
					
						
							|  |  |  |  * the current weights on a dive. */ | 
					
						
							| 
									
										
										
										
											2013-10-11 11:04:27 -03:00
										 |  |  | class WeightModel : public CleanerTableModel { | 
					
						
							| 
									
										
										
										
											2013-05-01 14:30:34 -07:00
										 |  |  | Q_OBJECT | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2013-10-11 11:04:27 -03:00
										 |  |  | 	enum Column {REMOVE, TYPE, WEIGHT}; | 
					
						
							| 
									
										
										
										
											2013-05-23 18:40:16 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	explicit WeightModel(QObject *parent = 0); | 
					
						
							| 
									
										
										
										
											2013-04-13 10:17:59 -03:00
										 |  |  | 	/*reimp*/ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; | 
					
						
							|  |  |  | 	/*reimp*/ int rowCount(const QModelIndex& parent = QModelIndex()) const; | 
					
						
							| 
									
										
										
										
											2013-05-22 12:20:00 -03:00
										 |  |  | 	/*reimp*/ Qt::ItemFlags flags(const QModelIndex& index) const; | 
					
						
							|  |  |  | 	/*reimp*/ bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole); | 
					
						
							| 
									
										
										
										
											2013-04-13 10:17:59 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-23 18:40:16 -07:00
										 |  |  | 	void passInData(const QModelIndex& index, const QVariant& value); | 
					
						
							| 
									
										
										
										
											2013-05-22 14:52:38 -03:00
										 |  |  | 	void add(); | 
					
						
							| 
									
										
										
										
											2013-04-13 10:17:59 -03:00
										 |  |  | 	void clear(); | 
					
						
							|  |  |  | 	void update(); | 
					
						
							| 
									
										
										
										
											2013-05-21 09:59:41 -03:00
										 |  |  | 	void setDive(struct dive *d); | 
					
						
							| 
									
										
										
										
											2013-07-18 11:53:47 -03:00
										 |  |  | 	weightsystem_t *weightSystemAt(const QModelIndex& index); | 
					
						
							| 
									
										
										
										
											2013-09-25 14:23:51 -03:00
										 |  |  | 	bool changed; | 
					
						
							| 
									
										
										
										
											2013-07-18 11:53:47 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-22 11:00:20 -03:00
										 |  |  | public slots: | 
					
						
							|  |  |  | 	void remove(const QModelIndex& index); | 
					
						
							| 
									
										
										
										
											2013-05-21 09:59:41 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-13 10:17:59 -03:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2013-05-21 09:59:41 -03:00
										 |  |  | 	struct dive *current; | 
					
						
							|  |  |  | 	int rows; | 
					
						
							| 
									
										
										
										
											2013-04-13 10:17:59 -03:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-04-21 22:12:36 -03:00
										 |  |  | /*! An AbstractItemModel for recording dive trip information such as a list of dives.
 | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2013-05-01 23:51:34 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-17 18:59:50 -03:00
										 |  |  | struct TreeItem { | 
					
						
							| 
									
										
										
										
											2013-05-22 21:25:05 -07:00
										 |  |  | 	Q_DECLARE_TR_FUNCTIONS (TreeItemDT); | 
					
						
							| 
									
										
										
										
											2013-04-21 22:12:36 -03:00
										 |  |  | public: | 
					
						
							| 
									
										
										
										
											2013-06-17 18:59:50 -03:00
										 |  |  | 	virtual ~TreeItem(); | 
					
						
							| 
									
										
										
										
											2013-06-18 13:29:37 -07:00
										 |  |  | 	TreeItem(); | 
					
						
							| 
									
										
										
										
											2013-05-22 21:25:05 -07:00
										 |  |  | 	virtual QVariant data (int column, int role) const; | 
					
						
							| 
									
										
										
										
											2013-11-18 22:33:01 -02:00
										 |  |  | 	virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole); | 
					
						
							|  |  |  | 	virtual Qt::ItemFlags flags(const QModelIndex &index) const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-01 23:51:34 -03:00
										 |  |  | 	int row() const; | 
					
						
							| 
									
										
										
										
											2013-06-17 18:59:50 -03:00
										 |  |  | 	QList<TreeItem*> children; | 
					
						
							|  |  |  | 	TreeItem *parent; | 
					
						
							| 
									
										
										
										
											2013-05-01 23:51:34 -03:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2013-04-21 22:12:36 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-11 12:40:08 +03:00
										 |  |  | struct DiveItem : public TreeItem { | 
					
						
							|  |  |  | 	enum Column {NR, DATE, RATING, DEPTH, DURATION, TEMPERATURE, TOTALWEIGHT, | 
					
						
							|  |  |  | 		SUIT, CYLINDER, NITROX, SAC, OTU, MAXCNS, LOCATION, COLUMNS }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	virtual QVariant data(int column, int role) const; | 
					
						
							|  |  |  | 	struct dive* dive; | 
					
						
							| 
									
										
										
										
											2013-11-18 22:33:01 -02:00
										 |  |  | 	virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole); | 
					
						
							|  |  |  | 	virtual Qt::ItemFlags flags(const QModelIndex& index) const; | 
					
						
							| 
									
										
										
										
											2013-07-11 12:41:50 +03:00
										 |  |  | 	QString displayDate() const; | 
					
						
							| 
									
										
										
										
											2013-07-11 12:40:08 +03:00
										 |  |  | 	QString displayDuration() const; | 
					
						
							|  |  |  | 	QString displayDepth() const; | 
					
						
							|  |  |  | 	QString displayTemperature() const; | 
					
						
							|  |  |  | 	QString displayWeight() const; | 
					
						
							|  |  |  | 	QString displaySac() const; | 
					
						
							|  |  |  | 	int weight() const; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-01 23:51:34 -03:00
										 |  |  | struct TripItem; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-17 18:59:50 -03:00
										 |  |  | class TreeModel : public QAbstractItemModel | 
					
						
							| 
									
										
										
										
											2013-05-01 23:51:34 -03:00
										 |  |  | { | 
					
						
							|  |  |  | 	Q_OBJECT | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2013-06-17 18:59:50 -03:00
										 |  |  | 	TreeModel(QObject *parent = 0); | 
					
						
							|  |  |  | 	virtual ~TreeModel(); | 
					
						
							|  |  |  | 	virtual   QVariant data(const QModelIndex &index, int role) const; | 
					
						
							| 
									
										
										
										
											2013-05-01 23:51:34 -03:00
										 |  |  | 	/*reimp*/ int rowCount(const QModelIndex &parent = QModelIndex()) const; | 
					
						
							| 
									
										
										
										
											2013-04-21 22:12:36 -03:00
										 |  |  | 	/*reimp*/ int columnCount(const QModelIndex &parent = QModelIndex()) const; | 
					
						
							|  |  |  | 	/*reimp*/ QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; | 
					
						
							|  |  |  | 	/*reimp*/ QModelIndex parent(const QModelIndex &child) const; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-17 18:59:50 -03:00
										 |  |  | protected: | 
					
						
							|  |  |  | 	int columns; | 
					
						
							|  |  |  | 	TreeItem *rootItem; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class DiveTripModel : public TreeModel { | 
					
						
							| 
									
										
										
										
											2013-06-17 19:41:05 -03:00
										 |  |  | 	Q_OBJECT | 
					
						
							| 
									
										
										
										
											2013-06-17 18:59:50 -03:00
										 |  |  | public: | 
					
						
							|  |  |  | 	enum Column {NR, DATE, RATING, DEPTH, DURATION, TEMPERATURE, TOTALWEIGHT, | 
					
						
							|  |  |  | 		SUIT, CYLINDER, NITROX, SAC, OTU, MAXCNS, LOCATION, COLUMNS }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-16 18:41:47 -02:00
										 |  |  | 	enum ExtraRoles{STAR_ROLE = Qt::UserRole + 1, DIVE_ROLE, TRIP_ROLE, SORT_ROLE, DIVE_IDX}; | 
					
						
							| 
									
										
										
										
											2013-06-17 18:59:50 -03:00
										 |  |  | 	enum Layout{TREE, LIST, CURRENT}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	Qt::ItemFlags flags(const QModelIndex &index) const; | 
					
						
							| 
									
										
										
										
											2013-10-15 04:37:31 -07:00
										 |  |  | 	virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; | 
					
						
							| 
									
										
										
										
											2013-11-18 22:33:01 -02:00
										 |  |  | 	virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole); | 
					
						
							| 
									
										
										
										
											2013-10-15 04:37:31 -07:00
										 |  |  | 	DiveTripModel(QObject* parent = 0); | 
					
						
							| 
									
										
										
										
											2013-05-28 16:56:58 -03:00
										 |  |  | 	Layout layout() const; | 
					
						
							|  |  |  | 	void setLayout(Layout layout); | 
					
						
							| 
									
										
										
										
											2013-04-21 22:12:36 -03:00
										 |  |  | private: | 
					
						
							| 
									
										
										
										
											2013-05-01 23:51:34 -03:00
										 |  |  | 	void setupModelData(); | 
					
						
							|  |  |  | 	QMap<dive_trip_t*, TripItem*> trips; | 
					
						
							| 
									
										
										
										
											2013-05-28 16:56:58 -03:00
										 |  |  | 	Layout currentLayout; | 
					
						
							| 
									
										
										
										
											2013-04-21 22:12:36 -03:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-11 11:42:33 -03:00
										 |  |  | class DiveComputerModel : public CleanerTableModel | 
					
						
							| 
									
										
										
										
											2013-06-07 11:43:45 -03:00
										 |  |  | { | 
					
						
							|  |  |  | 	Q_OBJECT | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2013-10-11 11:42:33 -03:00
										 |  |  | 	enum {REMOVE, MODEL, ID, NICKNAME}; | 
					
						
							| 
									
										
										
										
											2013-06-17 15:58:26 -07:00
										 |  |  | 	DiveComputerModel(QMultiMap<QString, DiveComputerNode> &dcMap, QObject *parent = 0); | 
					
						
							|  |  |  | 	virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; | 
					
						
							|  |  |  | 	virtual int rowCount(const QModelIndex& parent = QModelIndex()) const; | 
					
						
							|  |  |  | 	virtual Qt::ItemFlags flags(const QModelIndex& index) const; | 
					
						
							|  |  |  | 	virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole); | 
					
						
							| 
									
										
										
										
											2013-06-07 11:43:45 -03:00
										 |  |  | 	void update(); | 
					
						
							| 
									
										
										
										
											2013-06-17 15:58:26 -07:00
										 |  |  | 	void keepWorkingList(); | 
					
						
							|  |  |  | 	void dropWorkingList(); | 
					
						
							| 
									
										
										
										
											2013-06-17 18:59:50 -03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-07 15:25:29 -03:00
										 |  |  | public slots: | 
					
						
							|  |  |  | 	void remove(const QModelIndex& index); | 
					
						
							| 
									
										
										
										
											2013-06-07 11:43:45 -03:00
										 |  |  | private: | 
					
						
							|  |  |  | 	int numRows; | 
					
						
							| 
									
										
										
										
											2013-06-17 15:58:26 -07:00
										 |  |  | 	QMultiMap<QString, DiveComputerNode> dcWorkingMap; | 
					
						
							| 
									
										
										
										
											2013-06-07 11:43:45 -03:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-17 19:41:05 -03:00
										 |  |  | class YearlyStatisticsModel : public TreeModel { | 
					
						
							|  |  |  | 	Q_OBJECT | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2013-12-06 14:29:38 -02:00
										 |  |  | 	enum {	YEAR,DIVES,TOTAL_TIME,AVERAGE_TIME,SHORTEST_TIME,LONGEST_TIME,AVG_DEPTH,MIN_DEPTH, | 
					
						
							| 
									
										
										
										
											2013-06-17 19:41:05 -03:00
										 |  |  | 		MAX_DEPTH,AVG_SAC,MIN_SAC,MAX_SAC,AVG_TEMP,MIN_TEMP,MAX_TEMP,COLUMNS}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; | 
					
						
							|  |  |  | 	YearlyStatisticsModel(QObject* parent = 0); | 
					
						
							| 
									
										
										
										
											2013-06-17 21:05:17 -03:00
										 |  |  | 	void update_yearly_stats(); | 
					
						
							| 
									
										
										
										
											2013-06-17 19:41:05 -03:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2013-07-25 12:52:20 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* TablePrintModel:
 | 
					
						
							|  |  |  |  * for now we use a blank table model with row items TablePrintItem. | 
					
						
							|  |  |  |  * these are pretty much the same as DiveItem, but have color | 
					
						
							|  |  |  |  * properties, as well. perhaps later one a more unified model has to be | 
					
						
							|  |  |  |  * considered, but the current TablePrintModel idea has to be extended | 
					
						
							|  |  |  |  * to support variadic column lists and column list orders that can | 
					
						
							|  |  |  |  * be controlled by the user. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | struct TablePrintItem { | 
					
						
							|  |  |  | 	QString number; | 
					
						
							|  |  |  | 	QString date; | 
					
						
							|  |  |  | 	QString depth; | 
					
						
							|  |  |  | 	QString duration; | 
					
						
							|  |  |  | 	QString divemaster; | 
					
						
							|  |  |  | 	QString buddy; | 
					
						
							|  |  |  | 	QString location; | 
					
						
							|  |  |  | 	unsigned int colorBackground; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class TablePrintModel : public QAbstractTableModel | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Q_OBJECT | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	QList<struct TablePrintItem *> list; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	~TablePrintModel(); | 
					
						
							|  |  |  | 	TablePrintModel(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	int rows, columns; | 
					
						
							|  |  |  | 	void insertRow(int index = -1); | 
					
						
							|  |  |  | 	void callReset(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	QVariant data(const QModelIndex &index,	int role) const; | 
					
						
							|  |  |  | 	bool setData(const QModelIndex &index, const QVariant &value, int role); | 
					
						
							|  |  |  | 	int rowCount(const QModelIndex &parent) const; | 
					
						
							|  |  |  | 	int columnCount(const QModelIndex &parent) const; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-10-03 17:50:40 +03:00
										 |  |  | /* ProfilePrintModel:
 | 
					
						
							|  |  |  |  * this model is used when printing a data table under a profile. it requires | 
					
						
							|  |  |  |  * some exact usage of setSpan(..) on the target QTableView widget. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | class ProfilePrintModel : public QAbstractTableModel | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	Q_OBJECT | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	struct dive *dive; | 
					
						
							|  |  |  | 	QString truncateString(char *str, const int maxlen) const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	ProfilePrintModel(QObject *parent = 0); | 
					
						
							|  |  |  | 	int rowCount(const QModelIndex &parent = QModelIndex()) const; | 
					
						
							|  |  |  | 	int columnCount(const QModelIndex &parent = QModelIndex()) const; | 
					
						
							|  |  |  | 	QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; | 
					
						
							|  |  |  | 	void setDive(struct dive *divePtr); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-14 17:39:35 -02:00
										 |  |  | class GasSelectionModel : public QStringListModel{ | 
					
						
							|  |  |  | 	Q_OBJECT | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	static GasSelectionModel* instance(); | 
					
						
							|  |  |  | 	Qt::ItemFlags flags(const QModelIndex& index) const; | 
					
						
							| 
									
										
										
										
											2013-11-14 17:43:28 -02:00
										 |  |  | 	virtual QVariant data(const QModelIndex& index, int role) const; | 
					
						
							| 
									
										
										
										
											2013-11-14 17:39:35 -02:00
										 |  |  | public slots: | 
					
						
							|  |  |  | 	void repopulate(); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-06 14:29:38 -02:00
										 |  |  | 
 | 
					
						
							|  |  |  | class LanguageModel : public QAbstractListModel { | 
					
						
							|  |  |  | 	Q_OBJECT | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  | 	static LanguageModel* instance(); | 
					
						
							|  |  |  | 	virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; | 
					
						
							|  |  |  | 	virtual int rowCount(const QModelIndex& parent = QModelIndex()) const; | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  | 	LanguageModel(QObject* parent = 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	QStringList languages; | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2013-04-13 10:17:59 -03:00
										 |  |  | #endif
 |