digiKam
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  * Copyright (C) 2006-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10  * Copyright (C) 2005-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  * Copyright (C) 2015 by Mohamed_Anwer <m_dot_anwer at gmx dot com>
12  *
13  * This program is free software; you can redistribute it
14  * and/or modify it under the terms of the GNU General
15  * Public License as published by the Free Software Foundation;
16  * either version 2, or (at your option)
17  * any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * ============================================================ */
25 
26 #ifndef DIGIKAM_THUMB_NAIL_LOAD_THREAD_P_H
27 #define DIGIKAM_THUMB_NAIL_LOAD_THREAD_P_H
28 
29 #include "thumbnailloadthread.h"
30 
31 // Qt includes
32 
33 #include <QApplication>
34 #include <QMessageBox>
35 #include <QEventLoop>
36 #include <QPainter>
37 #include <QHash>
38 #include <QIcon>
39 #include <QMimeType>
40 #include <QMimeDatabase>
41 
42 // KDE includes
43 
44 #include <klocalizedstring.h>
45 
46 // Local includes
47 
48 #include "digikam_debug.h"
49 #include "iccmanager.h"
50 #include "iccprofile.h"
51 #include "loadingcache.h"
52 #include "thumbsdbaccess.h"
53 #include "thumbnailsize.h"
54 #include "thumbnailcreator.h"
55 
56 namespace Digikam
57 {
58 
59 class Q_DECL_HIDDEN ThumbnailResult
60 {
61 
62 public:
63 
64  explicit ThumbnailResult(const LoadingDescription& description, const QImage& image)
65  : loadingDescription(description),
66  image (image)
67  {
68  }
69 
71  QImage image;
72 };
73 
74 // -------------------------------------------------------------------
75 
76 class Q_DECL_HIDDEN ThumbnailLoadThreadStaticPriv
77 {
78 public:
79 
81  : firstThreadCreated (false),
82  storageMethod (ThumbnailCreator::FreeDesktopStandard),
83  provider (nullptr),
84  profile (IccProfile::sRGB())
85  {
86  }
87 
89  {
90  delete provider;
91  }
92 
93 public:
94 
96 
100 };
101 
102 // -------------------------------------------------------------------
103 
104 class Q_DECL_HIDDEN ThumbnailLoadThread::Private
105 {
106 
107 public:
108 
109  explicit Private()
110  : wantPixmap (true),
111  highlight (true),
112  sendSurrogate (true),
113  notifiedForResults (false),
114  size (ThumbnailSize::maxThumbsSize()),
115  creator (nullptr)
116  {
117  }
118 
120  bool highlight;
123 
124  int size;
125 
127 
128  QHash<QString, ThumbnailResult> collectedResults;
129  QMutex resultsMutex;
130 
132 
133 public:
134 
135  LoadingDescription createLoadingDescription(const ThumbnailIdentifier& identifier, int size, bool setLastDescription = true);
136  LoadingDescription createLoadingDescription(const ThumbnailIdentifier& identifier, int size,
137  const QRect& detailRect, bool setLastDescription = true);
138  bool checkDescription(const LoadingDescription& description);
139  QList<LoadingDescription> makeDescriptions(const QList<ThumbnailIdentifier>& identifiers, int size);
140  QList<LoadingDescription> makeDescriptions(const QList<QPair<ThumbnailIdentifier, QRect> >& idsAndRects, int size);
141  bool hasHighlightingBorder() const;
142  int pixmapSizeForThumbnailSize(int thumbnailSize) const;
143  int thumbnailSizeForPixmapSize(int pixmapSize) const;
144 };
145 
146 // --- ThumbnailImageCatcher ---------------------------------------------------------
147 
148 class Q_DECL_HIDDEN ThumbnailImageCatcher::Private
149 {
150 
151 public:
152 
154  {
158  Quitting
159  };
160 
161 public:
162 
163  class Q_DECL_HIDDEN CatcherResult
164  {
165  public:
166 
168  : description(d),
169  received (false)
170  {
171  }
172 
173  CatcherResult(const LoadingDescription& d, const QImage& image)
174  : image (image),
175  description(d),
176  received (true)
177  {
178  }
179 
180  public:
181 
182  QImage image;
184  bool received;
185  };
186 
187 public:
188 
189  explicit Private()
190  : state (Inactive),
191  active(true),
192  thread(nullptr)
193  {
194  }
195 
196  void reset();
197  void harvest(const LoadingDescription& description, const QImage& image);
198 
199 public:
200 
202 
203  bool active;
207 
208  QMutex mutex;
209  QWaitCondition condVar;
210 };
211 
212 } // namespace Digikam
213 
214 #endif // DIGIKAM_THUMB_NAIL_LOAD_THREAD_P_H
Definition: iccprofile.h:43
Definition: loadingdescription.h:45
Definition: thumbnailcreator.h:51
StorageMethod
Definition: thumbnailcreator.h:55
Definition: thumbnailinfo.h:40
Definition: thumbnailloadthread_p.h:164
bool received
Definition: thumbnailloadthread_p.h:184
QImage image
Definition: thumbnailloadthread_p.h:182
CatcherResult(const LoadingDescription &d, const QImage &image)
Definition: thumbnailloadthread_p.h:173
LoadingDescription description
Definition: thumbnailloadthread_p.h:183
CatcherResult(const LoadingDescription &d)
Definition: thumbnailloadthread_p.h:167
Definition: thumbnailloadthread_p.h:149
QMutex mutex
Definition: thumbnailloadthread_p.h:208
bool active
Definition: thumbnailloadthread_p.h:203
ThumbnailLoadThread * thread
Definition: thumbnailloadthread_p.h:204
QList< Private::CatcherResult > intermediate
Definition: thumbnailloadthread_p.h:206
CatcherState
Definition: thumbnailloadthread_p.h:154
@ Accepting
Definition: thumbnailloadthread_p.h:156
@ Waiting
Definition: thumbnailloadthread_p.h:157
@ Inactive
Definition: thumbnailloadthread_p.h:155
CatcherState state
Definition: thumbnailloadthread_p.h:201
Private()
Definition: thumbnailloadthread_p.h:189
QList< Private::CatcherResult > tasks
Definition: thumbnailloadthread_p.h:205
QWaitCondition condVar
Definition: thumbnailloadthread_p.h:209
Definition: thumbnailloadthread.h:283
Definition: thumbnailinfo.h:112
Definition: thumbnailloadthread_p.h:77
ThumbnailLoadThreadStaticPriv()
Definition: thumbnailloadthread_p.h:80
~ThumbnailLoadThreadStaticPriv()
Definition: thumbnailloadthread_p.h:88
IccProfile profile
Definition: thumbnailloadthread_p.h:99
bool firstThreadCreated
Definition: thumbnailloadthread_p.h:95
ThumbnailCreator::StorageMethod storageMethod
Definition: thumbnailloadthread_p.h:97
ThumbnailInfoProvider * provider
Definition: thumbnailloadthread_p.h:98
Definition: thumbnailloadthread_p.h:105
bool notifiedForResults
Definition: thumbnailloadthread_p.h:122
bool sendSurrogate
Definition: thumbnailloadthread_p.h:121
bool highlight
Definition: thumbnailloadthread_p.h:120
Private()
Definition: thumbnailloadthread_p.h:109
int size
Definition: thumbnailloadthread_p.h:124
QMutex resultsMutex
Definition: thumbnailloadthread_p.h:129
QList< LoadingDescription > lastDescriptions
Definition: thumbnailloadthread_p.h:131
bool wantPixmap
Definition: thumbnailloadthread_p.h:119
QHash< QString, ThumbnailResult > collectedResults
Definition: thumbnailloadthread_p.h:128
ThumbnailCreator * creator
Definition: thumbnailloadthread_p.h:126
Definition: thumbnailloadthread.h:46
Definition: thumbnailloadthread_p.h:60
ThumbnailResult(const LoadingDescription &description, const QImage &image)
Definition: thumbnailloadthread_p.h:64
QImage image
Definition: thumbnailloadthread_p.h:71
LoadingDescription loadingDescription
Definition: thumbnailloadthread_p.h:70
Definition: thumbnailsize.h:42
Definition: piwigotalker.h:48
Definition: datefolderview.cpp:43