Commit graph

56 commits

Author SHA1 Message Date
Berthold Stoeger
ab29f6416b Dive site: replace UUID_ROLE by DIVESITE_ROLE
Access to dive-sites in the LocationInformationModel was via UUID.
Replace this by a direct access to the struct dive_site pointer.
Accordingly, rename the UUID_ROLE to DIVESITE_ROLE.

This is a small step in replacing dive-site UUIDs by pointers
throughout the code base.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-29 00:09:31 +00:00
Berthold Stoeger
f527a70831 Dive site: pass dive-site pointer to delete_dive_site()
Instead of passing a uuid, pass a pointer to the dive site.
This is small step in an effort to remove uuids.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-29 00:09:31 +00:00
Linus Torvalds
28e3413ff6 Add 'location_t' data structure
Instead of having people treat latitude and longitude as separate
things, just add a 'location_t' data structure that contains both.

Almost all cases want to always act on them together.

This is really just prep-work for adding a few more locations that we
track: I want to add a entry/exit location to each dive (independent of
the dive site) because of how the Garmin Descent gives us the
information (and hopefully, some day, other dive computers too).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2018-10-21 19:55:09 +03:00
Berthold Stoeger
f39596df06 Map: remove access to displayed_dive_site in GPS-filter model
The location information shows a list of dive sites at the
same location as the edited dive site. This was done by passing
a function to an "SsrfSortFilterProxyModel". Unfortunately,
the latter does only support function pointers without state
and therefore had to access the global "displayed_dive_site"
object.

Replace the SsrfSortFilterProxyModel by a proper subclass of
QSortFilterProxyModel that contains information on the position
and id of the currently edited dive site.

Update the filter model if the location of the dive site changes.
This introduces a behavioral change: editing the GPS location
will lead to an updated list.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-11 16:25:32 -07:00
Berthold Stoeger
d6010b5155 Dive locations: factor out common code of models
For increased maintainability, use the same columns, roles and
the same accessor function for both dive-site models.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-09 21:00:44 -07:00
Berthold Stoeger
19d651a36b Dive sites: remove internalRowCount from LocationInformationModel
This was redundant. Directly use dive_site_table.nr instead.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-09 21:00:44 -07:00
Berthold Stoeger
50e42bffa1 Dive sites: don't add dummy entries to LocationInformationModel
The LocationInformationModel added two dummy sites to the front
of the list (add new dive site). This was never used - desktop
uses its own model, mobile only extracts the list of dive site
names with a custom function. Remove this functionality.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-09 21:00:44 -07:00
Berthold Stoeger
65ca3444f5 Dive sites: remove LocationInformationModel::setData() function
Editing of dive sites does not work via this model and the function
was broken anyway (it didn't subtract 2 from the index).

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-10-09 21:00:44 -07:00
Berthold Stoeger
879cb73b8b Localization: remove gettextFromC::instance()
There were a handfull instances of the kind
1) gettextFromC::instance()->tr(...)
2) gettextFromC::instance()->trGettext(...)

1) is pointless, as tr is a static function.

All instances of 2) were likewise pointless, because trGettext()
returns a C-string, which was then immediately converted to a
QString.

Thus, replace both constructs by gettextFromC::tr(...).

After this change there was only one user of gettextFromC::instance()
left, viz. the C-interface funtion trGettext(). Therefore, remove
gettextFromC::instance() and do all the caching / translating
directly in the global trGettext().

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-06-24 20:31:14 +02:00
jan Iversen
b0e48a5e8f qt-models: Change Q_UNUSED to no parameter name
C++ permits use of parameters without name, which signals unused

Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-21 12:48:04 -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
Berthold Stoeger
5c248d91cd Coding-style: remove superfluous parentheses
Mostly replace "return (expression);" by "return expression;" and one
case of "function((parameter))" by "function(parameter)".

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-17 19:38:52 -08:00
Jan Mulder
494ad26540 mobile cleanup: restyle construction of locationlist
See also e6e1473e6. The construction of the locationlist
was not the same as the 3 previous lists, and it needs
the inclusion of a new model file (divelocationmodel.cpp)
in the mobile app. In addition, as the mobile app is mainly
interested in a simple stringList (model) to populate a HintsText
field (or maybe later a combobox), this stringlist is added
to the model, to easy interfacing with QML.

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2018-01-31 14:48:14 +01:00
Martin Měřinský
8ef87e618a Use better aliases for icons.
Icon aliases were complete mess.
Some icons had alias some didn't.
Named with underscores vs. hyphens vs. camelCase.
Lower vs. upper case.
"ICON" prefix vs. suffix vs. nothing.
With vs. without filename suffix.
Some didn't make sence. Eg. mapwidget-marker-gray
(I can see, it's grey, but what does it represent?)
Some were duplicated, eg warning vs. warning-icon.
Some were name after widget, which is wrong.

Do not reinvent wheel. Use widely used naming scheme
close to Freedesktop Icon Naming Specification. This
will enable usage of common icons from current set in
the future. Thus Subsurface will fit nicely to GUI.

This changes icon aliases to one, easy grep-able style.

Signed-off-by: Martin Měřinský <mermar@centrum.cz>
2017-11-30 23:14:46 -08:00
Dirk Hohndel
2747056889 Revert "Use consistent aliases for all icons."
This reverts commit 92e9c6606f.
2017-11-29 14:05:07 -08:00
Martin Měřinský
92e9c6606f Use consistent aliases for all icons.
Icon aliases were inconsistent mess. Underscores vs. hyphens vs. camelCase.
With vs. without filename suffix. Lower vs. upper case. "icon" suffix vs.
prefix vs. nothing. Some were duplicated, eg warning vs. warning-icon. Some
icons didn't have alias at all.

This changes all icon aliases to one, easy grep-able style which complies
to Freedesktop Icon Naming Specification (Guidelines).

Signed-off-by: Martin Měřinský <mermar@centrum.cz>
2017-11-29 11:46:35 +01:00
Berthold Stoeger
bf65f1e507 Fix comparison function in qt-models/divelocationmodel.cpp
The function dive_site_less_than() in qt-models/divelocationmodel.cpp
does not what it promises: it uses less-or-equal instead of less-than
comparison.

Note that, even though this may sound pedantic, this is an actual bug.
Usually, sorting functions suppose that they are provided with
strict weak ordering, which <= does *not* provide.

This is the actual reason for the crash mentioned in commit
f8a3a85210.

While touching this function, make it of static linkage, since
its usage is local to this translation unit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-26 18:49:05 -08:00
Berthold Stoeger
d1545b27b4 Remove unused method LocationInformationModel::addDiveSite()
The call to this method was removed in commit f4c31f110f

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-11-26 23:37:01 +01:00
Dirk Hohndel
5372f12d8b Add SPDX header to Qt models
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-04-29 13:32:55 -07:00
Jan Mulder
12a59ef313 Correct divesite geocoding translation
See https://github.com/Subsurface-divelog/subsurface/issues/345. The
menues where not translated. The basis of this error is a simple
typo in core/taxonomy.c where the classname was mis-spelled in the
QT_TRANSLATE_NOOP. In addition, to pull and translate the strings
from C code, the normal tr() does not work, and the functionality
from the gettextfromc class is used.

Fixes: #345

Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-04-26 05:34:40 -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
Tomaz Canabrava
b23ff086cf Silence warnings in divelocationmodel.cpp
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-03-08 20:58:21 -08:00
Lubomir I. Ivanov
9b20a5bd4f divelocationmodel: fix some signed/unsigned warnings
Use uint32_t for divesite UUIDs.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-11-07 22:26:32 -08:00
Tomaz Canabrava
d611d97406 Do not show lack of coordinates as having same gps information
The filter that takes care to show the dive sites that have the
same gps information should not take into account dives that have
no gps information.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-10-09 10:50:51 -07:00
Sander Kleijwegt
6427564d33 Hide current dive site from dive sites with same coordinates.
Signed-off-by: Sander Kleijwegt <sander@myowndomain.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-12 08:28:13 -07:00
Sander Kleijwegt
8dafc32228 Remove id from divelocation selection list
Signed-off-by: Sander Kleijwegt <sander@myowndomain.nl>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-12 08:24:51 -07:00
Tomaz Canabrava
e36e4d1faa UI code to merge dive sites
Get the Qt data structures and convert to something
that we can use in our C - core.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-31 18:43:09 -07:00
Tomaz Canabrava
a3d6098c8c Display dive sites with same gps as the current
So we can merge them later - currently we are showing
only the ID, ugly - fixing next.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-31 18:42:15 -07:00
Tomaz Canabrava
71e366a6e4 Add function to filter same-gps dive sites
This should be userfull to show dive sites that are
mergeable.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-31 18:41:32 -07:00
Tomaz Canabrava
fc6d819616 Create a new dive site and edit it automatically
If the user clicks on the first or second option of the drop
down list, subsurface will move him to the dive site edit panel
automatically, since it's a new dive site and there's no information
about it yet.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25 18:00:15 -07:00
Dirk Hohndel
e03b553e80 Make created dive site uuid deterministic
Having random uuids seemed like a good idea, but there are several
situations where they really cause problems. One is merging dive file
imports from V2 logfiles. Another is testing such imports.

Instead of making the uuid random we now hash the name and add the
timestamp of the first dive associated with this dive site to the hash
(first in this context is "first encountered" with no guarantee that it is
the chronologically first). This way V2 imports create deterministic uuids
but uuid conflicts are still extremely unlikely, even if the user has
multiple dive sites with the same name.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-25 10:43:48 -07:00
Dirk Hohndel
2a4cacda21 Better invalid dive site name
This should ensure that no one ever might end up with our "invalid" name
for real. And it allows us to more easily test elsewhere for that invalid
value.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-17 08:39:49 -07:00
Tomaz Canabrava
56240cff5b Show only 1 possibility if string is unique
We should only show one possibility if the dive_site name
string is unique - we don't have that dive_site yet - so
we pass to the Completer filter a Dummy string that will
surelly not be a dive site - konami code.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-16 18:33:57 -07:00
Dirk Hohndel
f98ace681a Dive site edit: add second "create" line without completion
We now have TWO special entries. One with just what the user has typed and
one with the first completion of that text. This way both Henrik and Linus
can get what they want. I'm not sure I love this, but it's easy to revert
if the consensus is that this is too confusing. But it's much easier to
discuss this if people can actually play with it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-16 12:22:56 -07:00
Dirk Hohndel
14016f83ff Better text for fake completion entry
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-15 10:37:09 -07:00
Tomaz Canabrava
cd3f10d5ad Offer an option to just complete the text
Make the kids fight no more.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-14 14:54:01 -07:00
Dirk Hohndel
bc8c54f1ee Rename enum values for taxonomy
This avoids confusion and namespace collisions.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-02 10:22:31 -07:00
Dirk Hohndel
f554c2d16c Merge branch 'taxonomy' 2015-07-02 07:03:03 -07:00
Tomaz Canabrava
db8b140c52 More information on dive site model
All of dive site information is now exposed to the model

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-01 19:21:23 -07:00
Dirk Hohndel
a413141b33 Geo taxonomy: adjust the preferences to the new data structures
This allows us to pick which three categories of geo taxonomy will be
shown in the UI.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-01 12:38:40 -07:00
Tomaz Canabrava
7f83b35ec9 Add model to populate the Preferences for GeoRef
Simple model that list the options for GeoRef.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22 17:10:57 -07:00
Dirk Hohndel
f8a3a85210 Fix potential crash using std::sort
It's entirely unclear why std::sort sometimes accesses the element with
index -1. In my limited testing switching to qSort avoids that.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-04 08:45:45 -07:00
Tomaz Canabrava
efeca58474 Correctly decrease the number of rows in the dive_site model
We were removing the dive site, but forgetting to decrease the amount of
rowCount, leading to crashes.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:41:21 -07:00
Tomaz Canabrava
09ca240c3e Do not reset the model when adding a new dive site
This makes insertion faster, and also it doesn't break the current
selection in the QComboBox.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:38:19 -07:00
Robert C. Helling
be0a708db0 Two if's to prevent null pointer dereferencing
I need these to prevent subsurface from segfaulting when opening a new log.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-03 21:25:46 -07:00
Tomaz Canabrava
6cd85d9b73 Simplify model handling and crashes fixes
So, there's only one crash left (that I put a big TODO: on the maintab.cpp
about) and I'll fix it tomorrow as it's quite late here and I'm almost
sleeping at the keyboard.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-01 21:36:48 -07:00
Tomaz Canabrava
9dc32de878 Remove Combobox from LocationManagement
I tought about it a bit, and the combobox of the location management was a
bit overkill - we already have another combobox to select the divesite and
also the plus button to add one.

If the user wanna edit the current divesite, he can go to menu and edit it.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-01 21:35:50 -07:00
Tomaz Canabrava
a9ba98942c Correctly change the dive_site name
Correctly change and update the dive_site, updating the name on the
combobox or other attached views.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-01 21:31:16 -07:00
Dirk Hohndel
64753e0682 Fix dive site sorting
std::sort sorts [first,last) so last is excluded.

Also fix the mis-spelling of the compare function.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-01 17:00:09 -07:00
Tomaz Canabrava
b8092c07a4 Create a new DiveSite when user clicks on add
Also reorganized a bit of the code, and renamed a few misleading methods.

[Dirk Hohndel: remove some C++11 code]

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-01 13:24:37 -07:00