QElectroTech 0.100.0-dev
Loading...
Searching...
No Matches
diagramcontext.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 DIAGRAM_CONTEXT_H
19#define DIAGRAM_CONTEXT_H
20#include "pugixml/src/pugixml.hpp"
21
22#include <QDomElement>
23#include <QHash>
24#include <QSettings>
25#include <QString>
26#include <QStringList>
27#include <QVariant>
57{
58 public:
64
65 void add(DiagramContext other);
66 void remove(const QString &key);
67 QList<QString> keys(KeyOrder = None) const;
68 bool contains(const QString &) const;
69 const QVariant operator[](const QString &) const;
70 bool addValue(const QString &, const QVariant &, bool show = true);
71 QVariant value(const QString &key) const;
72 void clear();
73 int count();
74 bool keyMustShow (const QString &) const;
75
76 bool operator==(const DiagramContext &) const;
77 bool operator!=(const DiagramContext &) const;
78
79 void toXml(QDomElement &, const QString & = "property") const;
80 void fromXml(const QDomElement &, const QString & = "property");
81 void fromXml(const pugi::xml_node &dom_element, const QString &tag_name = "property");
82 void toSettings(QSettings &, const QString &) const;
83 void fromSettings(QSettings &, const QString &);
84
85 static bool isKeyAcceptable(const QString &);
86
87 private:
88 static bool stringLongerThan(const QString &, const QString &);
89 static QString validKeyRegExp();
90
92 QHash<QString, QVariant> m_content;
93 QHash<QString, bool> m_content_show;
94};
95
96QDebug operator <<(QDebug debug, const DiagramContext &context);
97#endif
Definition diagramcontext.h:57
static QString validKeyRegExp()
Definition diagramcontext.cpp:227
bool contains(const QString &) const
Definition diagramcontext.cpp:71
QHash< QString, bool > m_content_show
Definition diagramcontext.h:93
bool keyMustShow(const QString &) const
DiagramContext::keyMustShow.
Definition diagramcontext.cpp:129
QHash< QString, QVariant > m_content
Diagram context data (key/value pairs)
Definition diagramcontext.h:92
QList< QString > keys(KeyOrder=None) const
Definition diagramcontext.cpp:50
void toXml(QDomElement &, const QString &="property") const
Definition diagramcontext.cpp:151
void fromSettings(QSettings &, const QString &)
Definition diagramcontext.cpp:212
bool addValue(const QString &, const QVariant &, bool show=true)
Definition diagramcontext.cpp:94
void toSettings(QSettings &, const QString &) const
Definition diagramcontext.cpp:195
void clear()
Definition diagramcontext.cpp:111
KeyOrder
Definition diagramcontext.h:59
@ Alphabetical
Definition diagramcontext.h:61
@ None
Definition diagramcontext.h:60
@ DecreasingLength
Definition diagramcontext.h:62
void remove(const QString &key)
DiagramContext::remove.
Definition diagramcontext.cpp:43
void fromXml(const QDomElement &, const QString &="property")
Definition diagramcontext.cpp:167
static bool isKeyAcceptable(const QString &)
Definition diagramcontext.cpp:243
const QVariant operator[](const QString &) const
Definition diagramcontext.cpp:79
bool operator==(const DiagramContext &) const
Definition diagramcontext.cpp:136
QVariant value(const QString &key) const
Definition diagramcontext.cpp:103
bool operator!=(const DiagramContext &) const
Definition diagramcontext.cpp:142
static bool stringLongerThan(const QString &, const QString &)
Definition diagramcontext.cpp:235
void add(DiagramContext other)
DiagramContext::add Add all value of other to this. If a key already exist, the value is replaced....
Definition diagramcontext.cpp:32
int count()
Definition diagramcontext.cpp:120
QDebug operator<<(QDebug debug, const DiagramContext &context)
Definition diagramcontext.cpp:251