summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qt-models/cylindermodel.cpp22
-rw-r--r--qt-models/cylindermodel.h3
-rw-r--r--qt-models/diveplannermodel.cpp1
3 files changed, 15 insertions, 11 deletions
diff --git a/qt-models/cylindermodel.cpp b/qt-models/cylindermodel.cpp
index c2bd0198a..8a79ff1e5 100644
--- a/qt-models/cylindermodel.cpp
+++ b/qt-models/cylindermodel.cpp
@@ -11,8 +11,9 @@
#include "core/subsurface-string.h"
#include <string>
-CylindersModel::CylindersModel(QObject *parent) : CleanerTableModel(parent),
+CylindersModel::CylindersModel(bool planner, QObject *parent) : CleanerTableModel(parent),
d(nullptr),
+ inPlanner(planner),
tempRow(-1),
tempCyl(empty_cylinder)
{
@@ -28,7 +29,7 @@ CylindersModel::CylindersModel(QObject *parent) : CleanerTableModel(parent),
QVariant CylindersModel::headerData(int section, Qt::Orientation orientation, int role) const
{
- if (role == Qt::DisplayRole && orientation == Qt::Horizontal && in_planner() && section == WORKINGPRESS)
+ if (role == Qt::DisplayRole && orientation == Qt::Horizontal && inPlanner && section == WORKINGPRESS)
return tr("Start press.");
else
return CleanerTableModel::headerData(section, orientation, role);
@@ -249,8 +250,8 @@ QVariant CylindersModel::data(const QModelIndex &index, int role) const
case Qt::DecorationRole:
case Qt::SizeHintRole:
if (index.column() == REMOVE) {
- if ((in_planner() && DivePlannerPointsModel::instance()->tankInUse(index.row())) ||
- (!in_planner() && is_cylinder_prot(d, index.row()))) {
+ if ((inPlanner && DivePlannerPointsModel::instance()->tankInUse(index.row())) ||
+ (!inPlanner && is_cylinder_prot(d, index.row()))) {
return trashForbiddenIcon();
}
return trashIcon();
@@ -259,8 +260,8 @@ QVariant CylindersModel::data(const QModelIndex &index, int role) const
case Qt::ToolTipRole:
switch (index.column()) {
case REMOVE:
- if ((in_planner() && DivePlannerPointsModel::instance()->tankInUse(index.row())) ||
- (!in_planner() && is_cylinder_prot(d, index.row()))) {
+ if ((inPlanner && DivePlannerPointsModel::instance()->tankInUse(index.row())) ||
+ (!inPlanner && is_cylinder_prot(d, index.row()))) {
return tr("This gas is in use. Only cylinders that are not used in the dive can be removed.");
}
return tr("Clicking here will remove this cylinder.");
@@ -450,7 +451,7 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
break;
}
- if (in_planner()) {
+ if (inPlanner) {
// In the planner - simply overwrite the cylinder in the dive with the modified cylinder.
// We have only made a shallow copy, therefore copy the new cylinder first.
cylinder_t copy = clone_cylinder(cyl);
@@ -590,7 +591,7 @@ void CylindersModel::moveAtFirst(int cylid)
mapping[cylid] = 0;
std::iota(mapping.begin() + (cylid + 1), mapping.end(), cylid);
cylinder_renumber(d, &mapping[0]);
- if (in_planner())
+ if (inPlanner)
DivePlannerPointsModel::instance()->cylinderRenumber(&mapping[0]);
endMoveRows();
}
@@ -705,7 +706,7 @@ void CylindersModel::commitTempCyl(int row)
return;
// Only submit a command if the type changed
if (!same_string(cyl->type.description, tempCyl.type.description) || gettextFromC::tr(cyl->type.description) != QString(tempCyl.type.description)) {
- if (in_planner())
+ if (inPlanner)
std::swap(*cyl, tempCyl);
else
Command::editCylinder(tempRow, tempCyl, false);
@@ -715,7 +716,8 @@ void CylindersModel::commitTempCyl(int row)
#endif
}
-CylindersModelFiltered::CylindersModelFiltered(QObject *parent) : QSortFilterProxyModel(parent)
+CylindersModelFiltered::CylindersModelFiltered(QObject *parent) : QSortFilterProxyModel(parent),
+ source(false) // Currently, only the EquipmentTab uses the filtered model.
{
setSourceModel(&source);
}
diff --git a/qt-models/cylindermodel.h b/qt-models/cylindermodel.h
index e4585b0ac..7b868b5b2 100644
--- a/qt-models/cylindermodel.h
+++ b/qt-models/cylindermodel.h
@@ -35,7 +35,7 @@ public:
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.
};
- explicit CylindersModel(QObject *parent = 0);
+ explicit CylindersModel(bool planner, QObject *parent = 0); // First argument: true if this model is used for the planner
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;
@@ -61,6 +61,7 @@ slots:
private:
dive *d;
+ bool inPlanner;
// Used if we temporarily change a line because the user is selecting a weight type
int tempRow;
cylinder_t tempCyl;
diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp
index 4928900c4..09d08c79a 100644
--- a/qt-models/diveplannermodel.cpp
+++ b/qt-models/diveplannermodel.cpp
@@ -415,6 +415,7 @@ int DivePlannerPointsModel::rowCount(const QModelIndex&) const
}
DivePlannerPointsModel::DivePlannerPointsModel(QObject *parent) : QAbstractTableModel(parent),
+ cylinders(true),
mode(NOTHING),
recalc(false)
{