aboutsummaryrefslogtreecommitdiffstats
path: root/qthelper.cpp
AgeCommit message (Collapse)Author
2015-09-17Hash images upon loading divelog file rather than when loading imageGravatar Robert C. Helling
Up to now, we only computed hashes of images upon actually displaying the images. With this patch we start to compute hashes once we load the xml or from git. This happens in the background, so the user should note an increased CPU load only once per divelog. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-09qthelper.cpp: don't hardcode the Dive m_duration as minutesGravatar Lubomir I. Ivanov
get_dive_duration_string() should be used in a similiar way to socialnetworks.cpp so that the Dive::put_duration() method sets the variable in the h:min format. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-09-09qthelper.cpp: use timeFormat and dateFormat for the Dive classGravatar Lubomir I. Ivanov
The Dive class has a method which sets the m_time and m_date members but it uses a custom format. By using the static dateFormat and timeFormat variables this helper class now uses the same date and time format as in the dive list. Fixes #920 Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-31QML UI: Remove unneeded MobileDive classGravatar Grace Karanja
The MobileDive class in divelistmodel.h is a duplication of the Dive class in templatelayout.h. This patch moves the Dive to the qthelper file. [Dirk Hohndel: merged with upstream master - let's hope I didn't mess anything up] Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-31Remove unneeded includesGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-22Continue to separate logic code from UI codeGravatar Dirk Hohndel
We don't want to call into the MainWindow from C code. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-18Replace global in_planner variable by helper functionGravatar Robert C. Helling
as promised earlier Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-08-03Make debugging cleanerGravatar Robert C. Helling
Don't try to connect the globe when NOMARBLE is active. Check exisistance before trying to open an image file. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-25Move initialization of preferences to helper functionGravatar Dirk Hohndel
This way we can read the preferences without instantiating the PreferencesDialog class. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-07-14Location completer: give distance if knownGravatar Dirk Hohndel
If both the displayed dive and the dive site which is shown as a potential completion have a GPS fix, indicate the distance. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-22Cloud storage: correctly store pictures even if they weren't shown beforeGravatar Dirk Hohndel
We could end up in a situation where the hash for a picture hadn't been recorded yet and then the lookup to make sure that we find the correct file actually got us nothing. Now we make sure that the picture is in the hash table before looking up the file location and before creating the name of the blob that we store in git. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21HTML export: need to work harder to find the picturesGravatar Dirk Hohndel
Simply looking at the filename in the picture structure isn't enough (now, arguably one might say that it should be and that that data structure should be updated, but that's not how other parts of Subsurface have implemented things so I don't want to break that assumption here). So instead we look up where the pictures actually was loaded from and then copy that file into the right location. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21Git storage: implement picture loading from gitGravatar Dirk Hohndel
The interesting challenge here is what to do with the picture data stored in the git repository. If the pictures are already in the file system (for example because Subsurface is runnin on the same machine that this data file was saved on) it would be silly to extract them again every time the dive log is opened. So instead we try to figure out if the pictures can be located and only create local copies of them if that isn't the case. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21Add helper function to return local filename of picture as C stringGravatar Dirk Hohndel
This way we can actually find the picture that we are showing. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-21Make helper function deal with files that don't existGravatar Dirk Hohndel
Ignoring when you can't open a file and happily hashing its contents seems wrong. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-17Remove some include files from qthelper.cppGravatar Dirk Hohndel
We keep forgetting to remove include files after modifying the code in ways that no longer requires them. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-16Fix silly typoGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-16Move checking the cloud connection into its own filesGravatar Dirk Hohndel
This isn't UI related and shouldn't have been in a file full of UI functionality. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-16Code cleanup: implement window title update via signalGravatar Dirk Hohndel
This seems quite convoluted to me but I can't seem to make a more straight forward implementation work. The idea is that core code should never directly call into the UI. So instead the core code (this is C code) calls a helper function. That helper function calls a member function of a class which in return emits a signal. The UI code connects to that signal and acts accordingly when it is received. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-15Cloud storage: use preference member instead of hard coded stringsGravatar Dirk Hohndel
This creates the basis to allow other backends to be used with the cloud storage infrastructure. So far this should all just transparently continue to work. A user would have to manually add the cloud_base_url entry to the CloudStorage section in their config file in order to use a different backend server. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13system_default_directory() is broken with Qt 5.4Gravatar Dirk Hohndel
So for now just keep using the same function as we use with earlier versions of Qt5 as that seems to work. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13Add helper function to create a directoryGravatar Dirk Hohndel
Yes, this could easily done from the C code. But this seems just so much easier and I don't have to worry about the oddities of Windows and all that. I'm lazy. So sue me. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-13Don't show an error if you fail to open the cloud storageGravatar Dirk Hohndel
The lower level functions will already report that things didn't connect successfully, no reason to repeat it here (which then exposes the git URL). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-12Indicate that there are unsaved changes with a '*' in the window titleGravatar Dirk Hohndel
This seems to be a fairly common way to indicate this property. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-12Cloud storage: check connection before connectingGravatar Dirk Hohndel
libgit2 takes forever (a minute or so) to figure out that it can't connect to a remote server. So if we are using https as connection protocol, quickly check utilizing RFCs 2324/7168 to make sure we can reach the cloud server (and not some captive portal or something). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-12Cloud storage: Setup http proxy for git connectionGravatar Dirk Hohndel
At the time of this commit support for this feature has not landed in upstream libgit2, yet (but there is a pull request). Yet supporting this here doesn't appear to cause any issue with older versions of libgit2, either, so the http proxy support will simply not work when enabled and a version of libgit2 that's too old is used. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-09Cloud storage: implement confirmation of email address via PINGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-06-01Move helper function to the appropriate fileGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-29Move WeightModel to qt-modelsGravatar Tomaz Canabrava
One more step to make it easyer to port the app to Mobile. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-29Move DivePlannerModel and CylinderModel to qt-modelsGravatar Tomaz Canabrava
Still trying to make it easier for the Mobile Port: This patch is a bit bigger than I hopped, but it was the smallest that I could get. A lot of TODO items where added where I broke the code because the current implementation would break the QML implementtion on the designer. I'll most probably fix those myself when I finish the transition to the models to the new folder. I only moved both models at once because there's an interdependency between them (seems inevitable, tough, but I'll take a better look at it later). Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-26Allow a comma in decimal GPS coordinatesGravatar Robert C. Helling
this is the format used by Google maps and thus this... Fixes #875 Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-24Remove support for QT4 (part 3)Gravatar Tomaz Canabrava
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-20Add option to display GPS coordinates as decimalsGravatar Robert C. Helling
This adds a field to the units preferences to have GPS coordinates show as decimals (as for example Google maps does it). Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-24Allow images to be added via the webGravatar Robert C. Helling
This adds a new divelist context menu entry which asks for a URL. The file is retrieved and if it is an image it is added to the cache and the url is associated to dives as with local files. NB this currently only works with URLs pointing directly to images. But it should not be too hard to add the possibility to add a direction via an html file and its image tags. To test: open dives/test43.xml and delete the image and then add the URL http://euve10195.vserver.de/~robert/wreck.jpg Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-04-24Cleaning up variable names in image loadingGravatar Robert C. Helling
Use more explicit variabel names and make the get timestamp function actually return the timestamp rather than getting a pointer argument Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-30Protect writing to image hashes with a mutexGravatar Robert C. Helling
Hopefully... Fixes #861 Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-16Load remote imagesGravatar Robert C. Helling
When loading an image by filename and by hash fails, try to interpret the filename as URL and download the image. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-15Refactored image timestamp checking.Gravatar Jan Darowski
Seperated getting image timestamp from picture_load_exif_data() and ShiftImageTimesDialog::syncCameraClicked() into picture_get_timestamp() and seperated checking timestamp from dive_create_picture() to dive_check_picture_time(). Signed-off-by: Jan Darowski <jan.darowski@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-14Provide useful warning when we can't find an XSLT fileGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-10Don't call UI functions from helper codeGravatar Dirk Hohndel
This may seem much more complicated but actually is much cleaner. Add each thread we start to the list of future results and add a new UI function that updates the UI once all of the threads have finished. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-27UI to learn hashes of local image filesGravatar Robert C. Helling
This addes a menu entry for the user to select a directory that is recursively traversed to look for image files and compute the hashes of those images (for those images to be available to be displayed in dives according to their hash values). This traversal and hash computation happens in and independend thread and so far the only feedback to the user is that upon completion the dispayed images are updated. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-27Add hashes to imagesGravatar Robert C. Helling
Upon successfull reading an image file, this computes a SHA1 hash of the image and saves it with the picture tag in the log file. When a file is not successfully loaded (for example because the log was created on a different computer) we look up the hash in a dictionary that maps hashes to local file names. That dictionary (actually two for both directions), is loaded on startup and saved upon destruction of the main window. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-24Fixed cmake build.Gravatar Patrick Valsecchi
Non parallel build was broken because qthelper.cpp was depending indirectly on a QT generated file and no cmake dependency was enforcing the file to be generated before. I've removed the not needed #include that was introducing this dependency. In cmake, {FOO STREQUAL ""} is TRUE only if FOO is defined and empty. Fixed a couple of bad usages. Made the required libraries actually required in cmake. From ef5ab90f258c5754d3022a023c28050cbafed3d5 Mon Sep 17 00:00:00 2001 From: Patrick Valsecchi <patrick@thus.ch> Date: Tue, 24 Feb 2015 08:38:49 +0100 Subject: [PATCH 1/2] Fixed cmake build. Non parallel build was broken because qthelper.cpp was depending indirectly on a QT generated file and no cmake dependency was enforcing the file to be generated before. I've removed the not needed #include that was introducing this dependency. In cmake, {FOO STREQUAL ""} is TRUE only if FOO is defined and empty. Fixed a couple of bad usages. Made the required libraries actually required in cmake. Signed-off-by: Patrick Valsecchi <patrick@thus.ch> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-23Move helper functions aroundGravatar Dirk Hohndel
We had a ton of helper functions in qt-gui.cpp which really didn't make much sense. So I moved them all into qthelper.cpp. Also moved the UserAgent helper that didn't belong in the UpdateHandler to begin with - that's a generic helper used in many places... With this we can successfully build using cmake again. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-23Add support for more GPS coordinate formats.Gravatar Patrick Valsecchi
As requested in the user forum and in the mailing list, now support: - 46.473881 6.784696 (format used in XML files) - 48 51.491n 2 17.677e I was not able to handle the XML format in a generic way without making the code too ugly. So I've added an exception. Signed-off-by: Patrick Valsecchi <patrick@thus.ch> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-15qthelper.cpp: use QStandardPaths::DataLocation for older QtGravatar Lubomir I. Ivanov
system_default_directory(): QStandardPaths::AppDataLocation was introduced in Qt 5.4. For older versions we use the deprecated ::DataLocation. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-15Add 'system_default_directory()' helper functionGravatar Linus Torvalds
This is just a extern "C" wrapper around QStandardPaths::AppDataLocation, while also making sure the entry exists. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-14Proof of concept for reverse geo locationGravatar Dirk Hohndel
When reading a pre-v3 XML file, we now do reverse geo lookups on the GPS coordinates and add the country to the dive site notes. Eventually this wants to be a tag (once we implement tags for dive sites). This is going to add quite a bit of delay when people open a V2 XML file - depending on how many distinct GPS fixes they have. In my case with 127 GPS fixes it took about 20 seconds to open the file... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-14Use C API for printGPSCoordsGravatar Dirk Hohndel
This way we can call this helper from both C and C++ code. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-02-12Remove coordinates from main tabGravatar Dirk Hohndel
It seems to make sense to only have them on the dive site screen. For the main UI they were redundant (we have the map) and not all that useful. The only time people would want them is if they wanted to manually add GPS coordinates for a dive, but that should now be done via the dive site UI. There are a couple of FIXMEs in the code and a few code blocks that have been commented out as they will be needed in one form or another once this GPS handling is done on the dive site UI, which right now it is NOT. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>