QElectroTech 0.200.1-dev
Loading...
Searching...
No Matches
qetxml.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2026 The QElectroTech Team
3 This file is part of QElectroTech.
4
5 QElectroTech is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 2 of the License, or
8 (at your option) any later version.
9
10 QElectroTech is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17*/
18#ifndef QETXML_H
19#define QETXML_H
20
21#include <QDomElement>
22#include <QPen>
23#include <QUuid>
24
25class QDomDocument;
26class QDir;
27class QFile;
28class QAbstractItemModel;
29class QGraphicsItem;
30
34namespace QETXML
35{
36 QDomElement penToXml(QDomDocument &parent_document, const QPen& pen);
37 QPen penFromXml (const QDomElement &element);
38
39 QDomElement brushToXml (
40 QDomDocument &parent_document,
41 const QBrush& brush);
42
43 QBrush brushFromXml (const QDomElement &element);
44
46 QDomDocument &document,
47 const QDir &dir,
48 const QString& rename = QString());
49
51 QDomDocument &document,
52 QFile &file,
53 const QString& rename = QString());
54
55 bool writeXmlFile(
56 const QDomDocument &xml_document,
57 const QString &file_path,
58 QString *error_message = nullptr);
59
60 QDomElement textToDomElement (
61 QDomDocument &document,
62 const QString& tag_name,
63 const QString& value);
64
65 QVector <QDomElement> directChild(
66 const QDomElement &element,
67 const QString &tag_name);
68
69 QVector <QDomElement> subChild(
70 const QDomElement &element,
71 const QString parent_tag_name,
72 const QString &children_tag_name);
73
74 QDomElement marginsToXml (
75 QDomDocument &parent_document,
76 const QMargins &margins);
77
78 QMargins marginsFromXml(const QDomElement &element);
79
80 QDomElement modelHeaderDataToXml(
81 QDomDocument &parent_document,
82 const QAbstractItemModel *model,
83 QHash<int,
84 QList<int>> horizontal_section_role,
85 QHash<int,
86 QList<int>> vertical_section_role);
87
89 const QDomElement &element,
90 QAbstractItemModel *model);
91
92 QVector<QDomElement> findInDomElement(const QDomElement &dom_elmt,
93 const QString &tag_name);
94
95 QDomElement qGraphicsItemPosToXml(QGraphicsItem *item, QDomDocument &document);
96 bool qGraphicsItemPosFromXml(QGraphicsItem *item, const QDomElement &xml_elmt);
97
98 void orientationToAttribute(const Qt::Orientation &orientation, QDomElement &element);
99 Qt::Orientation orientationFromAttribute(const QDomElement &element, Qt::Orientation def_value = Qt::Vertical);
100
101 void alignmentToAttribute(const Qt::Alignment &alignment, QDomElement &element);
102 Qt::Alignment alignmentFromAttribute (const QDomElement &element);
103
104 QString boolToString(bool value);
105 bool boolFromString(const QString &value,
106 bool default_value = true,
107 bool *conv_ok = nullptr);
108
109 const QString integerS = "int";
110 const QString doubleS = "double";
111 const QString boolS = "bool";
112 const QString stringS = "string";
113 const QString uuidS = "uuid";
114 const QString colorS = "color";
115
120 // = 4
121 };
122
126 QDomElement createXmlProperty(const QString& name, const QString value);
127 QDomElement createXmlProperty(const QString& name, const char* value);
128 QDomElement createXmlProperty(const QString& name, const int value);
129 QDomElement createXmlProperty(const QString& name, const double value);
130 QDomElement createXmlProperty(const QString& name, const bool value);
131 QDomElement createXmlProperty(const QString& name, const QUuid value);
132 QDomElement createXmlProperty(const QString& name, const QColor value);
133
134 PropertyFlags propertyInteger(const QString& value, int* entry = nullptr);
135 PropertyFlags propertyInteger(const QDomElement &e, const QString& attribute_name, int *entier = nullptr);
136 PropertyFlags propertyDouble(const QString& value, double* entry = nullptr);
137 PropertyFlags propertyDouble(const QDomElement &e, const QString& attribute_name, double *reel = nullptr);
138 PropertyFlags propertyString(const QDomElement& e, const QString& attribute_name, QString* string = nullptr);
139 PropertyFlags propertyBool(const QString& value, bool* entry = nullptr);
140 PropertyFlags propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean = nullptr);
141 PropertyFlags propertyUuid(const QString& value, QUuid* entry = nullptr);
142 PropertyFlags propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid = nullptr);
143 PropertyFlags propertyColor(const QString& value, QColor* entry = nullptr);
144 PropertyFlags propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color = nullptr);
145
146 QDomElement property(const QDomElement& e, const QString& name);
147 bool attribute(const QDomElement& e, const QString& attribute_name, const QString& type, QString* attr);
148
155 bool validXmlProperty(const QDomElement& e);
156}
157
158#endif // QETXML_H
Definition qetxml.cpp:587
PropertyFlags propertyInteger(const QDomElement &e, const QString &attribute_name, int *entier)
PropertiesInterface::propertyInteger Reads an integer from the XML element.
Definition qetxml.cpp:722
QDomElement fileSystemElementToXmlCollectionElement(QDomDocument &document, QFile &file, const QString &rename=QString())
Definition qetxml.cpp:222
PropertyFlags
Definition qetxml.h:116
@ NoValidConversion
Definition qetxml.h:119
@ NotFound
Definition qetxml.h:118
@ Success
Definition qetxml.h:117
QDomElement fileSystemDirToXmlCollectionDir(QDomDocument &document, const QDir &dir, const QString &rename=QString())
Definition qetxml.cpp:178
Qt::Orientation orientationFromAttribute(const QDomElement &element, Qt::Orientation def_value)
orientationFromAttribute
Definition qetxml.cpp:978
const QString boolS
Definition qetxml.h:111
bool writeXmlFile(const QDomDocument &xml_document, const QString &file_path, QString *error_message=nullptr)
QETXML::writeXmlFile Export an XML document to an UTF-8 text file indented with 4 spaces,...
Definition qetxml.cpp:257
void alignmentToAttribute(const Qt::Alignment &alignment, QDomElement &element)
Definition qetxml.cpp:991
bool qGraphicsItemPosFromXml(QGraphicsItem *item, const QDomElement &xml_elmt)
Definition qetxml.cpp:944
QDomElement qGraphicsItemPosToXml(QGraphicsItem *item, QDomDocument &document)
qGraphicsItemPosToXml Save the pos of a QGraphicsItem into an xml element. The tag name of the xml el...
Definition qetxml.cpp:934
QMargins marginsFromXml(const QDomElement &element)
QETXML::marginsFromXml.
Definition qetxml.cpp:409
void modelHeaderDataFromXml(const QDomElement &element, QAbstractItemModel *model)
QETXML::modelHeaderDataFromXml Restore from xml modele header data.
Definition qetxml.cpp:511
const QString colorS
Definition qetxml.h:114
QVector< QDomElement > directChild(const QDomElement &element, const QString &tag_name)
QETXML::directChild.
Definition qetxml.cpp:322
QString boolToString(bool value)
boolToString
Definition qetxml.cpp:594
void orientationToAttribute(const Qt::Orientation &orientation, QDomElement &element)
orientationToAttribute Write the Qt::orientation has an attribute of
Definition qetxml.cpp:964
QVector< QDomElement > findInDomElement(const QDomElement &dom_elmt, const QString &tag_name)
QETXML::findInDomElement.
Definition qetxml.cpp:566
QDomElement brushToXml(QDomDocument &parent_document, const QBrush &brush)
QETXML::brushToXml Write attribute of a QBrush in xml element.
Definition qetxml.cpp:100
bool attribute(const QDomElement &e, const QString &attribute_name, const QString &type, QString *attr)
PropertiesInterface::attribute Returns the property with the name attribute_name and type type.
Definition qetxml.cpp:888
QDomElement marginsToXml(QDomDocument &parent_document, const QMargins &margins)
QETXML::marginsToXml Save a QMargins to xml. the xml tag name is 'margins'.
Definition qetxml.cpp:387
const QString doubleS
Definition qetxml.h:110
bool validXmlProperty(const QDomElement &e)
PropertiesInterface::validXmlProperty Check if the Xml element contains the needed fields.
Definition qetxml.cpp:912
const QString integerS
Definition qetxml.h:109
Qt::Alignment alignmentFromAttribute(const QDomElement &element)
alignmentFromAttribute
Definition qetxml.cpp:1020
PropertyFlags propertyUuid(const QDomElement &e, const QString &attribute_name, QUuid *uuid)
Definition qetxml.cpp:830
bool boolFromString(const QString &value, bool default_value, bool *conv_ok)
boolFromString return value converted to bool
Definition qetxml.cpp:607
const QString stringS
Definition qetxml.h:112
QPen penFromXml(const QDomElement &element)
QETXML::penFromXml Build a QPen from a xml description.
Definition qetxml.cpp:65
PropertyFlags propertyString(const QDomElement &e, const QString &attribute_name, QString *string)
Definition qetxml.cpp:853
QBrush brushFromXml(const QDomElement &element)
QETXML::brushFromXml Build a QBrush from a xml description.
Definition qetxml.cpp:138
QDomElement property(const QDomElement &e, const QString &name)
Definition qetxml.cpp:867
QDomElement penToXml(QDomDocument &parent_document, const QPen &pen)
QETXML::penToXml Write attribute of a QPen in xml element.
Definition qetxml.cpp:36
QVector< QDomElement > subChild(const QDomElement &element, const QString parent_tag_name, const QString &children_tag_name)
QETXML::subChild.
Definition qetxml.cpp:350
const QString uuidS
Definition qetxml.h:113
QDomElement textToDomElement(QDomDocument &document, const QString &tag_name, const QString &value)
QETXML::textToDomElement Return a QDomElement, created from document, with tag name tag_name and text...
Definition qetxml.cpp:304
PropertyFlags propertyDouble(const QDomElement &e, const QString &attribute_name, double *reel)
Definition qetxml.cpp:747
QDomElement createXmlProperty(const QString &name, const QString value)
Use this functions to add properties to the xml document.
Definition qetxml.cpp:641
PropertyFlags propertyColor(const QDomElement &e, const QString &attribute_name, QColor *color)
Definition qetxml.cpp:805
PropertyFlags propertyBool(const QDomElement &e, const QString &attribute_name, bool *boolean)
Definition qetxml.cpp:773
QDomElement modelHeaderDataToXml(QDomDocument &parent_document, const QAbstractItemModel *model, QHash< int, QList< int > > horizontal_section_role, QHash< int, QList< int > > vertical_section_role)
QETXML::modelHeaderDataToXml Save to xml element all header data specified by horizontal_section_role...
Definition qetxml.cpp:439