File indexing completed on 2025-01-05 03:59:45

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2010-02-13
0007  * Description : a list of selectable options with preview
0008  *               effects as thumbnails.
0009  *
0010  * SPDX-FileCopyrightText: 2010-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #ifndef DIGIKAM_PREVIEW_LIST_H
0017 #define DIGIKAM_PREVIEW_LIST_H
0018 
0019 // Qt includes
0020 
0021 #include <QObject>
0022 #include <QPixmap>
0023 #include <QListWidget>
0024 #include <QListWidgetItem>
0025 
0026 // Local includes
0027 
0028 #include "digikam_export.h"
0029 
0030 namespace Digikam
0031 {
0032 
0033 class DImgThreadedFilter;
0034 
0035 class DIGIKAM_EXPORT PreviewThreadWrapper : public QObject
0036 {
0037     Q_OBJECT
0038 
0039 public:
0040 
0041     explicit PreviewThreadWrapper(QObject* const parent = nullptr);
0042     ~PreviewThreadWrapper() override;
0043 
0044     void registerFilter(int id, DImgThreadedFilter* const filter);
0045 
0046     void startFilters();
0047     void stopFilters();
0048 
0049 Q_SIGNALS:
0050 
0051     void signalFilterStarted(int);
0052     void signalFilterFinished(int, const QPixmap&);
0053 
0054 private Q_SLOTS:
0055 
0056     void slotFilterStarted();
0057     void slotFilterFinished(bool success);
0058     void slotFilterProgress(int progress);
0059 
0060 private:
0061 
0062     class Private;
0063     Private* const d;
0064 };
0065 
0066 // -------------------------------------------------------------------
0067 
0068 class DIGIKAM_EXPORT PreviewListItem : public QListWidgetItem
0069 {
0070 
0071 public:
0072 
0073     explicit PreviewListItem(QListWidget* const parent = nullptr);
0074     ~PreviewListItem()    override;
0075 
0076     void setPixmap(const QPixmap& pix);
0077 
0078     void setId(int id);
0079     int  id()       const;
0080 
0081     void setBusy(bool b);
0082     bool isBusy()   const;
0083 
0084 private:
0085 
0086     class Private;
0087     Private* const d;
0088 
0089 private:
0090 
0091     Q_DISABLE_COPY(PreviewListItem)
0092 };
0093 
0094 // -------------------------------------------------------------------
0095 
0096 class DIGIKAM_EXPORT PreviewList : public QListWidget
0097 {
0098     Q_OBJECT
0099 
0100 public:
0101 
0102     explicit PreviewList(QWidget* const parent = nullptr);
0103     ~PreviewList()                            override;
0104 
0105     PreviewListItem* addItem(DImgThreadedFilter* const filter, const QString& txt, int id);
0106 
0107     void setCurrentId(int id);
0108     int  currentId()                    const;
0109 
0110     void startFilters();
0111     void stopFilters();
0112 
0113 private Q_SLOTS:
0114 
0115     void slotProgressTimerDone();
0116     void slotFilterStarted(int);
0117     void slotFilterFinished(int, const QPixmap&);
0118 
0119 private:
0120 
0121     PreviewListItem* findItem(int id)   const;
0122 
0123 private:
0124 
0125     class Private;
0126     Private* const d;
0127 };
0128 
0129 } // namespace Digikam
0130 
0131 #endif // DIGIKAM_PREVIEW_LIST_H