From 3358bff4322714b59c6f54e67a0db980f215a29d Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Wed, 21 Oct 2020 23:34:15 +0200 Subject: cleanup: move mark_divelist_changed() to qmlmanager.cpp Desktop does not use mark_divelist_changed() anymore - all is done via the undo machinery. Therefore move this function (and its counterpart unsaved_changes()) to qmlmanager.cpp. Ultimately, it probably should be removed from there as well, but currently I don't dare to touch all the cloud-logic! Signed-off-by: Berthold Stoeger --- core/divelist.c | 18 ------------------ core/divelist.h | 2 -- mobile-widgets/qmlmanager.cpp | 18 ++++++++++++++++++ 3 files changed, 18 insertions(+), 20 deletions(-) diff --git a/core/divelist.c b/core/divelist.c index 2dd4e3e81..3599ec498 100644 --- a/core/divelist.c +++ b/core/divelist.c @@ -17,10 +17,6 @@ #include "table.h" #include "trip.h" -/* This flag is set to true by operations that are not implemented in the - * undo system. It is therefore only cleared on save and load. */ -static bool dive_list_changed = false; - bool autogroup = false; void set_autogroup(bool value) @@ -803,19 +799,6 @@ bool filter_dive(struct dive *d, bool shown) return changed; } -void mark_divelist_changed(bool changed) -{ - if (dive_list_changed == changed) - return; - dive_list_changed = changed; - updateWindowTitle(); -} - -int unsaved_changes() -{ - return dive_list_changed; -} - void process_loaded_dives() { int i; @@ -1058,7 +1041,6 @@ void add_imported_dives(struct dive_table *import_table, struct trip_table *impo /* We might have deleted the old selected dive. * Choose the newest dive as selected (if any) */ current_dive = dive_table.nr > 0 ? dive_table.dives[dive_table.nr - 1] : NULL; - mark_divelist_changed(true); free_device_table(devices_to_add); diff --git a/core/divelist.h b/core/divelist.h index 1042c88cc..7a7687293 100644 --- a/core/divelist.h +++ b/core/divelist.h @@ -26,8 +26,6 @@ extern struct dive_table dive_table; #define DATAFORMAT_VERSION 3 extern void update_cylinder_related_info(struct dive *); -extern void mark_divelist_changed(bool); -extern int unsaved_changes(void); extern int init_decompression(struct deco_state *ds, struct dive *dive); /* divelist core logic functions */ diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index 8f28ab912..81c6c7420 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -93,6 +93,23 @@ static void appendTextToLogStandalone(const char *text) self->appendTextToLog(QString(text)); } +// This flag is set to true by operations that are not implemented in the +// undo system. It is therefore only cleared on save and load. +static bool dive_list_changed = false; + +void mark_divelist_changed(bool changed) +{ + if (dive_list_changed == changed) + return; + dive_list_changed = changed; + updateWindowTitle(); +} + +int unsaved_changes() +{ + return dive_list_changed; +} + // this callback is used from the uiNotification() function // the detour via callback allows us to keep the core code independent from QMLManager // I'm not sure it makes sense to have three different progress callbacks, @@ -455,6 +472,7 @@ void QMLManager::mergeLocalRepo() struct filter_preset_table filter_presets; parse_file(qPrintable(nocloud_localstorage()), &table, &trips, &sites, &devices, &filter_presets); add_imported_dives(&table, &trips, &sites, &devices, IMPORT_MERGE_ALL_TRIPS); + mark_divelist_changed(true); } void QMLManager::copyAppLogToClipboard() -- cgit v1.2.3-70-g09d2