summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-02-03 18:59:12 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-02-11 20:37:09 -0800
commit1336ea755b7ad2ef18cb869ca6219a1a6e237ff9 (patch)
treeb5ecb061f62d98bcae4c7180c6ee777a2e604726
parent190a2a876e3fe3148c6cfce87ac630f251833066 (diff)
downloadsubsurface-1336ea755b7ad2ef18cb869ca6219a1a6e237ff9.tar.gz
Planner: don't filter cylinders
In the planner we used to filter out "unused" cylinders as in the equipment tab. It is unclear whether that makes sense or can even easily be reproduced, since such cylinders have to come from an imported dive. To be on the save side, let's not do this. Replace the CylindersFilteredModel introduced recently by a plain CylindersModel. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r--backend-shared/plannershared.cpp10
-rw-r--r--desktop-widgets/diveplanner.cpp18
-rw-r--r--qt-models/diveplannermodel.cpp18
-rw-r--r--qt-models/diveplannermodel.h4
4 files changed, 25 insertions, 25 deletions
diff --git a/backend-shared/plannershared.cpp b/backend-shared/plannershared.cpp
index bc2fa58be..164c4cf46 100644
--- a/backend-shared/plannershared.cpp
+++ b/backend-shared/plannershared.cpp
@@ -126,7 +126,7 @@ void PlannerShared::set_o2narcotic(bool value)
{
qPrefDivePlanner::set_o2narcotic(value);
DivePlannerPointsModel::instance()->emitDataChanged();
- DivePlannerPointsModel::instance()->cylindersModel()->model()->updateBestMixes();
+ DivePlannerPointsModel::instance()->cylindersModel()->updateBestMixes();
}
double PlannerShared::bottompo2()
@@ -136,7 +136,7 @@ double PlannerShared::bottompo2()
void PlannerShared::set_bottompo2(double value)
{
qPrefDivePlanner::set_bottompo2((int) (value * 1000.0));
- DivePlannerPointsModel::instance()->cylindersModel()->model()->updateBestMixes();
+ DivePlannerPointsModel::instance()->cylindersModel()->updateBestMixes();
}
double PlannerShared::decopo2()
@@ -148,8 +148,8 @@ void PlannerShared::set_decopo2(double value)
pressure_t olddecopo2;
olddecopo2.mbar = prefs.decopo2;
qPrefDivePlanner::instance()->set_decopo2((int) (value * 1000.0));
- DivePlannerPointsModel::instance()->cylindersModel()->model()->updateDecoDepths(olddecopo2);
- DivePlannerPointsModel::instance()->cylindersModel()->model()->updateBestMixes();
+ DivePlannerPointsModel::instance()->cylindersModel()->updateDecoDepths(olddecopo2);
+ DivePlannerPointsModel::instance()->cylindersModel()->updateBestMixes();
}
int PlannerShared::bestmixend()
@@ -159,5 +159,5 @@ int PlannerShared::bestmixend()
void PlannerShared::set_bestmixend(int value)
{
qPrefDivePlanner::set_bestmixend(units_to_depth(value).mm);
- DivePlannerPointsModel::instance()->cylindersModel()->model()->updateBestMixes();
+ DivePlannerPointsModel::instance()->cylindersModel()->updateBestMixes();
}
diff --git a/desktop-widgets/diveplanner.cpp b/desktop-widgets/diveplanner.cpp
index b15a05b85..c773d95f2 100644
--- a/desktop-widgets/diveplanner.cpp
+++ b/desktop-widgets/diveplanner.cpp
@@ -110,7 +110,7 @@ void DiveHandler::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f)
{
DivePlannerPointsModel *plannerModel = DivePlannerPointsModel::instance();
- CylindersModelFiltered *cylinders = DivePlannerPointsModel::instance()->cylindersModel();
+ CylindersModel *cylinders = DivePlannerPointsModel::instance()->cylindersModel();
ui.setupUi(this);
ui.dateEdit->setDisplayFormat(prefs.date_format);
@@ -123,7 +123,7 @@ DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidg
ui.cylinderTableWidget->setTitle(tr("Available gases"));
ui.cylinderTableWidget->setBtnToolTip(tr("Add cylinder"));
ui.cylinderTableWidget->setModel(cylinders);
- connect(ui.cylinderTableWidget, &TableView::itemClicked, cylinders, &CylindersModelFiltered::remove);
+ connect(ui.cylinderTableWidget, &TableView::itemClicked, cylinders, &CylindersModel::remove);
ui.waterType->setItemData(0, FRESHWATER_SALINITY);
ui.waterType->setItemData(1, SEAWATER_SALINITY);
ui.waterType->setItemData(2, EN13319_SALINITY);
@@ -141,13 +141,13 @@ DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidg
// Continue to use old syntax, to avoid problems.
connect(ui.tableWidget, SIGNAL(addButtonClicked()), plannerModel, SLOT(addStop()));
- connect(cylinders, &CylindersModelFiltered::dataChanged, GasSelectionModel::instance(), &GasSelectionModel::repopulate);
- connect(cylinders, &CylindersModelFiltered::rowsInserted, GasSelectionModel::instance(), &GasSelectionModel::repopulate);
- connect(cylinders, &CylindersModelFiltered::rowsRemoved, GasSelectionModel::instance(), &GasSelectionModel::repopulate);
- connect(cylinders, &CylindersModelFiltered::dataChanged, plannerModel, &DivePlannerPointsModel::emitDataChanged);
- connect(cylinders, &CylindersModelFiltered::dataChanged, plannerModel, &DivePlannerPointsModel::cylinderModelEdited);
- connect(cylinders, &CylindersModelFiltered::rowsInserted, plannerModel, &DivePlannerPointsModel::cylinderModelEdited);
- connect(cylinders, &CylindersModelFiltered::rowsRemoved, plannerModel, &DivePlannerPointsModel::cylinderModelEdited);
+ connect(cylinders, &CylindersModel::dataChanged, GasSelectionModel::instance(), &GasSelectionModel::repopulate);
+ connect(cylinders, &CylindersModel::rowsInserted, GasSelectionModel::instance(), &GasSelectionModel::repopulate);
+ connect(cylinders, &CylindersModel::rowsRemoved, GasSelectionModel::instance(), &GasSelectionModel::repopulate);
+ connect(cylinders, &CylindersModel::dataChanged, plannerModel, &DivePlannerPointsModel::emitDataChanged);
+ connect(cylinders, &CylindersModel::dataChanged, plannerModel, &DivePlannerPointsModel::cylinderModelEdited);
+ connect(cylinders, &CylindersModel::rowsInserted, plannerModel, &DivePlannerPointsModel::cylinderModelEdited);
+ connect(cylinders, &CylindersModel::rowsRemoved, plannerModel, &DivePlannerPointsModel::cylinderModelEdited);
connect(plannerModel, &DivePlannerPointsModel::calculatedPlanNotes, MainWindow::instance(), &MainWindow::setPlanNotes);
diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp
index cf7dd0361..26d78bcb6 100644
--- a/qt-models/diveplannermodel.cpp
+++ b/qt-models/diveplannermodel.cpp
@@ -21,7 +21,7 @@
#define UNIT_FACTOR ((prefs.units.length == units::METERS) ? 1000.0 / 60.0 : feet_to_mm(1.0) / 60.0)
-CylindersModelFiltered *DivePlannerPointsModel::cylindersModel()
+CylindersModel *DivePlannerPointsModel::cylindersModel()
{
return &cylinders;
}
@@ -42,7 +42,7 @@ void DivePlannerPointsModel::removeSelectedPoints(const QVector<int> &rows)
divepoints.remove(v2[i]);
}
endRemoveRows();
- cylinders.model()->updateTrashIcon();
+ cylinders.updateTrashIcon();
}
void DivePlannerPointsModel::createSimpleDive()
@@ -320,7 +320,7 @@ bool DivePlannerPointsModel::setData(const QModelIndex &index, const QVariant &v
if (value.toInt() >= 0) {
p.depth = units_to_depth(value.toInt());
if (updateMaxDepth())
- cylinders.model()->updateBestMixes();
+ cylinders.updateBestMixes();
}
break;
case RUNTIME:
@@ -346,8 +346,8 @@ bool DivePlannerPointsModel::setData(const QModelIndex &index, const QVariant &v
p.cylinderid = value.toInt();
/* Did we change the start (dp 0) cylinder to another cylinderid than 0? */
if (value.toInt() != 0 && index.row() == 0)
- cylinders.model()->moveAtFirst(value.toInt());
- cylinders.model()->updateTrashIcon();
+ cylinders.moveAtFirst(value.toInt());
+ cylinders.updateTrashIcon();
break;
case DIVEMODE:
if (value.toInt() < FREEDIVE) {
@@ -802,9 +802,9 @@ void DivePlannerPointsModel::editStop(int row, divedatapoint newData)
divepoints[row] = newData;
std::sort(divepoints.begin(), divepoints.end(), divePointsLessThan);
if (updateMaxDepth())
- cylinders.model()->updateBestMixes();
+ cylinders.updateBestMixes();
if (divepoints[0].cylinderid != old_first_cylid)
- cylinders.model()->moveAtFirst(divepoints[0].cylinderid);
+ cylinders.moveAtFirst(divepoints[0].cylinderid);
emitDataChanged();
}
@@ -853,9 +853,9 @@ void DivePlannerPointsModel::remove(const QModelIndex &index)
divepoints.remove(index.row());
}
endRemoveRows();
- cylinders.model()->updateTrashIcon();
+ cylinders.updateTrashIcon();
if (divepoints[0].cylinderid != old_first_cylid)
- cylinders.model()->moveAtFirst(divepoints[0].cylinderid);
+ cylinders.moveAtFirst(divepoints[0].cylinderid);
}
struct diveplan &DivePlannerPointsModel::getDiveplan()
diff --git a/qt-models/diveplannermodel.h b/qt-models/diveplannermodel.h
index 4dda5cc6e..4d0967a26 100644
--- a/qt-models/diveplannermodel.h
+++ b/qt-models/diveplannermodel.h
@@ -48,7 +48,7 @@ public:
bool tankInUse(int cylinderid);
void setupCylinders();
bool updateMaxDepth();
- CylindersModelFiltered *cylindersModel();
+ CylindersModel *cylindersModel();
int ascrate75Display();
int ascrate50Display();
@@ -129,7 +129,7 @@ private:
void computeVariations(struct diveplan *diveplan, const struct deco_state *ds);
void computeVariationsFreeDeco(struct diveplan *diveplan, struct deco_state *ds);
int analyzeVariations(struct decostop *min, struct decostop *mid, struct decostop *max, const char *unit);
- CylindersModelFiltered cylinders;
+ CylindersModel cylinders;
Mode mode;
bool recalc;
QVector<divedatapoint> divepoints;