aboutsummaryrefslogtreecommitdiffstats
path: root/qt-models/divelocationmodel.cpp
AgeCommit message (Collapse)Author
2018-06-24Localization: remove gettextFromC::instance()Gravatar Berthold Stoeger
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-05-21qt-models: Change Q_UNUSED to no parameter nameGravatar jan Iversen
C++ permits use of parameters without name, which signals unused Signed-off-by: Jan Iversen <jani@apache.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-02-17Coding-style: remove superfluous parenthesesGravatar Berthold Stoeger
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-01-31mobile cleanup: restyle construction of locationlistGravatar Jan Mulder
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>
2017-11-30Use better aliases for icons.Gravatar Martin Měřinský
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-29Revert "Use consistent aliases for all icons."Gravatar Dirk Hohndel
This reverts commit 92e9c6606f6ef3ad16d2e31f9f9a8f5fa14f2c1a.
2017-11-29Use consistent aliases for all icons.Gravatar Martin Měřinský
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-26Fix comparison function in qt-models/divelocationmodel.cppGravatar Berthold Stoeger
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 f8a3a8521003a26525b658840ce8e7bfd3f7b141. 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-26Remove unused method LocationInformationModel::addDiveSite()Gravatar Berthold Stoeger
The call to this method was removed in commit f4c31f110fc98eb6d5d18c806e6b0f2ccc762d54 Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-04-29Add SPDX header to Qt modelsGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-04-26Correct divesite geocoding translationGravatar Jan Mulder
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>
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>
2016-03-08Silence warnings in divelocationmodel.cppGravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-11-07divelocationmodel: fix some signed/unsigned warningsGravatar Lubomir I. Ivanov
Use uint32_t for divesite UUIDs. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
2015-10-09Do not show lack of coordinates as having same gps informationGravatar Tomaz Canabrava
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-09-12Hide current dive site from dive sites with same coordinates.Gravatar Sander Kleijwegt
Signed-off-by: Sander Kleijwegt <sander@myowndomain.nl> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-12Remove id from divelocation selection listGravatar Sander Kleijwegt
Signed-off-by: Sander Kleijwegt <sander@myowndomain.nl> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-31UI code to merge dive sitesGravatar Tomaz Canabrava
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-31Display dive sites with same gps as the currentGravatar Tomaz Canabrava
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-31Add function to filter same-gps dive sitesGravatar Tomaz Canabrava
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-25Create a new dive site and edit it automaticallyGravatar Tomaz Canabrava
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-25Make created dive site uuid deterministicGravatar Dirk Hohndel
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-07-17Better invalid dive site nameGravatar Dirk Hohndel
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-16Show only 1 possibility if string is uniqueGravatar Tomaz Canabrava
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-16Dive site edit: add second "create" line without completionGravatar Dirk Hohndel
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-15Better text for fake completion entryGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-14Offer an option to just complete the textGravatar Tomaz Canabrava
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-02Rename enum values for taxonomyGravatar Dirk Hohndel
This avoids confusion and namespace collisions. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-02Merge branch 'taxonomy'Gravatar Dirk Hohndel
2015-07-01More information on dive site modelGravatar Tomaz Canabrava
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-01Geo taxonomy: adjust the preferences to the new data structuresGravatar Dirk Hohndel
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-06-22Add model to populate the Preferences for GeoRefGravatar Tomaz Canabrava
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-04Fix potential crash using std::sortGravatar Dirk Hohndel
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-03Correctly decrease the number of rows in the dive_site modelGravatar Tomaz Canabrava
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-03Do not reset the model when adding a new dive siteGravatar Tomaz Canabrava
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-03Two if's to prevent null pointer dereferencingGravatar Robert C. Helling
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-01Simplify model handling and crashes fixesGravatar Tomaz Canabrava
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-01Remove Combobox from LocationManagementGravatar Tomaz Canabrava
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-01Correctly change the dive_site nameGravatar Tomaz Canabrava
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-01Fix dive site sortingGravatar Dirk Hohndel
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-01Create a new DiveSite when user clicks on addGravatar Tomaz Canabrava
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-05-31Organize the dive_sites alphabeticallyGravatar Tomaz Canabrava
run std::sort on the dive_site list inside of the model. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-31Don't calculate what we already haveGravatar Tomaz Canabrava
We already have the correct number of dive_sites, why use a loop to calculate it? Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-31Fix off-by-one errorGravatar Tomaz Canabrava
i is one greater than the number of dive_sites, use the correct nr. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-29Correctly set the dive site id on the diveGravatar Tomaz Canabrava
When changing the index of the combobox we were discarting the dive_site_id. This fixes it. Now I need to understand what's happening to the globe. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-29Update DiveLocationModel when thread finishesGravatar Tomaz Canabrava
This patch updates the DiveLocationModel when the GeoLoockupInformationThread finishes, and also selects the correct index for the displayed dive. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-29LocationInformationModel moved to qt-modelsGravatar Tomaz Canabrava
I forgot about this one, and we are going to use it in the mobile version too. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>