mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Added the code that will load and populate the Tank Info ComboBox that`s used by the user to select the Cylinder description. Code curerntly implements more than the GTK version since the GTK version of it was a plain-list, this one is a table based model that can be used in ListViews ( like we use now in the ComboBox ) but also in TableViews ( if there`s a need in the future to see everything that`s catalogued in the Tank Info struct. ) Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
70 lines
2.1 KiB
C++
70 lines
2.1 KiB
C++
/*
|
|
* models.h
|
|
*
|
|
* header file for the equipment models of Subsurface
|
|
*
|
|
*/
|
|
#ifndef MODELS_H
|
|
#define MODELS_H
|
|
|
|
#include <QAbstractTableModel>
|
|
#include "../dive.h"
|
|
|
|
/* Encapsulates the tank_info global variable
|
|
* to show on Qt`s Model View System.*/
|
|
class TankInfoModel : public QAbstractTableModel {
|
|
Q_OBJECT
|
|
public:
|
|
enum { DESCRIPTION, ML, BAR};
|
|
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;
|
|
};
|
|
|
|
class CylindersModel : public QAbstractTableModel {
|
|
Q_OBJECT
|
|
public:
|
|
enum {TYPE, SIZE, MAXPRESS, START, END, O2, HE};
|
|
|
|
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:
|
|
dive *currentDive;
|
|
|
|
/* 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. */
|
|
QMap<dive*, int> usedRows;
|
|
};
|
|
|
|
class WeightModel : public QAbstractTableModel {
|
|
enum{TYPE, WEIGHT};
|
|
/*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(weight_t *weight);
|
|
void clear();
|
|
void update();
|
|
private:
|
|
int rows;
|
|
};
|
|
|
|
#endif
|