mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
cylinders: add cylinder before hidden cylinders
When adding a cylinder, it was added at the end of the list. This would make hidden cylinders visible as the new rule is to only hide unused cylinders at the end of the list. Therefore, add the cylinder after the last used cylinder, i.e. before the first hidden cylinder. This means that the position where the cylinder is added has to be hidden in the undo command. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
a40b40ae7a
commit
1af67512a1
5 changed files with 42 additions and 34 deletions
|
@ -131,27 +131,6 @@ static QVariant percent_string(fraction_t fraction)
|
|||
return QString("%L1%").arg(permille / 10.0, 0, 'f', 1);
|
||||
}
|
||||
|
||||
bool CylindersModel::cylinderUsed(int i) const
|
||||
{
|
||||
if (i < 0 || i >= d->cylinders.nr)
|
||||
return false;
|
||||
if (is_cylinder_used(d, i))
|
||||
return true;
|
||||
|
||||
cylinder_t *cyl = get_cylinder(d, i);
|
||||
if (cyl->start.mbar || cyl->sample_start.mbar ||
|
||||
cyl->end.mbar || cyl->sample_end.mbar)
|
||||
return true;
|
||||
if (cyl->manually_added)
|
||||
return true;
|
||||
|
||||
/*
|
||||
* The cylinder has some data, but none of it is very interesting,
|
||||
* it has no pressures and no gas switches. Do we want to show it?
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
// Calculate the number of displayed cylinders: If hideUnused
|
||||
// is set, we don't show unused cylinders at the end of the list.
|
||||
int CylindersModel::calcNumRows() const
|
||||
|
@ -160,10 +139,7 @@ int CylindersModel::calcNumRows() const
|
|||
return 0;
|
||||
if (!hideUnused || prefs.display_unused_tanks)
|
||||
return d->cylinders.nr;
|
||||
int res = d->cylinders.nr;
|
||||
while (res > 0 && !cylinderUsed(res - 1))
|
||||
--res;
|
||||
return res;
|
||||
return first_hidden_cylinder(d);
|
||||
}
|
||||
|
||||
QVariant CylindersModel::data(const QModelIndex &index, int role) const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue