QElectroTech  0.8-dev
diagramcontext.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2020 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 <QDomElement>
21 #include <QHash>
22 #include <QSettings>
23 #include <QString>
24 #include <QVariant>
25 #include <QStringList>
26 
27 #include "pugixml.hpp"
56 {
57  public:
58  enum KeyOrder {
62  };
63 
64  void add(DiagramContext other);
65  void remove(const QString &key);
66  QList<QString> keys(KeyOrder = None) const;
67  bool contains(const QString &) const;
68  const QVariant operator[](const QString &) const;
69  bool addValue(const QString &, const QVariant &, bool show = true);
70  QVariant value(const QString &key) const;
71  void clear();
72  int count();
73  bool keyMustShow (const QString &) const;
74 
75  bool operator==(const DiagramContext &) const;
76  bool operator!=(const DiagramContext &) const;
77 
78  void toXml(QDomElement &, const QString & = "property") const;
79  void fromXml(const QDomElement &, const QString & = "property");
80  void fromXml(const pugi::xml_node &dom_element, const QString &tag_name = "property");
81  void toSettings(QSettings &, const QString &) const;
82  void fromSettings(QSettings &, const QString &);
83 
84  static QString validKeyRegExp();
85 
86  private:
87  static bool stringLongerThan(const QString &, const QString &);
88  bool keyIsAcceptable(const QString &) const;
90  QHash<QString, QVariant> m_content;
91  QHash<QString, bool> m_content_show;
92 };
93 
94 QDebug operator <<(QDebug debug, const DiagramContext &context);
95 #endif
DiagramContext::Alphabetical
@ Alphabetical
Definition: diagramcontext.h:60
DiagramContext::keys
QList< QString > keys(KeyOrder=None) const
Definition: diagramcontext.cpp:49
DiagramContext::m_content
QHash< QString, QVariant > m_content
Diagram context data (key/value pairs)
Definition: diagramcontext.h:90
DiagramContext::fromXml
void fromXml(const QDomElement &, const QString &="property")
Definition: diagramcontext.cpp:157
operator<<
QDebug operator<<(QDebug debug, const DiagramContext &context)
Definition: diagramcontext.cpp:236
DiagramContext::fromSettings
void fromSettings(QSettings &, const QString &)
Definition: diagramcontext.cpp:201
DiagramContext::remove
void remove(const QString &key)
DiagramContext::remove.
Definition: diagramcontext.cpp:42
QET::findInDomElement
QList< QDomElement > findInDomElement(const QDomElement &, const QString &)
Definition: qet.cpp:333
DiagramContext::validKeyRegExp
static QString validKeyRegExp()
Definition: diagramcontext.cpp:216
DiagramContext::None
@ None
Definition: diagramcontext.h:59
DiagramContext::stringLongerThan
static bool stringLongerThan(const QString &, const QString &)
Definition: diagramcontext.cpp:223
DiagramContext::KeyOrder
KeyOrder
Definition: diagramcontext.h:58
qet.h
DiagramContext::m_content_show
QHash< QString, bool > m_content_show
Definition: diagramcontext.h:91
DiagramContext::value
QVariant value(const QString &key) const
Definition: diagramcontext.cpp:100
DiagramContext::keyIsAcceptable
bool keyIsAcceptable(const QString &) const
Definition: diagramcontext.cpp:231
operator<<
QDebug operator<<(QDebug debug, const DiagramContext &context)
Definition: diagramcontext.cpp:236
DiagramContext::operator!=
bool operator!=(const DiagramContext &) const
Definition: diagramcontext.cpp:134
DiagramContext::keyMustShow
bool keyMustShow(const QString &) const
DiagramContext::keyMustShow.
Definition: diagramcontext.cpp:123
DiagramContext::count
int count()
Definition: diagramcontext.cpp:115
DiagramContext::toXml
void toXml(QDomElement &, const QString &="property") const
Definition: diagramcontext.cpp:142
DiagramContext::toSettings
void toSettings(QSettings &, const QString &) const
Definition: diagramcontext.cpp:185
DiagramContext::clear
void clear()
Definition: diagramcontext.cpp:107
DiagramContext::add
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:31
diagramcontext.h
DiagramContext::contains
bool contains(const QString &) const
Definition: diagramcontext.cpp:70
DiagramContext::operator[]
const QVariant operator[](const QString &) const
Definition: diagramcontext.cpp:77
DiagramContext::operator==
bool operator==(const DiagramContext &) const
Definition: diagramcontext.cpp:129
DiagramContext::addValue
bool addValue(const QString &, const QVariant &, bool show=true)
Definition: diagramcontext.cpp:91
DiagramContext
Definition: diagramcontext.h:56
DiagramContext::DecreasingLength
@ DecreasingLength
Definition: diagramcontext.h:61