aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui
AgeCommit message (Collapse)Author
2014-05-20Migrate code to for_each_dive and for_each_dcGravatar Anton Lundin
[Dirk Hohndel: this overlapped with my commit 09e7c61feeea ("Consistently use for_each_dive (and use it correctly)") so I took the pieces that I had missed] Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-20Fix building with NO_MARBLE prepareForGetDiveCoordinatesGravatar Anton Lundin
Commit fb82da58a2 ("Globe: assume that we are looking at the current_dive") changed the prototype for GlobeGPS::prepareForGetDiveCoordinates. This patches the dummy in NO_MARBLE. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-20Fix building with NO_MARBLE, centerOnCurrentDiveGravatar Anton Lundin
Commit 2bc76beb65 ("Globe: we always center on the current dive") changed GlobeGPS::centerOn to GlobeGPS::centerOnCurrentDive. This patches the dummy in NO_MARBLE, too. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-20Consistently use for_each_dive (and use it correctly)Gravatar Dirk Hohndel
The way the macro is written there is no need to test the dive against NULL before dereferencing. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-20Dive list: add context menu function to renumber dive(s)Gravatar Dirk Hohndel
No attempt is made to ensure that what the user does is sane. So this can result in duplicate numbers, non-consecutive numbers, non-monotonous numbers, whatever floats the users boat. You can renumber a single dive or all selected dives (with a starting number given that is applied to the oldest selected dive and then for each newer selected dive that number is incremented by one). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-19Add ability to make a dive computer the first dive computer of a diveGravatar Dirk Hohndel
If a dive has multiple dive computers we enable a special context menu when the user right-clicks on the dive computer name AND is not already showing the first dive computer. In that case we offer to make the currently shown dive computer the first one. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-19Show the dive computer number (if a dive has more than one)Gravatar Dirk Hohndel
For most users this is no change at all. For the few who download from multiple dive computers this now shows them which of them is the primary dive computer. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-19Make the code easier to readGravatar Dirk Hohndel
This uses the new helper function from commit fc4f133f19d0 ("Add new helper function that looks up the index of a dive by its uniq ID") to make the logic implemented in commit 122593a63a46 ("Fix selection after downloading dives from the dive computer") much saner to read. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-19Fix selection after downloading dives from the dive computerGravatar Dirk Hohndel
If we successfully download dives, the old selection should be cleared and the one of the newly downloaded dives should be selected. I decided to pick the last dive downloaded, which for most dive computers (but for example not for the Uemis SDA) will be the first or earliest of the dives. That seems much more intuitive than keeping the previous selection around. Of course this is harder than it should be because of the way we track selections and because we need a consistent dive list model in order to change the selection. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-19Change get_dive_by_diveid to get_dive_by_uniq_idGravatar Dirk Hohndel
The original name was a really bad choice as we have a 'diveid' as part of struct divecomputer - and that is not the diveid that is being used here. Instead we use the 'id' member of struct dive which holds the "unique ID" for this dive. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-19Download from dive computer: Fix the broken selection of devicesGravatar Dirk Hohndel
The old code was completely bogus - it's confused about what the variable 'i' is counting. This also let's us select the Uemis mount point by default if that's the only valid "device" that we found. Compile tested on Windows, untested on Mac. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-19Divecomputer download: try to offer only those devices that make senseGravatar Dirk Hohndel
If the user selects a Uemis divecomputer, don't show serial devices. If the user selects a serial divecomputer, don't show the Uemis filesystem. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-18Improve the tag widget to allow us to tab to the next fieldGravatar Dirk Hohndel
If the last key that went in ended a tag and the next key is a tab - deliver that to the TabWidget instead so we can navigate between input fields. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-14Do not use default filename as default for "Save as"Gravatar Dirk Hohndel
This may sound counterintuitive but it actually makes sense. If you have a default filename that's the name of you "normal working file". If you want "Save as" something, that by definition is NOT your normal working file but a subset or an experiment or something. And you most definitely do NOT want to overwrite your default file with that. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-13Do not check for null before free.Gravatar Tomaz Canabrava
C specs says that we can safelly free a NULL pointer, so there's no reason to check if it's null before freeing it. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-13Rename getDiveById to get_dive_by_id to keep current c code organized.Gravatar Tomaz Canabrava
This commit renames getDiveById to get_dive_by_id, and it also removes the Q_ASSERTS and if(!dive) return that the callers of this function were calling. If it has a Q_ASSERT this means that the dive must exist, so checking for nullness was bogus too. I've changed the assert (done in a silly C-Way. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-13Move DiveList related methods/classes to own file.Gravatar Tomaz Canabrava
The DiveList classes were a partial mess (and some of it is still in a messy state). The classes that deal with it where done in 'qtHelpers.h', the extern global variable in dive.h, a few methods here and there. This concentrates most - but not all - functions in their own file. The reason for that is to make the new developer faster when looking for things: if it's a divecomputer related method, it should be in a single file, not scattered around. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-13Move printGpsCoords from MainTab to QtHelperGravatar Tomaz Canabrava
Last time I touched this I got a scream from dirk, but then I looked at the code again and the problem that I faced was that I broke translations in a sad way, well, now I broke it again. However, this method shouldn't belong to MainTab ( because of that thingy that I said before and also many others: Separate the logic of your application from the UI specific code ) This generates a string that's going to be used on the Interface, it doesn't display it on the interface. Move it down below makes it easier to test ( I don't need to create an Widget and worry about the parent-relationship with the mainwindow just to test this function, for instance. ) Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-11Correct the usage of std::string and QStringGravatar Tomaz Canabrava
QStrings shouldn't be == "" to check for empty string, use .isEmpty() QStrings shouldn't be != "" to check for non empty, use .size() std::string shouldn't be cleared with = "", use .clear() Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-08When starting the planner, copy cylinders from currently selected dive.Gravatar Robert C. Helling
This way, the user can save dives containing sets of "standard cylinders". Selecting one of those prepopulates the gas list for the planner. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-08Fix building with NO_MARBLE after prototype changeGravatar Anton Lundin
4243fcb915 ("Dont set coordinates when two or more dives are selected") Changed how the prototypes in GlobeGPS looks. This aligns NO_MARBLE version of GlobeGPS with that. Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-08Planner: Offer to discard the plan when Quit is triggered in planner.Gravatar Robert C. Helling
Upon pressing Ctrl-Q or the window close button a modal dialog was shown to remind the user that the planned dive is not saved. This patch triggers the "cancel plan" action before trying to quit. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-08Planner: show gas for the NEXT segmentGravatar Robert C. Helling
For deco stops show the gas of the next segment in the table. In recalculation remove old deco stops earlier. In struct diveplan, the items are "segments" with a beginning, a duration, and a gas. In contrast, the UI of the planner uses "waypoints" which are the boundaries between segments. It is conventional at least for deco stops to display the gas of the _next_ segment in the runtime table (i.e. the gas possibly to be switched to). Furthermore, in addStop, the old deco stops have to be removed earlier as otherwise a new waypoint later than a previous generated gas switch inherits the gas of the old switch. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-08Planner: Change when we recalculate decoGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07Fix another dangling pointerGravatar Thiago Macieira
Same problem as the previous commit: toStdString() returns a temporary, and c_str() will return a pointer to internal data, freed at the end of the statement. So get the pointer to be strcpy'ed in the same statement. Changed to toUtf8() to be more explicit about the encoding and to avoid std::string Signed-off-by: Thiago Macieira <thiago@macieira.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07Fix crash on dereferencing dangling pointersGravatar Thiago Macieira
QList::first() returns a reference to an item, but that list was a temporary. The list gets destroyed at the end of the statement (the semi-colon), so we ended up keeping a reference to freed data (i.e., a dangling pointer) Signed-off-by: Thiago Macieira <thiago@macieira.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07Apply the edit of trip locationsGravatar Anton Lundin
This re-adds this code that got removed in a209dfbfd53 ("Multi dive edit: don't change location texts until user saves the change") Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07Only mark location changed when in edit modeGravatar Anton Lundin
Otherwise the code loading a dive into the field would mark it as changed. This re-adds this code that got removed in a209dfbfd53 ("Multi dive edit: don't change location texts until user saves the change") Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07Improve the color coding when editing coordinatesGravatar Dirk Hohndel
This still gets it wrong (i.e. marks things as edited when they are not or not edited when they are) but at least they are no longer incorrectly marked as incorrectly parsed. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07Hack around a translation issueGravatar Dirk Hohndel
I cannot figure out how to get the hemisphere letters translated correctly in qthelper.cpp. Short term hack for now - someone who understands how this is supposed to work really needs to take a look. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07Remove spurious debug printoutGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07Globe: assume that we are looking at the current_diveGravatar Dirk Hohndel
As in commit 3870bdafee53 ("Globe: we always center on the current dive") passing in a specific dive here makes no sense - it's always about the current dive. Fixes #513 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07Globe: we always center on the current diveGravatar Dirk Hohndel
Simplify the API (we'll take advantage of this in the next commit). We always center the globe on the current dive, so no point in passing that dive in. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07Multi dive edit: don't change location texts until user saves the changeGravatar Dirk Hohndel
If we keep updating the location text of all selected dives we can lose the status of which dives had the same text of the original dive and which did not (this happens if the location we are adding is identical to a selected location but adds text to the end of it). Now we only edit the other dives after we accepted the change. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-07Even if there is progress text, still set the progress bar percentageGravatar Dirk Hohndel
I don't understand why we wouldn't set the percentage if we displayed text there as well. This looks much better. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-06Simplify string comparisonGravatar Dirk Hohndel
This is based on Linus' idea on the mailing list. Treat NULL strings and empty strings as identical. Suggested-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-06More multi-edit fixesGravatar Dirk Hohndel
This time for values that aren't simply text. For normal integers this is rather straight forward. For the 'when' timestamp we simply assume that this is a shift in time. What is still missing is consistent handling of the three fields that are implemented as tags: tags, buddy and divemaster. We have special code for tags that makes no sense in a multi-edit scenario. And we treat divemaster and buddy as a single string - which kinda works but treats "Bill, Joe" and "Joe, Bill" as different. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-06Only change identical fields when editing multiple divesGravatar Dirk Hohndel
This was broken when porting to Qt - we used to do this correctly in the Gtk version. When editing multiple dives we show the current dive to the user and allow them to edit that and then apply those edits to all selected dives. The way this is SUPPOSED to work is that we only change those selected dives that had the same value for the edited field as the current_dive had for that field. Let's say you select ten dives. The current dive shows divemaster Joe. You change that to divemaster Jim. Then only the selected dives that had divemaster Joe should change to Jim. All other dives should stay unchanged. This seems to implement that logic. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-06Change EDIT_SELECTED_DIVES macroGravatar Dirk Hohndel
The way this is implemented is broken in several ways. This fixes the first issue. For the invocations where we are in the 'WHAT' checking to see if the value we are changing in the selected dive was previously the same as in the current dive (which is the one shown to the user for editing), then we need to make sure we change the current dive last, otherwise the comparison will fail. Of course, right now we only do this check for gps location, which is a massive bug as far as I am concerned. Fixes #515 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-05Change the profile redraw logic after preferences were changedGravatar Dirk Hohndel
I we are showing a calculated ceiling, then we have to replot the profile after a preferences change as the gradient factors could have changed which might change a calculated ceiling. Also use the rulergraph preference instead of checking the settings directly. Fixes #511 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-05Correctly parse boolean preferencesGravatar Dirk Hohndel
QVariant does the right thing, regardless of whether the value is stored as int or as string - so let's just use that instead of manually checking for integers (and failing if the values are stored as "true" and "false"). Fixes #511 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-05Fix odd indentationGravatar Dirk Hohndel
I need to fix this in the tool as well... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-05Make rulergraph a pref as wellGravatar Dirk Hohndel
I don't see a point in treating it differently from the other graphs. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-05Fix bug in handling of fake SAMPLE_EVENT_PO2 eventsGravatar Dirk Hohndel
In commit bcdd6192fe45 ("Show translated event names in tooltip") I was too aggressive in replacing the checking for event names with checking for event types. It turns out that we are abusing an existing event type in the planner (and use a different event name to mark the difference). By just checking for the type this now caused incorrect information to be displayed in the info box (a simply "PO2 warning" on a Suunto D9 could turn into a "Bailing out to OC" notice). The correct fix is to get our own range of SAMPLE_EVENT_xxx numbers from libdivecomputer. Once we have those, we can do this the right way. For now we just fall back to also checking the event name (which is what I wanted to get away from so translated names don't trip us up). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-05Add images to all dive computers and refresh profileGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-05Correct check for existence of DateTimeOriginal exif tagGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-04Add conditional so globe.cpp builds with older versions of MarbleGravatar Dirk Hohndel
In commit 7f3b487c77c7 ("Restore the previous globe zoom level after showing dive without GPS") I was a bit too aggressive in replacing a deprecated API function - people still need to be able to compile against Marble versions older than 4.10. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-01Re-center on current dive if dive edit is canceledGravatar Dirk Hohndel
If the user changes the coordinates for a dive but then cancels the dive edit, the globe would stay at the location that was temporarily set and not rotate back to the still active coordinates. This fixes it. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-01Only change dive coordinates on double clickGravatar Dirk Hohndel
Apparently this only happens on Windows, but there we would change the dive coordinates on a SINGLE click when editing a dive. With this change we simply bail if the event isn't a double click. Fixes #505 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-05-01Dont set coordinates when two or more dives are selectedv4.0.97Gravatar Tomaz Canabrava
If a trip is selected (or for other reasons more than one dive), this would change the GPS coordinates of the whole selection which almost certainly isn't what the user wanted. Instead, only allow changes of the coordinates on the globe if exactly one dive is selected. [Dirk Hohndel: massively rewritten and extended - but I didn't want to simply "steal" the commit from Tomaz... This now maintains the "zoom out mode" for dives without GPS coordinates and deals with edits of multiple dives that are initiated the "normal way" by starting to edit other data as well.] Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>