desktop: unglobalize ComboBox-models

The combo-boxes (cylinder type, weightsystem, etc.) were controlled
by global models. Keeping these models up-to-date was very combersome
and buggy.

Create a new model everytime a combobox is opened. Ultimately it
might even be better to create a copy of the strings and switch
to simple QStringListModel. Set data in the core directly and
don't do this via the models.

The result is much simpler and easier to handle.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-03-30 13:40:00 +01:00 committed by Michael Keller
parent de313bd01a
commit 0d011231e6
16 changed files with 130 additions and 215 deletions

View file

@ -18,9 +18,10 @@ Qt::ItemFlags GasSelectionModel::flags(const QModelIndex&) const
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
void GasSelectionModel::repopulate(const dive *d)
GasSelectionModel::GasSelectionModel(const dive &d, QObject *parent)
: QStringListModel(parent)
{
setStringList(get_dive_gas_list(d));
setStringList(get_dive_gas_list(&d));
}
QVariant GasSelectionModel::data(const QModelIndex &index, int role) const
@ -37,7 +38,7 @@ Qt::ItemFlags DiveTypeSelectionModel::flags(const QModelIndex&) const
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
}
DiveTypeSelectionModel::DiveTypeSelectionModel()
DiveTypeSelectionModel::DiveTypeSelectionModel(QObject *parent) : QStringListModel(parent)
{
QStringList modes;
for (int i = 0; i < FREEDIVE; i++)