From 229e8f529d7488c4a499dcf4877a620036af0fac Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Mon, 5 Dec 2016 22:58:52 +0300 Subject: [PATCH] resourcePath property has been added to ImageItem --- limereport/items/lrimageitem.cpp | 30 ++++++++++++++++++++---------- limereport/items/lrimageitem.h | 8 +++++--- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/limereport/items/lrimageitem.cpp b/limereport/items/lrimageitem.cpp index a8e255e..38e4441 100644 --- a/limereport/items/lrimageitem.cpp +++ b/limereport/items/lrimageitem.cpp @@ -56,16 +56,21 @@ BaseDesignIntf *ImageItem::createSameTypeItem(QObject *owner, QGraphicsItem *par void ImageItem::updateItemSize(DataSourceManager* dataManager, RenderPass pass, int maxHeight) { - if (!m_datasource.isEmpty() && !m_field.isEmpty() && m_picture.isNull()){ - IDataSource* ds = dataManager->dataSource(m_datasource); - if (ds) { - QVariant data = ds->data(m_field); - if (data.isValid()){ - if (data.type()==QVariant::Image){ - m_picture = data.value(); - } else - m_picture.loadFromData(data.toByteArray()); - } + + if (m_picture.isNull()){ + if (!m_datasource.isEmpty() && !m_field.isEmpty()){ + IDataSource* ds = dataManager->dataSource(m_datasource); + if (ds) { + QVariant data = ds->data(m_field); + if (data.isValid()){ + if (data.type()==QVariant::Image){ + m_picture = data.value(); + } else + m_picture.loadFromData(data.toByteArray()); + } + } + } else if (!m_resourcePath.isEmpty()){ + m_picture = QImage(m_resourcePath); } } if (m_autoSize){ @@ -80,6 +85,11 @@ bool ImageItem::isNeedUpdateSize(RenderPass) const return m_picture.isNull() || m_autoSize; } +QString ImageItem::resourcePath() const +{ + return m_resourcePath; +} + qreal ImageItem::minHeight() const{ if (!m_picture.isNull() && autoSize()) { diff --git a/limereport/items/lrimageitem.h b/limereport/items/lrimageitem.h index 4e3fa23..631f292 100644 --- a/limereport/items/lrimageitem.h +++ b/limereport/items/lrimageitem.h @@ -44,12 +44,14 @@ class ImageItem : public LimeReport::ItemDesignIntf Q_PROPERTY(bool scale READ scale WRITE setScale) Q_PROPERTY(bool keepAspectRatio READ keepAspectRatio WRITE setKeepAspectRatio) Q_PROPERTY(bool center READ center WRITE setCenter) + Q_PROPERTY(QString resourcePath READ resourcePath WRITE setResourcePath) 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 setContent(const QString &value){m_content=value;} + void setResourcePath(const QString &value){m_resourcePath=value;} + QString resourcePath() const; QString datasource() const; void setDatasource(const QString &datasource); QString field() const; @@ -72,8 +74,8 @@ protected: bool isNeedUpdateSize(RenderPass) const; bool drawDesignBorders() const {return m_picture.isNull();} private: - QImage m_picture; - QString m_content; + QImage m_picture; + QString m_resourcePath; QString m_datasource; QString m_field; bool m_autoSize;