mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 06:15:26 +00:00
delegate: don't add WSInfo entry in delegate
The weightsystem info for new weightsystem types is added by the undo command. Remove this redundant code. Use the lookup only to determine the weight and the canonical name (i.e. use the capitalization according to the saved entry, in analogy to tanks). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
fb76eb9a1a
commit
64a5f10cfe
1 changed files with 8 additions and 11 deletions
|
@ -336,19 +336,16 @@ void WSInfoDelegate::setModelData(QWidget*, QAbstractItemModel*, const QModelInd
|
||||||
{
|
{
|
||||||
WeightModel *mymodel = qobject_cast<WeightModel *>(currCombo.model);
|
WeightModel *mymodel = qobject_cast<WeightModel *>(currCombo.model);
|
||||||
WSInfoModel *wsim = WSInfoModel::instance();
|
WSInfoModel *wsim = WSInfoModel::instance();
|
||||||
QModelIndexList matches = wsim->match(wsim->index(0, 0), Qt::DisplayRole, currCombo.activeText, 1, Qt::MatchFixedString | Qt::MatchWrap);
|
QString weightName = currCombo.activeText;
|
||||||
int row;
|
QModelIndexList matches = wsim->match(wsim->index(0, 0), Qt::DisplayRole, weightName, 1, Qt::MatchFixedString | Qt::MatchWrap);
|
||||||
if (matches.isEmpty()) {
|
int grams = 0;
|
||||||
// we need to add this puppy
|
if (!matches.isEmpty()) {
|
||||||
wsim->insertRows(wsim->rowCount(), 1);
|
int row = matches.first().row();
|
||||||
wsim->setData(wsim->index(wsim->rowCount() - 1, 0), currCombo.activeText);
|
weightName = matches.first().data().toString();
|
||||||
row = wsim->rowCount() - 1;
|
grams = wsim->data(wsim->index(row, WSInfoModel::GR)).toInt();
|
||||||
} else {
|
|
||||||
row = matches.first().row();
|
|
||||||
}
|
}
|
||||||
int grams = wsim->data(wsim->index(row, WSInfoModel::GR)).toInt();
|
|
||||||
|
|
||||||
mymodel->setTempWS(currCombo.currRow, weightsystem_t{ { grams }, copy_qstring(currCombo.activeText) });
|
mymodel->setTempWS(currCombo.currRow, weightsystem_t{ { grams }, copy_qstring(weightName) });
|
||||||
}
|
}
|
||||||
|
|
||||||
WSInfoDelegate::WSInfoDelegate(QObject *parent) : ComboBoxDelegate(WSInfoModel::instance(), parent, true)
|
WSInfoDelegate::WSInfoDelegate(QObject *parent) : ComboBoxDelegate(WSInfoModel::instance(), parent, true)
|
||||||
|
|
Loading…
Add table
Reference in a new issue