34
34
* \class VariantTree
35
35
* \brief A recursive structure for storing QVariants in trees, with comments
37
* All the methods in this class are recursive, based on a hierachy delimited
38
* with dots in the node name. As such, the nodes "Paris" and "Benvolio" are
39
* top level elements (members of this layer), while "Capulet.Juliet" is a
40
* member of a deeper node ("Capulet") and "Verona.Montague.Romeo" represents
37
* All the methods in this class are recursive, based on a hierachy delimited
38
* with dots in the node name. As such, the nodes "Paris" and "Benvolio" are
39
* top level elements (members of this layer), while "Capulet.Juliet" is a
40
* member of a deeper node ("Capulet") and "Verona.Montague.Romeo" represents
41
41
* the node "Romeo" which is a member of "Montague", which is again a member
42
42
* of "Verona" (which is a member of this layer).
44
* As such, for each function, if the supplied node contains a dot ("."),
45
* the node name is split at the first (if there are several) dot, with the
46
* remainder passed to the same method of the member of this node with the
44
* As such, for each function, if the supplied node contains a dot ("."),
45
* the node name is split at the first (if there are several) dot, with the
46
* remainder passed to the same method of the member of this node with the
47
47
* name given by the primary component. For the set methods, multiple layers
48
48
* in the hierachy may be created implicitly if the node is not found.
57
57
void setValue(QString node, QVariant value);
58
58
QVariant getValue(const QString& node) const;
60
60
bool isInternalNode(QString node) const;
62
62
void setComment(QString node, QString comment);
63
63
QString getComment(QString node) const;
65
65
bool remove(const QString &node, bool internal_nodes = false);
67
QStringList nodeChildren(const QString& node = "", bool direct = false, bool internal_nodes = false) const;
67
QStringList nodeChildren(const QString& node = "", bool direct = false, bool internal_nodes = false) const;
69
69
void toXml(QDomDocument &doc, QDomElement& ele) const;
70
70
void fromXml(const QDomElement &ele);
72
72
static bool isValidNodeName(const QString &name);
74
74
static const QVariant missingValue;
75
75
static const QString missingComment;
78
78
static QVariant elementToVariant(const QDomElement&);
79
79
static void variantToElement(const QVariant&, QDomElement&);
81
81
static bool getKeyRest(const QString& node, QString &key, QString &rest);
86
86
QHash<QString, QString> comments_;
87
87
QHash<QString, QDomDocumentFragment> unknowns_; // unknown types preservation
88
88
QHash<QString, QString> unknowns2_; // unknown types preservation
90
90
// needed to have a document for the fragments.
91
91
static QDomDocument *unknownsDoc;
92
92
friend class OptionsTreeReader;