1 /* ============================================================ 2 * 3 * This file is a part of digiKam project 4 * https://www.digikam.org 5 * 6 * Date : 2010-04-30 7 * Description : Graphics View item for DImg 8 * 9 * Copyright (C) 2010-2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de> 10 * Copyright (C) 2011-2021 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_GRAPHICS_DIMG_ITEM_H 26 #define DIGIKAM_GRAPHICS_DIMG_ITEM_H 27 28 // Qt includes 29 30 #include <QtGlobal> 31 #include <QGraphicsObject> 32 #include <QObject> 33 34 // Local includes 35 36 #include "digikam_export.h" 37 38 namespace Digikam 39 { 40 41 class DImg; 42 class ImageZoomSettings; 43 44 class DIGIKAM_EXPORT GraphicsDImgItem : public QGraphicsObject 45 { 46 Q_OBJECT 47 48 public: 49 50 explicit GraphicsDImgItem(QGraphicsItem* const parent = nullptr); 51 ~GraphicsDImgItem() override; 52 53 /** 54 * Sets the DImg to be drawn by this item. 55 * Note: DImg is explicitly shared, and no copy is automatically taken here. 56 */ 57 void setImage(const DImg& img); 58 DImg image() const; 59 60 const ImageZoomSettings* zoomSettings() const; 61 ImageZoomSettings* zoomSettings(); 62 63 void sizeHasChanged(); 64 void clearCache(); 65 66 QRectF boundingRect() const override; 67 void paint(QPainter* painter, 68 const QStyleOptionGraphicsItem* option, 69 QWidget* widget = nullptr) override; 70 userLoadingHint()71 virtual QString userLoadingHint() const 72 { 73 return QString(); 74 } 75 76 Q_SIGNALS: 77 78 void showContextMenu(QGraphicsSceneContextMenuEvent* e); 79 void imageChanged(); 80 void imageSizeChanged(const QSizeF& size); 81 82 protected: 83 84 void contextMenuEvent(QGraphicsSceneContextMenuEvent* e) override; 85 86 public: 87 88 // Declared public because of DImgPreviewItemPrivate. 89 class GraphicsDImgItemPrivate; 90 91 protected: 92 93 GraphicsDImgItem(GraphicsDImgItemPrivate& dd, QGraphicsItem* const parent); 94 GraphicsDImgItemPrivate* const d_ptr; 95 96 protected: 97 98 Q_DECLARE_PRIVATE(GraphicsDImgItem) 99 100 private: 101 102 // Disable 103 GraphicsDImgItem(QObject*); 104 }; 105 106 } // namespace Digikam 107 108 #endif // DIGIKAM_GRAPHICS_DIMG_ITEM_H 109