This function created a QFile that it didn't need and it returned a
dangling pointer (the std::string object was destroyed at the end of the
function).
The function now returns a pointer that the caller must free. For that
reason, it's easier in copy_image_and_overwrite to just go for the
QFileInfo call.
Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
There was at least one code flow where the parsed output parameter wasn't
set to true, even though nothing was wrong with the coordinates.
Fixes#592
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Dive photos are copied to the photos directory on export. The photos
section appears only if photos exist.
C++ helper functions are added to copy images to the photos directory,
Additionally the photos directory must be passed as a parameter to the
write_one_dive function to save photos to it. Some options structure may
be needed instead of passing many arguments.
Signed-off-by: Gehad elrobey <gehadelrobey@gmail.com>
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We already did a list of gases and volume consumed for the selected dive
on the Dive Info tab, but did not provide that same data on the Stats tab
for all the selected dives.
I arbitrary limited this to eight gases (as the list can get quite long
when you select a lot of dives). The gases are sorted by volume consumed.
Fixes#535
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
It makes no sense to store a 64bit time stamp with every picture. Even the
32bit offset (in seconds) from the dive start is WAY overkill. But
switching to that makes the code much more simple in a number of spots.
And makes what is saved to the XML file easier to read, too.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit breaks the loading of images that were done in the divelist
into smaller bits. A bit of code refactor was done in order to correct the
placement of a few methods.
ShiftTimesDialog::EpochFromExiv got moved to Exif::epoch dive_add_picture
is now used instead of add_event picture_load_exif_data got implemented
using the old listview code. dive_set_geodata_from_picture got
implemented using the old listview code.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The existing code took an odd approach. It tried to change all selected
dives whenever the user edited a field, and kept all this backup data in
case the user rejected the edits.
This code takes the opposite approach. Only edit a copy of the selected
dive and then when the user accepts it, edit all the dives and when the
user rejects the edit simply redraw the screen (as all the "real" data is
still unchanged).
This not only saves quite a bit of code, it should be much easier to get
correct.
Admitedly this code will need quite a bit more testing to make sure it
works as intended, but as far as I can tell it already gets more scenarios
right than the previous implementation.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This changes are only to make CMake compile again after the
addition of the export dialog.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
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>
I'll probably add prefixes to functions to make it easier to find method
via autocomplete from the grep or interface helpers, do you wanna know all
the functions that works with a dive? ask for the completion for dive_,
do you wanna know all the functions that works with a divelist? ask for
the completions on divelist_ or run grep -rIs divelist_ on the header
files.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
It's easyer to make a mistake in the loop insteaf of
using the currently correct one that's already written
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This removes unecessary creation and destruction of the object
making the code shine a bit more and be more fluffy. :)
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
this is not necessary when you don't have a variable
that has the exact same name as the 'this->variable' name,
also, there's no need to check if a QString is empty
before trying to use the == on them.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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>
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>
The C code should be compilable without the need to compile the Gui part,
too. This is expecially good for unit testing as we can test all the
algorithms without a window appearing out of nowhere.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The argument index used to pull in the translated hemisphere letters was
incorrect.
Fixes#418
Signed-off-by: Gopichand Paturi <gopichandpaturi@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I know everyone will hate it.
Go ahead. Complain. Call me names.
At least now things are consistent and reproducible.
If you want changes, have your complaint come with a patch to
scripts/whitespace.pl so that we can automate it.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
C++ style of accessing single instance class object.
Signed-off-by: Boris Barbulovski <bbarbulovski@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
As discussed with Mika this changes the ISO 6709 detection to use:
1st non-whitespace character is a digit and
number of commas is even.
The idea is that, as all the other formats seperate the lat from
long with a single comma, additional even numbers of commas could
ocour in locales where comma is used as a decimal point, but in
total an even number of commas (often 0) would indicate an ISO
format entry.
Signed-off-by: Tim Wootton <tim@tee-jay.demon.co.uk>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
ISO 6709 format dictates that the format includes characters ° (degree),
' and ". If we only test for the coordinates starting with decimal, we
match also the decimal notation on this test. Thus adding test for the
degree sign not to match input as ISO 6709 when coordinates are given in
decimal notation.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This id is just held in memory. It's not supposed to be used for anything
but having a unique handle that represents a dive. Whenever you need to
remember a dive across an operation that might change the dive_table, this
is what you should hold on to, not a dive number, a dive pointer, or
anything like that.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
As an aside, our resolution is great and certainly high enough for the
real world, but it's easy to get into situations where we don't display
the exact same degrees / minutes / seconds as the user entered...
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The previous implementation only accepted a decimal point. We now support
both point and comma, regardless of locale.
This also removes a debug message left behind in the previous patch.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This adds support for two more GPS coordinate formats and also fixes a
couple of issues with the previous implementation.
We used to only support full degrees and decimal minutes. We now also
support fully decimal and degrees, minutes and decimal seconds.
The previous implementation would color the input field red if either it
couldn't parse the string, or if it was able to parse it but it was the
same as the previous location. That's misleading.
The previous implementation also changed all gps coordinates to the new
coordinates in a multi-dive edit - instead of just changing the ones that
are the same as the master dive.
Fixes#387
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Minor oversight in commit 917b47b79c ("Parse localized GPS string") - we
accepted the translated hemisphere indicators in the regular expression,
but then didn't use them later when comparing with the result of applying
the regular expression.
Fixes#331
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Let's ALWAYS support the somewhat "international standard" N/S/W/E
characters, but ALSO support localized versions.
Fixes#315
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This patch remembers the trip selection across the Dive Tree Model.
It's a tiny bit big because we used to have a variable 'selected
trips' that's now calculed dynamically - this is more future proof.
This is a start of Un-cluttering the view ( for 4.1 I hope to reduce the
code in this class to nearly a half. )
Fixes#303
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Add a helper function to unify the calculation of the
weight display string, instead of having the same calculation
in two places in the code.
Signed-off-by: Benjamin Fogel <nystire@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
DiveComputerList::getExact() created a temporary QList with the
DiveComputerNodes matching a specific model. A pointer to a node in the
list was returned, which becomes invalid when the list goes out of scope
and gets destroyed. Causing a crash when the model strings are compared
later.
Instead of using contains() and creating a temporary list, we can just
use an iterator, which should be both faster and safer.
The crash is easy to trigger with DM4 imports, but can probably be
triggered in other cases too.
Similar problem with DiveComputerList::get().
Signed-off-by: Michael Andreen <harv@ruin.nu>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This sneaked into commit 9364436264.
It shouldn't be there.
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The compiler on MacOSX seems stricter than others:
qthelper.cpp: In destructor ‘DiveComputerList::~DiveComputerList()’:
qthelper.cpp:10: error: expected class-name before ‘(’ token
Fixed with help from http://stackoverflow.com/a/14777627/13365
Signed-off-by: Henrik Brautaset Aronsen <subsurface@henrik.synth.no>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This data structure was quite fragile and made 'undo' when editing
rather hard to implement. So instead I decided to turn this into a
QMultiMap which seemed like the ideal data structure for it.
This map holds all the dive computer related data indexed by the model. As
QMultiMap it allows multiple entries per key (model string) and
disambiguates between them with the deviceId.
This commit turned out much larger than I wanted. But I didn't manage to
find a clean way to break it up and make the pieces make sense.
So this brings back the Ok / Cancel button for the dive computer edit
dialog. And it makes those two buttons actually do the right thing (which
is what started this whole process). For this to work we simply copy the
map to a working copy and do all edits on that one - and then copy that
over the 'real' map when we accept the changes.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>