mirror of
https://github.com/fralx/LimeReport.git
synced 2025-01-11 17:18:10 +03:00
QVariant serializator has been added
This commit is contained in:
parent
43089b55d6
commit
a010c2012f
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user