digiKam
Loading...
Searching...
No Matches
thumbnailloadthread_p.h
Go to the documentation of this file.
1/* ============================================================
2 *
3 * This file is a part of digiKam project
4 * https://www.digikam.org
5 *
6 * Date : 2007-06-05
7 * Description : Thumbnail loading - private containers
8 *
9 * SPDX-FileCopyrightText: 2006-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10 * SPDX-FileCopyrightText: 2005-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
11 * SPDX-FileCopyrightText: 2015 by Mohamed_Anwer <m_dot_anwer at gmx dot com>
12 *
13 * SPDX-License-Identifier: GPL-2.0-or-later
14 *
15 * ============================================================ */
16
17#pragma once
18
19#include "thumbnailloadthread.h"
20
21// Qt includes
22
23#include <QApplication>
24#include <QMessageBox>
25#include <QEventLoop>
26#include <QPainter>
27#include <QHash>
28#include <QIcon>
29#include <QMimeType>
30#include <QMimeDatabase>
31
32// KDE includes
33
34#include <klocalizedstring.h>
35
36// Local includes
37
38#include "digikam_debug.h"
39#include "iccmanager.h"
40#include "iccprofile.h"
41#include "loadingcache.h"
42#include "thumbsdbaccess.h"
43#include "thumbnailsize.h"
44#include "thumbnailcreator.h"
45
46namespace Digikam
47{
48
49class Q_DECL_HIDDEN ThumbnailResult
50{
51
52public:
53
54 explicit ThumbnailResult(const LoadingDescription& description, const QImage& image)
55 : loadingDescription(description),
56 image (image)
57 {
58 }
59
61 QImage image;
62};
63
64// -------------------------------------------------------------------
65
67{
68public:
69
71
73 {
74 delete provider;
75 }
76
77public:
78
79 // Disable
82
83 bool firstThreadCreated = false;
84
85 ThumbnailCreator::StorageMethod storageMethod = ThumbnailCreator::FreeDesktopStandard;
86 ThumbnailInfoProvider* provider = nullptr;
87 IccProfile profile = IccProfile::sRGB();
88};
89
90// -------------------------------------------------------------------
91
92class Q_DECL_HIDDEN ThumbnailLoadThread::Private
93{
94
95public:
96
97 Private() = default;
98
99 bool wantPixmap = true;
100 bool highlight = true;
101 bool sendSurrogate = true;
102 bool notifiedForResults = false;
103
104 int size = ThumbnailSize::maxThumbsSize();
105
106 ThumbnailCreator* creator = nullptr;
107
108 QHash<QString, ThumbnailResult> collectedResults;
110
111 QList<LoadingDescription> lastDescriptions;
112
113public:
114
115 LoadingDescription createLoadingDescription(const ThumbnailIdentifier& identifier, int size, bool setLastDescription = true);
116 LoadingDescription createLoadingDescription(const ThumbnailIdentifier& identifier, int size,
117 const QRect& detailRect, bool setLastDescription = true);
118 bool checkDescription(const LoadingDescription& description);
119 QList<LoadingDescription> makeDescriptions(const QList<ThumbnailIdentifier>& identifiers, int size);
120 QList<LoadingDescription> makeDescriptions(const QList<QPair<ThumbnailIdentifier, QRect> >& idsAndRects, int size);
121 bool hasHighlightingBorder() const;
122 int pixmapSizeForThumbnailSize(int thumbnailSize) const;
123 int thumbnailSizeForPixmapSize(int pixmapSize) const;
124};
125
126// --- ThumbnailImageCatcher ---------------------------------------------------------
127
128class Q_DECL_HIDDEN ThumbnailImageCatcher::Private
129{
130
131public:
132
140
141public:
142
143 class Q_DECL_HIDDEN CatcherResult
144 {
145 public:
146
148 : description(d)
149 {
150 }
151
152 CatcherResult(const LoadingDescription& d, const QImage& image)
153 : image (image),
154 description(d),
155 received (true)
156 {
157 }
158
159 public:
160
161 QImage image;
163 bool received = false;
164 };
165
166public:
167
168 Private() = default;
169
170 void reset();
171 void harvest(const LoadingDescription& description, const QImage& image);
172
173public:
174
175 CatcherState state = Inactive;
176
177 bool active = true;
178 ThumbnailLoadThread* thread = nullptr;
179 QList<Private::CatcherResult> tasks;
180 QList<Private::CatcherResult> intermediate;
181
182 QMutex mutex;
183 QWaitCondition condVar;
184};
185
186} // namespace Digikam
Definition iccprofile.h:33
Definition loadingdescription.h:35
Definition thumbnailcreator.h:41
StorageMethod
Definition thumbnailcreator.h:45
Definition thumbnailinfo.h:31
Definition thumbnailloadthread_p.h:144
QImage image
Definition thumbnailloadthread_p.h:161
CatcherResult(const LoadingDescription &d, const QImage &image)
Definition thumbnailloadthread_p.h:152
LoadingDescription description
Definition thumbnailloadthread_p.h:162
CatcherResult(const LoadingDescription &d)
Definition thumbnailloadthread_p.h:147
Definition thumbnailloadthread_p.h:129
QMutex mutex
Definition thumbnailloadthread_p.h:182
QList< Private::CatcherResult > intermediate
Definition thumbnailloadthread_p.h:180
CatcherState
Definition thumbnailloadthread_p.h:134
@ Accepting
Definition thumbnailloadthread_p.h:136
@ Waiting
Definition thumbnailloadthread_p.h:137
@ Inactive
Definition thumbnailloadthread_p.h:135
QList< Private::CatcherResult > tasks
Definition thumbnailloadthread_p.h:179
QWaitCondition condVar
Definition thumbnailloadthread_p.h:183
Definition thumbnailloadthread.h:290
Definition thumbnailinfo.h:105
Definition thumbnailloadthread_p.h:67
~ThumbnailLoadThreadStaticPriv()
Definition thumbnailloadthread_p.h:72
ThumbnailLoadThreadStaticPriv & operator=(const ThumbnailLoadThreadStaticPriv &)=delete
ThumbnailLoadThreadStaticPriv(const ThumbnailLoadThreadStaticPriv &)=delete
Definition thumbnailloadthread_p.h:93
QMutex resultsMutex
Definition thumbnailloadthread_p.h:109
QList< LoadingDescription > lastDescriptions
Definition thumbnailloadthread_p.h:111
QHash< QString, ThumbnailResult > collectedResults
Definition thumbnailloadthread_p.h:108
Definition thumbnailloadthread.h:36
Definition thumbnailloadthread_p.h:50
ThumbnailResult(const LoadingDescription &description, const QImage &image)
Definition thumbnailloadthread_p.h:54
QImage image
Definition thumbnailloadthread_p.h:61
LoadingDescription loadingDescription
Definition thumbnailloadthread_p.h:60
Definition datefolderview.cpp:34