mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
de313bd01a
commit
0d011231e6
16 changed files with 130 additions and 215 deletions
|
@ -1,6 +1,5 @@
|
|||
// SPDX-License-Identifier: GPL-2.0
|
||||
#include "cylindermodel.h"
|
||||
#include "tankinfomodel.h"
|
||||
#include "models.h"
|
||||
#include "commands/command.h"
|
||||
#include "core/qthelper.h"
|
||||
|
@ -381,23 +380,12 @@ bool CylindersModel::setData(const QModelIndex &index, const QVariant &value, in
|
|||
cyl.type.description = newType.c_str();
|
||||
type = Command::EditCylinderType::TYPE;
|
||||
break;
|
||||
case SIZE: {
|
||||
TankInfoModel *tanks = TankInfoModel::instance();
|
||||
QModelIndexList matches = tanks->match(tanks->index(0, 0), Qt::DisplayRole, cyl.type.description);
|
||||
|
||||
cyl.type.size = string_to_volume(qPrintable(vString), cyl.type.workingpressure);
|
||||
if (!matches.isEmpty())
|
||||
tanks->setData(tanks->index(matches.first().row(), TankInfoModel::ML), cyl.type.size.mliter);
|
||||
}
|
||||
case SIZE:
|
||||
cyl.type.size = string_to_volume(qPrintable(vString), cyl.type.workingpressure);
|
||||
type = Command::EditCylinderType::TYPE;
|
||||
break;
|
||||
case WORKINGPRESS: {
|
||||
TankInfoModel *tanks = TankInfoModel::instance();
|
||||
QModelIndexList matches = tanks->match(tanks->index(0, 0), Qt::DisplayRole, cyl.type.description);
|
||||
cyl.type.workingpressure = string_to_pressure(qPrintable(vString));
|
||||
if (!matches.isEmpty())
|
||||
tanks->setData(tanks->index(matches.first().row(), TankInfoModel::BAR), cyl.type.workingpressure.mbar / 1000.0);
|
||||
}
|
||||
case WORKINGPRESS:
|
||||
cyl.type.workingpressure = string_to_pressure(qPrintable(vString));
|
||||
type = Command::EditCylinderType::TYPE;
|
||||
break;
|
||||
case START:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue