2010-12-19 18:08:08 +00:00
|
|
|
/*
|
2015-02-20 14:56:22 +00:00
|
|
|
Copyright 2006-2015 The QElectroTech Team
|
2010-12-19 18:08:08 +00:00
|
|
|
This file is part of QElectroTech.
|
|
|
|
|
|
|
|
QElectroTech is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
QElectroTech is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#ifndef DIAGRAM_CONTEXT_H
|
|
|
|
#define DIAGRAM_CONTEXT_H
|
2012-07-01 21:54:05 +00:00
|
|
|
#include <QDomElement>
|
2010-12-19 18:08:08 +00:00
|
|
|
#include <QHash>
|
2012-07-01 21:54:05 +00:00
|
|
|
#include <QSettings>
|
2010-12-19 18:08:08 +00:00
|
|
|
#include <QString>
|
|
|
|
#include <QVariant>
|
2014-02-12 17:36:35 +00:00
|
|
|
#include <QStringList>
|
2010-12-19 18:08:08 +00:00
|
|
|
/**
|
|
|
|
This class represents a diagram context, i.e. the data (a list of key/value
|
2010-12-20 02:45:36 +00:00
|
|
|
pairs) of a diagram at a given time. It is notably used by titleblock templates
|
2010-12-19 18:08:08 +00:00
|
|
|
to fetch the informations they need to do their rendering.
|
|
|
|
*/
|
|
|
|
class DiagramContext {
|
|
|
|
public:
|
2012-06-29 05:21:46 +00:00
|
|
|
enum KeyOrder {
|
|
|
|
None,
|
|
|
|
Alphabetical,
|
|
|
|
DecreasingLength
|
|
|
|
};
|
2014-02-12 17:36:35 +00:00
|
|
|
|
2012-06-29 05:21:46 +00:00
|
|
|
QList<QString> keys(KeyOrder = None) const;
|
2010-12-19 18:08:08 +00:00
|
|
|
bool contains(const QString &) const;
|
|
|
|
const QVariant operator[](const QString &) const;
|
2014-02-12 17:36:35 +00:00
|
|
|
bool addValue(const QString &, const QVariant &, bool show = true);
|
2012-07-01 21:54:03 +00:00
|
|
|
void clear();
|
2012-07-01 21:54:05 +00:00
|
|
|
int count();
|
2014-02-12 17:36:35 +00:00
|
|
|
bool keyMustShow (const QString &) const;
|
2010-12-19 18:08:08 +00:00
|
|
|
|
2011-01-09 15:16:51 +00:00
|
|
|
bool operator==(const DiagramContext &) const;
|
|
|
|
bool operator!=(const DiagramContext &) const;
|
|
|
|
|
2012-07-01 21:54:05 +00:00
|
|
|
void toXml(QDomElement &, const QString & = "property") const;
|
|
|
|
void fromXml(const QDomElement &, const QString & = "property");
|
|
|
|
void toSettings(QSettings &, const QString &) const;
|
|
|
|
void fromSettings(QSettings &, const QString &);
|
|
|
|
|
2012-05-09 17:21:46 +00:00
|
|
|
static QString validKeyRegExp();
|
|
|
|
|
2010-12-19 18:08:08 +00:00
|
|
|
private:
|
2012-06-29 05:21:46 +00:00
|
|
|
static bool stringLongerThan(const QString &, const QString &);
|
2010-12-19 18:08:08 +00:00
|
|
|
bool keyIsAcceptable(const QString &) const;
|
|
|
|
/// Diagram context data (key/value pairs)
|
|
|
|
QHash<QString, QVariant> content_;
|
2014-02-12 17:36:35 +00:00
|
|
|
QHash<QString, bool> content_show;
|
2010-12-19 18:08:08 +00:00
|
|
|
};
|
|
|
|
#endif
|