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>
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>
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>
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>
Lots and lots and lots of header files were being included without being
needed. This attempts to clean some of that crud up.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This prevents a warning caused by -Waddress, that the address
of 'displayed_dive' will always be defined.
Exact macro variant suggested by Dirk.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
We had pointers to data structures on the stack which we frequently
reallocated. These data structure contain basically a filename and an
offset. We then create a hash of the pointers to those datastructures with
the filename being the key. And then we passed those pointers around
through a Qt model(!!!) only in order to then later look up by filename
what the offset might be.
I am at a loss for words for the lunacy behind this design.
How about we just remember the offsets and pass the integers around?
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Added the remove_picture functionality, with code
shamelessy stolen from remove_event, and hoock it
up with the interface.
Fixes#650
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Q_FOREACH will expand and already creates a copy of the
contained container, so this is just a waste of cpu cycles
and also increases a tiny bit the memory consumption.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Instead of passing in a divenr of -1 to make it clear things this changes
things to use an options "clear" flag.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
No point in scaling them every time the user looks at the dive. Over time
this may waste some memory (especially if people have a ton of pictures
and let the process run a very long time). For now I won't worry about
that.
Fixes#577
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Too much noise on the headers, this commit remove uneeded
headers when they are uneeded.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Changes to hold a pointer to the struct picture on the model, so we can
use it to determine the correct positioning of the image on the profile.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This will make referencing it from a few places more easy.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
QPixmap cannot be accessed from outside the Main thread, but QImage can.
so change that. Also, make the Photo widget display in Icon mode.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Small changes in the model to display the pictures of the dives.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This method should give the correct data to all views that the model is
connected to.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Update the picture model to use the new picture function calls, wich made
the code smaller and easyer to understand. AND as a plus, it doesn't use
the magic 123 identifier for pictures. AND it correctly adds images
without timestamp to the list.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This code adds threaded processing of a batch of images. It uses the
QtConcurrent implementations to call a function repeteadly using
MAX_THREADS (Qt gets that for us) and returns a list of it.
This call is blocking, so while the pixmaps are being scaled in threads,
it will wait for all scalling to be done.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Call that method from the mainWindow when the dive changes.
The updateDivePictures walks around the events of the first dc (since all
pictures are distributed allong all dive computers) to get the events of
type '123' (I wonder if there's not a better way to save pictures on the
dive, like an linked list of char* named pictures.)
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Currently this does nothing, but since "dive photos" can also mean
photos that were taken during the trip to the dive, some of them
will not be visible on the profile. this currently shows nothing,
because I didn't work out the Model bits yet.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This has a few classes: the model is the list of pictures for the current
dive, the delegate is how this pictures will be displayed on screen, the
widget is the collection of delegates, and the DivePictureThumbnailThread
is a worker-thread to generate the thumbnails so the UI will not freeze.
[Dirk Hohndel: added the new files to subsurface.pro]
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>