Commit graph

18 commits

Author SHA1 Message Date
Tomaz Canabrava
ffc0c8ee99 Move DivePictureModel to qt-models
This class will surely be used on the mobile version, and it was very
tangled inside divepicturewidget.

Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2015-05-29 14:14:27 -07:00
Robert C. Helling
6b3b50cc2f Load remote images
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-16 12:42:36 -07:00
Dirk Hohndel
1e3700c11f Don't call UI functions from helper code
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-03-10 10:22:34 -07:00
Robert C. Helling
b02bf002a6 Add hashes to images
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-27 06:29:44 +01:00
Dirk Hohndel
4583cd8e09 Picture handling: cleaning up the mess
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-08-05 12:37:14 -07:00
Tomaz Canabrava
3b9bceacb6 Implement the functionality of remove_picture.
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-30 12:52:31 -07:00
Dirk Hohndel
ce47683de8 UI restructure: always display pictures for displayed dive
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-03 09:37:55 -07:00
Sergey Starosek
d1511aa968 Emit signal on photo double-click
Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-27 06:56:16 -07:00
Tomaz Canabrava
89816f64c2 Headers cleanup.
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-26 15:47:02 -07:00
Dirk Hohndel
1fec6453a2 Another futile attempt to keep whitespace consistent
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-06-03 16:49:56 -07:00
Tomaz Canabrava
b1847f9ebb Also hold a pointer to the struct picture on the model.
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-03 16:46:03 -07:00
Tomaz Canabrava
eb24d90c8e Add a static 'instance()' member for the Photos model.
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-03 16:40:01 -07:00
Tomaz Canabrava
dbdff1c0af Change from QPixmap to QImage due to thread issues.
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-03 00:06:42 -07:00
Tomaz Canabrava
3595ad0294 Make the new picture widget display the pictures.
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-03 00:05:24 -07:00
Tomaz Canabrava
f1d67cfbac Add threaded processing of image pixmaps
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-01 15:54:29 -07:00
Tomaz Canabrava
e140703d34 Add a method to update the dive pictures on the model.
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-01 15:54:29 -07:00
Tomaz Canabrava
4b520a8fbc Add a new widget on the main tab: Pictures.
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-01 15:54:29 -07:00
Tomaz Canabrava
1c34c831a4 Add stub for a widget to show the dive pictures.
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>
2014-06-01 15:54:07 -07:00