2010-12-19 18:08:08 +00:00
|
|
|
/*
|
2020-06-15 17:42:37 +02:00
|
|
|
Copyright 2006-2020 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>
|
2020-01-04 23:33:35 +01:00
|
|
|
|
|
|
|
#include "pugixml.hpp"
|
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
|
2016-11-09 16:06:04 +00:00
|
|
|
to fetch the informations they need to do their rendering, or element for retrieve information about itself
|
2010-12-19 18:08:08 +00:00
|
|
|
*/
|
2016-11-09 16:06:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Key for element :
|
|
|
|
* label -> label or identification of element
|
2016-11-24 16:45:55 +00:00
|
|
|
* formula -> formula used to create the label (formula is make with variable)
|
2016-11-09 16:06:04 +00:00
|
|
|
* designation -> exhaustive comment used to explain what the element does.
|
2017-10-02 16:59:53 +00:00
|
|
|
* description -> exhaustive description used to explain what the element does.
|
2018-12-04 19:07:14 +00:00
|
|
|
* plant -> the plant assigned to the element
|
2016-11-09 16:06:04 +00:00
|
|
|
* comment -> a little comment wich can be displayed in the folio
|
|
|
|
* manufacturer -> the manufacturer of the element
|
2020-04-12 19:45:19 +02:00
|
|
|
* manufacturer_reference -> the manufacturer reference of the element
|
2018-12-02 15:54:08 +00:00
|
|
|
* quantity -> quantity of the element
|
|
|
|
* unity -> unity of the element
|
2016-11-09 16:06:04 +00:00
|
|
|
* auxiliary1 -> auxiliary 1 of element
|
|
|
|
* auxiliary2 -> auxiliary 2 of element
|
2020-04-12 19:45:19 +02:00
|
|
|
* machine_manufacturer_reference -> reference of the machine manufacturer
|
2018-12-04 19:07:14 +00:00
|
|
|
* supplier -> the supplier of the element
|
2016-11-09 16:06:04 +00:00
|
|
|
* function -> the function of element
|
2018-12-04 19:07:14 +00:00
|
|
|
* location -> the location assigned to the element
|
2016-11-09 16:06:04 +00:00
|
|
|
* frozenLabel -> label locked at a given time
|
|
|
|
*
|
2020-08-16 11:19:36 +02:00
|
|
|
*/
|
2017-08-06 10:18:33 +00:00
|
|
|
class DiagramContext
|
|
|
|
{
|
2010-12-19 18:08:08 +00:00
|
|
|
public:
|
2017-08-06 10:18:33 +00:00
|
|
|
enum KeyOrder {
|
|
|
|
None,
|
|
|
|
Alphabetical,
|
|
|
|
DecreasingLength
|
|
|
|
};
|
2012-07-01 21:54:05 +00:00
|
|
|
|
2018-10-21 09:54:59 +00:00
|
|
|
void add(DiagramContext other);
|
2020-04-12 18:51:38 +02:00
|
|
|
void remove(const QString &key);
|
2017-08-06 10:18:33 +00:00
|
|
|
QList<QString> keys(KeyOrder = None) const;
|
|
|
|
bool contains(const QString &) const;
|
|
|
|
const QVariant operator[](const QString &) const;
|
|
|
|
bool addValue(const QString &, const QVariant &, bool show = true);
|
|
|
|
QVariant value(const QString &key) const;
|
|
|
|
void clear();
|
|
|
|
int count();
|
|
|
|
bool keyMustShow (const QString &) const;
|
|
|
|
|
|
|
|
bool operator==(const DiagramContext &) const;
|
|
|
|
bool operator!=(const DiagramContext &) const;
|
|
|
|
|
|
|
|
void toXml(QDomElement &, const QString & = "property") const;
|
|
|
|
void fromXml(const QDomElement &, const QString & = "property");
|
2020-01-04 23:33:35 +01:00
|
|
|
void fromXml(const pugi::xml_node &dom_element, const QString &tag_name = "property");
|
2017-08-06 10:18:33 +00:00
|
|
|
void toSettings(QSettings &, const QString &) const;
|
|
|
|
void fromSettings(QSettings &, const QString &);
|
|
|
|
|
|
|
|
static QString validKeyRegExp();
|
2012-05-09 17:21:46 +00:00
|
|
|
|
2010-12-19 18:08:08 +00:00
|
|
|
private:
|
2017-08-06 10:18:33 +00:00
|
|
|
static bool stringLongerThan(const QString &, const QString &);
|
|
|
|
bool keyIsAcceptable(const QString &) const;
|
|
|
|
/// Diagram context data (key/value pairs)
|
|
|
|
QHash<QString, QVariant> m_content;
|
|
|
|
QHash<QString, bool> m_content_show;
|
2010-12-19 18:08:08 +00:00
|
|
|
};
|
2020-05-15 10:26:05 +02:00
|
|
|
|
|
|
|
QDebug operator <<(QDebug debug, const DiagramContext &context);
|
2010-12-19 18:08:08 +00:00
|
|
|
#endif
|