2013-04-14 03:44:02 +00:00
|
|
|
/*
|
|
|
|
* models.h
|
|
|
|
*
|
|
|
|
* header file for the equipment models of Subsurface
|
|
|
|
*
|
|
|
|
*/
|
2013-04-13 13:17:59 +00:00
|
|
|
#ifndef MODELS_H
|
|
|
|
#define MODELS_H
|
|
|
|
|
|
|
|
#include <QAbstractTableModel>
|
|
|
|
#include "../dive.h"
|
2013-04-27 15:27:27 +00:00
|
|
|
#include "../divelist.h"
|
2013-04-15 18:04:35 +00:00
|
|
|
/* Encapsulates the tank_info global variable
|
|
|
|
* to show on Qt`s Model View System.*/
|
|
|
|
class TankInfoModel : public QAbstractTableModel {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2013-04-22 01:12:36 +00:00
|
|
|
enum Column { DESCRIPTION, ML, BAR};
|
2013-04-15 18:04:35 +00:00
|
|
|
TankInfoModel();
|
|
|
|
|
|
|
|
/*reimp*/ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
|
|
|
/*reimp*/ int columnCount(const QModelIndex& parent = QModelIndex()) const;
|
|
|
|
/*reimp*/ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
|
|
|
/*reimp*/ int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
|
|
|
|
|
|
|
void add(const QString& description);
|
|
|
|
void clear();
|
|
|
|
void update();
|
|
|
|
private:
|
|
|
|
int rows;
|
|
|
|
};
|
|
|
|
|
2013-04-22 01:12:36 +00:00
|
|
|
/* Encapsulation of the Cylinder Model, that presents the
|
|
|
|
* Current cylinders that are used on a dive. */
|
2013-04-13 13:17:59 +00:00
|
|
|
class CylindersModel : public QAbstractTableModel {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2013-04-22 01:12:36 +00:00
|
|
|
enum Column {TYPE, SIZE, MAXPRESS, START, END, O2, HE};
|
2013-04-13 13:17:59 +00:00
|
|
|
|
|
|
|
explicit CylindersModel(QObject* parent = 0);
|
|
|
|
/*reimp*/ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
|
|
|
/*reimp*/ int columnCount(const QModelIndex& parent = QModelIndex()) const;
|
|
|
|
/*reimp*/ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
|
|
|
/*reimp*/ int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
|
|
|
|
|
|
|
void add(cylinder_t *cyl);
|
|
|
|
void clear();
|
|
|
|
void update();
|
|
|
|
private:
|
|
|
|
/* Since the dive doesn`t stores the number of cylinders that
|
|
|
|
* it has ( max 8 ) and since I don`t want to make a
|
|
|
|
* model-for-each-dive, let`s hack this here instead. */
|
2013-05-01 16:04:14 +00:00
|
|
|
QMap<struct dive *, int> usedRows;
|
2013-04-13 13:17:59 +00:00
|
|
|
};
|
|
|
|
|
2013-04-22 01:12:36 +00:00
|
|
|
/* Encapsulation of the Weight Model, that represents
|
|
|
|
* the current weights on a dive. */
|
2013-04-13 13:17:59 +00:00
|
|
|
class WeightModel : public QAbstractTableModel {
|
2013-04-22 01:12:36 +00:00
|
|
|
enum Column {TYPE, WEIGHT};
|
2013-04-13 13:17:59 +00:00
|
|
|
/*reimp*/ QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
|
|
|
/*reimp*/ int columnCount(const QModelIndex& parent = QModelIndex()) const;
|
|
|
|
/*reimp*/ QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
|
|
|
|
/*reimp*/ int rowCount(const QModelIndex& parent = QModelIndex()) const;
|
|
|
|
|
2013-05-01 17:11:46 +00:00
|
|
|
void add(weightsystem_t *weight);
|
2013-04-13 13:17:59 +00:00
|
|
|
void clear();
|
|
|
|
void update();
|
|
|
|
private:
|
2013-05-01 16:04:14 +00:00
|
|
|
/* Remember the number of rows in a dive */
|
|
|
|
QMap<struct dive *, int> usedRows;
|
2013-04-13 13:17:59 +00:00
|
|
|
};
|
|
|
|
|
2013-04-22 01:12:36 +00:00
|
|
|
/*! An AbstractItemModel for recording dive trip information such as a list of dives.
|
|
|
|
*
|
|
|
|
*/
|
2013-04-27 15:27:27 +00:00
|
|
|
class DiveItem;
|
2013-04-22 01:12:36 +00:00
|
|
|
class DiveTripModel : public QAbstractItemModel
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum Column {NR, DATE, RATING, DEPTH, DURATION, TEMPERATURE, TOTALWEIGHT, SUIT, CYLINDER, NITROX, SAC, OTU, MAXCNS, LOCATION, COLUMNS };
|
|
|
|
|
|
|
|
DiveTripModel(QObject *parent = 0);
|
|
|
|
|
|
|
|
/*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) const;
|
|
|
|
/*reimp*/ int rowCount(const QModelIndex &parent) 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;
|
|
|
|
|
|
|
|
private:
|
|
|
|
DiveItem *itemForIndex(const QModelIndex& index) const;
|
|
|
|
DiveItem *rootItem;
|
|
|
|
};
|
|
|
|
|
2013-04-13 13:17:59 +00:00
|
|
|
#endif
|