planner: initialize dive selection mode in constructor

There is no point in repopulating this regularly, as the
content does not change.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2022-11-08 07:48:49 +01:00 committed by bstoeger
parent 4c02d1c279
commit 1fb9d6236b
3 changed files with 5 additions and 13 deletions

View file

@ -582,7 +582,6 @@ void PlannerWidgets::planDive()
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
repopulateGasModel();
diveTypeModel->repopulate(); // TODO: this doesn't change anything!?
plannerWidget.setReplanButton(false);
plannerWidget.setupStartTime(timestampToDateTime(planned_dive->when)); // This will reload the profile!
}
@ -597,7 +596,6 @@ void PlannerWidgets::replanDive(int currentDC)
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::PLAN);
DivePlannerPointsModel::instance()->loadFromDive(planned_dive.get(), currentDC);
diveTypeModel->repopulate(); // TODO: this doesn't change anything!?
plannerWidget.setReplanButton(true);
plannerWidget.setupStartTime(timestampToDateTime(planned_dive->when));
if (planned_dive->surface_pressure.mbar)

View file

@ -25,11 +25,11 @@ void GasSelectionModel::repopulate(const dive *d)
QVariant GasSelectionModel::data(const QModelIndex &index, int role) const
{
if (role == Qt::FontRole) {
if (role == Qt::FontRole)
return defaultModelFont();
}
return QStringListModel::data(index, role);
}
// Dive Type Model for the divetype combo box
Qt::ItemFlags DiveTypeSelectionModel::flags(const QModelIndex&) const
@ -37,7 +37,7 @@ Qt::ItemFlags DiveTypeSelectionModel::flags(const QModelIndex&) const
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
void DiveTypeSelectionModel::repopulate()
DiveTypeSelectionModel::DiveTypeSelectionModel()
{
QStringList modes;
for (int i = 0; i < FREEDIVE; i++)
@ -47,13 +47,11 @@ void DiveTypeSelectionModel::repopulate()
QVariant DiveTypeSelectionModel::data(const QModelIndex &index, int role) const
{
if (role == Qt::FontRole) {
if (role == Qt::FontRole)
return defaultModelFont();
}
return QStringListModel::data(index, role);
}
// Language Model, The Model to populate the list of possible Languages.
LanguageModel *LanguageModel::instance()

View file

@ -26,19 +26,15 @@ class GasSelectionModel : public QStringListModel {
public:
Qt::ItemFlags flags(const QModelIndex &index) const;
QVariant data(const QModelIndex &index, int role) const override;
public
slots:
void repopulate(const dive *d);
};
class DiveTypeSelectionModel : public QStringListModel {
Q_OBJECT
public:
DiveTypeSelectionModel();
Qt::ItemFlags flags(const QModelIndex &index) const;
QVariant data(const QModelIndex &index, int role) const override;
public
slots:
void repopulate();
};
class LanguageModel : public QAbstractListModel {