QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
qetxml.h
Go to the documentation of this file.
1/*
2 Copyright 2006-2024 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
24class QDomDocument;
25class QDir;
26class QFile;
27class QAbstractItemModel;
28class QGraphicsItem;
29
33namespace QETXML
34{
35 QDomElement penToXml(QDomDocument &parent_document, const QPen& pen);
36 QPen penFromXml (const QDomElement &element);
37
38 QDomElement brushToXml (
39 QDomDocument &parent_document,
40 const QBrush& brush);
41
42 QBrush brushFromXml (const QDomElement &element);
43
45 QDomDocument &document,
46 const QDir &dir,
47 const QString& rename = QString());
48
50 QDomDocument &document,
51 QFile &file,
52 const QString& rename = QString());
53
54 bool writeXmlFile(
55 const QDomDocument &xml_document,
56 const QString &file_path,
57 QString *error_message = nullptr);
58
59 QDomElement textToDomElement (
60 QDomDocument &document,
61 const QString& tag_name,
62 const QString& value);
63
64 QVector <QDomElement> directChild(
65 const QDomElement &element,
66 const QString &tag_name);
67
68 QVector <QDomElement> subChild(
69 const QDomElement &element,
70 const QString parent_tag_name,
71 const QString &children_tag_name);
72
73 QDomElement marginsToXml (
74 QDomDocument &parent_document,
75 const QMargins &margins);
76
77 QMargins marginsFromXml(const QDomElement &element);
78
79 QDomElement modelHeaderDataToXml(
80 QDomDocument &parent_document,
81 const QAbstractItemModel *model,
82 QHash<int,
83 QList<int>> horizontal_section_role,
84 QHash<int,
85 QList<int>> vertical_section_role);
86
88 const QDomElement &element,
89 QAbstractItemModel *model);
90
91 QVector<QDomElement> findInDomElement(const QDomElement &dom_elmt,
92 const QString &tag_name);
93
94 QDomElement qGraphicsItemPosToXml(QGraphicsItem *item, QDomDocument &document);
95 bool qGraphicsItemPosFromXml(QGraphicsItem *item, const QDomElement &xml_elmt);
96
97 QString boolToString(bool value);
98 bool boolFromString(const QString &value,
99 bool default_value = true,
100 bool *conv_ok = nullptr);
101
102 const QString integerS = "int";
103 const QString doubleS = "double";
104 const QString boolS = "bool";
105 const QString stringS = "string";
106 const QString uuidS = "uuid";
107 const QString colorS = "color";
108
113 // = 4
114 };
115
119 QDomElement createXmlProperty(const QString& name, const QString value);
120 QDomElement createXmlProperty(const QString& name, const char* value);
121 QDomElement createXmlProperty(const QString& name, const int value);
122 QDomElement createXmlProperty(const QString& name, const double value);
123 QDomElement createXmlProperty(const QString& name, const bool value);
124 QDomElement createXmlProperty(const QString& name, const QUuid value);
125 QDomElement createXmlProperty(const QString& name, const QColor value);
126
127 PropertyFlags propertyInteger(const QString& value, int* entry = nullptr);
128 PropertyFlags propertyInteger(const QDomElement &e, const QString& attribute_name, int *entier = nullptr);
129 PropertyFlags propertyDouble(const QString& value, double* entry = nullptr);
130 PropertyFlags propertyDouble(const QDomElement &e, const QString& attribute_name, double *reel = nullptr);
131 PropertyFlags propertyString(const QDomElement& e, const QString& attribute_name, QString* string = nullptr);
132 PropertyFlags propertyBool(const QString& value, bool* entry = nullptr);
133 PropertyFlags propertyBool(const QDomElement &e, const QString& attribute_name, bool* boolean = nullptr);
134 PropertyFlags propertyUuid(const QString& value, QUuid* entry = nullptr);
135 PropertyFlags propertyUuid(const QDomElement &e, const QString& attribute_name, QUuid* uuid = nullptr);
136 PropertyFlags propertyColor(const QString& value, QColor* entry = nullptr);
137 PropertyFlags propertyColor(const QDomElement &e, const QString& attribute_name, QColor* color = nullptr);
138
139 QDomElement property(const QDomElement& e, const QString& name);
140 bool attribute(const QDomElement& e, const QString& attribute_name, const QString& type, QString* attr);
141
148 bool validXmlProperty(const QDomElement& e);
149}
150
151#endif // QETXML_H
Definition qetxml.cpp:586
PropertyFlags propertyInteger(const QDomElement &e, const QString &attribute_name, int *entier)
PropertiesInterface::propertyInteger Reads an integer from the XML element.
Definition qetxml.cpp:721
QDomElement fileSystemElementToXmlCollectionElement(QDomDocument &document, QFile &file, const QString &rename=QString())
Definition qetxml.cpp:221
PropertyFlags
Definition qetxml.h:109
@ NoValidConversion
Definition qetxml.h:112
@ NotFound
Definition qetxml.h:111
@ Success
Definition qetxml.h:110
QDomElement fileSystemDirToXmlCollectionDir(QDomDocument &document, const QDir &dir, const QString &rename=QString())
Definition qetxml.cpp:177
const QString boolS
Definition qetxml.h:104
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:256
bool qGraphicsItemPosFromXml(QGraphicsItem *item, const QDomElement &xml_elmt)
Definition qetxml.cpp:943
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:933
QMargins marginsFromXml(const QDomElement &element)
QETXML::marginsFromXml.
Definition qetxml.cpp:408
void modelHeaderDataFromXml(const QDomElement &element, QAbstractItemModel *model)
QETXML::modelHeaderDataFromXml Restore from xml modele header data.
Definition qetxml.cpp:510
const QString colorS
Definition qetxml.h:107
QVector< QDomElement > directChild(const QDomElement &element, const QString &tag_name)
QETXML::directChild.
Definition qetxml.cpp:321
QString boolToString(bool value)
boolToString
Definition qetxml.cpp:593
QVector< QDomElement > findInDomElement(const QDomElement &dom_elmt, const QString &tag_name)
QETXML::findInDomElement.
Definition qetxml.cpp:565
QDomElement brushToXml(QDomDocument &parent_document, const QBrush &brush)
QETXML::brushToXml Write attribute of a QBrush in xml element.
Definition qetxml.cpp:99
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:887
QDomElement marginsToXml(QDomDocument &parent_document, const QMargins &margins)
QETXML::marginsToXml Save a QMargins to xml. the xml tag name is 'margins'.
Definition qetxml.cpp:386
const QString doubleS
Definition qetxml.h:103
bool validXmlProperty(const QDomElement &e)
PropertiesInterface::validXmlProperty Check if the Xml element contains the needed fields.
Definition qetxml.cpp:911
const QString integerS
Definition qetxml.h:102
PropertyFlags propertyUuid(const QDomElement &e, const QString &attribute_name, QUuid *uuid)
Definition qetxml.cpp:829
bool boolFromString(const QString &value, bool default_value, bool *conv_ok)
boolFromString return value converted to bool
Definition qetxml.cpp:606
const QString stringS
Definition qetxml.h:105
QPen penFromXml(const QDomElement &element)
QETXML::penFromXml Build a QPen from a xml description.
Definition qetxml.cpp:64
PropertyFlags propertyString(const QDomElement &e, const QString &attribute_name, QString *string)
Definition qetxml.cpp:852
QBrush brushFromXml(const QDomElement &element)
QETXML::brushFromXml Build a QBrush from a xml description.
Definition qetxml.cpp:137
QDomElement property(const QDomElement &e, const QString &name)
Definition qetxml.cpp:866
QDomElement penToXml(QDomDocument &parent_document, const QPen &pen)
QETXML::penToXml Write attribute of a QPen in xml element.
Definition qetxml.cpp:35
QVector< QDomElement > subChild(const QDomElement &element, const QString parent_tag_name, const QString &children_tag_name)
QETXML::subChild.
Definition qetxml.cpp:349
const QString uuidS
Definition qetxml.h:106
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:303
PropertyFlags propertyDouble(const QDomElement &e, const QString &attribute_name, double *reel)
Definition qetxml.cpp:746
QDomElement createXmlProperty(const QString &name, const QString value)
Use this functions to add properties to the xml document.
Definition qetxml.cpp:640
PropertyFlags propertyColor(const QDomElement &e, const QString &attribute_name, QColor *color)
Definition qetxml.cpp:804
PropertyFlags propertyBool(const QDomElement &e, const QString &attribute_name, bool *boolean)
Definition qetxml.cpp:772
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:438