Official websites use .gov
A .gov website belongs to an official government organization in the United States.

Secure .gov websites use HTTPS
A lock ( ) or https:// means you’ve safely connected to the .gov website. Share sensitive information only on official, secure websites.

Isis 3 Programmer Reference
DisplayProperties.cpp
1
6
7/* SPDX-License-Identifier: CC0-1.0 */
8
9#include "DisplayProperties.h"
10
11#include <QBuffer>
12#include <QDataStream>
13#include <QXmlStreamWriter>
14
15#include "FileName.h"
16#include "Pvl.h"
17
18namespace Isis {
36
37
43
44
45 void DisplayProperties::fromPvl(const PvlObject &pvl) {
46 setDisplayName(((IString)pvl["DisplayName"][0]).ToQt());
47
48 QByteArray hexValues(pvl["Values"][0].toLatin1());
49 QDataStream valuesStream(QByteArray::fromHex(hexValues));
50 valuesStream.setVersion(int(pvl["QtVersion"]));
51 valuesStream >> *m_propertyValues;
52 }
53
54
60 PvlObject DisplayProperties::toPvl() const {
61 PvlObject output("DisplayProperties");
62 output += PvlKeyword("DisplayName", displayName());
63
64 QBuffer dataBuffer;
65 dataBuffer.open(QIODevice::ReadWrite);
66
67 QDataStream propsStream(&dataBuffer);
68 propsStream << *m_propertyValues;
69 dataBuffer.seek(0);
70
71 output += PvlKeyword("Values", QString(dataBuffer.data().toHex()));
72
73 return output;
74 }
75
76
81 return m_displayName;
82 }
83
92
93
100 void DisplayProperties::addSupport(int property) {
101 if (!supports(property)) {
103 emit supportAdded(property);
104 }
105 }
106
107
114 bool DisplayProperties::supports(int property) {
115 return (m_propertiesUsed & property) == property;
116 }
117
118
123 void DisplayProperties::setValue(int property, QVariant value) {
124 if ((*m_propertyValues)[property] != value) {
125 (*m_propertyValues)[property] = value;
126
127 if (supports(property)) {
128 emit propertyChanged(this);
129 }
130 }
131 }
132
133
139 QVariant DisplayProperties::getValue(int property) const {
140 return (*m_propertyValues)[property];
141 }
142
143
151 void DisplayProperties::save(QXmlStreamWriter &stream, const Project *project,
152 FileName newProjectRoot) const {
153 stream.writeStartElement("displayProperties");
154
155 stream.writeAttribute("displayName", displayName());
156
157 // Get hex-encoded data
158 QBuffer dataBuffer;
159 dataBuffer.open(QIODevice::ReadWrite);
160 QDataStream propsStream(&dataBuffer);
161 propsStream << *m_propertyValues;
162 dataBuffer.seek(0);
163
164 stream.writeCharacters(dataBuffer.data().toHex());
165
166 stream.writeEndElement();
167 }
168}
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.
The main project for ipce.
Definition Project.h:287
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16