mirror of
https://github.com/python-LimeReport/LimeReport.git
synced 2025-01-11 12:28:09 +03:00
Merge branch 'master' into 1.4
This commit is contained in:
commit
826e62abe0
@ -59,7 +59,7 @@ void VariablesHolder::addVariable(const QString& name, const QVariant& value, Va
|
||||
varValue->setVarType(type);
|
||||
varValue->setRenderPass(pass);
|
||||
m_varNames.insert(name,varValue);
|
||||
if (type==VarDesc::User)
|
||||
if (type==VarDesc::Report)
|
||||
m_userVariables.append(varValue);
|
||||
} else {
|
||||
throw ReportError(tr("variable with name ")+name+tr(" already exists !!"));
|
||||
|
@ -76,6 +76,10 @@ LimeReport::SerializatorIntf* createQByteArraySerializator(QDomDocument *doc, QD
|
||||
return new LimeReport::XmlQByteArraySerializator(doc,node);
|
||||
}
|
||||
|
||||
LimeReport::SerializatorIntf* createQVariantSerializator(QDomDocument *doc, QDomElement *node){
|
||||
return new LimeReport::XmlQVariantSerializator(doc,node);
|
||||
}
|
||||
|
||||
bool registredQString = LimeReport::XMLAbstractSerializatorFactory::instance().registerCreator("QString", createQStringSerializator);
|
||||
bool registredInt = LimeReport::XMLAbstractSerializatorFactory::instance().registerCreator("int", createIntSerializator);
|
||||
bool registredEnumAndFlags = LimeReport::XMLAbstractSerializatorFactory::instance().registerCreator("enumAndFlags",createEnumAndFlagsSerializator);
|
||||
@ -87,6 +91,7 @@ bool registredQReal = LimeReport::XMLAbstractSerializatorFactory::instance().reg
|
||||
bool registerDouble = LimeReport::XMLAbstractSerializatorFactory::instance().registerCreator("double", createQRealSerializator);
|
||||
bool registerQColor = LimeReport::XMLAbstractSerializatorFactory::instance().registerCreator("QColor", createQColorSerializator);
|
||||
bool registerQByteArray = LimeReport::XMLAbstractSerializatorFactory::instance().registerCreator("QByteArray", createQByteArraySerializator);
|
||||
bool registerQVariant = LimeReport::XMLAbstractSerializatorFactory::instance().registerCreator("QVariant", createQVariantSerializator);
|
||||
|
||||
}
|
||||
|
||||
@ -275,6 +280,21 @@ QVariant XmlQByteArraySerializator::loadValue()
|
||||
return QByteArray::fromBase64(ba);
|
||||
}
|
||||
|
||||
void XmlQVariantSerializator::save(const QVariant &value, QString name)
|
||||
{
|
||||
QDomElement _node = doc()->createElement(name);
|
||||
_node.setAttribute("Type","QVariant");
|
||||
_node.setAttribute("Value",QString(value.toByteArray().toBase64()));
|
||||
node()->appendChild(_node);
|
||||
}
|
||||
|
||||
QVariant XmlQVariantSerializator::loadValue()
|
||||
{
|
||||
QByteArray ba;
|
||||
ba.append(node()->attribute("Value").toLatin1());
|
||||
return QByteArray::fromBase64(ba);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -137,5 +137,14 @@ private:
|
||||
virtual QVariant loadValue();
|
||||
};
|
||||
|
||||
class XmlQVariantSerializator : public XmlBaseSerializator
|
||||
{
|
||||
public:
|
||||
XmlQVariantSerializator(QDomDocument *doc, QDomElement *node):XmlBaseSerializator(doc,node){}
|
||||
private:
|
||||
virtual void save(const QVariant &value, QString name);
|
||||
virtual QVariant loadValue();
|
||||
};
|
||||
|
||||
}
|
||||
#endif // LRXMLBASETYPESSERIALIZATORS_H
|
||||
|
@ -125,8 +125,13 @@ QDomElement XMLWriter::putQObjectItem(QString name, QObject *item)
|
||||
|
||||
void XMLWriter::saveProperty(QString name, QObject* item, QDomElement *node)
|
||||
{
|
||||
CreateSerializator creator=0;
|
||||
QString typeName;
|
||||
if (name.compare("itemIndexMethod")==0)
|
||||
typeName = item->metaObject()->property(item->metaObject()->indexOfProperty(name.toLatin1())).typeName();
|
||||
else
|
||||
typeName = item->property(name.toLatin1()).typeName();
|
||||
|
||||
CreateSerializator creator=0;
|
||||
if (isCollection(name,item)) { saveCollection(name,item,node); return;}
|
||||
if (isQObject(name,item)) {
|
||||
if (qvariant_cast<QObject *>(item->property(name.toLatin1())))
|
||||
@ -143,12 +148,10 @@ void XMLWriter::saveProperty(QString name, QObject* item, QDomElement *node)
|
||||
);
|
||||
else
|
||||
try {
|
||||
creator=XMLAbstractSerializatorFactory::instance().objectCreator(
|
||||
item->metaObject()->property(item->metaObject()->indexOfProperty(name.toLatin1())).typeName()
|
||||
);
|
||||
creator=XMLAbstractSerializatorFactory::instance().objectCreator(typeName);
|
||||
} catch (LimeReport::ReportError &exception){
|
||||
qDebug()<<"class name ="<<item->metaObject()->className()
|
||||
<<"property name="<<name<<" property type="<<item->property(name.toLatin1()).typeName()
|
||||
<<"property name="<<name<<" property type="<<typeName
|
||||
<<exception.what();
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user