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>
|
2013-05-02 02:51:34 +00:00
|
|
|
#include <QCoreApplication>
|
2013-05-23 18:33:20 +00:00
|
|
|
#include <QStringList>
|
2013-05-02 02:51:34 +00:00
|
|
|
|
2013-04-13 13:17:59 +00:00
|
|
|
#include "../dive.h"
|
2013-04-27 15:27:27 +00:00
|
|
|
#include "../divelist.h"
|
2013-06-17 22:58:26 +00:00
|
|
|
#include "../qthelper.h"
|
2013-05-02 02:51:34 +00:00
|
|
|
|
2013-06-16 15:33:27 +00:00
|
|
|
QFont defaultModelFont();
|
|
|
|
|
2013-04-15 18:04:35 +00:00
|
|
|
/* Encapsulates the tank_info global variable
|
2013-05-14 07:28:30 +00:00
|
|
|
* to show on Qt's Model View System.*/
|
2013-04-15 18:04:35 +00:00
|
|
|
class TankInfoModel : public QAbstractTableModel {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2013-05-23 18:33:20 +00:00
|
|
|
static TankInfoModel* instance();
|
|
|
|
|
2013-05-24 01:40:16 +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;
|
2013-05-23 18:33:20 +00: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 16:28:59 +00:00
|
|
|
const QString& biggerString() const;
|
2013-04-15 18:04:35 +00:00
|
|
|
void clear();
|
|
|
|
void update();
|
|
|
|
private:
|
|
|
|
int rows;
|
2013-06-16 16:28:59 +00:00
|
|
|
QString biggerEntry;
|
2013-04-15 18:04:35 +00:00
|
|
|
};
|
|
|
|
|
2013-05-24 01:40:16 +00:00
|
|
|
/* Encapsulate ws_info */
|
|
|
|
class WSInfoModel : public QAbstractTableModel {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
static WSInfoModel* instance();
|
|
|
|
|
|
|
|
enum Column {DESCRIPTION, GR};
|
|
|
|
WSInfoModel();
|
|
|
|
|
|
|
|
/*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;
|
|
|
|
/*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 16:28:59 +00:00
|
|
|
const QString& biggerString() const;
|
2013-05-24 01:40:16 +00:00
|
|
|
void clear();
|
|
|
|
void update();
|
|
|
|
private:
|
|
|
|
int rows;
|
2013-06-16 16:28:59 +00:00
|
|
|
QString biggerEntry;
|
2013-05-24 01:40:16 +00:00
|
|
|
};
|
|
|
|
|
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-05-26 03:16:16 +00:00
|
|
|
enum Column {REMOVE, TYPE, SIZE, WORKINGPRESS, START, END, O2, HE, COLUMNS};
|
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;
|
2013-05-22 15:20:00 +00: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 13:17:59 +00:00
|
|
|
|
2013-05-23 20:31:46 +00:00
|
|
|
void passInData(const QModelIndex& index, const QVariant& value);
|
2013-05-22 17:52:38 +00:00
|
|
|
void add();
|
2013-04-13 13:17:59 +00:00
|
|
|
void clear();
|
|
|
|
void update();
|
2013-05-21 12:33:55 +00:00
|
|
|
void setDive(struct dive *d);
|
2013-07-18 13:24:02 +00:00
|
|
|
cylinder_t *cylinderAt(const QModelIndex& index);
|
|
|
|
|
2013-05-22 14:00:20 +00:00
|
|
|
public slots:
|
|
|
|
void remove(const QModelIndex& index);
|
2013-05-21 12:33:55 +00:00
|
|
|
|
2013-04-13 13:17:59 +00:00
|
|
|
private:
|
2013-05-21 12:33:55 +00:00
|
|
|
struct dive *current;
|
|
|
|
int rows;
|
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-05-01 21:30:34 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2013-05-22 14:00:20 +00:00
|
|
|
enum Column {REMOVE, TYPE, WEIGHT, COLUMNS};
|
2013-05-24 01:40:16 +00:00
|
|
|
|
|
|
|
explicit WeightModel(QObject *parent = 0);
|
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-22 15:20:00 +00: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 13:17:59 +00:00
|
|
|
|
2013-05-24 01:40:16 +00:00
|
|
|
void passInData(const QModelIndex& index, const QVariant& value);
|
2013-05-22 17:52:38 +00:00
|
|
|
void add();
|
2013-04-13 13:17:59 +00:00
|
|
|
void clear();
|
|
|
|
void update();
|
2013-05-21 12:59:41 +00:00
|
|
|
void setDive(struct dive *d);
|
2013-05-22 14:00:20 +00:00
|
|
|
public slots:
|
|
|
|
void remove(const QModelIndex& index);
|
2013-05-21 12:59:41 +00:00
|
|
|
|
2013-04-13 13:17:59 +00:00
|
|
|
private:
|
2013-05-21 12:59:41 +00:00
|
|
|
struct dive *current;
|
|
|
|
int rows;
|
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-05-02 02:51:34 +00:00
|
|
|
|
2013-06-17 21:59:50 +00:00
|
|
|
struct TreeItem {
|
2013-05-23 04:25:05 +00:00
|
|
|
Q_DECLARE_TR_FUNCTIONS (TreeItemDT);
|
2013-04-22 01:12:36 +00:00
|
|
|
public:
|
2013-06-17 21:59:50 +00:00
|
|
|
virtual ~TreeItem();
|
2013-06-18 20:29:37 +00:00
|
|
|
TreeItem();
|
2013-05-23 04:25:05 +00:00
|
|
|
virtual QVariant data (int column, int role) const;
|
2013-05-02 02:51:34 +00:00
|
|
|
int row() const;
|
2013-06-17 21:59:50 +00:00
|
|
|
QList<TreeItem*> children;
|
|
|
|
TreeItem *parent;
|
2013-05-02 02:51:34 +00:00
|
|
|
};
|
2013-04-22 01:12:36 +00:00
|
|
|
|
2013-07-11 09:40:08 +00: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-07-11 09:41:50 +00:00
|
|
|
QString displayDate() const;
|
2013-07-11 09:40:08 +00:00
|
|
|
QString displayDuration() const;
|
|
|
|
QString displayDepth() const;
|
|
|
|
QString displayTemperature() const;
|
|
|
|
QString displayWeight() const;
|
|
|
|
QString displaySac() const;
|
|
|
|
int weight() const;
|
|
|
|
};
|
|
|
|
|
2013-05-02 02:51:34 +00:00
|
|
|
struct TripItem;
|
|
|
|
|
2013-06-17 21:59:50 +00:00
|
|
|
class TreeModel : public QAbstractItemModel
|
2013-05-02 02:51:34 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2013-06-17 21:59:50 +00:00
|
|
|
TreeModel(QObject *parent = 0);
|
|
|
|
virtual ~TreeModel();
|
2013-05-28 19:56:58 +00:00
|
|
|
|
2013-06-17 21:59:50 +00:00
|
|
|
virtual QVariant data(const QModelIndex &index, int role) const;
|
2013-05-02 02:51:34 +00:00
|
|
|
/*reimp*/ int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
2013-04-22 01:12:36 +00: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 21:59:50 +00:00
|
|
|
protected:
|
|
|
|
int columns;
|
|
|
|
TreeItem *rootItem;
|
|
|
|
};
|
|
|
|
|
|
|
|
class DiveTripModel : public TreeModel {
|
2013-06-17 22:41:05 +00:00
|
|
|
Q_OBJECT
|
2013-06-17 21:59:50 +00:00
|
|
|
public:
|
|
|
|
enum Column {NR, DATE, RATING, DEPTH, DURATION, TEMPERATURE, TOTALWEIGHT,
|
|
|
|
SUIT, CYLINDER, NITROX, SAC, OTU, MAXCNS, LOCATION, COLUMNS };
|
|
|
|
|
2013-06-27 05:16:40 +00:00
|
|
|
enum ExtraRoles{STAR_ROLE = Qt::UserRole + 1, DIVE_ROLE, TRIP_ROLE, SORT_ROLE};
|
2013-06-17 21:59:50 +00:00
|
|
|
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);
|
2013-05-28 19:56:58 +00:00
|
|
|
Layout layout() const;
|
|
|
|
void setLayout(Layout layout);
|
2013-06-17 21:59:50 +00:00
|
|
|
|
2013-04-22 01:12:36 +00:00
|
|
|
private:
|
2013-05-02 02:51:34 +00:00
|
|
|
void setupModelData();
|
|
|
|
QMap<dive_trip_t*, TripItem*> trips;
|
2013-05-28 19:56:58 +00:00
|
|
|
Layout currentLayout;
|
2013-04-22 01:12:36 +00:00
|
|
|
};
|
|
|
|
|
2013-06-07 14:43:45 +00:00
|
|
|
class DiveComputerModel : public QAbstractTableModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
enum {REMOVE, MODEL, ID, NICKNAME, COLUMNS};
|
2013-06-17 22:58:26 +00:00
|
|
|
DiveComputerModel(QMultiMap<QString, DiveComputerNode> &dcMap, QObject *parent = 0);
|
|
|
|
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
|
|
|
virtual int columnCount(const QModelIndex& parent = QModelIndex()) const;
|
|
|
|
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 14:43:45 +00:00
|
|
|
void update();
|
2013-06-17 22:58:26 +00:00
|
|
|
void keepWorkingList();
|
|
|
|
void dropWorkingList();
|
2013-06-17 21:59:50 +00:00
|
|
|
|
2013-06-07 18:25:29 +00:00
|
|
|
public slots:
|
|
|
|
void remove(const QModelIndex& index);
|
2013-06-07 14:43:45 +00:00
|
|
|
private:
|
|
|
|
int numRows;
|
2013-06-17 22:58:26 +00:00
|
|
|
QMultiMap<QString, DiveComputerNode> dcWorkingMap;
|
2013-06-07 14:43:45 +00:00
|
|
|
};
|
|
|
|
|
2013-06-17 22:41:05 +00:00
|
|
|
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);
|
2013-06-18 00:05:17 +00:00
|
|
|
void update_yearly_stats();
|
2013-06-17 22:41:05 +00:00
|
|
|
};
|
2013-04-13 13:17:59 +00:00
|
|
|
#endif
|