mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Create a 'remove_event' function that removes an event.
The logic of removing the event was in the UI, and this makes the code harder to test because we need to take into account also the events that the interface is receiving, instead of only relying on the algorithm to test. so, now it lives in dive.h/.c and a unittest is easyer to make. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
3750d55665
commit
ef4705070f
3 changed files with 13 additions and 7 deletions
|
@ -830,13 +830,7 @@ void ProfileWidget2::removeEvent()
|
|||
tr("Remove the selected event?"),
|
||||
tr("%1 @ %2:%3").arg(event->name).arg(event->time.seconds / 60).arg(event->time.seconds % 60, 2, 10, QChar('0'))),
|
||||
QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) {
|
||||
struct event **ep = ¤t_dc->events;
|
||||
while (ep && *ep != event)
|
||||
ep = &(*ep)->next;
|
||||
if (ep) {
|
||||
*ep = event->next;
|
||||
free(event);
|
||||
}
|
||||
remove_event(event);
|
||||
mark_divelist_changed(true);
|
||||
replot();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue