This has been the cause of issues in several cases. We should simply always try
to push all data to the server - it deals with redundant uploads quite nicely.
(previous commits already stopped responding to this flag, this simply removes
all mention of it)
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
- load the data from settings as we start
- improve upload to server
- keep settings and in memory model in sync
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Instead of using the Settings as our data structure and constantly accessing
them, we now have a QMap for the GPS fixes and only access the Settings to keep
them in sync with the QMap. This should significantly speed things up.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This will use the depth units from user preferences when exporting the
worldmap.
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Of course, as of this writing, there are no images on the server.
In addition, this patch adds comments to explain the by now convoluted
image retrieval logic (local file, filename as URL, by hash, cloud server).
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
As Linus pointed out in mail list, user is forced to manually renumber
his dives after doing a merge, unless the merged dives were those at
the list tail.
This patch try to manage the more usual cases, letting the user to deal
with those more complex, based on some assumptions:
1.- We are working on an time ordered list of type:
dive_table.nr ... 100 -- 101 -- 102 -- 103 -- 104 ...
dive_table.dives.number ... 234 -- 235 -- 236 -- 245 -- 246 ...
2.- It's unlikely to merge no consecutive dives, as merging is time
based.
3.- It's unlikely (although possible) to find consecutive dives with
no consecutive numbers.
4.- It would be rather bizarre to find that newer dive,of those to
merge, has lower number than older.
5.- It can be found that one (or both) dives to merge are zero
numbered.
6.- There is only need to renumber from merged dives in advance.
A variable, "factor", is fixed before reworking the dive table. This
number will be substracted from the original dive number.
If we are in point 5.- case, "factor" will be set to zero, meaning
that dive numbers will not change (if older dive is zero, merged one
will be numbered zero too and will let the user to manage this; if
newer dive is zero there won't be need of renumbering as following
dives will be correctly numbered, e.g. after splitting a dive which
is not at the tail of the table).
In most cases, "factor" *should* be set to 1.
While renumbering it can be found a dive with it's number set to zero,
this won't be changed and will remain zeroed to avoid negative
numbers. It, mostly, means that the user has pending work on his
dives.
I don't know why I've written such a big explanation for such a tiny
patch :-)
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This only deletes the fix on the mobile device, not on the server.
And it is really really slow. Re-reading the data from the settings just isn't
a smart way to do this.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
and rename it to DiveObjectHelper, since it should be an QObject
based class to make it easier on the QML, grantlee and widgets
side to display the dive's internal data.
each Q_PROPERTY defined in the DiveObjectHelper.h file
can be acessed directly via it's name.
So, if you are on a model that returns a dive, acess it's name
by dive.name
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
with the adittion of gpslistmodel/location, the libraries
qt-models had a direct dependency on subsurface-core, and
subsurface-core had a direct dependency on qt-models, this is
bad.
Moving a bit of code around I'v managed to clean this out, and
also to clear a bit of uneeded code (GpsTracker and gpsTracker where
basically the same thing.)
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
While the conversion of uint64_t to QVariant works fine with some Qt /
compiler combinations, it fails on others. Use Qt's type instead.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This is not the same as the existing download to apply the gps fixes to the
dive list. This allows us to download and store the GPS fixes in the settings.
I may end up changing things around to have a shared implementation for
downloading the GPS fixes, but for now this seemed easier.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
At the moment, if we have, say, dives ... 100, 101 and 102 and we merge 101 and
102, we get a list numbered ... 99, 100, 102. This is, probably, an
undesired behavior. The patch simple chooses lower of both dive numbers instead
of higher one.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
It seems that the first language in the list of languages isn't always the one
that specifies the country code. So try the first three to see which one is the
first to contain a country code.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If we loaded the dive list from cache and then try to figure out if the remote
repository had anything different, we were being super stupid if the SHA was
identical... we had already cleared the dive list by the time we decided that
we didn't need to load things. Granted, the model was still populated (oops),
but the backend data structure was cleared and accesses to it (e.g., when
drawing the profile) would cause things to crash.
The helper function duplicates some code, but trying to not duplicate the code
made things even harder to read.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
It makes much more sense to have this as a private member of the class instead
of a static in one of the functions.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Getting closer to being able to really edit / add dives in the mobile UI.
This works for manually added dives - needs a bit more thought for dives
downloaded from dive computers as we don't necessarily want to change the
maxdepth in conflict with the samples.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In commit 8c1cc4524d ("Don't reload identical data") I got a little
carried away. Before comparing SHAs we need to make sure that
a) this is a git repository at all
b) we have an actual SHA before we claim to have the data loaded
Reported-by: Paul-Erik Törrönen <poltsi@777-team.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Found by cppcheck. Minor memory leak if usb_reset fails
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This probably is a serious bug, found by cppcheck.
Original code had paren's in probably the wrong place!
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If we already have the same SHA loaded and no changes have been made to the
dive list then there is no point in loading the dives again.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This way we can check if the local cache is in sync with the remote without
always triggering a load of the dives from git.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If the QML UI needs the GPS information, we need a way to get to it.
I'm not convinced that having it as comma separated string is the best way to
go, but that's what I need for the Google API so that's what I picked for now.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
It no longer makes sense to lie about the version. If you are running a product
build, then the canonical version is the same version as the plain version used
to be. And in either case it makes much more sense to simply log the full
version information.
We used to have the differently styled versions for different OSs, but I don't
think this is needed anymore. Let's hope this doesn't go down as one of these
"famous last words" moments...
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Also fixes a capitalization error that prevented finding libssh2 in some
circumstances. And adds a missing include when building with libzip on Mac.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We need to calculate the offset based on the time of the dive - the mobile
version doesn't use displayed_dive. This way time stamps are now correct
all year round.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If we looking for dive details and are trying to guess the offset between
object_id and logfilenr, we need to treat logfilenr 0 as special - it
means we read past the end of the list of stored dives and need to walk
backwards.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Some backends support giving tank data for some, but not all models that
they support (and simply report no tanks for those models that don't
support this). The Suunto Vyper is one of the dive computers where this
happens and without this change we report angry red warnings after a
perfectly correct download.
So this changes the logic to only show that error if there actually were
tanks reported.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Adding pictures to the repository was a big mistake on my part. It's very
easy for the git repositories to reach a gigabyte and more making sync
times (and especially "first download" times) completely unreasonable.
This doesn't solve the problem for existing repositories (as the pictures
are already there, in the git history), but at least it prevents us from
storing more pictures out there.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Tank icons were shown at incorrect spots on the profile
when the DiveEventItem object held a pointer to a struct
event even after the struct event at that address had
been freed. When internalEvent is a pointer to freed
memory, internalEvent->time.seconds could have all kinds
of crazy values, which get used in member function
DiveEventItem::recalculatePos to place the tank at bad
x coordinates.
The DiveEventItem(s) no longer store a pointer to memory
that they do not own. This way, no matter how the path of
execution arrives into slot recalculatePos, we never need
fear that the DiveEventItem will dereference a garbage
pointer to a struct event.
Fixes#968
Signed-off-by: K. Heller <pestophagous@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
One user's debug log shows valid data, only not in the format we've seen
before (with the response starting with '{'). Instead he gets a repeat of
the second word in the response to processSync prepended to the expected
output. So let's skip the data until the first '{'.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If we already have an air temperature set, don't overwrite it with
potentially less accurate infromation from the first sample.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The runtime html table is printed only if printing
a verbatim diveplan is disabled. So the closing tags
should be printed only in that case.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This prepares for the smartrack converter webservice.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
"warning: "DC_VERSION" redefined" is thrown if a chain of
includes previously includes windows.h:
In file included from c:/bin/mingw/i686-w64-mingw32/include/windows.h:71:0,
from C:/bin/qt/5.5/mingw492_32/include/QtCore/qt_windows.h:63,
from C:/bin/qt/5.5/mingw492_32/include/QtGui/qopengl.h:43,
from C:/bin/qt/5.5/mingw492_32/include/QtQuick/qquickwindow.h:39,
from C:/bin/qt/5.5/mingw492_32/include/QtQuick/QQuickWindow:1,
from C:/dev/subsurface/subsurface-core/qt-gui.h:13,
from C:\dev\subsurface\subsurface-mobile-main.cpp:9:
and which on it's own includes wingdi.h which defines
"DC_VERSION 10" (windows printer stack related).
To solve the warning DC_VERSION is undefined in
subsurface-core/libdivecomputer.h.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
QDateTime::toTime_t() is misleading as it does not return
a C time_t type, but a 'unsigned int' or rather the Qt
'uint' typedef.
To prevent the warning we cast it to 'time_t' and to
comply with the 'lastTime' variable.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In theory this should only report a location service if this is a
satellite based service, but sadly geoclue appears to claim that there is
a satellite based service in my Linux VM - so I'm doubtful that this does
what the documentation says it does.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
While this is primarily something targeted at a mobile device, with many
of the 2 in 1 devices it is possible that the user might be running the
desktop version of Subsurface on a mobile device.
As a first step to make it possible to collect GPS fixes on such a device
we need to make the infrastructure to do so available in the desktop
application as well.
This still needs to be hooked up in the desktop UI.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In order to allow the backend to match account in multi user mode, it
needs to know if the requests are coming from the same instance of
Subsurface. Since I had to change the backend to add the ability to
retrieve a location service userid I added this capability at the same
time.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
When the user requests "dive.cylinders" from Grantlee HTML
we need to always put at least the default cylinder and mark
the description as "unknown" (same as other locations) if it's
not set (i.e. when the description pointer is NULL).
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The Dive helper class only picks the first cylinder and the total
weight. This patch adds the option to dump the cylinders and weights
as formatted lists (via cylinders() and weights()) or to retrieve
a specific cylinder or weight via (cylinder(index) and weight(index)).
Each cylinder and weight string contains detailed information:
cylinder:
- desc.
- pressure (+start/end)
- gasmix
- etc...
weight:
- desc.
- weight (in units e.g. kg)
If no description is found for a cylinder or weight the contents
for this particular unit is filled with EMPTY_DIVE_STRING ("--").
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The macro is used as a common replacer for the "--"
string when the Dive class members return no particular
information for a "struct dive" property.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The Dive::put_notes() does not handle HTML formatting or line
breaks properly. Apparently Grantlee supports HTML variables, but
the planned notes (which are HTML) look very bad when inserted in the
Grantlee template - e.g. the text is huge and the table box is cut
for some odd reason. I don't have a good solution for these issues
ATM; especially for the "table cell being cut part".
An important feature in the dive notes is to support line breaks.
This patch adds support for line breaks both in planned dive notes
and non-planned dive notes via the <br> tag. This makes the
planned dive notes look tolerable.
The next step would be to support the <br> tag, which has
to happen in the bundled templates them self.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fix obvious spelling mistakes in comments (and one error message).
Yes, this is trivial but I saw one while reviewing some of the code
and after that decided to run code through some tools.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
There is a bug on OSX where free() is called on non-allocated
memory in free_prefs(). Most of the preferences are not freed
in free_prefs() while copy_string() is used on them, so let's
not free() any pointers in free_prefs() and leave them
as one-time leaks.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
In add_plan_to_notes() the 'disclaimer' is set to the temporary
buffer 'buf'. By making 'buf' static, 'disclaimer' now points to a
persistent buffer.
Bug was reported as bad characters when printing the planner
deco text.
Reported-by: Stefan Fuchs <sfuchs@gmx.de>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Oops. I fixed the previous commit, tested the fix, and then forgot to
update the commit and instead pushed it out. That was dumb.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
But keep the Interface so it's still userfull to create a new
SocialNetwork when needed, but it will be part of the code,
and not a plugin.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Once again compile time enabled. I guess it would be nice to turn this
into a logfile (just like we have with the libdivecomputer backends).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
I user had a Uemis that had a dive log entry for a certain internal id but
no dive info for it. This appeared to be one of those dreaded dives when
the Uemis decides to start a dive at the end of a flight and then stays in
dive mode until it runs out of battery.
Anyway, if we see a number above and a number below, just give up and move
on.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
If every dive in a download block from the Uemis was deleted we kept
downloading that same block of dives. With this we remember how far we got
even if the dives ended up being deleted.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This drastically improves the time it takes to select a dive
with several pictures at the expense of longer startup and
bigger hash files.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
On the Mac the info on the download dialog isn't shown. So print it on
stderr as well when in verbose mode.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Since we can't forbit the plugins to upload more than just the
current dive, it's better to change the name of the call.
also add a stub to make sure it's calling the right method inside
the plugin.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
It appears that the default path we tried to use on Android since commit
80056278f7 ("android.cpp: update path retriaval scheme") didn't work -
so let's just go back to what we used to do as that was perfectly fine.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Subsurface-mobile doesn't have a window title with the name of our file
name at this point, so simply don't try to trigger the update.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This fixes the build for me against Qt 5.5. It seems Android is not
Linux anymore, but uses its own CMAKE_SYSTEM_NAME now, so in this case
we also want to compile android.cpp.
This change should be rather safe, since it catches a condition that was
not previously handled.
Signed-off-by: Sebastian Kügler <sebas@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This solves the root problem of most of the dpi-depdent sizing in the
mobile Android version.
When setting a custom font size, we circumvent Android's defaults, which
means that we end up setting the font size further down the road to get
readable fonts.
I suppose this was set in order to make the QWidget-based user interface
"work" on Android. Hard-coding a font size at this central point brings
more headache than needed, one could instead consider adding an #ifdef
Q_OS_ANDROID in main window.
Signed-off-by: Sebastian Kügler <sebas@kde.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This required a bit more untangling, but with this it seems we can build
subsurface-mobile again (at least on the desktop).
Interesting is the removal from inside the ImageDownloader of the call to
DivePictureModel::instance()->updateDivePictures() - which actually could
cause some interesting recursion issues. If it turns out we did indeed
need this, it needs to be re-architected.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
ruleritem.cpp throws an error about incomplete type
'struct gas_pressures'.
'struct gas_pressures' is defined in dive.h, so every header
that has usage of the type needs to include dive.h.
Such a header is profile.h which has 'struct gas_pressures pressures'
in 'struct plot_data', by including dive.h on top of profile.h
every source file (e.g. ruleritem.cpp) that includes profile.h will
now receive knowledge of a complete 'struct gas_pressures' type.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
'default_filename' is obtained from system_default_filename()
but system_default_filename() returns a static pointer
the HEAP memory of which is handled in main().
Remove the free() for 'default_filename' free_prefs()
to prevent a double free().
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The introduction of -std=c++11 breaks usage of M_PI in Mingw,
but technically M_PI is not standard C or C++.
Defining M_PI in units.h solves the issue.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Currently we need to copy manually the plugin dynamic library
to the /plugins folder.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The magic happens here: We are iterating over the plugins
and populating the main menu with all actions provided by
them. Currently we can't test this as we don't have a single
plugin. Next patch series of commits will be adding the
Facebook plugin.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This bit of code will try to load all plugins avaliable.
Now I need to port a Facebook plugin for this new system,
then I'll delete the old preferences widget.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This class is currently very small but the reason of existence
is to allow subsurface to be easily extendable via plugins.
The current type of plugin that I'm making is Social Network,
but another possibilities:
- Dive Simulation Algorithm
- Import/Export Filters
- Profile Overlays
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
The Social Network plugins need an interface file to describe
the expected behavior of it, this little header file will serve
for that.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Since we have now destkop and mobile versions, 'qt-ui' was a very
poor name choice for a folder that contains only destkop-enabled
widgets.
Also, move the graphicsview-common.h/cpp to subsurface-core because
it doesn't depend on qgraphicsview, it merely implements all the
colors that we use throughout Subsurface, and we will use colors on both
desktop and mobile versions
Same thing applies for metrics.h/cpp
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
And adapt a new CMakeLists.txt file for it. On the way I've also
found out that we where double-compilling a few files. I've also
set the subsurface-core as a include_path but that was just to
reduce the noise on this commit, since I plan to remove it from
the include path to make it obligatory to specify something like
include "subsurface-core/dive.h"
for the header files. Since the app is growing quite a bit we ended
up having a few different files with almost same name that did
similar things, I want to kill that (for instance Dive.h, dive.h,
PrintDive.h and such).
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>