9#include "DisplayProperties.h"
13#include <QXmlStreamWriter>
17#include "XmlStackedHandlerReader.h"
43 xmlReader->pushContentHandler(
new XmlHandler(
this));
54 void DisplayProperties::fromPvl(
const PvlObject &pvl) {
57 QByteArray hexValues(pvl[
"Values"][0].toLatin1());
58 QDataStream valuesStream(QByteArray::fromHex(hexValues));
73 dataBuffer.open(QIODevice::ReadWrite);
75 QDataStream propsStream(&dataBuffer);
79 output +=
PvlKeyword(
"Values", QString(dataBuffer.data().toHex()));
111 emit supportAdded(property);
133 (*m_propertyValues)[property] = value;
136 emit propertyChanged(
this);
161 stream.writeStartElement(
"displayProperties");
163 stream.writeAttribute(
"displayName",
displayName());
167 dataBuffer.open(QIODevice::ReadWrite);
168 QDataStream propsStream(&dataBuffer);
172 stream.writeCharacters(dataBuffer.data().toHex());
174 stream.writeEndElement();
178 DisplayProperties::XmlHandler::XmlHandler(
DisplayProperties *displayProperties) {
179 m_displayProperties = displayProperties;
183 bool DisplayProperties::XmlHandler::startElement(
const QString &namespaceURI,
184 const QString &localName,
const QString &qName,
const QXmlAttributes &atts) {
185 if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) {
186 if (localName ==
"displayProperties") {
199 bool DisplayProperties::XmlHandler::characters(
const QString &ch) {
202 return XmlStackedHandler::characters(ch);
206 bool DisplayProperties::XmlHandler::endElement(
const QString &namespaceURI,
207 const QString &localName,
const QString &qName) {
208 if (localName ==
"displayProperties") {
209 QByteArray hexValues(m_hexData.toLatin1());
210 QDataStream valuesStream(QByteArray::fromHex(hexValues));
211 valuesStream >> *m_displayProperties->m_propertyValues;
214 return XmlStackedHandler::endElement(namespaceURI, localName, qName);
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...
QVariant getValue(int property) const
Get a property's associated data.
QString displayName() const
Returns the display name.
void save(QXmlStreamWriter &stream, const Project *project, FileName newProjectRoot) const
Output format:
void setDisplayName(QString displayName)
Sets display name.
void setValue(int prop, QVariant value)
This is the generic mutator for properties.
virtual ~DisplayProperties()
destructor
PvlObject toPvl() const
Convert to Pvl for project files.
QString m_displayName
This is the display name.
DisplayProperties(QString displayName, QObject *parent=NULL)
DisplayProperties constructor.
bool supports(int property)
Support may come later, please make sure you are connected to the supportAdded signal.
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.
File name manipulation and expansion.
Adds specific functionality to C++ strings.
The main project for ipce.
A single keyword-value pair.
Contains Pvl Groups and Pvl Objects.
Manage a stack of content handlers for reading XML files.
This is free and unencumbered software released into the public domain.