summaryrefslogtreecommitdiffstats
path: root/mobile-widgets
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-06-17 22:45:33 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-09-29 16:13:03 -0700
commit41cf83583d129edde607654592a52fe7bff57dc7 (patch)
tree7127476f88358f2248b22684c01f127997380d43 /mobile-widgets
parentcef15c978d466af37a0f453c50f2e8942ed7cdc2 (diff)
downloadsubsurface-41cf83583d129edde607654592a52fe7bff57dc7.tar.gz
filter: load filter presets from XML files
This is a bit painful: since we don't want to modify the filter presets when the user imports (as opposed to opens) a log, we have to provide a table where the parser stores the presets. Calling the parser is getting quite unwieldy, since many tables are passed. We probably should introduce a structure representing a full log-book at one point, which collects all the things that are saved to the log. Apart from that, this is simply the counterpart to saving to XML. The interpretation of the string data is performed by core functions, not the parser itself to avoid code duplication with the git parser. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'mobile-widgets')
-rw-r--r--mobile-widgets/qmlmanager.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp
index 19057fef9..86e5052e1 100644
--- a/mobile-widgets/qmlmanager.cpp
+++ b/mobile-widgets/qmlmanager.cpp
@@ -353,7 +353,7 @@ void QMLManager::openLocalThenRemote(QString url)
* we try to open this), parse_file (which is called by openAndMaybeSync) will ALWAYS connect
* to the remote and populate the cache.
* Otherwise parse_file will respect the git_local_only flag and only update if that isn't set */
- int error = parse_file(encodedFilename.constData(), &dive_table, &trip_table, &dive_site_table);
+ int error = parse_file(encodedFilename.constData(), &dive_table, &trip_table, &dive_site_table, &filter_preset_table);
if (error) {
/* there can be 2 reasons for this:
* 1) we have cloud credentials, but there is no local repo (yet).
@@ -451,7 +451,8 @@ void QMLManager::mergeLocalRepo()
struct dive_table table = empty_dive_table;
struct trip_table trips = empty_trip_table;
struct dive_site_table sites = empty_dive_site_table;
- parse_file(qPrintable(nocloud_localstorage()), &table, &trips, &sites);
+ filter_preset_table_t filter_presets;
+ parse_file(qPrintable(nocloud_localstorage()), &table, &trips, &sites, &filter_presets);
add_imported_dives(&table, &trips, &sites, IMPORT_MERGE_ALL_TRIPS);
}
@@ -525,7 +526,7 @@ void QMLManager::finishSetup()
qPrefCloudStorage::set_cloud_verification_status(qPrefCloudStorage::CS_NOCLOUD);
saveCloudCredentials(qPrefCloudStorage::cloud_storage_email(), qPrefCloudStorage::cloud_storage_password(), qPrefCloudStorage::cloud_storage_pin());
appendTextToLog(tr("working in no-cloud mode"));
- int error = parse_file(existing_filename, &dive_table, &trip_table, &dive_site_table);
+ int error = parse_file(existing_filename, &dive_table, &trip_table, &dive_site_table, &filter_preset_table);
if (error) {
// we got an error loading the local file
setNotificationText(tr("Error parsing local storage, giving up"));
@@ -709,7 +710,7 @@ void QMLManager::loadDivesWithValidCredentials()
error = git_load_dives(git, branch, &dive_table, &trip_table, &dive_site_table);
} else {
appendTextToLog(QString("didn't receive valid git repo, try again"));
- error = parse_file(fileNamePrt.data(), &dive_table, &trip_table, &dive_site_table);
+ error = parse_file(fileNamePrt.data(), &dive_table, &trip_table, &dive_site_table, &filter_preset_table);
}
setDiveListProcessing(false);
if (!error) {
@@ -2235,9 +2236,10 @@ void QMLManager::importCacheRepo(QString repo)
struct dive_table table = empty_dive_table;
struct trip_table trips = empty_trip_table;
struct dive_site_table sites = empty_dive_site_table;
+ filter_preset_table_t filter_presets;
QString repoPath = QString("%1/cloudstorage/%2").arg(system_default_directory()).arg(repo);
appendTextToLog(QString("importing %1").arg(repoPath));
- parse_file(qPrintable(repoPath), &table, &trips, &sites);
+ parse_file(qPrintable(repoPath), &table, &trips, &sites, &filter_presets);
add_imported_dives(&table, &trips, &sites, IMPORT_MERGE_ALL_TRIPS);
changesNeedSaving();
}