0
0
mirror of https://github.com/fralx/LimeReport.git synced 2024-12-27 01:48:09 +03:00
LimeReport/limereport/lrfactoryinitializer.cpp

431 lines
19 KiB
C++
Raw Normal View History

2017-06-12 13:11:00 +03:00
#include "bands/lrdataband.h"
#include "bands/lrgroupbands.h"
#include "bands/lrpagefooter.h"
#include "bands/lrpageheader.h"
#include "bands/lrreportheader.h"
#include "bands/lrreportfooter.h"
#include "bands/lrsubdetailband.h"
#include "bands/lrtearoffband.h"
#include "items/lrtextitem.h"
2017-06-13 13:03:38 +03:00
#ifdef HAVE_ZINT
2017-06-12 13:11:00 +03:00
#include "items/lrbarcodeitem.h"
2017-06-13 13:03:38 +03:00
#endif
2017-06-12 13:11:00 +03:00
#include "items/lrhorizontallayout.h"
#include "items/lrimageitem.h"
#include "items/lrshapeitem.h"
#include "lrdesignelementsfactory.h"
#include "objectinspector/lrobjectpropitem.h"
#include "objectinspector/propertyItems/lrboolpropitem.h"
#include "objectinspector/propertyItems/lrcolorpropitem.h"
#include "objectinspector/propertyItems/lrcontentpropitem.h"
#include "objectinspector/propertyItems/lrdatasourcepropitem.h"
#include "objectinspector/propertyItems/lrenumpropitem.h"
#include "objectinspector/propertyItems/lrflagspropitem.h"
#include "objectinspector/propertyItems/lrfontpropitem.h"
#include "objectinspector/propertyItems/lrgroupfieldpropitem.h"
#include "objectinspector/propertyItems/lrimagepropitem.h"
#include "objectinspector/propertyItems/lrintpropitem.h"
#include "objectinspector/propertyItems/lrqrealpropitem.h"
#include "objectinspector/propertyItems/lrrectproptem.h"
#include "objectinspector/propertyItems/lrstringpropitem.h"
#include "items/lralignpropitem.h"
#include "items/lrsubitemparentpropitem.h"
#include "serializators/lrxmlbasetypesserializators.h"
#include "serializators/lrxmlqrectserializator.h"
#include "serializators/lrxmlserializatorsfactory.h"
void initResources(){
2017-06-12 13:11:00 +03:00
Q_INIT_RESOURCE(report);
Q_INIT_RESOURCE(lobjectinspector);
Q_INIT_RESOURCE(lrdatabrowser);
Q_INIT_RESOURCE(items);
Q_INIT_RESOURCE(lrscriptbrowser);
}
namespace LimeReport{
BaseDesignIntf * createDataBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
return new LimeReport::DataBand(owner,parent);
}
BaseDesignIntf * createHeaderDataBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
return new LimeReport::DataHeaderBand(owner,parent);
}
BaseDesignIntf * createFooterDataBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
return new LimeReport::DataFooterBand(owner,parent);
}
BaseDesignIntf* createGroupHeaderBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
return new LimeReport::GroupBandHeader(owner,parent);
}
BaseDesignIntf * createGroupFooterBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
return new LimeReport::GroupBandFooter(owner,parent);
}
BaseDesignIntf * createPageHeaderBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
return new LimeReport::PageHeader(owner,parent);
}
BaseDesignIntf * createPageFooterBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
return new LimeReport::PageFooter(owner,parent);
}
BaseDesignIntf * createSubDetailBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
return new LimeReport::SubDetailBand(owner,parent);
}
BaseDesignIntf * createSubDetailHeaderBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
return new LimeReport::SubDetailHeaderBand(owner,parent);
}
BaseDesignIntf * createSubDetailFooterBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
return new LimeReport::SubDetailFooterBand(owner,parent);
}
BaseDesignIntf * createTearOffBand(QObject* owner, LimeReport::BaseDesignIntf* parent){
return new LimeReport::TearOffBand(owner,parent);
}
BaseDesignIntf * createTextItem(QObject* owner, LimeReport::BaseDesignIntf* parent){
return new LimeReport::TextItem(owner,parent);
}
#ifdef HAVE_ZINT
2017-06-12 13:11:00 +03:00
BaseDesignIntf * createBarcodeItem(QObject* owner, LimeReport::BaseDesignIntf* parent){
return new BarcodeItem(owner,parent);
}
#endif
2017-06-12 13:11:00 +03:00
BaseDesignIntf* createHLayout(QObject *owner, LimeReport::BaseDesignIntf *parent)
{
return new HorizontalLayout(owner, parent);
}
BaseDesignIntf * createImageItem(QObject* owner, LimeReport::BaseDesignIntf* parent){
return new ImageItem(owner,parent);
}
BaseDesignIntf * createShapeItem(QObject* owner, LimeReport::BaseDesignIntf* parent){
return new ShapeItem(owner,parent);
}
void initReportItems(){
initResources();
DesignElementsFactory::instance().registerCreator(
"TextItem",
LimeReport::ItemAttribs(QObject::tr("Text Item"),"TextItem"),
createTextItem
);
#ifdef HAVE_ZINT
DesignElementsFactory::instance().registerCreator(
"BarcodeItem",
LimeReport::ItemAttribs(QObject::tr("Barcode Item"),"Item"),
createBarcodeItem
);
#endif
DesignElementsFactory::instance().registerCreator(
"HLayout",
LimeReport::ItemAttribs(QObject::tr("HLayout"), LimeReport::Const::bandTAG),
createHLayout
);
DesignElementsFactory::instance().registerCreator(
"ImageItem", LimeReport::ItemAttribs(QObject::tr("Image Item"),"Item"), createImageItem
);
DesignElementsFactory::instance().registerCreator(
"ShapeItem", LimeReport::ItemAttribs(QObject::tr("Shape Item"),"Item"), createShapeItem
);
DesignElementsFactory::instance().registerCreator(
"Data",
LimeReport::ItemAttribs(QObject::tr("Data"),LimeReport::Const::bandTAG),
createDataBand
);
DesignElementsFactory::instance().registerCreator(
"DataHeader",
LimeReport::ItemAttribs(QObject::tr("DataHeader"),LimeReport::Const::bandTAG),
createHeaderDataBand
);
DesignElementsFactory::instance().registerCreator(
"DataFooter",
LimeReport::ItemAttribs(QObject::tr("DataFooter"),LimeReport::Const::bandTAG),
createFooterDataBand
);
DesignElementsFactory::instance().registerCreator(
"GroupHeader",
LimeReport::ItemAttribs(QObject::tr("GroupHeader"),LimeReport::Const::bandTAG),
createGroupHeaderBand
);
DesignElementsFactory::instance().registerCreator(
"GroupFooter",
LimeReport::ItemAttribs(QObject::tr("GroupFooter"),LimeReport::Const::bandTAG),
createGroupFooterBand
);
DesignElementsFactory::instance().registerCreator(
"PageFooter",
LimeReport::ItemAttribs(QObject::tr("Page Footer"),LimeReport::Const::bandTAG),
createPageFooterBand
);
DesignElementsFactory::instance().registerCreator(
"PageHeader",
LimeReport::ItemAttribs(QObject::tr("Page Header"),LimeReport::Const::bandTAG),
createPageHeaderBand
);
DesignElementsFactory::instance().registerCreator(
"SubDetail",
LimeReport::ItemAttribs(QObject::tr("SubDetail"),LimeReport::Const::bandTAG),
createSubDetailBand
);
DesignElementsFactory::instance().registerCreator(
"SubDetailHeader",
LimeReport::ItemAttribs(QObject::tr("SubDetailHeader"),LimeReport::Const::bandTAG),
createSubDetailHeaderBand
);
DesignElementsFactory::instance().registerCreator(
"SubDetailFooter",
LimeReport::ItemAttribs(QObject::tr("SubDetailFooter"),LimeReport::Const::bandTAG),
createSubDetailFooterBand
);
DesignElementsFactory::instance().registerCreator(
"TearOffBand",
LimeReport::ItemAttribs(QObject::tr("Tear-off Band"),LimeReport::Const::bandTAG),
createTearOffBand
);
}
ObjectPropItem * createBoolPropItem(
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
{
return new LimeReport::BoolPropItem(object, objects, name, displayName, data, parent, readonly);
}
ObjectPropItem * createColorPropItem(
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
{
return new ColorPropItem(object, objects, name, displayName, data, parent, readonly);
}
ObjectPropItem * createContentPropItem(
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
{
return new ContentPropItem(object, objects, name, displayName, data, parent, readonly);
}
ObjectPropItem * createDatasourcePropItem(
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
{
return new LimeReport::DatasourcePropItem(object, objects, name, displayName, data, parent, readonly);
}
ObjectPropItem* createFieldPropItem(QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly){
return new LimeReport::FieldPropItem(object, objects, name, displayName, data, parent, readonly);
}
ObjectPropItem * createEnumPropItem(
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
{
return new LimeReport::EnumPropItem(object, objects, name, displayName, data, parent, readonly);
}
ObjectPropItem * createFlagsPropItem(
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
{
return new LimeReport::FlagsPropItem(object, objects, name, displayName, data, parent, readonly);
}
ObjectPropItem * createFontPropItem(
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
{
return new LimeReport::FontPropItem(object, objects, name, displayName, data, parent, readonly);
}
ObjectPropItem* createGroupFieldPropItem(QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly){
return new LimeReport::GroupFieldPropItem(object, objects, name, displayName, data, parent, readonly);
}
ObjectPropItem * createImagePropItem(
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
{
return new LimeReport::ImagePropItem(object, objects, name, displayName, data, parent, readonly);
}
ObjectPropItem * createIntPropItem(
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
{
return new LimeReport::IntPropItem(object, objects, name, displayName, data, parent, readonly);
}
ObjectPropItem * createQRealPropItem(
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
{
return new LimeReport::QRealPropItem(object, objects, name, displayName, data, parent, readonly);
}
ObjectPropItem * createReqtItem(
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly
){
return new LimeReport::RectPropItem(object, objects, name, displayName, data, parent, readonly);
}
ObjectPropItem * createReqtMMItem(
QObject*object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly
){
return new LimeReport::RectMMPropItem(object, objects, name, displayName, data, parent, readonly);
}
ObjectPropItem * createStringPropItem(
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
{
return new LimeReport::StringPropItem(object, objects, name, displayName, data, parent, readonly);
}
ObjectPropItem * createAlignItem(
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly
){
return new LimeReport::AlignmentPropItem(object, objects, name, displayName, data, parent, readonly);
}
ObjectPropItem * createLocationPropItem(
QObject *object, LimeReport::ObjectPropItem::ObjectsList* objects, const QString& name, const QString& displayName, const QVariant& data, LimeReport::ObjectPropItem* parent, bool readonly)
{
return new LimeReport::ItemLocationPropItem(object, objects, name, displayName, data, parent, readonly);
}
void initObjectInspectorProperties()
{
ObjectPropFactory::instance().registerCreator(
LimeReport::APropIdent("bool",""),QObject::tr("bool"),createBoolPropItem
);
ObjectPropFactory::instance().registerCreator(
LimeReport::APropIdent("QColor",""),QObject::tr("QColor"),createColorPropItem
);
ObjectPropFactory::instance().registerCreator(
LimeReport::APropIdent("content","LimeReport::TextItem"),QObject::tr("content"),createContentPropItem
);
ObjectPropFactory::instance().registerCreator(
LimeReport::APropIdent("datasource","LimeReport::DataBandDesignIntf"),QObject::tr("datasource"),createDatasourcePropItem
);
ObjectPropFactory::instance().registerCreator(
LimeReport::APropIdent("datasource","LimeReport::ImageItem"),QObject::tr("datasource"),createDatasourcePropItem
);
ObjectPropFactory::instance().registerCreator(
LimeReport::APropIdent("field","LimeReport::ImageItem"),QObject::tr("field"),createFieldPropItem
);
ObjectPropFactory::instance().registerCreator(
LimeReport::APropIdent("enum",""),QObject::tr("enum"),createEnumPropItem
);
ObjectPropFactory::instance().registerCreator(
LimeReport::APropIdent("flags",""),QObject::tr("flags"),createFlagsPropItem
);
ObjectPropFactory::instance().registerCreator(
LimeReport::APropIdent("QFont",""),QObject::tr("QFont"),createFontPropItem
);
ObjectPropFactory::instance().registerCreator(
LimeReport::APropIdent("groupFieldName","LimeReport::GroupBandHeader"),QObject::tr("field"),createGroupFieldPropItem
);
ObjectPropFactory::instance().registerCreator(
LimeReport::APropIdent("QImage",""),QObject::tr("QImage"),createImagePropItem
);
ObjectPropFactory::instance().registerCreator(
LimeReport::APropIdent("int",""),QObject::tr("int"),createIntPropItem
);
ObjectPropFactory::instance().registerCreator(
LimeReport::APropIdent("qreal",""),QObject::tr("qreal"),createQRealPropItem
);
ObjectPropFactory::instance().registerCreator(
LimeReport::APropIdent("double",""),QObject::tr("qreal"),createQRealPropItem
);
ObjectPropFactory::instance().registerCreator(
LimeReport::APropIdent("QRect",""),QObject::tr("QRect"),createReqtItem
);
ObjectPropFactory::instance().registerCreator(
LimeReport::APropIdent("QRectF",""),QObject::tr("QRectF"),createReqtItem
);
ObjectPropFactory::instance().registerCreator(
LimeReport::APropIdent("geometry","LimeReport::BaseDesignIntf"),QObject::tr("geometry"),createReqtMMItem
);
ObjectPropFactory::instance().registerCreator(
LimeReport::APropIdent("QString",""),QObject::tr("QString"),createStringPropItem
);
ObjectPropFactory::instance().registerCreator(
LimeReport::APropIdent("alignment","LimeReport::TextItem"),QObject::tr("alignment"),createAlignItem
);
ObjectPropFactory::instance().registerCreator(
LimeReport::APropIdent("itemLocation","LimeReport::ItemDesignIntf"),QObject::tr("itemLocation"),createLocationPropItem
);
}
SerializatorIntf * createIntSerializator(QDomDocument *doc, QDomElement *node){
return new LimeReport::XmlIntSerializator(doc,node);
}
SerializatorIntf * createQRealSerializator(QDomDocument *doc, QDomElement *node){
return new LimeReport::XmlQRealSerializator(doc,node);
}
SerializatorIntf * createQStringSerializator(QDomDocument *doc, QDomElement *node){
return new LimeReport::XmlQStringSerializator(doc,node);
}
SerializatorIntf * createEnumAndFlagsSerializator(QDomDocument *doc, QDomElement *node){
return new LimeReport::XmlEnumAndFlagsSerializator(doc,node);
}
SerializatorIntf * createBoolSerializator(QDomDocument *doc, QDomElement *node){
return new LimeReport::XmlBoolSerializator(doc,node);
}
SerializatorIntf * createFontSerializator(QDomDocument *doc, QDomElement *node){
return new LimeReport::XmlFontSerializator(doc,node);
}
SerializatorIntf * createQSizeFSerializator(QDomDocument *doc, QDomElement *node){
return new LimeReport::XmlQSizeFSerializator(doc,node);
}
SerializatorIntf * createQImageSerializator(QDomDocument *doc, QDomElement *node){
return new LimeReport::XmlQImageSerializator(doc,node);
}
SerializatorIntf * createQColorSerializator(QDomDocument *doc, QDomElement *node){
return new LimeReport::XmlColorSerializator(doc,node);
}
SerializatorIntf* createQByteArraySerializator(QDomDocument *doc, QDomElement *node){
return new LimeReport::XmlQByteArraySerializator(doc,node);
}
SerializatorIntf* createQVariantSerializator(QDomDocument *doc, QDomElement *node){
return new LimeReport::XmlQVariantSerializator(doc,node);
}
SerializatorIntf * createQRectSerializator(QDomDocument *doc, QDomElement *node){
return new LimeReport::XMLQRectSerializator(doc,node);
}
void initSerializators()
{
XMLAbstractSerializatorFactory::instance().registerCreator("QString", createQStringSerializator);
XMLAbstractSerializatorFactory::instance().registerCreator("int", createIntSerializator);
XMLAbstractSerializatorFactory::instance().registerCreator("enumAndFlags",createEnumAndFlagsSerializator);
XMLAbstractSerializatorFactory::instance().registerCreator("bool", createBoolSerializator);
XMLAbstractSerializatorFactory::instance().registerCreator("QFont", createFontSerializator);
XMLAbstractSerializatorFactory::instance().registerCreator("QSizeF", createQSizeFSerializator);
XMLAbstractSerializatorFactory::instance().registerCreator("QImage", createQImageSerializator);
XMLAbstractSerializatorFactory::instance().registerCreator("qreal", createQRealSerializator);
XMLAbstractSerializatorFactory::instance().registerCreator("double", createQRealSerializator);
XMLAbstractSerializatorFactory::instance().registerCreator("QColor", createQColorSerializator);
XMLAbstractSerializatorFactory::instance().registerCreator("QByteArray", createQByteArraySerializator);
XMLAbstractSerializatorFactory::instance().registerCreator("QVariant", createQVariantSerializator);
XMLAbstractSerializatorFactory::instance().registerCreator("QRect", createQRectSerializator);
XMLAbstractSerializatorFactory::instance().registerCreator("QRectF", createQRectSerializator);
}
} //namespace LimeReport