2016-11-09 16:06:04 +00:00
|
|
|
/*
|
2019-01-13 16:56:12 +00:00
|
|
|
Copyright 2006-2019 The QElectroTech Team
|
2016-11-09 16:06:04 +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 ASSIGNVARIABLES_H
|
|
|
|
#define ASSIGNVARIABLES_H
|
|
|
|
|
|
|
|
#include <QString>
|
|
|
|
#include <QPointF>
|
|
|
|
#include <QStringList>
|
|
|
|
|
2016-11-22 17:21:53 +00:00
|
|
|
#include "numerotationcontext.h"
|
2017-08-16 13:52:15 +00:00
|
|
|
#include "diagramcontext.h"
|
2016-11-22 17:21:53 +00:00
|
|
|
|
2016-11-09 16:06:04 +00:00
|
|
|
class Diagram;
|
|
|
|
class Element;
|
2016-11-26 19:30:59 +00:00
|
|
|
class ElementsLocation;
|
2016-11-09 16:06:04 +00:00
|
|
|
|
|
|
|
namespace autonum
|
|
|
|
{
|
2016-12-08 15:06:46 +00:00
|
|
|
class sequentialNumbers
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
sequentialNumbers();
|
2016-12-28 10:03:47 +00:00
|
|
|
sequentialNumbers(const sequentialNumbers &other);
|
|
|
|
~sequentialNumbers();
|
2016-12-08 15:06:46 +00:00
|
|
|
|
|
|
|
sequentialNumbers &operator= (const sequentialNumbers &other);
|
|
|
|
bool operator== (const sequentialNumbers &other) const;
|
|
|
|
bool operator!= (const sequentialNumbers &other) const;
|
|
|
|
|
2018-07-19 14:14:31 +00:00
|
|
|
QDomElement toXml(QDomDocument &document, const QString& tag_name = QString("sequentialNumbers")) const;
|
2016-12-08 15:06:46 +00:00
|
|
|
void fromXml(const QDomElement &element);
|
2018-04-12 17:59:05 +00:00
|
|
|
void clear();
|
2016-12-08 15:06:46 +00:00
|
|
|
|
2016-11-09 16:06:04 +00:00
|
|
|
QStringList unit;
|
|
|
|
QStringList unit_folio;
|
|
|
|
QStringList ten;
|
|
|
|
QStringList ten_folio;
|
|
|
|
QStringList hundred;
|
|
|
|
QStringList hundred_folio;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The AssignVariables class
|
|
|
|
* This class assign variable of a formula string.
|
|
|
|
* Return the final string used to be displayed from a formula string.
|
|
|
|
*/
|
|
|
|
class AssignVariables
|
|
|
|
{
|
|
|
|
public:
|
2016-12-08 15:06:46 +00:00
|
|
|
static QString formulaToLabel (QString formula, sequentialNumbers &seqStruct, Diagram *diagram, const Element *elmt = nullptr);
|
2017-08-16 13:52:15 +00:00
|
|
|
static QString replaceVariable (const QString &formula, const DiagramContext &dc);
|
2016-11-09 16:06:04 +00:00
|
|
|
|
|
|
|
private:
|
2018-07-19 14:14:31 +00:00
|
|
|
AssignVariables(const QString& formula, const sequentialNumbers& seqStruct , Diagram *diagram, const Element *elmt = nullptr);
|
2016-11-09 16:06:04 +00:00
|
|
|
void assignTitleBlockVar();
|
|
|
|
void assignProjectVar();
|
|
|
|
void assignSequence();
|
|
|
|
|
|
|
|
Diagram *m_diagram = nullptr;
|
|
|
|
QString m_arg_formula;
|
|
|
|
QString m_assigned_label;
|
2016-12-08 15:06:46 +00:00
|
|
|
sequentialNumbers m_seq_struct;
|
2016-11-16 16:01:53 +00:00
|
|
|
const Element *m_element = nullptr;
|
2016-11-09 16:06:04 +00:00
|
|
|
};
|
|
|
|
|
2018-07-19 14:14:31 +00:00
|
|
|
void setSequentialToList(QStringList &list, NumerotationContext &nc, const QString& type);
|
|
|
|
void setFolioSequentialToHash(QStringList &list, QHash<QString, QStringList> &hash, const QString& autoNumName);
|
|
|
|
void setSequential(const QString& label, autonum::sequentialNumbers &seqStruct, NumerotationContext &context, Diagram *diagram, const QString& hashKey);
|
2016-11-26 19:30:59 +00:00
|
|
|
QString numerotationContextToFormula(const NumerotationContext &nc);
|
|
|
|
QString elementPrefixForLocation(const ElementsLocation &location);
|
2016-11-09 16:06:04 +00:00
|
|
|
}
|
|
|
|
|
2016-12-28 10:03:47 +00:00
|
|
|
Q_DECLARE_METATYPE(autonum::sequentialNumbers)
|
|
|
|
|
2016-11-09 16:06:04 +00:00
|
|
|
#endif // ASSIGNVARIABLES_H
|