2017-04-27 18:25:32 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2015-05-28 19:23:49 +00:00
|
|
|
#ifndef CYLINDERMODEL_H
|
|
|
|
#define CYLINDERMODEL_H
|
|
|
|
|
2020-01-30 19:12:11 +00:00
|
|
|
#include <QSortFilterProxyModel>
|
|
|
|
|
2015-05-28 19:23:49 +00:00
|
|
|
#include "cleanertablemodel.h"
|
2020-05-15 14:01:32 +00:00
|
|
|
#include "core/equipment.h"
|
2015-05-28 19:23:49 +00:00
|
|
|
|
|
|
|
/* Encapsulation of the Cylinder Model, that presents the
|
|
|
|
* Current cylinders that are used on a dive. */
|
|
|
|
class CylindersModel : public CleanerTableModel {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
enum Column {
|
|
|
|
REMOVE,
|
|
|
|
TYPE,
|
|
|
|
SIZE,
|
|
|
|
WORKINGPRESS,
|
|
|
|
START,
|
|
|
|
END,
|
|
|
|
O2,
|
|
|
|
HE,
|
|
|
|
DEPTH,
|
2016-07-06 12:40:32 +00:00
|
|
|
MOD,
|
|
|
|
MND,
|
2015-05-28 19:23:49 +00:00
|
|
|
USE,
|
2020-02-27 18:46:48 +00:00
|
|
|
WORKINGPRESS_INT,
|
|
|
|
SIZE_INT,
|
2022-02-19 17:47:25 +00:00
|
|
|
SENSORS,
|
2015-05-28 19:23:49 +00:00
|
|
|
COLUMNS
|
|
|
|
};
|
|
|
|
|
2020-02-27 18:46:48 +00:00
|
|
|
enum Roles {
|
2020-02-28 19:38:04 +00:00
|
|
|
TEMP_ROLE = Qt::UserRole + 1, // Temporarily set data, but don't store in dive
|
|
|
|
COMMIT_ROLE, // Save the temporary data to the dive. Must be set with Column == TYPE.
|
|
|
|
REVERT_ROLE // Revert to original data from dive. Must be set with Column == TYPE.
|
2020-02-27 18:46:48 +00:00
|
|
|
};
|
2021-11-20 08:37:28 +00:00
|
|
|
explicit CylindersModel(bool planner, bool hideUnused, QObject *parent = 0); // First argument: true if this model is used for the planner
|
2018-09-29 20:13:44 +00:00
|
|
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
|
|
|
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole) override;
|
2015-05-28 19:23:49 +00:00
|
|
|
|
|
|
|
void add();
|
|
|
|
void clear();
|
2022-05-21 20:08:46 +00:00
|
|
|
void updateDive(dive *d, int dcNr);
|
2016-07-06 12:40:30 +00:00
|
|
|
void updateDecoDepths(pressure_t olddecopo2);
|
2017-03-13 07:25:32 +00:00
|
|
|
void updateTrashIcon();
|
2017-10-11 19:29:47 +00:00
|
|
|
void moveAtFirst(int cylid);
|
2018-09-29 20:13:44 +00:00
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
2020-02-01 07:49:43 +00:00
|
|
|
bool updateBestMixes();
|
2020-07-11 11:15:21 +00:00
|
|
|
void emitDataChanged();
|
2015-05-28 19:23:49 +00:00
|
|
|
|
2020-03-27 20:49:19 +00:00
|
|
|
signals:
|
|
|
|
void divesEdited(int num);
|
|
|
|
|
2015-05-28 19:23:49 +00:00
|
|
|
public
|
|
|
|
slots:
|
2019-11-26 22:41:56 +00:00
|
|
|
void remove(QModelIndex index);
|
2019-06-23 07:22:26 +00:00
|
|
|
void cylindersReset(const QVector<dive *> &dives);
|
2020-02-26 21:32:04 +00:00
|
|
|
void cylinderAdded(dive *d, int pos);
|
|
|
|
void cylinderRemoved(dive *d, int pos);
|
|
|
|
void cylinderEdited(dive *d, int pos);
|
2015-05-28 19:23:49 +00:00
|
|
|
|
|
|
|
private:
|
2020-02-23 11:44:09 +00:00
|
|
|
dive *d;
|
2022-05-21 20:08:46 +00:00
|
|
|
int dcNr;
|
2020-03-01 15:12:13 +00:00
|
|
|
bool inPlanner;
|
2021-11-20 08:37:28 +00:00
|
|
|
bool hideUnused;
|
|
|
|
int numRows; // Does not include unused cylinders at the end
|
2020-02-28 19:38:04 +00:00
|
|
|
// Used if we temporarily change a line because the user is selecting a weight type
|
|
|
|
int tempRow;
|
|
|
|
cylinder_t tempCyl;
|
|
|
|
|
2020-02-27 18:54:31 +00:00
|
|
|
cylinder_t *cylinderAt(const QModelIndex &index);
|
2020-02-28 19:38:04 +00:00
|
|
|
void initTempCyl(int row);
|
|
|
|
void clearTempCyl();
|
|
|
|
void commitTempCyl(int row);
|
2021-11-20 08:37:28 +00:00
|
|
|
bool cylinderUsed(int i) const;
|
|
|
|
int calcNumRows() const;
|
|
|
|
void updateNumRows();
|
2020-01-30 19:12:11 +00:00
|
|
|
};
|
|
|
|
|
2015-05-28 19:23:49 +00:00
|
|
|
#endif
|