1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* ============================================================
 *
 * This file is a part of digiKam project
 * https://www.digikam.org
 *
 * Date        : 2010-04-30
 * Description : Graphics View items for DImg
 *
 * SPDX-FileCopyrightText: 2010-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 *
 * ============================================================ */

#ifndef DIGIKAM_DIMG_PREVIEW_ITEM_H
#define DIGIKAM_DIMG_PREVIEW_ITEM_H

// Qt includes

#include <QGraphicsItem>
#include <QObject>

// Local includes

#include "digikam_export.h"
#include "graphicsdimgitem.h"

namespace Digikam
{

class DImg;
class ICCSettingsContainer;
class LoadingDescription;
class PreviewSettings;

class DIGIKAM_EXPORT DImgPreviewItem : public GraphicsDImgItem
{
    Q_OBJECT

public:

    enum State
    {
        NoImage,
        Loading,
        ImageLoaded,
        ImageLoadingFailed
    };

public:

    explicit DImgPreviewItem(QGraphicsItem* const parent = nullptr);
    ~DImgPreviewItem()                override;

    void setDisplayingWidget(QWidget* const widget);
    void setPreviewSettings(const PreviewSettings& settings);

    QString path()              const;
    void    setPath(const QString& path, bool rePreview = false);

    State state()               const;
    bool  isLoaded()            const;
    void  reload();

    void setPreloadPaths(const QStringList& pathsToPreload);

    QString userLoadingHint()   const override;

Q_SIGNALS:

    void stateChanged(int state);
    void loaded();
    void loadingFailed();

private Q_SLOTS:

    void slotGotImagePreview(const LoadingDescription& loadingDescription, const DImg& image);
    void preloadNext();
    void slotFileChanged(const QString& path);
    void iccSettingsChanged(const ICCSettingsContainer& current, const ICCSettingsContainer& previous);

private:

    // Disable
    DImgPreviewItem(QObject*);

    class DImgPreviewItemPrivate;
    Q_DECLARE_PRIVATE(DImgPreviewItem)<--- Derived function 'DImgPreviewItem::d_func'

protected:

    explicit DImgPreviewItem(DImgPreviewItemPrivate& dd, QGraphicsItem* const parent = nullptr);
};

} // namespace Digikam

#endif // DIGIKAM_DIMG_PREVIEW_ITEM_H