mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: pass dive to DiveHandler
The DiveHandler shows a context menu where a cylinder can be chosen. This indirectly accesses the global displayed_dive variable. Remove this in a step to make the profile reentrant. The code was quite ominous: instead of simply generating the list of cylinders, a global model was reset and then accessed with Qt's cumbersome model/view API. All this trampling over global state can be removed by simply making the function that generates the list globally accessible. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
88c6ce988d
commit
235146a95f
6 changed files with 30 additions and 27 deletions
|
@ -1274,6 +1274,23 @@ QString get_gas_string(struct gasmix gas)
|
|||
return result;
|
||||
}
|
||||
|
||||
QStringList get_dive_gas_list(const struct dive *d)
|
||||
{
|
||||
QStringList list;
|
||||
for (int i = 0; i < d->cylinders.nr; i++) {
|
||||
const cylinder_t *cyl = get_cylinder(d, i);
|
||||
/* Check if we have the same gasmix two or more times
|
||||
* If yes return more verbose string */
|
||||
int same_gas = same_gasmix_cylinder(cyl, i, d, true);
|
||||
if (same_gas == -1)
|
||||
list.push_back(get_gas_string(cyl->gasmix));
|
||||
else
|
||||
list.push_back(get_gas_string(cyl->gasmix) + QString(" (%1 %2 ").arg(gettextFromC::tr("cyl.")).arg(i + 1) +
|
||||
cyl->type.description + ")");
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
QString get_taglist_string(struct tag_entry *tag_list)
|
||||
{
|
||||
char *buffer = taglist_get_tagstring(tag_list);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue