Equipment: Include Unused Tanks in Merge if Preference is Enabled.

Include unused tanks in merges of multiple logs into a single dive if
the 'Show unused cylinders' preference is enabled.
Also rename the preference (in code) to `include_unused_tanks` to
reflect the fact that it is already used in more places than just the
display (exporting, cloning dives).
Simplified the cylinder model to make forced inclusion of unused tanks
dependent on use of the model in planner.
Leaving the persisted name of the preference as `display_unused_tanks`
to avoid resetting this for all users - is there a good way to migrate
preference names?

Signed-off-by: Michael Keller <github@ike.ch>
This commit is contained in:
Michael Keller 2023-07-09 12:14:27 +12:00
parent cb6f768865
commit 5fae7ce7a0
17 changed files with 50 additions and 47 deletions

View file

@ -13,10 +13,9 @@
#include "core/subsurface-string.h"
#include <string>
CylindersModel::CylindersModel(bool planner, bool hideUnused, QObject *parent) : CleanerTableModel(parent),
CylindersModel::CylindersModel(bool planner, QObject *parent) : CleanerTableModel(parent),
d(nullptr),
inPlanner(planner),
hideUnused(hideUnused),
numRows(0),
tempRow(-1),
tempCyl(empty_cylinder)
@ -134,13 +133,14 @@ static QVariant percent_string(fraction_t fraction)
return QString("%L1%").arg(permille / 10.0, 0, 'f', 1);
}
// Calculate the number of displayed cylinders: If hideUnused
// is set, we don't show unused cylinders at the end of the list.
// Calculate the number of displayed cylinders: If we are in planner
// or prefs.include_unused_tanks is set we show unused cylinders
// at the end of the list.
int CylindersModel::calcNumRows() const
{
if (!d)
return 0;
if (!hideUnused || prefs.display_unused_tanks)
if (inPlanner || prefs.include_unused_tanks)
return d->cylinders.nr;
return first_hidden_cylinder(d);
}