aboutsummaryrefslogtreecommitdiffstats
path: root/core/imagedownloader.h
AgeCommit message (Collapse)Author
2018-06-13Dive pictures: Make failure of loading images less noisyGravatar Berthold Stoeger
For debug reasons, failure to load the original image was spilled to the console, even if the local file was then found. Only print a message, when also the local image failed loading. This needed a bit of code reshuffling. To know when to print a failed-loading message, the URL is now checked at the Thumbnailer level, not the ImageDownloader level. The ImageDownloader is passed the URL and the original filename (if different). The image is loaded from the URL, but the signals send the original filename, so that the thumbnail can be associated to the proper image. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-27Dive pictures: give user option to recalculate thumbnailsGravatar Berthold Stoeger
Even though hashes of image contents are calculated, the hashes are not compared to actual file contents in routine-operation. Therefore give the user the option to recalculate thumbnails, should they have edited the picture. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-26Cleanup: remove code related to pictures in the cloud-repositoryGravatar Berthold Stoeger
Storing pictures in the cloud never came to be, so remove the code. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-18core: solved PictureEntry defined as class and struct.Gravatar jan Iversen
PictureEntry was defined as class in imagedownloader.h and as struct in divepicturemodel.h A class has a vptr in front, so the difference is real at least for the clang compiler. Signed-off-by: Jan Iversen <jani@apache.org>
2018-05-16Dive pictures: Don't enter infinity loop on invalid picturesGravatar Berthold Stoeger
The recently committed refactoring of the dive-picture code introduced a severe bug: If an image couldn't be loaded from disk owing to an invalid file, the filename was interpreted as an url and loaded in the background. This succeeded, because the file actually exists. After download, the file would then still be invalid and the whole thing restarted, leading to an infinity loop. To fix this, do two things: 1) Don't even try to download local files. 2) If interpreting a downloaded file fails, don't try the downloading business again. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13Dive pictures: refactor image downloaderGravatar Berthold Stoeger
Instead of generating one ImageDownloader object per image to be downloaded and running every image download in a separate worker thread, use one global ImageDownloader object owned by the UI thread. The images are downloaded using event based IO (as probably was the intention of the QNetworkManager class). User-visible change: after download from the internet, the thumbnail is shown without having to change dives. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13Dive pictures: Move thumbnail-size to Thumbnailer classGravatar Berthold Stoeger
The size of the to-be-created thumbnails was passed from DivePictureModel to Thumbnailer. This became more and more bothersome, because the size had to be stored with the request. Calling from Thumbnailer into DivePictureModel was not an option, since this is not linked to all tests. Therefore, move these functions to the Thumbnailer class. Since the maximum thumbnail size is now known to the thumbnailer, the dummy and failure images can be precalculated, which makes switching between dives faster. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13Dive pictures: Introduce thumbnailer classGravatar Berthold Stoeger
Create a new class, which performs all thumbnailing code. This is mostly code reshuffling. Thumbnails are extracted either from a cache or thumbnail calculation is started in a worker thread. Since getHashedImage() is called from a worker thread it makes no sense to call subfunctions in yet another worker thread. Remove these calls. In contrast to the previous code, on error the background thread produces a failure image, but it is not yet shown. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13Dive pictures: replace picture struct by QStringGravatar Berthold Stoeger
In imagedownloader.cpp the only thing we need from the picture struct is the filename. Therefore, use QStrings instead of the picture struct. This simplifies memory management. Remove the clone_picture() function, which is not needed anymore. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-05-13Dive pictures: turn SHashedImage class into getHashedImage() functionGravatar Berthold Stoeger
SHashedImage was a subclass of QImage, which fetched the image according to the filename hashes. Turn this into a function, as this is much more idiomatic and flexible. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-04-19Coding style: remove superfluous semicolonsGravatar Berthold Stoeger
Remove a semicolon after Q_OBJECT and a few others after the closing braces of while loops. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-04-01Debug: Error reporting for SHashedImage loadingGravatar Berthold Stoeger
Overwrite QImage::load() in SHashedImage so that we can perform better error reporting. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05core/imagedownloader.cpp: remove recursionGravatar Berthold Stoeger
If loading from hash failed in the saveImage() slot(!) it would recurse into loadFromUrl(), which would generate a new network reply. Very scary and a (small) wonder that it worked. Let's try to make this all more explicit. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-03-05core/imagedownloader.cpp: Make the manager object local to load()Gravatar Berthold Stoeger
The QNetworkAccessManager is only used in the load() function. No point in it being a subobject. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-07Cleanup: remove unused typedefGravatar Berthold Stoeger
The type SHashedFilename defined in core/imagedownloader.h was not used anywhere. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-02-07Cleanup: Make local helpers and variables of static linkageGravatar Berthold Stoeger
In core/imagedownloader.cpp the helpers cloudImageUrl() and loadPicture() are made of static linkage. The global variables queuedPictures and pictureQueueMutex were moved into the loadPicture() function, because they are used only there. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2017-04-29Add SPDX header to remaining core filesGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2016-04-04Move subsurface-core to core and qt-mobile to mobile-widgetsGravatar Dirk Hohndel
Having subsurface-core as a directory name really messes with autocomplete and is obviously redundant. Simmilarly, qt-mobile caused an autocomplete conflict and also was inconsistent with the desktop-widget name for the directory containing the "other" UI. And while cleaning up the resulting change in the path name for include files, I decided to clean up those even more to make them consistent overall. This could have been handled in more commits, but since this requires a make clean before the build, it seemed more sensible to do it all in one. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>