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

@ -78,8 +78,10 @@ QVariant WeightModel::data(const QModelIndex &index, int role) const
// Ownership of passed in weight system will be taken. Caller must not use it any longer.
void WeightModel::setTempWS(int row, weightsystem_t ws)
{
if (!d || row < 0 || row >= d->weightsystems.nr) // Sanity check: row must exist
if (!d || row < 0 || row >= d->weightsystems.nr) { // Sanity check: row must exist
free_weightsystem(ws);
return;
}
clearTempWS(); // Shouldn't be necessary, just in case: Reset old temporary row.