mirror of
https://github.com/fralx/LimeReport.git
synced 2024-12-24 08:34:38 +03:00
Finish 1.5.42
This commit is contained in:
commit
bd905f8daa
@ -19,6 +19,12 @@ message(TOP_BUILD_DIR: $$TOP_BUILD_DIR)
|
|||||||
CONFIG *= zint
|
CONFIG *= zint
|
||||||
}
|
}
|
||||||
|
|
||||||
|
!contains(CONGIG, no_svg){
|
||||||
|
QT *= svg
|
||||||
|
CONFIG *= svg
|
||||||
|
DEFINES += HAVE_SVG
|
||||||
|
}
|
||||||
|
|
||||||
INCLUDEPATH += $$PWD/3rdparty/easyprofiler/easy_profiler_core/include
|
INCLUDEPATH += $$PWD/3rdparty/easyprofiler/easy_profiler_core/include
|
||||||
DEPENDPATH += $$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_MAJOR = 1
|
||||||
LIMEREPORT_VERSION_MINOR = 5
|
LIMEREPORT_VERSION_MINOR = 5
|
||||||
LIMEREPORT_VERSION_RELEASE = 41
|
LIMEREPORT_VERSION_RELEASE = 42
|
||||||
|
|
||||||
LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}'
|
LIMEREPORT_VERSION = '$${LIMEREPORT_VERSION_MAJOR}.$${LIMEREPORT_VERSION_MINOR}.$${LIMEREPORT_VERSION_RELEASE}'
|
||||||
DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\"
|
DEFINES *= LIMEREPORT_VERSION_STR=\\\"$${LIMEREPORT_VERSION}\\\"
|
||||||
|
@ -51,6 +51,12 @@ SOURCES += \
|
|||||||
$$REPORT_PATH/lrreportdesignwidget.cpp \
|
$$REPORT_PATH/lrreportdesignwidget.cpp \
|
||||||
$$REPORT_PATH/lrreportdesignwindow.cpp
|
$$REPORT_PATH/lrreportdesignwindow.cpp
|
||||||
|
|
||||||
|
contains(CONFIG, svg){
|
||||||
|
SOURCES += \
|
||||||
|
$$REPORT_PATH/objectinspector/editors/lrsvgeditor.cpp \
|
||||||
|
$$REPORT_PATH/objectinspector/propertyItems/lrsvgpropitem.cpp
|
||||||
|
}
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$REPORT_PATH/databrowser/lrdatabrowser.h \
|
$$REPORT_PATH/databrowser/lrdatabrowser.h \
|
||||||
$$REPORT_PATH/databrowser/lrsqleditdialog.h \
|
$$REPORT_PATH/databrowser/lrsqleditdialog.h \
|
||||||
@ -94,6 +100,12 @@ HEADERS += \
|
|||||||
$$REPORT_PATH/lrreportdesignwidget.h \
|
$$REPORT_PATH/lrreportdesignwidget.h \
|
||||||
$$REPORT_PATH/lrreportdesignwindow.h
|
$$REPORT_PATH/lrreportdesignwindow.h
|
||||||
|
|
||||||
|
contains(CONFIG, svg){
|
||||||
|
HEADERS += \
|
||||||
|
$$REPORT_PATH/objectinspector/editors/lrsvgeditor.h \
|
||||||
|
$$REPORT_PATH/objectinspector/propertyItems/lrsvgpropitem.h
|
||||||
|
}
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
$$REPORT_PATH/databrowser/lrsqleditdialog.ui \
|
$$REPORT_PATH/databrowser/lrsqleditdialog.ui \
|
||||||
$$REPORT_PATH/databrowser/lrconnectiondialog.ui \
|
$$REPORT_PATH/databrowser/lrconnectiondialog.ui \
|
||||||
|
BIN
limereport/items/images/SVGItem.png
Normal file
BIN
limereport/items/images/SVGItem.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 600 B |
@ -44,5 +44,6 @@
|
|||||||
<file alias="ChartItem">images/pie_chart2.png</file>
|
<file alias="ChartItem">images/pie_chart2.png</file>
|
||||||
<file alias="DataHeaderBand">images/DataHeaderBand.png</file>
|
<file alias="DataHeaderBand">images/DataHeaderBand.png</file>
|
||||||
<file alias="DataFooterBand">images/DataFooterBand.png</file>
|
<file alias="DataFooterBand">images/DataFooterBand.png</file>
|
||||||
|
<file alias="SVGItem">images/SVGItem.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
@ -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();
|
painter->save();
|
||||||
if (isSelected()) ppainter->setOpacity(Const::SELECTION_OPACITY);
|
if (isSelected()) painter->setOpacity(Const::SELECTION_OPACITY);
|
||||||
else ppainter->setOpacity(qreal(opacity())/100);
|
else painter->setOpacity(qreal(opacity())/100);
|
||||||
|
|
||||||
QPointF point = rect().topLeft();
|
QPointF point = rect().topLeft();
|
||||||
QImage img;
|
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;
|
QString text;
|
||||||
ppainter->setFont(transformToSceneFont(QFont("Arial",10)));
|
painter->setFont(transformToSceneFont(QFont("Arial",10)));
|
||||||
ppainter->setPen(Qt::black);
|
painter->setPen(Qt::black);
|
||||||
if (!datasource().isEmpty() && !field().isEmpty())
|
if (!datasource().isEmpty() && !field().isEmpty())
|
||||||
text = datasource()+"."+field();
|
text = datasource()+"."+field();
|
||||||
else if (m_useExternalPainter) text = tr("Ext."); else text = tr("Image");
|
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 {
|
} else {
|
||||||
if (m_externalPainter && m_useExternalPainter)
|
if (m_externalPainter && m_useExternalPainter)
|
||||||
m_externalPainter->paintByExternalPainter(this->patternName(), ppainter, option);
|
m_externalPainter->paintByExternalPainter(this->patternName(), painter, option);
|
||||||
else
|
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)
|
void ImageItem::setImage(QImage value)
|
||||||
|
@ -64,7 +64,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
ImageItem(QObject *owner, QGraphicsItem *parent);
|
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);
|
void setImage(QImage value);
|
||||||
QImage image();
|
QImage image();
|
||||||
void setResourcePath(const QString &value);
|
void setResourcePath(const QString &value);
|
||||||
|
151
limereport/items/lrsvgitem.cpp
Normal file
151
limereport/items/lrsvgitem.cpp
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
#include "lrsvgitem.h"
|
||||||
|
#include "lrdesignelementsfactory.h"
|
||||||
|
#include <QtSvg>
|
||||||
|
|
||||||
|
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<QByteArray>();
|
||||||
|
}
|
||||||
|
} 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>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
44
limereport/items/lrsvgitem.h
Normal file
44
limereport/items/lrsvgitem.h
Normal file
@ -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
|
@ -84,6 +84,10 @@ contains(CONFIG, zint){
|
|||||||
SOURCES += $$REPORT_PATH/items/lrbarcodeitem.cpp
|
SOURCES += $$REPORT_PATH/items/lrbarcodeitem.cpp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
contains(CONFIG, svg){
|
||||||
|
SOURCES += $$REPORT_PATH/items/lrsvgitem.cpp \
|
||||||
|
}
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$REPORT_PATH/base/lrsingleton.h \
|
$$REPORT_PATH/base/lrsingleton.h \
|
||||||
$$REPORT_PATH/base/lrsimpleabstractfactory.h \
|
$$REPORT_PATH/base/lrsimpleabstractfactory.h \
|
||||||
@ -173,6 +177,10 @@ contains(CONFIG,zint){
|
|||||||
HEADERS += $$REPORT_PATH/items/lrbarcodeitem.h
|
HEADERS += $$REPORT_PATH/items/lrbarcodeitem.h
|
||||||
}
|
}
|
||||||
|
|
||||||
|
contains(CONFIG, svg){
|
||||||
|
HEADERS += $$REPORT_PATH/items/lrsvgitem.h
|
||||||
|
}
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
$$REPORT_PATH/lrpreviewreportwindow.ui \
|
$$REPORT_PATH/lrpreviewreportwindow.ui \
|
||||||
$$REPORT_PATH/lrpreviewreportwidget.ui \
|
$$REPORT_PATH/lrpreviewreportwidget.ui \
|
||||||
|
@ -17,6 +17,11 @@
|
|||||||
#include "items/lrshapeitem.h"
|
#include "items/lrshapeitem.h"
|
||||||
#include "items/lrchartitem.h"
|
#include "items/lrchartitem.h"
|
||||||
#include "lrdesignelementsfactory.h"
|
#include "lrdesignelementsfactory.h"
|
||||||
|
#ifdef HAVE_SVG
|
||||||
|
#include "items/lrsvgitem.h"
|
||||||
|
#include "objectinspector/propertyItems/lrsvgpropitem.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_REPORT_DESIGNER
|
#ifdef HAVE_REPORT_DESIGNER
|
||||||
#include "objectinspector/lrobjectpropitem.h"
|
#include "objectinspector/lrobjectpropitem.h"
|
||||||
@ -111,6 +116,12 @@ BaseDesignIntf * createBarcodeItem(QObject* owner, LimeReport::BaseDesignIntf*
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_SVG
|
||||||
|
BaseDesignIntf* createSVGItem(QObject* owner, LimeReport::BaseDesignIntf* parent){
|
||||||
|
return new SVGItem(owner,parent);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
BaseDesignIntf* createHLayout(QObject *owner, LimeReport::BaseDesignIntf *parent)
|
BaseDesignIntf* createHLayout(QObject *owner, LimeReport::BaseDesignIntf *parent)
|
||||||
{
|
{
|
||||||
return new HorizontalLayout(owner, parent);
|
return new HorizontalLayout(owner, parent);
|
||||||
@ -142,6 +153,7 @@ void initReportItems(){
|
|||||||
createBarcodeItem
|
createBarcodeItem
|
||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
DesignElementsFactory::instance().registerCreator(
|
DesignElementsFactory::instance().registerCreator(
|
||||||
"HLayout",
|
"HLayout",
|
||||||
LimeReport::ItemAttribs(QObject::tr("HLayout"), LimeReport::Const::bandTAG),
|
LimeReport::ItemAttribs(QObject::tr("HLayout"), LimeReport::Const::bandTAG),
|
||||||
@ -150,6 +162,15 @@ void initReportItems(){
|
|||||||
DesignElementsFactory::instance().registerCreator(
|
DesignElementsFactory::instance().registerCreator(
|
||||||
"ImageItem", LimeReport::ItemAttribs(QObject::tr("Image Item"),"Item"), createImageItem
|
"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(
|
DesignElementsFactory::instance().registerCreator(
|
||||||
"ShapeItem", LimeReport::ItemAttribs(QObject::tr("Shape Item"),"Item"), createShapeItem
|
"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);
|
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(
|
ObjectPropItem * createIntPropItem(
|
||||||
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
|
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(
|
ObjectPropFactory::instance().registerCreator(
|
||||||
LimeReport::APropIdent("field","LimeReport::ImageItem"),QObject::tr("field"),createFieldPropItem
|
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(
|
ObjectPropFactory::instance().registerCreator(
|
||||||
LimeReport::APropIdent("enum",""),QObject::tr("enum"),createEnumPropItem
|
LimeReport::APropIdent("enum",""),QObject::tr("enum"),createEnumPropItem
|
||||||
);
|
);
|
||||||
@ -350,6 +385,11 @@ void initObjectInspectorProperties()
|
|||||||
ObjectPropFactory::instance().registerCreator(
|
ObjectPropFactory::instance().registerCreator(
|
||||||
LimeReport::APropIdent("QImage",""),QObject::tr("QImage"),createImagePropItem
|
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(
|
ObjectPropFactory::instance().registerCreator(
|
||||||
LimeReport::APropIdent("int",""),QObject::tr("int"),createIntPropItem
|
LimeReport::APropIdent("int",""),QObject::tr("int"),createIntPropItem
|
||||||
);
|
);
|
||||||
|
48
limereport/objectinspector/editors/lrsvgeditor.cpp
Normal file
48
limereport/objectinspector/editors/lrsvgeditor.cpp
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#include "lrsvgeditor.h"
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
29
limereport/objectinspector/editors/lrsvgeditor.h
Normal file
29
limereport/objectinspector/editors/lrsvgeditor.h
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
#ifndef SVGEDITOR_H
|
||||||
|
#define SVGEDITOR_H
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
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
|
@ -68,6 +68,14 @@ namespace{
|
|||||||
bool VARIABLE_IS_NOT_USED registredBarcodeFieldProp = LimeReport::ObjectPropFactory::instance().registerCreator(
|
bool VARIABLE_IS_NOT_USED registredBarcodeFieldProp = LimeReport::ObjectPropFactory::instance().registerCreator(
|
||||||
LimeReport::APropIdent("field","LimeReport::BarcodeItem"),QObject::tr("field"),createFieldPropItem
|
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{
|
QWidget* LimeReport::DatasourcePropItem::createProperyEditor(QWidget *parent) const{
|
||||||
|
42
limereport/objectinspector/propertyItems/lrsvgpropitem.cpp
Normal file
42
limereport/objectinspector/propertyItems/lrsvgpropitem.cpp
Normal file
@ -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<SvgEditor*>(propertyEditor);
|
||||||
|
editor->setImage(propertyValue().value<QByteArray>());
|
||||||
|
}
|
||||||
|
|
||||||
|
void SvgPropItem::setModelData(QWidget *propertyEditor, QAbstractItemModel *model, const QModelIndex &index)
|
||||||
|
{
|
||||||
|
model->setData(index,qobject_cast<SvgEditor*>(propertyEditor)->image());
|
||||||
|
object()->setProperty(propertyName().toLatin1(),propertyValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
QIcon SvgPropItem::iconValue() const
|
||||||
|
{
|
||||||
|
return QIcon(QPixmap::fromImage(propertyValue().value<QImage>()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
23
limereport/objectinspector/propertyItems/lrsvgpropitem.h
Normal file
23
limereport/objectinspector/propertyItems/lrsvgpropitem.h
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user