digiKam
previewlist.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 : 2010-02-13
7  * Description : a list of selectable options with preview
8  * effects as thumbnails.
9  *
10  * Copyright (C) 2010-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_PREVIEW_LIST_H
26 #define DIGIKAM_PREVIEW_LIST_H
27 
28 // Qt includes
29 
30 #include <QObject>
31 #include <QPixmap>
32 #include <QListWidget>
33 #include <QListWidgetItem>
34 
35 // Local includes
36 
37 #include "digikam_export.h"
38 
39 namespace Digikam
40 {
41 
42 class DImgThreadedFilter;
43 
44 class DIGIKAM_EXPORT PreviewThreadWrapper : public QObject
45 {
46  Q_OBJECT
47 
48 public:
49 
50  explicit PreviewThreadWrapper(QObject* const parent = nullptr);
51  ~PreviewThreadWrapper() override;
52 
53  void registerFilter(int id, DImgThreadedFilter* const filter);
54 
55  void startFilters();
56  void stopFilters();
57 
58 Q_SIGNALS:
59 
61  void signalFilterFinished(int, const QPixmap&);
62 
63 private Q_SLOTS:
64 
65  void slotFilterStarted();
66  void slotFilterFinished(bool success);
67  void slotFilterProgress(int progress);
68 
69 private:
70 
71  class Private;
72  Private* const d;
73 };
74 
75 // -------------------------------------------------------------------
76 
77 class DIGIKAM_EXPORT PreviewListItem : public QListWidgetItem
78 {
79 
80 public:
81 
82  explicit PreviewListItem(QListWidget* const parent = nullptr);
83  ~PreviewListItem() override;
84 
85  void setPixmap(const QPixmap& pix);
86 
87  void setId(int id);
88  int id() const;
89 
90  void setBusy(bool b);
91  bool isBusy() const;
92 
93 private:
94 
95  class Private;
96  Private* const d;
97 
98 private:
99 
100  Q_DISABLE_COPY(PreviewListItem)
101 };
102 
103 // -------------------------------------------------------------------
104 
105 class DIGIKAM_EXPORT PreviewList : public QListWidget
106 {
107  Q_OBJECT
108 
109 public:
110 
111  explicit PreviewList(QWidget* const parent = nullptr);
112  ~PreviewList() override;
113 
114  PreviewListItem* addItem(DImgThreadedFilter* const filter, const QString& txt, int id);
115 
116  void setCurrentId(int id);
117  int currentId() const;
118 
119  void startFilters();
120  void stopFilters();
121 
122 private Q_SLOTS:
123 
124  void slotProgressTimerDone();
125  void slotFilterStarted(int);
126  void slotFilterFinished(int, const QPixmap&);
127 
128 private:
129 
130  PreviewListItem* findItem(int id) const;
131 
132 private:
133 
134  class Private;
135  Private* const d;
136 };
137 
138 } // namespace Digikam
139 
140 #endif // DIGIKAM_PREVIEW_LIST_H
Definition: dimgthreadedfilter.h:41
Definition: previewlist.h:78
Definition: previewlist.h:106
Definition: previewlist.h:45
void signalFilterFinished(int, const QPixmap &)
Definition: datefolderview.cpp:43