diff options
Diffstat (limited to 'qt-ui/models.h')
-rw-r--r-- | qt-ui/models.h | 58 |
1 files changed, 36 insertions, 22 deletions
diff --git a/qt-ui/models.h b/qt-ui/models.h index e371ce1ea..35ed529e3 100644 --- a/qt-ui/models.h +++ b/qt-ui/models.h @@ -124,51 +124,55 @@ private: * */ -struct TreeItemDT { +struct TreeItem { Q_DECLARE_TR_FUNCTIONS (TreeItemDT); public: - enum Column {NR, DATE, RATING, DEPTH, DURATION, TEMPERATURE, TOTALWEIGHT, - SUIT, CYLINDER, NITROX, SAC, OTU, MAXCNS, LOCATION, COLUMNS }; - - enum ExtraRoles{STAR_ROLE = Qt::UserRole + 1, DIVE_ROLE, SORT_ROLE}; - - virtual ~TreeItemDT(); - int columnCount() const { - return COLUMNS; - }; + virtual ~TreeItem(); virtual QVariant data (int column, int role) const; int row() const; - QList<TreeItemDT *> children; - TreeItemDT *parent; + QList<TreeItem*> children; + TreeItem *parent; }; struct TripItem; -class DiveTripModel : public QAbstractItemModel +class TreeModel : public QAbstractItemModel { Q_OBJECT public: - enum Layout{TREE, LIST, CURRENT}; - - DiveTripModel(QObject *parent = 0); - ~DiveTripModel(); + TreeModel(QObject *parent = 0); + virtual ~TreeModel(); - /*reimp*/ Qt::ItemFlags flags(const QModelIndex &index) const; - /*reimp*/ QVariant data(const QModelIndex &index, int role) const; - /*reimp*/ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + virtual QVariant data(const QModelIndex &index, int role) const; /*reimp*/ int rowCount(const QModelIndex &parent = QModelIndex()) const; /*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; +protected: + int columns; + TreeItem *rootItem; +}; + +class DiveTripModel : public TreeModel { + Q_OBJECT +public: + enum Column {NR, DATE, RATING, DEPTH, DURATION, TEMPERATURE, TOTALWEIGHT, + SUIT, CYLINDER, NITROX, SAC, OTU, MAXCNS, LOCATION, COLUMNS }; + + enum ExtraRoles{STAR_ROLE = Qt::UserRole + 1, DIVE_ROLE, SORT_ROLE}; + enum Layout{TREE, LIST, CURRENT}; + + Qt::ItemFlags flags(const QModelIndex &index) const; + virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + DiveTripModel(QObject* parent = 0); Layout layout() const; void setLayout(Layout layout); + private: void setupModelData(); - - TreeItemDT *rootItem; QMap<dive_trip_t*, TripItem*> trips; Layout currentLayout; }; @@ -196,4 +200,14 @@ private: QMultiMap<QString, DiveComputerNode> dcWorkingMap; }; +class YearlyStatisticsModel : public TreeModel { + Q_OBJECT +public: + enum { YEAR,DIVES,TOTAL_TIME,AVERAGE_TIME,SHORTEST_TIME,LONGEST_TIME,AVG_DEPTH,MIN_DEPTH, + 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); + void update_yearly_stats(); +}; #endif |