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>
This commit is contained in:
Berthold Stoeger 2020-02-03 18:59:12 +01:00 committed by Dirk Hohndel
parent 190a2a876e
commit 1336ea755b
4 changed files with 25 additions and 25 deletions

View file

@ -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();
}

View file

@ -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);

View file

@ -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()

View file

@ -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;