mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Undo: turn dive- and trip-fields into flags
The divesEdited signal sends the changed field as a parameter. Since some undo-commands change multiple fields, this led to numerous signals for a single command. This in turn would lead to multiple profile-reloads and statistic recalculations. Therefore, turn the enum into a bitfield. For simplicity, provide a constructor that takes classical flags and turns them into the bitfield. This is necessary because C-style named initialization is only supported on C++20 onward! Is this somewhat overengineered? Yes, maybe. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
5c4d163a41
commit
8dea2ada3b
7 changed files with 122 additions and 128 deletions
|
@ -803,25 +803,16 @@ void PasteDives::undo()
|
|||
}
|
||||
|
||||
// Send signals.
|
||||
// TODO: We send one signal per changed field. This means that the dive list may
|
||||
// update the entry numerous times. Perhaps change the field-id into flags?
|
||||
// There seems to be a number of enums / flags describing dive fields. Perhaps unify them all?
|
||||
if (what.notes)
|
||||
emit diveListNotifier.divesChanged(divesToNotify, DiveField::NOTES);
|
||||
if (what.divemaster)
|
||||
emit diveListNotifier.divesChanged(divesToNotify, DiveField::DIVEMASTER);
|
||||
if (what.buddy)
|
||||
emit diveListNotifier.divesChanged(divesToNotify, DiveField::BUDDY);
|
||||
if (what.suit)
|
||||
emit diveListNotifier.divesChanged(divesToNotify, DiveField::SUIT);
|
||||
if (what.rating)
|
||||
emit diveListNotifier.divesChanged(divesToNotify, DiveField::RATING);
|
||||
if (what.visibility)
|
||||
emit diveListNotifier.divesChanged(divesToNotify, DiveField::VISIBILITY);
|
||||
if (what.divesite)
|
||||
emit diveListNotifier.divesChanged(divesToNotify, DiveField::DIVESITE);
|
||||
if (what.tags)
|
||||
emit diveListNotifier.divesChanged(divesToNotify, DiveField::TAGS);
|
||||
DiveField fields(DiveField::NONE);
|
||||
fields.notes = what.notes;
|
||||
fields.divemaster = what.divemaster;
|
||||
fields.buddy = what.buddy;
|
||||
fields.suit = what.suit;
|
||||
fields.rating = what.rating;
|
||||
fields.visibility = what.visibility;
|
||||
fields.divesite = what.divesite;
|
||||
fields.tags = what.tags;
|
||||
emit diveListNotifier.divesChanged(divesToNotify, fields);
|
||||
if (what.cylinders)
|
||||
emit diveListNotifier.cylindersReset(divesToNotify);
|
||||
if (what.weights)
|
||||
|
@ -888,14 +879,8 @@ void ReplanDive::undo()
|
|||
fixup_dive(d);
|
||||
|
||||
QVector<dive *> divesToNotify = { d };
|
||||
// TODO: Turn field into flags to avoid multiple signals
|
||||
emit diveListNotifier.divesChanged(divesToNotify, DiveField::DATETIME);
|
||||
emit diveListNotifier.divesChanged(divesToNotify, DiveField::DURATION);
|
||||
emit diveListNotifier.divesChanged(divesToNotify, DiveField::DEPTH);
|
||||
emit diveListNotifier.divesChanged(divesToNotify, DiveField::MODE);
|
||||
emit diveListNotifier.divesChanged(divesToNotify, DiveField::NOTES);
|
||||
emit diveListNotifier.divesChanged(divesToNotify, DiveField::SALINITY);
|
||||
emit diveListNotifier.divesChanged(divesToNotify, DiveField::ATM_PRESS);
|
||||
emit diveListNotifier.divesChanged(divesToNotify, DiveField::DATETIME | DiveField::DURATION | DiveField::DEPTH | DiveField::MODE |
|
||||
DiveField::NOTES | DiveField::SALINITY | DiveField::ATM_PRESS);
|
||||
emit diveListNotifier.cylindersReset(divesToNotify);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue