mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
selection: pass down selection to tab widgets
On selection change, pass down selection (including current dive and dc) to the tab widgets. Ultimately, this should remove access to global variables. A number of new accesses are marked as TODO. They shall be removed in due course. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
908da77863
commit
cded7ef5fe
16 changed files with 62 additions and 55 deletions
|
@ -59,7 +59,7 @@ void TabDiveStatistics::divesChanged(const QVector<dive *> &dives, DiveField fie
|
|||
|
||||
// TODO: make this more fine grained. Currently, the core can only calculate *all* statistics.
|
||||
if (field.duration || field.depth || field.mode || field.air_temp || field.water_temp)
|
||||
updateData();
|
||||
updateData(getDiveSelection(), current_dive, dc_number); // TODO: remember these data
|
||||
}
|
||||
|
||||
void TabDiveStatistics::cylinderChanged(dive *d)
|
||||
|
@ -67,10 +67,10 @@ void TabDiveStatistics::cylinderChanged(dive *d)
|
|||
// If the changed dive is not selected, do nothing
|
||||
if (!d->selected)
|
||||
return;
|
||||
updateData();
|
||||
updateData(getDiveSelection(), current_dive, dc_number); // TODO: remember these data
|
||||
}
|
||||
|
||||
void TabDiveStatistics::updateData()
|
||||
void TabDiveStatistics::updateData(const std::vector<dive *> &, dive *currentDive, int)
|
||||
{
|
||||
stats_t stats_selection;
|
||||
calculate_stats_selected(&stats_selection);
|
||||
|
@ -109,7 +109,7 @@ void TabDiveStatistics::updateData()
|
|||
}
|
||||
|
||||
|
||||
bool is_freedive = current_dive && current_dive->dc.divemode == FREEDIVE;
|
||||
bool is_freedive = currentDive && currentDive->dc.divemode == FREEDIVE;
|
||||
ui->divesAllText->setText(QString::number(stats_selection.selection_size));
|
||||
ui->totalTimeAllText->setText(get_dive_duration_string(stats_selection.total_time.seconds, tr("h"), tr("min"), tr("sec"), " ", is_freedive));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue