1 #include "DisplayProperties.h"
5 #include <QXmlStreamWriter>
9 #include "XmlStackedHandlerReader.h"
35 xmlReader->pushContentHandler(
new XmlHandler(
this));
46 void DisplayProperties::fromPvl(
const PvlObject &pvl) {
49 QByteArray hexValues(pvl[
"Values"][0].toLatin1());
50 QDataStream valuesStream(QByteArray::fromHex(hexValues));
65 dataBuffer.open(QIODevice::ReadWrite);
67 QDataStream propsStream(&dataBuffer);
71 output +=
PvlKeyword(
"Values", QString(dataBuffer.data().toHex()));
103 emit supportAdded(property);
125 (*m_propertyValues)[property] = value;
128 emit propertyChanged(
this);
153 stream.writeStartElement(
"displayProperties");
155 stream.writeAttribute(
"displayName",
displayName());
159 dataBuffer.open(QIODevice::ReadWrite);
160 QDataStream propsStream(&dataBuffer);
164 stream.writeCharacters(dataBuffer.data().toHex());
166 stream.writeEndElement();
170 DisplayProperties::XmlHandler::XmlHandler(
DisplayProperties *displayProperties) {
171 m_displayProperties = displayProperties;
175 bool DisplayProperties::XmlHandler::startElement(
const QString &namespaceURI,
176 const QString &localName,
const QString &qName,
const QXmlAttributes &atts) {
177 if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) {
178 if (localName ==
"displayProperties") {
181 if (!displayName.isEmpty()) {
182 m_displayProperties->setDisplayName(displayName);
191 bool DisplayProperties::XmlHandler::characters(
const QString &ch) {
194 return XmlStackedHandler::characters(ch);
198 bool DisplayProperties::XmlHandler::endElement(
const QString &namespaceURI,
199 const QString &localName,
const QString &qName) {
200 if (localName ==
"displayProperties") {
201 QByteArray hexValues(m_hexData.toLatin1());
202 QDataStream valuesStream(QByteArray::fromHex(hexValues));
203 valuesStream >> *m_displayProperties->m_propertyValues;
206 return XmlStackedHandler::endElement(namespaceURI, localName, qName);
QVariant getValue(int property) const
Get a property's associated data.
bool supports(int property)
Support may come later, please make sure you are connected to the supportAdded signal.
PvlObject toPvl() const
Convert to Pvl for project files.
The main project for cnetsuite.
File name manipulation and expansion.
QString m_displayName
This is the display name.
void setDisplayName(QString displayName)
Sets display name.
virtual ~DisplayProperties()
destructor
QString displayName() const
Returns the display name.
QMap< int, QVariant > * m_propertyValues
This is a map from Property to value – the reason I use an int is so Qt knows how to serialize this Q...
A single keyword-value pair.
void setValue(int prop, QVariant value)
This is the generic mutator for properties.
DisplayProperties(QString displayName, QObject *parent=NULL)
DisplayProperties constructor.
void addSupport(int property)
Call this with every property you support, otherwise they will not communicate properly between widge...
int m_propertiesUsed
This indicated whether any widgets with this DisplayProperties is using a particulay property...
Adds specific functionality to C++ strings.
Contains Pvl Groups and Pvl Objects.
void save(QXmlStreamWriter &stream, const Project *project, FileName newProjectRoot) const
Output format:
his enables stack-based XML parsing of XML files.