BornAgain  1.19.79
Simulate and fit neutron and x-ray scattering at grazing incidence
GUI::Session::XML Namespace Reference

Namespaces

 Tags
 

Functions

void assertExpectedTag (QXmlStreamReader *reader, const QString &tag)
 
void gotoEndElementOfTag (QXmlStreamReader *reader, const QString &tag)
 
constexpr auto InstrumentModelTag ("InstrumentModel")
 
constexpr auto ItemTag ("Item")
 
constexpr auto JobModelTag ("JobModel")
 
constexpr auto ModelTypeAttribute ("ModelType")
 
constexpr auto ParameterTag ("Parameter")
 
void readAttribute (QXmlStreamReader *reader, const QString &attributeBaseName, complex_t *c)
 
void readAttribute (QXmlStreamReader *reader, const QString &attributeBaseName, R3 *vec)
 
void readAttribute (QXmlStreamReader *reader, const QString &attributeName, double *d)
 
void readAttribute (QXmlStreamReader *reader, const QString &attributeName, QColor *c)
 
void readAttribute (QXmlStreamReader *reader, const QString &attributeName, QString *s)
 
bool readBoolAttribute (QXmlStreamReader *reader, const QString &attributeName)
 
void readItems (QXmlStreamReader *reader, SessionItem *parent, QString topTag="", MessageService *messageService=nullptr)
 
QString readProperty (QXmlStreamReader *reader, SessionItem *item)
 
unsigned readUIntAttribute (QXmlStreamReader *reader, const QString &attributeName)
 
constexpr auto RealDataModelTag ("RealDataModel")
 
constexpr auto Version ("Version")
 
void writeAttribute (QXmlStreamWriter *writer, const QString &attributeBaseName, const complex_t &c)
 
void writeAttribute (QXmlStreamWriter *writer, const QString &attributeBaseName, const R3 &vec)
 
void writeAttribute (QXmlStreamWriter *writer, const QString &attributeName, const QVariant &variant)
 Write the variant's value as an attribute. More...
 
void writeAttribute (QXmlStreamWriter *writer, const QString &attributeName, double d)
 
void writeAttribute (QXmlStreamWriter *writer, const QString &attributeName, int d)
 
void writeAttribute (QXmlStreamWriter *writer, const QString &attributeName, unsigned d)
 
void writeItemAndChildItems (QXmlStreamWriter *writer, const SessionItem *item)
 
void writeModel (QXmlStreamWriter *writer, SessionItem *modelRootItem)
 
void writeUid (QXmlStreamWriter *writer, const QString &id)
 
void writeUid (QXmlStreamWriter *writer, const QUuid &id)
 
void writeVariant (QXmlStreamWriter *writer, QVariant variant, int role)
 Write the variant as a complete tag, including the given role. More...
 

Variables

constexpr auto ItemMimeType = "application/org.bornagainproject.xml.item.z"
 
constexpr auto LinkMimeType = "application/org.bornagainproject.fittinglink"
 

Function Documentation

◆ assertExpectedTag()

void GUI::Session::XML::assertExpectedTag ( QXmlStreamReader *  reader,
const QString &  tag 
)

Definition at line 199 of file UtilXML.cpp.

200 {
201  if (reader->name() != expectedTag) {
202 #ifdef _DEBUG
203  // to simplify debugging: what is the current tag
204  QString foundTag = reader->name().toString();
205  Q_UNUSED(foundTag);
206 #endif
208  }
209 }
static DeserializationException streamError()

References DeserializationException::streamError().

Referenced by ProjectDocument::readProject().

Here is the call graph for this function:

◆ gotoEndElementOfTag()

void GUI::Session::XML::gotoEndElementOfTag ( QXmlStreamReader *  reader,
const QString &  tag 
)

Definition at line 49 of file UtilXML.cpp.

50 {
51  ASSERT(reader);
52  if (reader->name() != tag) {
53  if (!reader->isEndElement())
54  reader->skipCurrentElement();
55  reader->skipCurrentElement();
56  }
57  assertCurrentTag(reader, tag);
58  if (!reader->isEndElement())
59  reader->skipCurrentElement();
60 
61  assertCurrentToken(reader, QXmlStreamReader::EndElement);
62  assertCurrentTag(reader, tag);
63 }

Referenced by readItems(), and JobItem::readNonSessionItems().

◆ InstrumentModelTag()

constexpr auto GUI::Session::XML::InstrumentModelTag ( "InstrumentModel"  )
constexpr

◆ ItemTag()

constexpr auto GUI::Session::XML::ItemTag ( "Item"  )
constexpr

◆ JobModelTag()

constexpr auto GUI::Session::XML::JobModelTag ( "JobModel"  )
constexpr

Referenced by JobModel::JobModel().

◆ ModelTypeAttribute()

constexpr auto GUI::Session::XML::ModelTypeAttribute ( "ModelType"  )
constexpr

◆ ParameterTag()

constexpr auto GUI::Session::XML::ParameterTag ( "Parameter"  )
constexpr

Referenced by readItems(), and writeVariant().

◆ readAttribute() [1/5]

void GUI::Session::XML::readAttribute ( QXmlStreamReader *  reader,
const QString &  attributeBaseName,
complex_t *  c 
)

Definition at line 183 of file UtilXML.cpp.

185 {
186  double r, i;
187  readAttribute(reader, attributeBaseName + "Re", &r);
188  readAttribute(reader, attributeBaseName + "Im", &i);
189  c->real(r);
190  c->imag(i);
191 }
void readAttribute(QXmlStreamReader *reader, const QString &attributeName, double *d)
Definition: UtilXML.cpp:193

References readAttribute().

Here is the call graph for this function:

◆ readAttribute() [2/5]

void GUI::Session::XML::readAttribute ( QXmlStreamReader *  reader,
const QString &  attributeBaseName,
R3 *  vec 
)

Definition at line 173 of file UtilXML.cpp.

175 {
176  double x, y, z;
177  readAttribute(reader, attributeBaseName + "X", &x);
178  readAttribute(reader, attributeBaseName + "Y", &y);
179  readAttribute(reader, attributeBaseName + "Z", &z);
180  *vec = {x, y, z};
181 }

References readAttribute().

Here is the call graph for this function:

◆ readAttribute() [3/5]

void GUI::Session::XML::readAttribute ( QXmlStreamReader *  reader,
const QString &  attributeName,
double *  d 
)

Definition at line 193 of file UtilXML.cpp.

195 {
196  *d = reader->attributes().value(attributeName).toDouble();
197 }

Referenced by readAttribute(), ParameterContainerItem::readContentFrom(), MaterialItem::readContentFrom(), Serialize::rwProperty(), and Serialize::rwValue().

◆ readAttribute() [4/5]

void GUI::Session::XML::readAttribute ( QXmlStreamReader *  reader,
const QString &  attributeName,
QColor *  c 
)

Definition at line 166 of file UtilXML.cpp.

168 {
169  const QString parameter_value = reader->attributes().value(attributeName).toString();
170  *c = QColor(parameter_value);
171 }

◆ readAttribute() [5/5]

void GUI::Session::XML::readAttribute ( QXmlStreamReader *  reader,
const QString &  attributeName,
QString *  s 
)

Definition at line 160 of file UtilXML.cpp.

162 {
163  *s = reader->attributes().value(attributeName).toString();
164 }

◆ readBoolAttribute()

bool GUI::Session::XML::readBoolAttribute ( QXmlStreamReader *  reader,
const QString &  attributeName 
)

Definition at line 149 of file UtilXML.cpp.

150 {
151  return reader->attributes().value(attributeName).toUInt() != 0;
152 }

Referenced by SimulationOptionsItem::readContentFrom().

◆ readItems()

void GUI::Session::XML::readItems ( QXmlStreamReader *  reader,
SessionItem parent,
QString  topTag = "",
MessageService messageService = nullptr 
)

Definition at line 113 of file SessionXML.cpp.

115 {
116  bool legacyDistributionFound = false;
117  ASSERT(reader);
118  ASSERT(parent);
119  const QString start_type = parent->model()->getModelTag();
120  while (!reader->atEnd()) {
121  reader->readNext();
122  if (reader->isStartElement()) {
123  if (reader->name() == XML::ItemTag) {
124  const QString model_type =
125  reader->attributes().value(Tags::ModelTypeAttribute).toString();
126 
127  if (model_type == "ParticleDistribution") {
128  if (!legacyDistributionFound) {
129  QString message(
130  "This file contains particle distributions in the sample. Elements of "
131  "this type are not supported any more. Reading the file will be "
132  "continued as much as possible, but you should review the sample.");
133 
134  report_error(messageService, parent->model(), message);
135  }
136  legacyDistributionFound = true;
137  reader->skipCurrentElement();
138  continue;
139  }
140 
141  QString tag = reader->attributes().value(Tags::TagAttribute).toString();
142  QString displayName =
143  reader->attributes().value(Tags::DisplayNameAttribute).toString();
144 
145  if (!topTag.isEmpty()) {
146  // to handle copying of item to another parent
147  tag = topTag;
148  topTag.clear();
149  }
150  auto* newItem = createItem(parent, model_type, tag);
151  if (!newItem) {
152  QString message = QString("Error while parsing XML. Can't create item of "
153  "modelType '%1' for tag '%2', parent '%3'")
154  .arg(model_type, tag, parent->itemName());
155  report_error(messageService, parent->model(), message);
156  // risky attempt to recover the rest of the project
157  reader->skipCurrentElement();
158  } else {
159  parent = newItem;
160  parent->setDisplayName(displayName);
161  }
162  ASSERT(reader->name() == ItemTag);
163  } else if (reader->name() == ParameterTag) {
164  readProperty(reader, parent);
166  } else if (reader->name() == Tags::BinaryData) {
167  if (reader->attributes().value(XML::Version).toInt() == 1) {
168  QString valueAsBase64 =
169  reader->readElementText(QXmlStreamReader::SkipChildElements);
170  const auto data = QByteArray::fromBase64(
171  valueAsBase64.toLatin1()); // #baimport add a unit test for this!
172  parent->deserializeBinaryData(data);
173  } else
176  } else if (reader->name() == Tags::NonSessionItemData) {
177  parent->readNonSessionItems(reader);
179  }
180  } else if (reader->isEndElement()) {
181  if (reader->name() == XML::ItemTag && parent)
182  parent = parent->parentItem();
183  if (reader->name() == start_type)
184  break;
185  }
186  }
187 }
static DeserializationException tooNew()
QString itemName() const
Get item name, return display name if no name is set.
void setDisplayName(const QString &display_name)
Set display name.
virtual void deserializeBinaryData(const QByteArray &data)
SessionModel * model() const
Returns model of this item.
Definition: SessionItem.cpp:60
SessionItem * parentItem() const
Returns parent of this item.
Definition: SessionItem.cpp:67
virtual void readNonSessionItems(QXmlStreamReader *reader)
QString getModelTag() const
Definition: SessionModel.h:202
constexpr auto BinaryData("BinaryData")
constexpr auto NonSessionItemData("NonSessionItemData")
constexpr auto DisplayNameAttribute("DisplayName")
constexpr auto TagAttribute("Tag")
constexpr auto ParameterTag("Parameter")
constexpr auto ModelTypeAttribute("ModelType")
QString readProperty(QXmlStreamReader *reader, SessionItem *item)
Definition: SessionXML.cpp:189
constexpr auto ItemTag("Item")
void gotoEndElementOfTag(QXmlStreamReader *reader, const QString &tag)
Definition: UtilXML.cpp:49
constexpr auto Version("version")

References GUI::Session::XML::Tags::BinaryData(), SessionItem::deserializeBinaryData(), GUI::Session::XML::Tags::DisplayNameAttribute(), SessionModel::getModelTag(), gotoEndElementOfTag(), SessionItem::itemName(), ItemTag(), SessionItem::model(), ModelTypeAttribute(), GUI::Session::XML::Tags::NonSessionItemData(), ParameterTag(), SessionItem::parentItem(), SessionItem::readNonSessionItems(), readProperty(), SessionItem::setDisplayName(), GUI::Session::XML::Tags::TagAttribute(), DeserializationException::tooNew(), and XML::Tags::Version().

Referenced by SessionModel::copy(), and SessionModel::readFrom().

Here is the call graph for this function:

◆ readProperty()

QString GUI::Session::XML::readProperty ( QXmlStreamReader *  reader,
SessionItem item 
)

Definition at line 189 of file SessionXML.cpp.

190 {
191  ASSERT(reader);
192  const QString parameter_name =
193  reader->attributes().value(Tags::ParameterNameAttribute).toString();
194  const QString parameter_type =
195  reader->attributes().value(Tags::ParameterTypeAttribute).toString();
196  const int role = reader->attributes().value(Tags::ParameterRoleAttribute).toInt();
197 
198  if (!item)
199  throw Error(
200  QString("Attempt to set property '%1' for non existing item").arg(parameter_name));
201 
202  QVariant variant;
203  if (parameter_type == "double") {
204  double parameter_value =
205  reader->attributes().value(Tags::ParameterValueAttribute).toDouble();
206  variant = parameter_value;
207  } else if (parameter_type == "int") {
208  int parameter_value = reader->attributes().value(Tags::ParameterValueAttribute).toInt();
209  variant = parameter_value;
210  } else if (parameter_type == "uint") {
211  unsigned parameter_value =
212  reader->attributes().value(Tags::ParameterValueAttribute).toUInt();
213  variant = parameter_value;
214  } else if (parameter_type == "bool") {
215  bool parameter_value = reader->attributes().value(Tags::ParameterValueAttribute).toInt();
216  variant = parameter_value;
217  } else if (parameter_type == "QString") {
218  QString parameter_value =
219  reader->attributes().value(Tags::ParameterValueAttribute).toString();
220  variant = parameter_value;
221  } else if (parameter_type == "QColor") {
222  QString parameter_value =
223  reader->attributes().value(Tags::ParameterValueAttribute).toString();
224  variant = QColor(parameter_value);
225  } else if (parameter_type == "ExternalProperty") {
226  const bool isMaterialItemColor =
227  item->parentItem() != nullptr && dynamic_cast<MaterialItem*>(item->parentItem());
228 
229  if (isMaterialItemColor) {
230  // This handles legacy XML files for MaterialItem:
231  // In former times, the color of a MaterialItem was held as an "ExternalProperty". This
232  // has been changed to a simple QColor property => use only the color value of the
233  // "ExternalProperty" and store it as QColor in the variant
234  const QString colorName =
235  reader->attributes().value(Tags::ExternalPropertyColorAtt).toString();
236  variant = QColor(colorName);
237  } else {
238  // This handles legacy XML files for items referring to a material:
239  // In former times, the material in e.g. a ParticleItem was held as an
240  // "ExternalProperty". This has been changed to the material's identifier only (as
241  // QString)
242  // => use only the identifier value of the "ExternalProperty" and store it as QString in
243  // the variant
244  const QString identifier =
245  reader->attributes().value(Tags::ExternalPropertyIdentifierAtt).toString();
246  variant = identifier;
247  }
248  } else if (parameter_type == "ComboProperty") {
249  QString selections = reader->attributes().value(Tags::ParameterValueAttribute).toString();
250  QString values = reader->attributes().value(Tags::ParameterExtAttribute).toString();
251 
252  ComboProperty combo_property;
253  combo_property.setStringOfValues(values);
254  combo_property.setStringOfSelections(selections);
255 
256  variant = combo_property.variant();
257  } else {
258  QString message = QString("SessionModel::readProperty: parameter type not supported '"
259  + parameter_type + "'");
260  throw Error(message);
261  }
262 
263  if (variant.isValid())
264  item->setRoleProperty(role, variant);
265 
266  return parameter_name;
267 }
Custom property to define list of string values with multiple selections. Intended for QVariant.
Definition: ComboProperty.h:25
void setStringOfValues(const QString &values)
Sets values from the string containing delimeter ';'.
void setStringOfSelections(const QString &values)
Sets selected indices from string.
QVariant variant() const
Constructs variant enclosing given ComboProperty.
Definition: Error.h:21
bool setRoleProperty(int role, const QVariant &value)
Set the contained role property to the given value. See also setTranslatorForRolePropertySetter.
constexpr auto ParameterRoleAttribute("ParRole")
constexpr auto ParameterTypeAttribute("ParType")
constexpr auto ExternalPropertyColorAtt("Color")
constexpr auto ParameterValueAttribute("ParValue")
constexpr auto ParameterExtAttribute("ParExt")
constexpr auto ParameterNameAttribute("ParName")
constexpr auto ExternalPropertyIdentifierAtt("Identifier")

References GUI::Session::XML::Tags::ExternalPropertyColorAtt(), GUI::Session::XML::Tags::ExternalPropertyIdentifierAtt(), GUI::Session::XML::Tags::ParameterExtAttribute(), GUI::Session::XML::Tags::ParameterNameAttribute(), GUI::Session::XML::Tags::ParameterRoleAttribute(), GUI::Session::XML::Tags::ParameterTypeAttribute(), GUI::Session::XML::Tags::ParameterValueAttribute(), SessionItem::parentItem(), SessionItem::setRoleProperty(), ComboProperty::setStringOfSelections(), ComboProperty::setStringOfValues(), and ComboProperty::variant().

Referenced by readItems().

Here is the call graph for this function:

◆ readUIntAttribute()

unsigned GUI::Session::XML::readUIntAttribute ( QXmlStreamReader *  reader,
const QString &  attributeName 
)

Definition at line 154 of file UtilXML.cpp.

156 {
157  return reader->attributes().value(attributeName).toUInt();
158 }

Referenced by SimulationOptionsItem::readContentFrom().

◆ RealDataModelTag()

constexpr auto GUI::Session::XML::RealDataModelTag ( "RealDataModel"  )
constexpr

◆ Version()

◆ writeAttribute() [1/6]

void GUI::Session::XML::writeAttribute ( QXmlStreamWriter *  writer,
const QString &  attributeBaseName,
const complex_t &  c 
)

Definition at line 102 of file UtilXML.cpp.

104 {
105  writeAttribute(writer, attributeBaseName + "Re", c.real());
106  writeAttribute(writer, attributeBaseName + "Im", c.imag());
107 }
void writeAttribute(QXmlStreamWriter *writer, const QString &attributeName, const QVariant &variant)
Write the variant's value as an attribute.
Definition: UtilXML.cpp:65

References writeAttribute().

Here is the call graph for this function:

◆ writeAttribute() [2/6]

void GUI::Session::XML::writeAttribute ( QXmlStreamWriter *  writer,
const QString &  attributeBaseName,
const R3 &  vec 
)

Definition at line 94 of file UtilXML.cpp.

96 {
97  writeAttribute(writer, attributeBaseName + "X", vec.x());
98  writeAttribute(writer, attributeBaseName + "Y", vec.y());
99  writeAttribute(writer, attributeBaseName + "Z", vec.z());
100 }

References writeAttribute().

Here is the call graph for this function:

◆ writeAttribute() [3/6]

void GUI::Session::XML::writeAttribute ( QXmlStreamWriter *  writer,
const QString &  attributeName,
const QVariant &  variant 
)

Write the variant's value as an attribute.

Definition at line 65 of file UtilXML.cpp.

67 {
68  ASSERT(writer);
69  ASSERT(variant.isValid());
70 
71  if (variant.type() == QVariant::Double)
72  writeAttribute(writer, attributeName, variant.toDouble());
73  else if (variant.type() == QVariant::Int)
74  writeAttribute(writer, attributeName, variant.toInt());
75  else if (variant.type() == QVariant::UInt)
76  writeAttribute(writer, attributeName, variant.toUInt());
77  else if (variant.type() == QVariant::Bool)
78  writer->writeAttribute(attributeName, QString::number(variant.toBool()));
79  else if (variant.type() == QVariant::String)
80  writer->writeAttribute(attributeName, variant.toString());
81  else if (variant.type() == QVariant::Color) {
82  const auto col = variant.value<QColor>();
83  const QString tcol = col.isValid() ? col.name(QColor::HexArgb) : "";
84  writer->writeAttribute(attributeName, tcol);
85  } else if (QString(variant.typeName()) == "ComboProperty") {
86  auto combo = variant.value<ComboProperty>();
87  writer->writeAttribute(attributeName, combo.stringOfSelections());
88  writer->writeAttribute(Tags::ParameterExtAttribute, combo.stringOfValues());
89  } else
90  throw Error("GUI::Session::XML::writeVariant: Parameter type not supported "
91  + QString(variant.typeName()));
92 }

References GUI::Session::XML::Tags::ParameterExtAttribute().

Referenced by Serialize::rwProperty(), Serialize::rwValue(), writeAttribute(), ParameterContainerItem::writeContentTo(), MaterialItem::writeContentTo(), SimulationOptionsItem::writeContentTo(), JobItem::writeNonSessionItems(), and writeVariant().

Here is the call graph for this function:

◆ writeAttribute() [4/6]

void GUI::Session::XML::writeAttribute ( QXmlStreamWriter *  writer,
const QString &  attributeName,
double  d 
)

Definition at line 109 of file UtilXML.cpp.

111 {
112  writer->writeAttribute(attributeName, d == 0.0 ? "0" : QString::number(d, 'e', 12));
113 }

◆ writeAttribute() [5/6]

void GUI::Session::XML::writeAttribute ( QXmlStreamWriter *  writer,
const QString &  attributeName,
int  d 
)

Definition at line 115 of file UtilXML.cpp.

117 {
118  writer->writeAttribute(attributeName, QString::number(d));
119 }

◆ writeAttribute() [6/6]

void GUI::Session::XML::writeAttribute ( QXmlStreamWriter *  writer,
const QString &  attributeName,
unsigned  d 
)

Definition at line 121 of file UtilXML.cpp.

123 {
124  writer->writeAttribute(attributeName, QString::number(d));
125 }

◆ writeItemAndChildItems()

void GUI::Session::XML::writeItemAndChildItems ( QXmlStreamWriter *  writer,
const SessionItem item 
)

Definition at line 70 of file SessionXML.cpp.

71 {
72  ASSERT(item);
73  if (item->parentItem()) {
74  writer->writeStartElement(ItemTag);
75  writer->writeAttribute(ModelTypeAttribute, item->modelType());
76  QString tag = item->parentItem()->tagFromItem(item);
77  writer->writeAttribute(Tags::TagAttribute, tag);
78  writer->writeAttribute(Tags::DisplayNameAttribute,
80  for (int role : item->getRoles()) {
81  if (role == Qt::DisplayRole || role == Qt::EditRole)
82  writeVariant(writer, item->value(), role);
83  }
84  }
85 
86  for (auto* child : item->children())
87  if (item->allowWritingChildToXml(child))
88  writeItemAndChildItems(writer, child);
89 
90  QByteArray a = item->serializeBinaryData();
91  if (!a.isEmpty()) {
92  writer->writeStartElement(Tags::BinaryData);
93  writer->writeAttribute(XML::Version, "1");
94  writer->writeCharacters(a.toBase64());
95  writer->writeEndElement();
96  }
97 
98  QString nonSessionItemContent;
99  QXmlStreamWriter nonSessionItemStream(&nonSessionItemContent);
100  nonSessionItemStream.writeStartElement(Tags::NonSessionItemData); // for following writeAttrib
101  const auto sizeBefore = nonSessionItemContent.size();
102  item->writeNonSessionItems(&nonSessionItemStream);
103  if (sizeBefore != nonSessionItemContent.size()) {
104  writer->writeStartElement(Tags::NonSessionItemData);
105  item->writeNonSessionItems(writer);
106  writer->writeEndElement();
107  }
108 
109  if (item->parentItem())
110  writer->writeEndElement(); // ItemTag
111 }
QVariant value() const
Get value.
QVector< int > getRoles() const
Returns vector of all present roles.
virtual QByteArray serializeBinaryData() const
virtual bool allowWritingChildToXml(SessionItem *child) const
QVariant roleProperty(int role) const
Returns corresponding variant under given role, invalid variant when role is not present.
virtual void writeNonSessionItems(QXmlStreamWriter *writer) const
QVector< SessionItem * > children() const
Returns vector of all children.
Definition: SessionItem.cpp:95
QString modelType() const
Get model type.
QString tagFromItem(const SessionItem *item) const
Returns the tag name of given item when existing.
void writeItemAndChildItems(QXmlStreamWriter *writer, const SessionItem *item)
Definition: SessionXML.cpp:70
void writeVariant(QXmlStreamWriter *writer, QVariant variant, int role)
Write the variant as a complete tag, including the given role.
Definition: UtilXML.cpp:137

References SessionItem::allowWritingChildToXml(), GUI::Session::XML::Tags::BinaryData(), SessionItem::children(), GUI::Session::XML::Tags::DisplayNameAttribute(), SessionFlags::DisplayNameRole, SessionItem::getRoles(), ItemTag(), SessionItem::modelType(), ModelTypeAttribute(), GUI::Session::XML::Tags::NonSessionItemData(), SessionItem::parentItem(), SessionItem::roleProperty(), SessionItem::serializeBinaryData(), GUI::Session::XML::Tags::TagAttribute(), SessionItem::tagFromItem(), SessionItem::value(), XML::Tags::Version(), SessionItem::writeNonSessionItems(), and writeVariant().

Referenced by SessionModel::copy(), SessionModel::mimeData(), and writeModel().

Here is the call graph for this function:

◆ writeModel()

void GUI::Session::XML::writeModel ( QXmlStreamWriter *  writer,
SessionItem modelRootItem 
)

Definition at line 59 of file SessionXML.cpp.

60 {
61  ASSERT(writer);
62  ASSERT(modelRootItem);
63  writer->writeStartElement(modelRootItem->model()->getModelTag());
64 
65  writeItemAndChildItems(writer, modelRootItem);
66 
67  writer->writeEndElement(); // m_model_tag
68 }

References SessionModel::getModelTag(), SessionItem::model(), and writeItemAndChildItems().

Referenced by SessionModel::writeTo().

Here is the call graph for this function:

◆ writeUid() [1/2]

void GUI::Session::XML::writeUid ( QXmlStreamWriter *  writer,
const QString &  id 
)

Definition at line 127 of file UtilXML.cpp.

128 {
129  writer->writeAttribute(Tags::Id, id);
130 }
constexpr auto Id("id")

References XML::Tags::Id().

Referenced by Serialize::rwProperty().

Here is the call graph for this function:

◆ writeUid() [2/2]

void GUI::Session::XML::writeUid ( QXmlStreamWriter *  writer,
const QUuid &  id 
)

Definition at line 132 of file UtilXML.cpp.

133 {
134  writer->writeAttribute(Tags::Id, id.toString());
135 }
QString toString(const QModelIndex &index)
Provides string representation of index data.

References XML::Tags::Id(), and GUI::View::PropertyEditorFactory::toString().

Here is the call graph for this function:

◆ writeVariant()

void GUI::Session::XML::writeVariant ( QXmlStreamWriter *  writer,
QVariant  variant,
int  role 
)

Write the variant as a complete tag, including the given role.

Definition at line 137 of file UtilXML.cpp.

138 {
139  ASSERT(writer);
140  if (variant.isValid()) {
141  writer->writeStartElement(Tags::ParameterTag);
142  writer->writeAttribute(Tags::ParameterTypeAttribute, variant.typeName());
143  writer->writeAttribute(Tags::ParameterRoleAttribute, QString::number(role));
145  writer->writeEndElement(); // end ParameterTag
146  }
147 }

References GUI::Session::XML::Tags::ParameterRoleAttribute(), ParameterTag(), GUI::Session::XML::Tags::ParameterTypeAttribute(), GUI::Session::XML::Tags::ParameterValueAttribute(), and writeAttribute().

Referenced by writeItemAndChildItems().

Here is the call graph for this function:

Variable Documentation

◆ ItemMimeType

constexpr auto GUI::Session::XML::ItemMimeType = "application/org.bornagainproject.xml.item.z"
constexpr

◆ LinkMimeType

constexpr auto GUI::Session::XML::LinkMimeType = "application/org.bornagainproject.fittinglink"
constexpr