File indexing completed on 2025-04-27 03:58:24
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 item for DImg 0008 * 0009 * SPDX-FileCopyrightText: 2010-2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de> 0010 * SPDX-FileCopyrightText: 2011-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_GRAPHICS_DIMG_ITEM_H 0017 #define DIGIKAM_GRAPHICS_DIMG_ITEM_H 0018 0019 // Qt includes 0020 0021 #include <QtGlobal> 0022 #include <QGraphicsObject> 0023 #include <QObject> 0024 0025 // Local includes 0026 0027 #include "digikam_export.h" 0028 0029 namespace Digikam 0030 { 0031 0032 class DImg; 0033 class ImageZoomSettings; 0034 0035 class DIGIKAM_EXPORT GraphicsDImgItem : public QGraphicsObject 0036 { 0037 Q_OBJECT 0038 0039 public: 0040 0041 explicit GraphicsDImgItem(QGraphicsItem* const parent = nullptr); 0042 ~GraphicsDImgItem() override; 0043 0044 /** 0045 * Sets the DImg to be drawn by this item. 0046 * Note: DImg is explicitly shared, and no copy is automatically taken here. 0047 */ 0048 void setImage(const DImg& img); 0049 DImg image() const; 0050 0051 const ImageZoomSettings* zoomSettings() const; 0052 ImageZoomSettings* zoomSettings(); 0053 0054 void setDisplayWidget(QWidget* const widget); 0055 0056 void sizeHasChanged(); 0057 void clearCache(); 0058 0059 QRectF boundingRect() const override; 0060 void paint(QPainter* painter, 0061 const QStyleOptionGraphicsItem* option, 0062 QWidget* widget) override; 0063 0064 virtual QString userLoadingHint() const 0065 { 0066 return QString(); 0067 } 0068 0069 Q_SIGNALS: 0070 0071 void showContextMenu(QGraphicsSceneContextMenuEvent* e); 0072 void imageChanged(); 0073 void imageSizeChanged(const QSizeF& size); 0074 0075 protected: 0076 0077 void contextMenuEvent(QGraphicsSceneContextMenuEvent* e) override; 0078 0079 public: 0080 0081 // Declared public because of DImgPreviewItemPrivate. 0082 class GraphicsDImgItemPrivate; 0083 0084 protected: 0085 0086 GraphicsDImgItem(GraphicsDImgItemPrivate& dd, QGraphicsItem* const parent); 0087 GraphicsDImgItemPrivate* const d_ptr; 0088 0089 protected: 0090 0091 Q_DECLARE_PRIVATE(GraphicsDImgItem) 0092 0093 private: 0094 0095 // Disable 0096 GraphicsDImgItem(QObject*); 0097 }; 0098 0099 } // namespace Digikam 0100 0101 #endif // DIGIKAM_GRAPHICS_DIMG_ITEM_H