summaryrefslogtreecommitdiffstats
path: root/core/divesitehelpers.cpp
AgeCommit message (Collapse)Author
2019-08-08Cleanup: move error reporting function declarations to errorhelper.hGravatar Berthold Stoeger
Move the declarations of the "report_error()" and "set_error_cb()" functions and the "verbose" variable to errorhelper.h. Thus, error-reporting translation units don't have to import the big dive.h header file. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: use QUndoStack::isClean() to determine unsaved changesGravatar Berthold Stoeger
Properly implement the unsaved-changes flag(s). Since we currently have two kinds of changes, there are two flags: 1) dive_list_changed in divelist.c marks non-undoable changes. This flag is only cleared on save or load. 2) QUndoStack::isClean() is used to determine the state of undoable changes. Every time the user returns to the state where they saved, this flag is cleared. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11Geo lookup: don't pass arguments / result via global objectGravatar Berthold Stoeger
The reverseGeoLookup() fetches dive-site data via GPS coordinates. The coordinates and the result were passed via the global "displayed_dive_site" object. To make data-flow more clear, pass data as in and out parameters instead. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11Geo lookup: make the reply a managed-pointerGravatar Berthold Stoeger
By making reply a std::unique_ptr<>, the function can be quit from any point and the reply will be freed. This is valid according to Qt's documentation as we're not deleting during signal processing. This commit fixes a leak: reply was overwritten with the address of a new object without freeing the old object. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11Geo lookup: make the QNetworkAccessManager a static objectGravatar Berthold Stoeger
According to Qt's docs, the QNetworkAccessManager is supposed to be a long-living object. Therefore, don't create one on every geo-lookup, but a single object for all geo-lookups. By making the object function-local it is only initiaized on first use. Morover this limits the amount of concurrent geo lookups. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11Cleanup: remove ReverseGeoLookupThreadGravatar Berthold Stoeger
Fetching the taxonomy from GPS coordinates was implemented in a QThread. But the only access to the main function was a direct call to run(). Thus, the thread was *never* started. The function call was always asynchronous [it was using an event loop though, so the UI doesn't hang]. Notably this means that the signals connected to the thread would never fire. And the spinner would never be activated. Thus: 1) Turn the thread into a simple function. 2) Remove the spinner. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-04Cleanup: fold core/helpers.h into core/qthelper.hGravatar Berthold Stoeger
helpers.h included qthelper.h and all functions declared in helpers.h were defined in qthelper.h. Therefore fold the former into the latter, since the split seems completely arbitrary. While doing so, change the return-type of get_dc_nichname from "const QString" to "QString". Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-14Core: introduce new subsurface-string headerGravatar Dirk Hohndel
First small step to shrinking dive.h. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-03-14Cleanup: introduce copy_qstring() functionGravatar Berthold Stoeger
strdup(qPrintable(s)) and copy_string(qPrintable(s)) were such common occurrences that they seem worthy of a short helper-function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-01-06Remove unused urlsGravatar Jan Mulder
They are unused, and a relic from earlier plans. Just remove. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-10-16Reverse geo lookup string for http://api.geonames.org correctedGravatar Stefan Fuchs
Language selection should now work again with string "lang=xx". Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-04White space and clarifying bracesGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-04Whitespace changeGravatar Dirk Hohndel
This is just the indentation change for the code that was inside the loop before. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-04Simplify the geo reverse lookup functionGravatar Dirk Hohndel
We never actually create a list of dive sites for which we call the reverse lookup service, it's always just displayed_dive_site. So make this all much simpler and just go straight for that. This commit removes a loop, but doesn't change the indentation of the code inside the loop to make it easier to see what was changed. That whitespace change will be in my next commit. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-04fixup taxonomy typeGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-06Make compile with Qt developer buildsGravatar Alex Blasche
subsurface/core/divesitehelpers.cpp: In member function 'virtual void ReverseGeoLookupThread::run()': subsurface/core/divesitehelpers.cpp:128:12: error: invalid use of incomplete type 'class QDebug' qDebug() << "no reverse geo lookup; geonames returned\n" << fullReply; ^ Signed-off-by: Alex Blasche <alexander.blasche@qt.io>
2017-04-29Add SPDX header to remaining core filesGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04Move subsurface-core to core and qt-mobile to mobile-widgetsGravatar Dirk Hohndel
Having subsurface-core as a directory name really messes with autocomplete and is obviously redundant. Simmilarly, qt-mobile caused an autocomplete conflict and also was inconsistent with the desktop-widget name for the directory containing the "other" UI. And while cleaning up the resulting change in the path name for include files, I decided to clean up those even more to make them consistent overall. This could have been handled in more commits, but since this requires a make clean before the build, it seemed more sensible to do it all in one. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>