File indexing completed on 2025-04-27 03:58:23

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2010-04-30
0007  * Description : Graphics View items for DImg
0008  *
0009  * SPDX-FileCopyrightText: 2010-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #ifndef DIGIKAM_DIMG_PREVIEW_ITEM_H
0016 #define DIGIKAM_DIMG_PREVIEW_ITEM_H
0017 
0018 // Qt includes
0019 
0020 #include <QGraphicsItem>
0021 #include <QObject>
0022 
0023 // Local includes
0024 
0025 #include "digikam_export.h"
0026 #include "graphicsdimgitem.h"
0027 
0028 namespace Digikam
0029 {
0030 
0031 class DImg;
0032 class ICCSettingsContainer;
0033 class LoadingDescription;
0034 class PreviewSettings;
0035 
0036 class DIGIKAM_EXPORT DImgPreviewItem : public GraphicsDImgItem
0037 {
0038     Q_OBJECT
0039 
0040 public:
0041 
0042     enum State
0043     {
0044         NoImage,
0045         Loading,
0046         ImageLoaded,
0047         ImageLoadingFailed
0048     };
0049 
0050 public:
0051 
0052     explicit DImgPreviewItem(QGraphicsItem* const parent = nullptr);
0053     ~DImgPreviewItem() override;
0054 
0055     void setDisplayingWidget(QWidget* const widget);
0056     void setPreviewSettings(const PreviewSettings& settings);
0057 
0058     QString path()              const;
0059     void    setPath(const QString& path, bool rePreview = false);
0060 
0061     State state()               const;
0062     bool  isLoaded()            const;
0063     void  reload();
0064 
0065     void setPreloadPaths(const QStringList& pathsToPreload);
0066 
0067     QString userLoadingHint()   const override;
0068 
0069 Q_SIGNALS:
0070 
0071     void stateChanged(int state);
0072     void loaded();
0073     void loadingFailed();
0074 
0075 private Q_SLOTS:
0076 
0077     void slotGotImagePreview(const LoadingDescription& loadingDescription, const DImg& image);
0078     void preloadNext();
0079     void slotFileChanged(const QString& path);
0080     void iccSettingsChanged(const ICCSettingsContainer& current, const ICCSettingsContainer& previous);
0081 
0082 private:
0083 
0084     // Disable
0085     DImgPreviewItem(QObject*);
0086 
0087     class DImgPreviewItemPrivate;
0088     Q_DECLARE_PRIVATE(DImgPreviewItem)
0089 
0090 protected:
0091 
0092     explicit DImgPreviewItem(DImgPreviewItemPrivate& dd, QGraphicsItem* const parent = nullptr);
0093 };
0094 
0095 } // namespace Digikam
0096 
0097 #endif // DIGIKAM_DIMG_PREVIEW_ITEM_H