aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/divelistview.cpp
AgeCommit message (Collapse)Author
2013-11-15Fix potential crash when merging tripsGravatar Dirk Hohndel
strdup doesn't like to be passed a NULL pointer. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-14Expand the trip of the first selected dive.Gravatar Tomaz Canabrava
I probably broke this a while ago, as I was not using the big dirk dive file to test ( just using some random files over the test folder. ) Now it's working as it should. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-14Fix Last Column adding a horizontal Scroll on the Dive List.Gravatar Tomaz Canabrava
Fixes the last column adding a horizontal scroll on the dive list, since we have the hability to show / hide columns, I had to create a helper method to discover what is the last column and set the size of it very small so no scroll is created. Also, I'v set the setStrechLastSection to true. :) Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-14Maintain the selection when aborting "dive add"Gravatar Dirk Hohndel
We remember what was selected before and restore it. Maybe there's a more "Qt way" of doing this, but my implementation appears to work :-) Also remove unconditional debug output that snuck into an earlier commit. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-14Add file naming dialog for save asGravatar Miika Turkia
When right clicking a dive on the divelist a dialog for selecting a dive was opened. However, Save As requires a getSaveFileName dialog so that user can give a new file name as well as selecting an old file to overwrite. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-13When selection gets confused, don't try to select non-existing diveGravatar Dirk Hohndel
While the argument could be made that this is just a symptom of Subsurface getting very confused about the selection (which it still gets at times - most likely we are calling select_dive() instead of selectDive() (or the corresponding deselect functions) in places where we shouldn't), but either way, we should not crash. Fixes #220 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-11Mark divelist changed when deleting a diveGravatar Dirk Hohndel
Fixes #232 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-09Save / Restore the Tree after organizing by other columns.Gravatar Tomaz Canabrava
This patch saves and restores the state of the TreeView after the user clicks on another columns that will make the tree disappear. All of the branche states are saved, this way the expanded nodes will be restored when the user gets back to tree mode. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-09Save the status of the tree before trying to reset the display.Gravatar Tomaz Canabrava
This is a try: when the user changes the orientation on the columns by clicking on the title of them and organizing by something that's not the number, we lost track of the opened branches. this commit doesn't fix that, but it fixes a possible similar issue. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-11-09Moved the code that handles DiveList column sizes to its correct file.Gravatar Tomaz Canabrava
I got a bit lost trying to find the code that handled DiveList columns today, so I thought it was better to move it to its file, after all we do have a divelistview.h :) Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-05Fix dive mergingGravatar Dirk Hohndel
When merging dives, the indices of the following dives change - so we need to adjust the variable used in the for_each loop. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-11-05Remember the column we are sorting byGravatar Dirk Hohndel
A call to DiveListView::reload always reset our sortcolumn to be 0. Instead we are tracking the correct sort column and sort direction. This also removes an obsolete private member that was unused. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-20Export dives in UDDF formatGravatar Miika Turkia
Implement exporting in UDDF format as was done in Gtk version. File menu exports all the dives, right click on selection exports the selected ones. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-17Some adjustments to "save as"Gravatar Dirk Hohndel
The popup menu entries should be all lowercase. Also we should handle this the same as regular save and open when it comes to remembering the last path. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-17Added 'Save As' option on the dive list menu.Gravatar Tomaz Canabrava
This adds the 'Save As' option on the dive list, very straigth forward, just simple and beauty. tested and working. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-15Random white space cleanupGravatar Dirk Hohndel
Because I can. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-10-11Good deal of whitespace fixes and code cleanup.Gravatar Tomaz Canabrava
I just went thru all of subsurface code removing some whitespaces issues and trying to make the code prettyer, I also removed a few QString issues.d Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-10-04Fix showing all columns by default on first run.Gravatar Tomaz Canabrava
Some columns are a nice addition, but not a must have, and thus are hidden-by-default, uncluttering the user interface. This was discussed with a few designers before writting the code, and also discussed with dirk on irc. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-10-01Fix weight adding in the Qt UI & fix the header height for tablesGravatar Patrick Valsecchi
Fixes #203 Signed-off-by: Patrick Valsecchi <patrick@thus.ch> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-24Only offer to merge dives if they are consecutive in the divelistGravatar Dirk Hohndel
You cannot merge dives if there is another, unselected dive "between" them. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-24Much easier way to detect if more than one dive is selectedGravatar Dirk Hohndel
Instead of getting data from Qt just use our internal notion of the number of selected dive to decide if more than one dive is selected (and therefore if we need to show the 'merge dives' option in the context menu). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-23Add "merge selected dives" to dive list popup menuGravatar Dirk Hohndel
This is fairly straight forward. What I dislike is the check for the magic number of "14 indeces". I'm sure there's a better way to tell if more than one dive is selected... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-09-22Correctly handle empty dive list after deleteGravatar Dirk Hohndel
Things need to be cleared out and disabled. But fixing this bug leaves another issue - while the newly selected dive after a delete acts as if it was selected, it doesn't show up as selected in the dive list. Reported-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-08-16Fix for double-rendering, double selection and other annoyances.Gravatar Tomaz Canabrava
This patch fixes a thing that I run into when trying to implement the multi-edition system. Whenever a dive was selected, via mouse or keyboard, it had two stages: first, it would select the previous and the current ( and thus, render the profile of the current) and then whould release the previous and select the current again ( and thus, rerendering the profile again, plus a few other things. ) With the multi-edition system this caused a more severe bug, since the edition of the dives is directly applied as soon as the text fields changes, as soon as we selected any dive on the list, the 'before' dive would be modified by the 'current'. This patch fixes this - but since it's just a 'code removal' patch, this can led to bad things in the future, I tested it quite a bit, but didn't found anything, no regression. *fingers crossed.* Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-07-04Qt: Implement trip merging logicGravatar Linus Torvalds
So during my Maui trip, I had a short hiatus in diving, causing subsurface to start a new trip for the last day of diving. I could have just started the old gtk branch to fix it up, but decided that I might as well try to implement the "merge trip" logic in the Qt branch instead. This is the end result of that. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-17Changed a lot of code to reduce boilerplate on models in the future.Gravatar Tomaz Canabrava
So, I changed a lot of code to reduce boilerplate on models in the future. Currently we do not have a lot of models, but this can increase quite rapdly. There's a second TreeModel in the works, the Yearly Statistics, this patch will save around 250 LOC for this new model, and more and more models will give us a greater saving. Iwll do that for the table models in the future too - I did the tree models now because they are the most complex case and I didn't wanted to create a second tree model without this. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-14Show & edit trip location and notes when exactly one trip is selectedGravatar Dirk Hohndel
While we still show the selected_dive in the profile and use it for Dive Info and Equipment, in the Dive Notes tab we now show the trip location and trip notes (and none of the other fields), if the user directly selects a whole trip by clicking on the trip header. This clever reuse of the widget now allows trip location and notes to be edited in place. As a side note: the Gtk version has long allowed the user to edit the trip location and trip notes, but nowhere did it ever SHOW the trip notes... so this is more than just feature parity... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-14Don't offer "delete dive" context menu for tripGravatar Dirk Hohndel
If we are not on a dive we shouldn't try to delete it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-14First deselect, then selectGravatar Dirk Hohndel
For reasons I still don't understand, sometimes (but not always) when clicking on a trip header we appear to get a select notification for the trip and at the same time deselect notifications for every dive in the trip. This seems wrong but I can't seem to figure out why it happens - and of course it causes us to have a mixed up interpretation of what is selected in our internal selection tracking. Simply acting on the new selection after the newly deselected items are handled appears to fix the issue, but I do worry about this change. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-12Implements the DiveList to behave like Linus Explained.Gravatar Tomaz Canabrava
Implements the divelist to behave like linus explained, essentially, it filters the layoutChanges of the model, greps for trips, and for each trip that it finds, it set the 'firstColumnSpanned' property, to make the column to have the size of the whole table. e Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
2013-06-09Ticket 127 - Repopulate context menu on preferences changeGravatar Helio Chissini de Castro
Ticket 127 mention that context menu is fixed on imperial mode, which is partial true. Context menu only not have the changes on header model updated when preferences are chenges during execution. Hard to note because if program is closed and opened again, the context is initialized properly. Since actions aren't bound to the header model, we need iteract of current items and change the title. Signed-off-by: Helio Chissini de Castro <helio@kde.org>
2013-06-08Use the official QItemSelectionModel::SelectionFlagsGravatar Thiago Macieira
It's a typedef to the QFlags<QItemSelectionModel::SelectionFlag>. Signed-off-by: Thiago Macieira <thiago@macieira.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-07Make a map ctrl-click toggle the selection stateGravatar Linus Torvalds
This way the map selection works like normal selections do. Except we don't do "ranged" selections (shift-click) for fairly obvious reasons. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-07Fix unused variable warning and spellingGravatar Linus Torvalds
Commit 4b405caa2c47 ("Clean up divelist dive selection") made the sort model variable in headerClicked unused, so get rid of it. Fix a speling eror closeby while at it. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-06Try to get rid of unnecessary reloads of the dive listGravatar Dirk Hohndel
Don't call refreshDisplay() after preferences change. This strangely somehow leads to a situation where I need to move the mouse over the dive list before changes to the units are reflected. When calling reload() do not force layout change / resort unless that is the intention. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-06Add delete dive context menu entryGravatar Dirk Hohndel
Getting closer to the way this should work. Adjusted the call to reload to not switch back to tree view and resort (oops). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-06Implement the context menu a different wayGravatar Dirk Hohndel
It seems that this is the way this is supposed to be done - instead of manually looking at what kind of click we get, Qt decides when to create a context menu for us - this way things like the Windows Menu button will work automagically. As an example I also implemented the "remove dive from trip" functionality, which exposes some other bugs (like the fact that the dive that isn't part of a trip ends up being sorted at the very end of the dive list). This commit contains a "testSlot" implementation to remind me how to figure out which dive / trip we are on. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-06Only show expand/collapse context menu when in tree modeGravatar Dirk Hohndel
The options make no sense when in list view mode. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-06Distinguish between "collapse" and "collapse all"Gravatar Dirk Hohndel
Some users might want to really see nothing but trips, others might want to be able to keep the trip with the selected dive open. Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-06Add context menu to dive listGravatar Dirk Hohndel
So far we support "expand all" and "collapse" all. This still needs to be restricted to only be shown when in trip / tree mode. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-05Clean up divelist dive selectionGravatar Linus Torvalds
Since we have a "selectDive()" method, let's just use it rather than opencoding it. Similarly for "unselectDives()". Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-05Fixing some issues with the dive selection after OK on preferencesGravatar Dirk Hohndel
These changes should be correct - but they still don't fix the problem that after we click 'OK' on the preferences (regardless of whether any changes were made), the first dive is set as current dive and shown in the map window. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-05Keep selected dive in viewGravatar Dirk Hohndel
Somehow we managed to break this. Again. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-05First cut at selecting dives from the mapGravatar Linus Torvalds
We'll want to enhance this: better logic for which dives are near the selection, and it's probably best to have a "control-click" that adds the dives to the selection rather than deselecting all the old ones. But it's already useful. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-04Stop showing the first dive after a preferences changeGravatar Dirk Hohndel
What is missing is the code to actually show the RIGHT dive... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-06-02Once again try to fix the selectionGravatar Dirk Hohndel
Things got broken. Again. We no longer kept track of the selected dives in our structures which broke statistics. This attempts to fix that, but appears to still have a bug when selecting trips. Sometimes this results in 0 dives being selected according to our data structures, while Qt happily shows all dives of the trip as seected. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-31Scroll to (and re-expand) the selection when sorting and movingGravatar Linus Torvalds
The keyboard movement wouldn't scroll to the newly changed selection. Similarly, when sorting the dive list, we'd end up losing the currently selected dive (and generally collapsing the currently exposed trips). This adds the scrolling/exposing logic for those cases. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-30Add a proof of concept for filtering the Dive List,Gravatar Tomaz Canabrava
Press CTRL+F and a line edit will appear, whenever you write on that will be used as a filter against all columns. The results are maybe somewhat surprising in trip mode, but when sorting by another column this shows some potential. Hit ESC to remove the filtering. I need to find a better position to put the Widget, but it's a proof of concept. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-30Don't display "show" in front of every columnGravatar Henrik Brautaset Aronsen
When (de)selecting columns, a the list of columns have a "show" in front of every entry. We don't need that. Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-05-30Code layout changesGravatar Dirk Hohndel
Tomaz convinced me (with help from Linus) that it might be a good idea to go with the compacter "single line" case statements in some specific instances where this makes the code much more compact and easier to read. While doing that I changed Linus' code to do 'retVal = ...; break;' instead of just 'return ...;' - this is more consistent and makes debugging a little easier. And while doing all that, I also cleaned up divelistview.cpp a little bit. And removed an unused variable. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>