aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/divepicturewidget.cpp
AgeCommit message (Collapse)Author
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-03-17Create picture cache directory if neededGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-03-16Use QUrl::fromUserInput for image filesGravatar Robert C. Helling
... as suggested by Thiago. 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-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-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-01-17Clean up the header filesGravatar Dirk Hohndel
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>
2014-12-09Hide any pictures shown when closing divelogGravatar Dirk Hohndel
Fixes #776 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-10-28dive.h: add a variant of FOR_EACH_PICTUREGravatar Lubomir I. Ivanov
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>
2014-10-19Resolution-indepent dive picturesGravatar Giuseppe Bilotta
Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-08-05Picture handling: cleaning up the messGravatar Dirk Hohndel
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>
2014-07-30Mark divelist changed after removing a pictureGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-30Implement the functionality of remove_picture.Gravatar Tomaz Canabrava
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>
2014-07-15Do not create a backup for Q_FOREACH containerGravatar Tomaz Canabrava
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>
2014-07-03UI restructure: updateDiveInfo displays displayed_diveGravatar Dirk Hohndel
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>
2014-07-03UI restructure: always display pictures for displayed diveGravatar Dirk Hohndel
The only time this is ever wrong is in print mode, so let's never show pictures in print mode. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-07-01Implement a cache for the scaled imagesGravatar Dirk Hohndel
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>
2014-06-27Emit signal on photo double-clickGravatar Sergey Starosek
Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-26Headers cleanup.Gravatar Tomaz Canabrava
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>
2014-06-13Prevent using uninitialized variableGravatar Dirk Hohndel
numberOfPictures was be read before it is written. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03Another futile attempt to keep whitespace consistentGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03Also hold a pointer to the struct picture on the model.Gravatar Tomaz Canabrava
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>
2014-06-03Add a static 'instance()' member for the Photos model.Gravatar Tomaz Canabrava
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>
2014-06-03Change from QPixmap to QImage due to thread issues.Gravatar Tomaz Canabrava
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>
2014-06-03Make the new picture widget display the pictures.Gravatar Tomaz Canabrava
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>
2014-06-03Add the data() method of the Picture Model.Gravatar Tomaz Canabrava
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>
2014-06-03Update the picture model to use the new picture function calls.Gravatar Tomaz Canabrava
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>
2014-06-01Add threaded processing of image pixmapsGravatar Tomaz Canabrava
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>
2014-06-01Add a method to update the dive pictures on the model.Gravatar Tomaz Canabrava
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>
2014-06-01Add a new widget on the main tab: Pictures.Gravatar Tomaz Canabrava
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>
2014-06-01Add stub for a widget to show the dive pictures.Gravatar Tomaz Canabrava
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>