mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Complete the name of the first Cylinder on edit
When you entered part of the name of a cylinder this was being treated as a new cylinder, and not selecting the first one. Fixes #628 Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
1b6144350d
commit
b66f679d64
1 changed files with 3 additions and 2 deletions
|
@ -222,18 +222,19 @@ void TankInfoDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
|
||||||
TankInfoModel *tanks = TankInfoModel::instance();
|
TankInfoModel *tanks = TankInfoModel::instance();
|
||||||
QModelIndexList matches = tanks->match(tanks->index(0, 0), Qt::DisplayRole, currCombo.activeText);
|
QModelIndexList matches = tanks->match(tanks->index(0, 0), Qt::DisplayRole, currCombo.activeText);
|
||||||
int row;
|
int row;
|
||||||
|
QString cylinderName = currCombo.activeText;
|
||||||
if (matches.isEmpty()) {
|
if (matches.isEmpty()) {
|
||||||
// we need to add this
|
|
||||||
tanks->insertRows(tanks->rowCount(), 1);
|
tanks->insertRows(tanks->rowCount(), 1);
|
||||||
tanks->setData(tanks->index(tanks->rowCount() - 1, 0), currCombo.activeText);
|
tanks->setData(tanks->index(tanks->rowCount() - 1, 0), currCombo.activeText);
|
||||||
row = tanks->rowCount() - 1;
|
row = tanks->rowCount() - 1;
|
||||||
} else {
|
} else {
|
||||||
row = matches.first().row();
|
row = matches.first().row();
|
||||||
|
cylinderName = matches.first().data().toString();
|
||||||
}
|
}
|
||||||
int tankSize = tanks->data(tanks->index(row, TankInfoModel::ML)).toInt();
|
int tankSize = tanks->data(tanks->index(row, TankInfoModel::ML)).toInt();
|
||||||
int tankPressure = tanks->data(tanks->index(row, TankInfoModel::BAR)).toInt();
|
int tankPressure = tanks->data(tanks->index(row, TankInfoModel::BAR)).toInt();
|
||||||
|
|
||||||
mymodel->setData(IDX(CylindersModel::TYPE), currCombo.activeText, Qt::EditRole);
|
mymodel->setData(IDX(CylindersModel::TYPE), cylinderName, Qt::EditRole);
|
||||||
mymodel->passInData(IDX(CylindersModel::WORKINGPRESS), tankPressure);
|
mymodel->passInData(IDX(CylindersModel::WORKINGPRESS), tankPressure);
|
||||||
mymodel->passInData(IDX(CylindersModel::SIZE), tankSize);
|
mymodel->passInData(IDX(CylindersModel::SIZE), tankSize);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue