aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2019-04-12Dive site: remove edit mode from dive location widgetGravatar Berthold Stoeger
Since no dive site field editing enters edit mode anymore, the whole edit mode state and code can be removed from the widget. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: update map when dive site location is changed by undo commandGravatar Berthold Stoeger
Simply hook into the appropriate signal. Thus, the "update dive site location" button can be removed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: implement undo of dive site location editingGravatar Berthold Stoeger
Simply copy the code of note editing. It's a bit more complex, since we have to parse the Gps coordinates. For consitency, rename the COORD field to LOCATION (the field in the dive_site struct is called LOCATION). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Cleanup: remove LATITUDE and LONGITUDE columns in DiveLocationModelGravatar Berthold Stoeger
These were never used and it's hard to imagine when one of these would be used. Typically users are more interested in the coordinates than just one component, no? Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: implement undo of dive site country editingGravatar Berthold Stoeger
Simply copy the code of notes editing, but use the taxonomy_* functions to read and set the value. Moreover, replace the three TAXONOMY_n field ids by a single TAXONOMY id. We will probably never show one column per taxonomy field, but rather a single column with a string derived from all taxonomy fields. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: implement undo of dive site notes editingGravatar Berthold Stoeger
Simply copy the code of description editing. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Desktop: create new custom TextEdit widget for notes-fieldGravatar Berthold Stoeger
Currently, the notes field uses a QTextEdit, which doesn't send a signal if it goes out of focus. But for undo of dive-editing we don't want to create an undo object for *every* text change. Thus, create a custom TextEdit widget that derives from QTextEdit and turns the focusOutEvent into a editingFinished signal. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: use undo commands for name and description editing in widgetGravatar Berthold Stoeger
In the dive site widget, use the undo commands instead of editing only on accept. This introduces an inconsistency betwee the name and description and the other fields. This will be fixed in follow-up commits. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive site: remove LocationInformation::nameChanged signalGravatar Berthold Stoeger
This signal was used by the old filter and the last user was removed in e0f473fcb49c8121a0a9c52bf0536049b0f342ed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive site: scroll to changed dive siteGravatar Berthold Stoeger
If the name of a dive site is edited, it might wander somewhere else in the table and thus out of view. Hook into the "dive site changed" signal and scroll there. The code is rather subtle as it depends on signals being called in a certain order: First the item is moved in the model, only then can we scroll to the correct place. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive site: on first addition of dive site, edit nameGravatar Berthold Stoeger
When adding a dive site, enter the name field of the new dive site. Thus, when adding a new dive site, the user can immediately edit the name. The code is rather subtle: It hooks into the dive site added signal before executing the command and unhooks afterwards. This only works, because signals are executed in order of connect - thus the model adds the index first and only *then* is the field edited. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: implement undo of dive site additionGravatar Berthold Stoeger
Implement a dive site addition undo command and connect it to the add dive site button. The added dive site has a default name ("new dive site"). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: implement undo of dive site description editingGravatar Berthold Stoeger
Simply duplicate the code of dive site name editing. Split out the common functionality that swaps a C and a Qt string. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive site: remove implicit deletion of empty dive sitesGravatar Berthold Stoeger
There was a way of deleting dive sites by clearing all fields. This is not necessary anymore, as now the user can delete a dive site in the dive site list. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive site: don't auto delete unused dive sitesGravatar Berthold Stoeger
This feature will be replaced by. 1) An explicit purge empty dive sites feature. 2) Not allocating dummy dive sites for GPS coordinates. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: Implement undo of dive site name editingGravatar Berthold Stoeger
Implement an undo command that edits the name of a dive site. Connect it to the dive site table, so that names can be edited directly in the table. Send signals on undo / redo so that the dive site table and the dive site edit widget can be updated. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: make dive site removal undoableGravatar Berthold Stoeger
Create a new undo-command for deleting dive sites. If there are dives associated with that site, the dives will be removed. The frontend is not yet updated in such a case, as that infrastructure is in a different PR. Connect the trashcan icon of the dive site table to the undo command. Currently, this code is in the dive site model, which makes little sense, but is how the TableView class works. We might want to change that when cylinder and weight editing are made undoable. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive site: introduce proxy model DiveSiteSortedModelGravatar Berthold Stoeger
The LocationInformationModel used to sort its entries and was completely rebuilt after every change. This makes it rather complex to support incremental changes. Instead, keep LocationInformationModel sorted by UUID so that indexes are consistent with indices in the core dive site table. Implement sorting by other columns than name and enable sorting in the dive site view. Finally, don't cache the list of dive site names for the mobile app, since that would also need some rather convoluted methods of keeping the list up to date. Calculate it on the fly. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Coding style: add tab before Q_OBJECTGravatar Berthold Stoeger
In virtually all cases we use a tab before Q_OBJECT. Fix the four exceptions. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive site: inform model of dive site addition / deletionGravatar Berthold Stoeger
Introduce two DiveListNotifier signals which are sent by the undo commands if dives are added to / removed from the core. The signal has the dive site and the index in the global dive site table as payload. Thus, the model has only to remove the appropriate rows. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Cleanup: macroize dive site table functions, keep table sortedGravatar Berthold Stoeger
Turn the table functions of the dive site handling into macros as was already used for dives and dive trips. This has the effect that the table is kept sorted by UUID. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Cleanup: move table-macros into own headerGravatar Berthold Stoeger
dive- and trip-table functions are generated in dive.c by macros. Move this macros to a new "core/table.h" header file. Thus, these functions can be used for other tables (e.g. dive site) and the trip function can be moved to a separate translation unit (divelist.c being quite large already). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Cleanup: autogenerate remove_dive() and remove_trip()Gravatar Berthold Stoeger
The other dive- and trip-table functions were already autogenerated. Let's do the same for these two. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Cleanup: rename unregister_trip() to remove_trip()Gravatar Berthold Stoeger
For consistency with remove_dive(). Moreover, swap parameter order in remove_dive() so that both functions use the same parameter order. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: keep frontend informed of changes to dive site countGravatar Berthold Stoeger
Add a new signal to DiveListNotifier. Send signal if dives are added or removed and therefore the dive count of a dive site changes. The dive sites are collected and the signal is sent at the end of the command. Add code to update the table view. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive site: add dive site list tabGravatar Berthold Stoeger
Add a very simple tab-widget presenting the list of known dive sites. The table is rendered using our custom "TableView". The (mis)uses the "LocationInformationModel". It moves the items to be displayed (delete, name, description, number of dives) to the front and makes the others hidden. Moreover, it was necessary to limit the geo-tag decoration role to the name to avoid having the icon next to each column. Make the trash-can icon active and the name and description editable. This is modelled after the cylinders-table code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive sites: simplify nr_of_dives_at_dive_site()Gravatar Berthold Stoeger
1) The second parameter (selected_only) was always false. Therefore, remove it. 2) Simplify the function by simply returning the reference count. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive site: use ref-counts to see if dive site is usedGravatar Berthold Stoeger
Checking for dive site usage is now simply checking the number of dives. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive site: add dive site ref-countingGravatar Berthold Stoeger
Instead of setting dive->dive_site directly, call the add_dive_to_dive_site() and unregister_dive_from_dive_site() functions. In the parser this turned out to be a bit tricky. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive sites: prepare for dive site ref-countingGravatar Berthold Stoeger
Add a dive site table to each dive site to keep track of dives that have been added to a dive site. Add two functions to add dives to / remove dives from dive sites. Since dive sites now contain a dive table, the order of includes had to be changed: "divesite.h" now includes "dive.h" and not vice-versa. This caused some include churn. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Cleanup: move declaration of get_stylesheet() to qthelper.hGravatar Berthold Stoeger
The function is defined in qthelper.c and thus not all users of dive.h have to suck in the xslt headers. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Cleanup: remove "libxml/tree.h" include from "dive.h"Gravatar Berthold Stoeger
Apparently it wasn't used anyway. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Cleanup: move parse-function declarations out of "dive.h"Gravatar Berthold Stoeger
Move the declaration of these functions to "file.h" and "parse.h" according to the translation unit they are defined in. Thus, not all users of "dive.h" have to suck in "sqlite3.h". Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Cleanup: remove "sha1.h" include in "dive.h"Gravatar Berthold Stoeger
No point in pulling that in for all users of "dive.h" Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive site: set UUID only on save or loadGravatar Berthold Stoeger
Since the UUID will be overwritten on save and is only used on save and load, set it only on save or load. For other created dive sites, leave the UUID field uninitialized. This means that the UUID will change between saves. Let's see how the git saver handles that. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive site: ensure that no two dive sites have same UUIDGravatar Berthold Stoeger
We absolutely want to avoid dive site with the same UUID. But that could happen when reimporting a log where the dive sites diverged. Therefore, on adding a dive site to a table, change the UUID if it already exists. Since dives are associated to dive sites with pointers, this should have no negative impact. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: consider dive site in AddDive()Gravatar Berthold Stoeger
If a dive site was added for a new dive, remove it on undo. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Cleanup: Remove dead code when picking a new dive siteGravatar Berthold Stoeger
When a new dive site is created in MainTab::updateDiveSite() and there is no text, it gets a generic name. But: the function exits early if there is no text, so this is dead code. Remove. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Cleanup: let get_dive_site_idx() compare pointersGravatar Berthold Stoeger
The code used dive site uuids, which are not really used anymore. The only caller of this function does certainly not use a copy, so let's compare pointers instead. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Undo: make undo-system dive site-awareGravatar Berthold Stoeger
As opposed to dive trips, dive sites were always directly added to the global table, even on import. Instead, parse the divesites into a distinct table and merge them on import. Currently, this does not do any merging of dive sites, i.e. dive sites are considered as either equal or different. Nevertheless, merging of data should be rather easy to implement and simply follow the code of the dive merging. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Parser: parse into custom dive site tableGravatar Berthold Stoeger
To extend the undo system to dive sites, the importers and downloaders must not parse directly into the global dive site table. Instead, pass a dive_site_table argument to parse into. For now, always pass the global dive_site_table so that this commit should not cause any functional change. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Build: add DiveListNotifier.cpp to qmake project fileGravatar Berthold Stoeger
In the future, we will need DiveListNotifier.cpp in mobile builds. Therefore, add it to the qmake project file for iOS. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12Dive site: add dive site table parameter to dive site functionsGravatar Berthold Stoeger
To enable undo of dive site functions, it is crucial to work with different dive site tables. Therefore add a dive site table parameter to dive site functions. For now, always pass the global dive site table. Thus, this commit shouldn't alter any functionality. After this change, a simple search for dive_site_table reveals all places where the global dive site table is accessed. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-04-12optimize selectedDivesGasUsed()Gravatar Rolf Eike Beer
-return the result instead of storing in a parameter, we now know that the list contains only those results that are generated in the function -allocate the result with the correct length right from the start -do not iterate over keys of a map and then do a map lookup to get the value but use an iterator that gives us both right from the start -remove one call alltogether as the results were not used there Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
2019-04-12CMake: move enable_testing() to the top levelGravatar Rolf Eike Beer
This allows calling ctest from the main build directory instead of having to change one level down. As a bonus the unittests now show up in my KDevelop so I can directly run them from the IDE. Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
2019-04-12use qDeleteAll()Gravatar Rolf Eike Beer
Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
2019-04-12replace deprecated qSort() with std::sort()Gravatar Rolf Eike Beer
Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
2019-04-12tell QObject to give the desired children right awayGravatar Rolf Eike Beer
Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
2019-04-12use the default constructor for empty QString and QByteArray constantsGravatar Rolf Eike Beer
Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>
2019-04-12use QStringLiteral for constantsGravatar Rolf Eike Beer
Signed-off-by: Rolf Eike Beer <eike@sf-mail.de>