mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: move freestanding functions into divelog class
There were only two of them, from the time C-code had to access the divelog: clear_divelog() and delete_single_dive(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
90d5bab4e9
commit
6e352d5281
9 changed files with 16 additions and 22 deletions
|
|
@ -976,7 +976,7 @@ void add_imported_dives(struct divelog *import_log, int flags)
|
|||
/* Remove old dives */
|
||||
for (i = 0; i < dives_to_remove.nr; i++) {
|
||||
idx = get_divenr(dives_to_remove.dives[i]);
|
||||
delete_single_dive(&divelog, idx);
|
||||
divelog.delete_single_dive(idx);
|
||||
}
|
||||
dives_to_remove.nr = 0;
|
||||
|
||||
|
|
@ -1272,7 +1272,7 @@ void clear_dive_file_data()
|
|||
select_single_dive(NULL); // This is propagated up to the UI and clears all the information.
|
||||
|
||||
current_dive = NULL;
|
||||
clear_divelog(&divelog);
|
||||
divelog.clear();
|
||||
|
||||
clear_event_types();
|
||||
|
||||
|
|
|
|||
|
|
@ -62,22 +62,22 @@ struct divelog &divelog::operator=(divelog &&log)
|
|||
|
||||
/* this implements the mechanics of removing the dive from the
|
||||
* dive log and the trip, but doesn't deal with updating dive trips, etc */
|
||||
void delete_single_dive(struct divelog *log, int idx)
|
||||
void divelog::delete_single_dive(int idx)
|
||||
{
|
||||
if (idx < 0 || idx > log->dives->nr) {
|
||||
if (idx < 0 || idx > dives->nr) {
|
||||
report_info("Warning: deleting unexisting dive with index %d", idx);
|
||||
return;
|
||||
}
|
||||
struct dive *dive = log->dives->dives[idx];
|
||||
remove_dive_from_trip(dive, log->trips);
|
||||
struct dive *dive = dives->dives[idx];
|
||||
remove_dive_from_trip(dive, trips);
|
||||
unregister_dive_from_dive_site(dive);
|
||||
delete_dive_from_table(log->dives, idx);
|
||||
delete_dive_from_table(dives, idx);
|
||||
}
|
||||
|
||||
void divelog::clear()
|
||||
{
|
||||
while (dives->nr > 0)
|
||||
delete_single_dive(this, dives->nr - 1);
|
||||
delete_single_dive(dives->nr - 1);
|
||||
sites->clear();
|
||||
if (trips->nr != 0) {
|
||||
report_info("Warning: trip table not empty in divelog::clear()!");
|
||||
|
|
@ -86,8 +86,3 @@ void divelog::clear()
|
|||
clear_device_table(devices);
|
||||
filter_presets->clear();
|
||||
}
|
||||
|
||||
void clear_divelog(struct divelog *log)
|
||||
{
|
||||
log->clear();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,16 +18,15 @@ struct divelog {
|
|||
struct device_table *devices;
|
||||
struct filter_preset_table *filter_presets;
|
||||
bool autogroup;
|
||||
void clear();
|
||||
divelog();
|
||||
~divelog();
|
||||
divelog(divelog &&log); // move constructor (argument is consumed).
|
||||
divelog &operator=(divelog &&log); // move assignment (argument is consumed).
|
||||
void delete_single_dive(int idx);
|
||||
void clear();
|
||||
};
|
||||
|
||||
extern struct divelog divelog;
|
||||
|
||||
void clear_divelog(struct divelog *);
|
||||
extern void delete_single_dive(struct divelog *, int idx);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ void DownloadThread::run()
|
|||
|
||||
report_info("Starting download from %s", qPrintable(getTransportString(transports)));
|
||||
report_info("downloading %s dives", internalData->force_download ? "all" : "only new");
|
||||
clear_divelog(&log);
|
||||
log.clear();
|
||||
|
||||
Q_ASSERT(internalData->log != nullptr);
|
||||
std::string errorText;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue