From afa4bcb9bf95700129e0062e0d4cb62572a4b067 Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Wed, 7 Aug 2019 12:40:42 +0300 Subject: [PATCH] If resourcePath contains a simple path to an image file, that image will be shown in design mode. --- limereport/items/lrimageitem.cpp | 15 +++++++++++++++ limereport/items/lrimageitem.h | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/limereport/items/lrimageitem.cpp b/limereport/items/lrimageitem.cpp index c3fce2f..9952479 100644 --- a/limereport/items/lrimageitem.cpp +++ b/limereport/items/lrimageitem.cpp @@ -340,6 +340,21 @@ void ImageItem::setImage(QImage value) } } +QImage ImageItem::image(){ + if (m_picture.isNull() && !resourcePath().isEmpty() && itemMode() == DesignMode){ + QFileInfo fileInfo(m_resourcePath); + if (fileInfo.exists()){ + return QImage(m_resourcePath); + } + } + return m_picture; +} + +void ImageItem::setResourcePath(const QString &value){ + m_resourcePath=value; + update(); +} + ImageItem::Format ImageItem::format() const { return m_format; diff --git a/limereport/items/lrimageitem.h b/limereport/items/lrimageitem.h index 5d474e2..8eb7da7 100644 --- a/limereport/items/lrimageitem.h +++ b/limereport/items/lrimageitem.h @@ -61,8 +61,8 @@ public: ImageItem(QObject *owner, QGraphicsItem *parent); virtual void paint(QPainter *ppainter, const QStyleOptionGraphicsItem *option, QWidget *widget); void setImage(QImage value); - QImage image(){return m_picture;} - void setResourcePath(const QString &value){m_resourcePath=value;} + QImage image(); + void setResourcePath(const QString &value); QString resourcePath() const; QString datasource() const; void setDatasource(const QString &datasource);