From 3b3790d7bcd5bfbbcea87d100558df572dee543d Mon Sep 17 00:00:00 2001 From: Arin Alexander Date: Wed, 18 Mar 2020 13:34:11 +0300 Subject: [PATCH] SVGItem has been added --- common.pri | 8 +- limereport/designer.pri | 12 ++ limereport/items/images/SVGItem.png | Bin 0 -> 600 bytes limereport/items/items.qrc | 1 + limereport/items/lrimageitem.cpp | 25 +-- limereport/items/lrimageitem.h | 2 +- limereport/items/lrsvgitem.cpp | 151 ++++++++++++++++++ limereport/items/lrsvgitem.h | 44 +++++ limereport/limereport.pri | 8 + limereport/lrfactoryinitializer.cpp | 40 +++++ .../objectinspector/editors/lrsvgeditor.cpp | 48 ++++++ .../objectinspector/editors/lrsvgeditor.h | 29 ++++ .../propertyItems/lrdatasourcepropitem.cpp | 8 + .../propertyItems/lrsvgpropitem.cpp | 42 +++++ .../propertyItems/lrsvgpropitem.h | 23 +++ 15 files changed, 427 insertions(+), 14 deletions(-) create mode 100644 limereport/items/images/SVGItem.png create mode 100644 limereport/items/lrsvgitem.cpp create mode 100644 limereport/items/lrsvgitem.h create mode 100644 limereport/objectinspector/editors/lrsvgeditor.cpp create mode 100644 limereport/objectinspector/editors/lrsvgeditor.h create mode 100644 limereport/objectinspector/propertyItems/lrsvgpropitem.cpp create mode 100644 limereport/objectinspector/propertyItems/lrsvgpropitem.h diff --git a/common.pri b/common.pri index e626a70..3635474 100644 --- a/common.pri +++ b/common.pri @@ -19,6 +19,12 @@ message(TOP_BUILD_DIR: $$TOP_BUILD_DIR) CONFIG *= zint } +!contains(CONGIG, no_svg){ + QT *= svg + CONFIG *= svg + DEFINES += HAVE_SVG +} + INCLUDEPATH += $$PWD/3rdparty/easyprofiler/easy_profiler_core/include DEPENDPATH += $$PWD/3rdparty/easyprofiler/easy_profiler_core/include @@ -127,7 +133,7 @@ RCC_DIR = $${ARCH_DIR}/$${BUILD_TYPE}/rcc LIMEREPORT_VERSION_MAJOR = 1 LIMEREPORT_VERSION_MINOR = 5 -LIMEREPORT_VERSION_RELEASE = 41 +LIMEREPORT_VERSION_RELEASE = 42 LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}' DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\" diff --git a/limereport/designer.pri b/limereport/designer.pri index deef2d8..72bd275 100644 --- a/limereport/designer.pri +++ b/limereport/designer.pri @@ -51,6 +51,12 @@ SOURCES += \ $$REPORT_PATH/lrreportdesignwidget.cpp \ $$REPORT_PATH/lrreportdesignwindow.cpp +contains(CONFIG, svg){ + SOURCES += \ + $$REPORT_PATH/objectinspector/editors/lrsvgeditor.cpp \ + $$REPORT_PATH/objectinspector/propertyItems/lrsvgpropitem.cpp +} + HEADERS += \ $$REPORT_PATH/databrowser/lrdatabrowser.h \ $$REPORT_PATH/databrowser/lrsqleditdialog.h \ @@ -94,6 +100,12 @@ HEADERS += \ $$REPORT_PATH/lrreportdesignwidget.h \ $$REPORT_PATH/lrreportdesignwindow.h +contains(CONFIG, svg){ + HEADERS += \ + $$REPORT_PATH/objectinspector/editors/lrsvgeditor.h \ + $$REPORT_PATH/objectinspector/propertyItems/lrsvgpropitem.h +} + FORMS += \ $$REPORT_PATH/databrowser/lrsqleditdialog.ui \ $$REPORT_PATH/databrowser/lrconnectiondialog.ui \ diff --git a/limereport/items/images/SVGItem.png b/limereport/items/images/SVGItem.png new file mode 100644 index 0000000000000000000000000000000000000000..1351373b5a06769a74bddb258376ca5b1a3da34f GIT binary patch literal 600 zcmV-e0;m0nP)lbb;dmUEGc&TyzZHDrh7!5zl@oF4D+KJa*aAN=cd zTompVYrU0&Up`E90CYAsUwGmz8Gg@i`&D20+be1dE~WGLM(Mo7%+ncir5v?-jVW$Q11R_VERMWD8kVAFL9H1PC97DV`UZyFG_fa$YXjeZR|T@sz!VJ!YTHQms{) zx;4dF=?nmi-hy7OC-Nb}`kQqk3lUH#5U-?-V1={nubg+ zL;Pc$vBzU9hnAZY_``mZpOd)kE_5m#a+w?e$tbZFUBljQ2f!&g2_1$oX-y27hA4b5 zGimages/pie_chart2.png images/DataHeaderBand.png images/DataFooterBand.png + images/SVGItem.png diff --git a/limereport/items/lrimageitem.cpp b/limereport/items/lrimageitem.cpp index 76542d3..0ded44b 100644 --- a/limereport/items/lrimageitem.cpp +++ b/limereport/items/lrimageitem.cpp @@ -293,11 +293,11 @@ void ImageItem::setDatasource(const QString &datasource) } -void ImageItem::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *option, QWidget *widget) +void ImageItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { - ppainter->save(); - if (isSelected()) ppainter->setOpacity(Const::SELECTION_OPACITY); - else ppainter->setOpacity(qreal(opacity())/100); + painter->save(); + if (isSelected()) painter->setOpacity(Const::SELECTION_OPACITY); + else painter->setOpacity(qreal(opacity())/100); QPointF point = rect().topLeft(); QImage img; @@ -339,22 +339,23 @@ void ImageItem::paint(QPainter *ppainter, const QStyleOptionGraphicsItem *option } } - if (img.isNull() && itemMode()==DesignMode){ + if (img.isNull() && itemMode() == DesignMode){ QString text; - ppainter->setFont(transformToSceneFont(QFont("Arial",10))); - ppainter->setPen(Qt::black); + painter->setFont(transformToSceneFont(QFont("Arial",10))); + painter->setPen(Qt::black); if (!datasource().isEmpty() && !field().isEmpty()) text = datasource()+"."+field(); else if (m_useExternalPainter) text = tr("Ext."); else text = tr("Image"); - ppainter->drawText(rect().adjusted(4,4,-4,-4), Qt::AlignCenter, text ); + painter->drawText(rect().adjusted(4,4,-4,-4), Qt::AlignCenter, text ); } else { if (m_externalPainter && m_useExternalPainter) - m_externalPainter->paintByExternalPainter(this->patternName(), ppainter, option); + m_externalPainter->paintByExternalPainter(this->patternName(), painter, option); else - ppainter->drawImage(point,img); + painter->drawImage(point,img); } - ItemDesignIntf::paint(ppainter,option,widget); - ppainter->restore(); + + ItemDesignIntf::paint(painter,option,widget); + painter->restore(); } void ImageItem::setImage(QImage value) diff --git a/limereport/items/lrimageitem.h b/limereport/items/lrimageitem.h index e86e92a..a8bc51a 100644 --- a/limereport/items/lrimageitem.h +++ b/limereport/items/lrimageitem.h @@ -64,7 +64,7 @@ public: #endif ImageItem(QObject *owner, QGraphicsItem *parent); - virtual void paint(QPainter *ppainter, const QStyleOptionGraphicsItem *option, QWidget *widget); + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); void setImage(QImage value); QImage image(); void setResourcePath(const QString &value); diff --git a/limereport/items/lrsvgitem.cpp b/limereport/items/lrsvgitem.cpp new file mode 100644 index 0000000..4a50af9 --- /dev/null +++ b/limereport/items/lrsvgitem.cpp @@ -0,0 +1,151 @@ +#include "lrsvgitem.h" +#include "lrdesignelementsfactory.h" +#include + +namespace{ + const QString xmlTag = "SVGItem"; + LimeReport::BaseDesignIntf * createSVGItem(QObject* owner, LimeReport::BaseDesignIntf* parent){ + return new LimeReport::SVGItem(owner,parent); + } + bool VARIABLE_IS_NOT_USED registred = LimeReport::DesignElementsFactory::instance().registerCreator( + xmlTag, LimeReport::ItemAttribs(QObject::tr("SVG Item"),"Item"), createSVGItem + ); +} + +namespace LimeReport{ +SVGItem::SVGItem(QObject *owner, QGraphicsItem *parent) + :ItemDesignIntf(xmlTag,owner,parent) +{ +} + +void SVGItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +{ + painter->save(); + if (isSelected()) painter->setOpacity(Const::SELECTION_OPACITY); + else painter->setOpacity(qreal(opacity())/100); + if (m_image.isNull() && itemMode() == DesignMode){ + QString text; + painter->setFont(transformToSceneFont(QFont("Arial",10))); + painter->setPen(Qt::black); + if (!datasource().isEmpty() && !field().isEmpty()) + text = datasource()+"."+field(); + else text = tr("SVG Image"); + painter->drawText(rect().adjusted(4,4,-4,-4), Qt::AlignCenter, text ); + } + else if (!m_image.isEmpty()){ + QSvgRenderer render; + render.load(m_image); + render.render(painter, option->rect); + } + ItemDesignIntf::paint(painter,option,widget); + painter->restore(); +}; + +BaseDesignIntf* SVGItem::createSameTypeItem(QObject *owner, QGraphicsItem *parent){ + return new SVGItem(owner, parent); +} + +void SVGItem::updateItemSize(DataSourceManager *dataManager, RenderPass pass, int maxHeight) +{ + Q_UNUSED(maxHeight) + if (m_image.isEmpty()){ + if (!m_datasource.isEmpty() && !m_field.isEmpty()){ + IDataSource* ds = dataManager->dataSource(m_datasource); + if (ds) { + QVariant data = ds->data(m_field); + m_image = data.value(); + } + } else if (!m_resourcePath.isEmpty()){ + m_resourcePath = expandUserVariables(m_resourcePath, pass, NoEscapeSymbols, dataManager); + m_resourcePath = expandDataFields(m_resourcePath, NoEscapeSymbols, dataManager); + m_image = imageFromResource(m_resourcePath); + } else if (!m_variable.isEmpty()){ + QVariant data = dataManager->variable(m_variable); + if (data.type() == QVariant::String){ + m_image = imageFromResource(data.toString()); + } else if (data.type() == QVariant::Image){ + m_image = data.value(); + } + } + } +} + +QByteArray SVGItem::imageFromResource(QString resourcePath) +{ + QFile file(resourcePath); + if (file.open(QIODevice::ReadOnly)){ + return file.readAll(); + } + return QByteArray(); +} + +QString SVGItem::variable() const +{ + return m_variable; +} + +void SVGItem::setVariable(const QString &variable) +{ + if (m_variable != variable){ + QString oldValue = m_variable; + m_variable = variable; + update(); + notify("variable", oldValue, m_variable); + } + m_variable = variable; +} + +QString SVGItem::resourcePath() const +{ + return m_resourcePath; +} + +void SVGItem::setResourcePath(const QString &resourcePath) +{ + if (m_resourcePath != resourcePath){ + QString oldValue = m_resourcePath; + m_resourcePath = resourcePath; + QFile file(resourcePath); + if (file.open(QIODevice::ReadOnly)){ + m_image = file.readAll(); + } + update(); + notify("resourcePath", oldValue, resourcePath); + } +} + +QByteArray SVGItem::image() const +{ + return m_image; +} + +void SVGItem::setImage(const QByteArray &image) +{ + if (m_image != image){ + QByteArray oldValue = m_image; + m_image = image; + update(); + notify("image", oldValue, image); + } +} + +QString SVGItem::datasource() const +{ + return m_datasource; +} + +void SVGItem::setDatasource(const QString &datasource) +{ + m_datasource = datasource; +} + +QString SVGItem::field() const +{ + return m_field; +} + +void SVGItem::setField(const QString &field) +{ + m_field = field; +}; +} // namespace LimeReport diff --git a/limereport/items/lrsvgitem.h b/limereport/items/lrsvgitem.h new file mode 100644 index 0000000..cae58e0 --- /dev/null +++ b/limereport/items/lrsvgitem.h @@ -0,0 +1,44 @@ +#ifndef SVGITEM_H +#define SVGITEM_H + +#include "lritemdesignintf.h" + +namespace LimeReport{ +class SVGItem: public ItemDesignIntf +{ + Q_OBJECT + Q_PROPERTY(QString resourcePath READ resourcePath WRITE setResourcePath) + Q_PROPERTY(QByteArray image READ image WRITE setImage) + Q_PROPERTY(QString datasource READ datasource WRITE setDatasource) + Q_PROPERTY(QString field READ field WRITE setField) + Q_PROPERTY(int opacity READ opacity WRITE setOpacity) + Q_PROPERTY(QString variable READ variable WRITE setVariable) + Q_PROPERTY(bool watermark READ isWatermark WRITE setWatermark) +public: + SVGItem(QObject *owner, QGraphicsItem *parent); + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + + QString resourcePath() const; + void setResourcePath(const QString &resourcePath); + QByteArray image() const; + void setImage(const QByteArray &image); + QString datasource() const; + void setDatasource(const QString &datasource); + QString field() const; + void setField(const QString &field); + QString variable() const; + void setVariable(const QString &variable); + +protected: + BaseDesignIntf *createSameTypeItem(QObject *owner, QGraphicsItem *parent); + void updateItemSize(DataSourceManager *dataManager, RenderPass pass, int maxHeight); + QByteArray imageFromResource(QString resourcePath); +private: + QString m_resourcePath; + QByteArray m_image; + QString m_datasource; + QString m_field; + QString m_variable; +}; +} // namespace LimeReport +#endif // SVGITEM_H diff --git a/limereport/limereport.pri b/limereport/limereport.pri index 219dbb4..28cb4ee 100644 --- a/limereport/limereport.pri +++ b/limereport/limereport.pri @@ -84,6 +84,10 @@ contains(CONFIG, zint){ SOURCES += $$REPORT_PATH/items/lrbarcodeitem.cpp } +contains(CONFIG, svg){ + SOURCES += $$REPORT_PATH/items/lrsvgitem.cpp \ +} + HEADERS += \ $$REPORT_PATH/base/lrsingleton.h \ $$REPORT_PATH/base/lrsimpleabstractfactory.h \ @@ -173,6 +177,10 @@ contains(CONFIG,zint){ HEADERS += $$REPORT_PATH/items/lrbarcodeitem.h } +contains(CONFIG, svg){ + HEADERS += $$REPORT_PATH/items/lrsvgitem.h +} + FORMS += \ $$REPORT_PATH/lrpreviewreportwindow.ui \ $$REPORT_PATH/lrpreviewreportwidget.ui \ diff --git a/limereport/lrfactoryinitializer.cpp b/limereport/lrfactoryinitializer.cpp index f244d1a..ccfc024 100644 --- a/limereport/lrfactoryinitializer.cpp +++ b/limereport/lrfactoryinitializer.cpp @@ -17,6 +17,11 @@ #include "items/lrshapeitem.h" #include "items/lrchartitem.h" #include "lrdesignelementsfactory.h" +#ifdef HAVE_SVG +#include "items/lrsvgitem.h" +#include "objectinspector/propertyItems/lrsvgpropitem.h" +#endif + #ifdef HAVE_REPORT_DESIGNER #include "objectinspector/lrobjectpropitem.h" @@ -111,6 +116,12 @@ BaseDesignIntf * createBarcodeItem(QObject* owner, LimeReport::BaseDesignIntf* } #endif +#ifdef HAVE_SVG +BaseDesignIntf* createSVGItem(QObject* owner, LimeReport::BaseDesignIntf* parent){ + return new SVGItem(owner,parent); +} +#endif + BaseDesignIntf* createHLayout(QObject *owner, LimeReport::BaseDesignIntf *parent) { return new HorizontalLayout(owner, parent); @@ -142,6 +153,7 @@ void initReportItems(){ createBarcodeItem ); #endif + DesignElementsFactory::instance().registerCreator( "HLayout", LimeReport::ItemAttribs(QObject::tr("HLayout"), LimeReport::Const::bandTAG), @@ -150,6 +162,15 @@ void initReportItems(){ DesignElementsFactory::instance().registerCreator( "ImageItem", LimeReport::ItemAttribs(QObject::tr("Image Item"),"Item"), createImageItem ); + +#ifdef HAVE_SVG + DesignElementsFactory::instance().registerCreator( + "BarcodeItem", + LimeReport::ItemAttribs(QObject::tr("SVG Item"),"Item"), + createSVGItem + ); +#endif + DesignElementsFactory::instance().registerCreator( "ShapeItem", LimeReport::ItemAttribs(QObject::tr("Shape Item"),"Item"), createShapeItem ); @@ -273,6 +294,14 @@ ObjectPropItem * createImagePropItem( return new LimeReport::ImagePropItem(object, objects, name, displayName, data, parent, readonly); } +#ifdef HAVE_SVG +ObjectPropItem * createSVGPropItem( + QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly) +{ + return new LimeReport::SvgPropItem(object, objects, name, displayName, data, parent, readonly); +} +#endif + ObjectPropItem * createIntPropItem( QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly) { @@ -335,6 +364,12 @@ void initObjectInspectorProperties() ObjectPropFactory::instance().registerCreator( LimeReport::APropIdent("field","LimeReport::ImageItem"),QObject::tr("field"),createFieldPropItem ); + ObjectPropFactory::instance().registerCreator( + LimeReport::APropIdent("datasource","LimeReport::SVGItem"),QObject::tr("datasource"),createDatasourcePropItem + ); + ObjectPropFactory::instance().registerCreator( + LimeReport::APropIdent("field","LimeReport::SVGItem"),QObject::tr("field"),createFieldPropItem + ); ObjectPropFactory::instance().registerCreator( LimeReport::APropIdent("enum",""),QObject::tr("enum"),createEnumPropItem ); @@ -350,6 +385,11 @@ void initObjectInspectorProperties() ObjectPropFactory::instance().registerCreator( LimeReport::APropIdent("QImage",""),QObject::tr("QImage"),createImagePropItem ); +#ifdef HAVE_SVG + ObjectPropFactory::instance().registerCreator( + LimeReport::APropIdent("image","LimeReport::SVGItem"),QObject::tr("image"),createSVGPropItem + ); +#endif ObjectPropFactory::instance().registerCreator( LimeReport::APropIdent("int",""),QObject::tr("int"),createIntPropItem ); diff --git a/limereport/objectinspector/editors/lrsvgeditor.cpp b/limereport/objectinspector/editors/lrsvgeditor.cpp new file mode 100644 index 0000000..37952e7 --- /dev/null +++ b/limereport/objectinspector/editors/lrsvgeditor.cpp @@ -0,0 +1,48 @@ +#include "lrsvgeditor.h" +#include +#include +#include "lrimageeditor.h" + +namespace LimeReport{ + +SvgEditor::SvgEditor(QWidget* parent) + :QWidget(parent) +{ + m_button.setIcon(QIcon(":items/ImageItem")); + m_clearButton.setIcon(QIcon(":items/clear.png")); + QHBoxLayout* layout = new QHBoxLayout(this); + layout->addWidget(&m_button); + layout->addWidget(&m_clearButton); + layout->setSpacing(1); + layout->setContentsMargins(1,0,1,1); + setLayout(layout); + setFocusProxy(&m_button); + setAutoFillBackground(true); + connect(&m_button,SIGNAL(clicked()),this,SLOT(slotButtonClicked())); + connect(&m_clearButton,SIGNAL(clicked()),this,SLOT(slotClearButtonClicked())); +} + +QByteArray SvgEditor::image() +{ + return m_image; +} + +void SvgEditor::slotButtonClicked() +{ + QString fileName = QFileDialog::getOpenFileName(this, "", "SVG| *.svg"); + if (!fileName.isEmpty()){ + QFile file(fileName); + if (file.open(QIODevice::ReadOnly)){ + m_image = file.readAll(); + } + } + emit editingFinished(); +} + +void SvgEditor::slotClearButtonClicked() +{ + m_image = QByteArray(); + emit editingFinished(); +} + +} diff --git a/limereport/objectinspector/editors/lrsvgeditor.h b/limereport/objectinspector/editors/lrsvgeditor.h new file mode 100644 index 0000000..6ba0649 --- /dev/null +++ b/limereport/objectinspector/editors/lrsvgeditor.h @@ -0,0 +1,29 @@ +#ifndef SVGEDITOR_H +#define SVGEDITOR_H +#include +#include + +namespace LimeReport{ + +class SvgEditor : public QWidget +{ + Q_OBJECT + +public: + SvgEditor(QWidget *parent=0); + QByteArray image(); + void setImage(const QByteArray& image){m_image=image;} +signals: + void editingFinished(); +private slots: + void slotButtonClicked(); + void slotClearButtonClicked(); +private: + QPushButton m_button; + QPushButton m_clearButton; + QByteArray m_image; +}; + +} // namespace LimeReport + +#endif // SVGEDITOR_H diff --git a/limereport/objectinspector/propertyItems/lrdatasourcepropitem.cpp b/limereport/objectinspector/propertyItems/lrdatasourcepropitem.cpp index 08fc0a3..6a3f1b6 100644 --- a/limereport/objectinspector/propertyItems/lrdatasourcepropitem.cpp +++ b/limereport/objectinspector/propertyItems/lrdatasourcepropitem.cpp @@ -68,6 +68,14 @@ namespace{ bool VARIABLE_IS_NOT_USED registredBarcodeFieldProp = LimeReport::ObjectPropFactory::instance().registerCreator( LimeReport::APropIdent("field","LimeReport::BarcodeItem"),QObject::tr("field"),createFieldPropItem ); + + bool VARIABLE_IS_NOT_USED registredSVGItemDatasouceProp = LimeReport::ObjectPropFactory::instance().registerCreator( + LimeReport::APropIdent("datasource","LimeReport::SVGItem"),QObject::tr("datasource"),createDatasourcePropItem + ); + + bool VARIABLE_IS_NOT_USED registredSVGFieldProp = LimeReport::ObjectPropFactory::instance().registerCreator( + LimeReport::APropIdent("field","LimeReport::SVGItem"),QObject::tr("field"),createFieldPropItem + ); } QWidget* LimeReport::DatasourcePropItem::createProperyEditor(QWidget *parent) const{ diff --git a/limereport/objectinspector/propertyItems/lrsvgpropitem.cpp b/limereport/objectinspector/propertyItems/lrsvgpropitem.cpp new file mode 100644 index 0000000..2d702f0 --- /dev/null +++ b/limereport/objectinspector/propertyItems/lrsvgpropitem.cpp @@ -0,0 +1,42 @@ +#include "lrsvgpropitem.h" +#include "editors/lrsvgeditor.h" + +namespace{ +LimeReport::ObjectPropItem * createSvgPropItem( + QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly) +{ + return new LimeReport::SvgPropItem(object, objects, name, displayName, data, parent, readonly); +} +bool VARIABLE_IS_NOT_USED registredImageProp = LimeReport::ObjectPropFactory::instance().registerCreator(LimeReport::APropIdent("image","LimeReport::SVGItem"),QObject::tr("image"),createSvgPropItem); +} + +namespace LimeReport{ + +QWidget* SvgPropItem::createProperyEditor(QWidget *parent) const +{ + return new SvgEditor(parent); +} + +QString SvgPropItem::displayValue() const +{ + return (propertyValue().isNull()) ? "" : QObject::tr("image"); +} + +void SvgPropItem::setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const +{ + SvgEditor *editor = qobject_cast(propertyEditor); + editor->setImage(propertyValue().value()); +} + +void SvgPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index) +{ + model->setData(index,qobject_cast(propertyEditor)->image()); + object()->setProperty(propertyName().toLatin1(),propertyValue()); +} + +QIcon SvgPropItem::iconValue() const +{ + return QIcon(QPixmap::fromImage(propertyValue().value())); +} + +} diff --git a/limereport/objectinspector/propertyItems/lrsvgpropitem.h b/limereport/objectinspector/propertyItems/lrsvgpropitem.h new file mode 100644 index 0000000..ee28331 --- /dev/null +++ b/limereport/objectinspector/propertyItems/lrsvgpropitem.h @@ -0,0 +1,23 @@ +#ifndef SVGPROPITEM_H +#define SVGPROPITEM_H + +#include "lrobjectpropitem.h" +namespace LimeReport{ + +class SvgPropItem : public ObjectPropItem +{ + Q_OBJECT +public: + SvgPropItem():ObjectPropItem(){} + SvgPropItem(QObject* object, ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& value,ObjectPropItem* parent, bool readonly) + :ObjectPropItem(object, objects, name, displayName, value, parent, readonly){} + QWidget* createProperyEditor(QWidget *parent) const; + QString displayValue() const; + void setPropertyEditorData(QWidget *propertyEditor, const QModelIndex &) const; + void setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index); + virtual QIcon iconValue() const; +}; + +} // namespace LimeReport + +#endif // SVGPROPITEM_H