Commit graph

19 commits

Author SHA1 Message Date
Berthold Stoeger
eb55ffde16 cleanup: split uiLanguage() in two functions
The uiLanguage() function was used for two purposes: to initialize
the language related preferences and to read the current language.
To make things more easy to follow, split this function in two:
one for initializing, one for getting the current language.

Moreover, don't return the current locale in an out-parameter
as there is already a function to do that [getLocale()].

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2020-03-22 12:01:09 -07:00
Berthold Stoeger
5da09a21bb Cleanup: move error reporting function declarations to errorhelper.h
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-08-08 16:26:30 -07:00
Berthold Stoeger
58f2e5f77c Undo: use QUndoStack::isClean() to determine unsaved changes
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>
2019-04-12 18:19:07 +03:00
Berthold Stoeger
ad57871a2c Geo lookup: don't pass arguments / result via global object
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-11 16:25:02 -07:00
Berthold Stoeger
04ad9c885d Geo lookup: make the reply a managed-pointer
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-11 16:25:02 -07:00
Berthold Stoeger
cb2f09a8e3 Geo lookup: make the QNetworkAccessManager a static object
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-11 16:25:02 -07:00
Berthold Stoeger
ce8199cdfd Cleanup: remove ReverseGeoLookupThread
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-10-11 16:25:02 -07:00
Berthold Stoeger
36b9e5e31e Cleanup: fold core/helpers.h into core/qthelper.h
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-06-04 08:50:10 -07:00
Dirk Hohndel
d577467f97 Core: introduce new subsurface-string header
First small step to shrinking dive.h.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2018-05-14 10:13:39 -07:00
Berthold Stoeger
d1572a8d95 Cleanup: introduce copy_qstring() function
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-03-14 13:55:36 +02:00
Jan Mulder
74eb7b21a8 Remove unused urls
They are unused, and a relic from earlier plans.
Just remove.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-06 09:21:16 +01:00
Stefan Fuchs
5b415ad8db Reverse geo lookup string for http://api.geonames.org corrected
Language selection should now work again with string "lang=xx".

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
2017-10-16 03:43:02 -08:00
Dirk Hohndel
b19db6afb5 White space and clarifying braces
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-04 08:05:09 -07:00
Dirk Hohndel
9162dee8a1 Whitespace change
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-04 08:05:09 -07:00
Dirk Hohndel
09b02aae4e Simplify the geo reverse lookup function
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-04 08:05:09 -07:00
Dirk Hohndel
b96633d3e9 fixup taxonomy type
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-10-04 08:05:09 -07:00
Alex Blasche
bf3cc2f64b Make compile with Qt developer builds
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-07-06 12:43:42 +09:00
Dirk Hohndel
b368ecd5aa Add SPDX header to remaining core files
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-04-29 13:32:55 -07:00
Dirk Hohndel
7be962bfc2 Move subsurface-core to core and qt-mobile to mobile-widgets
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>
2016-04-04 22:33:58 -07:00
Renamed from subsurface-core/divesitehelpers.cpp (Browse further)