QElectroTech  0.8-dev
assignvariables.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 ASSIGNVARIABLES_H
19 #define ASSIGNVARIABLES_H
20 
21 #include <QString>
22 #include <QPointF>
23 #include <QStringList>
24 
25 #include "numerotationcontext.h"
26 #include "diagramcontext.h"
27 
28 class Diagram;
29 class Element;
30 class ElementsLocation;
31 
32 namespace autonum
33 {
35  {
36  public:
40 
42  bool operator== (const sequentialNumbers &other) const;
43  bool operator!= (const sequentialNumbers &other) const;
44 
45  QDomElement toXml(QDomDocument &document, const QString& tag_name = QString("sequentialNumbers")) const;
46  void fromXml(const QDomElement &element);
47  void clear();
48 
49  QStringList unit;
50  QStringList unit_folio;
51  QStringList ten;
52  QStringList ten_folio;
53  QStringList hundred;
54  QStringList hundred_folio;
55  };
56 
63  {
64  public:
65  static QString formulaToLabel (QString formula, sequentialNumbers &seqStruct, Diagram *diagram, const Element *elmt = nullptr);
66  static QString replaceVariable (const QString &formula, const DiagramContext &dc);
67 
68  private:
69  AssignVariables(const QString& formula, const sequentialNumbers& seqStruct , Diagram *diagram, const Element *elmt = nullptr);
70  void assignTitleBlockVar();
71  void assignProjectVar();
72  void assignSequence();
73 
74  Diagram *m_diagram = nullptr;
75  QString m_arg_formula;
78  const Element *m_element = nullptr;
79  };
80 
81  void setSequentialToList(QStringList &list, NumerotationContext &nc, const QString& type);
82  void setFolioSequentialToHash(QStringList &list, QHash<QString, QStringList> &hash, const QString& autoNumName);
83  void setSequential(const QString& label, autonum::sequentialNumbers &seqStruct, NumerotationContext &context, Diagram *diagram, const QString& hashKey);
85  QString elementPrefixForLocation(const ElementsLocation &location);
86 }
87 
89 
90 #endif // ASSIGNVARIABLES_H
DiagramPosition::number
unsigned int number() const
Definition: diagramposition.h:41
Diagram::m_elmt_tenfolio_max
QHash< QString, QStringList > m_elmt_tenfolio_max
Definition: diagram.h:102
QETProject::projectProperties
DiagramContext projectProperties()
Definition: qetproject.cpp:1669
DiagramContext::keys
QList< QString > keys(KeyOrder=None) const
Definition: diagramcontext.cpp:49
autonum::AssignVariables::m_diagram
Diagram * m_diagram
Definition: assignvariables.h:74
autonum::sequentialNumbers
Definition: assignvariables.h:35
autonum::sequentialNumbers::clear
void clear()
Definition: assignvariables.cpp:165
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(NamesList)
autonum::sequentialNumbers::fromXml
void fromXml(const QDomElement &element)
sequentialNumbers::fromXml Import sequential values from a QDomElement
Definition: assignvariables.cpp:138
QETApp::customElementsDir
static QString customElementsDir()
QETApp::customElementsDir.
Definition: qetapp.cpp:657
ElementsLocation::fileName
QString fileName() const
ElementLocation::fileName.
Definition: elementslocation.cpp:793
diagramposition.h
NumerotationContext::isEmpty
bool isEmpty() const
NumerotationContext::isEmpty.
Definition: numerotationcontext.cpp:101
autonum::sequentialNumbers::operator!=
bool operator!=(const sequentialNumbers &other) const
Definition: assignvariables.cpp:78
DiagramPosition::letter
QString letter() const
Definition: diagramposition.h:42
autonum::sequentialNumbers::sequentialNumbers
sequentialNumbers()
sequentialNumbers::sequentialNumbers
Definition: assignvariables.cpp:34
autonum::sequentialNumbers::unit_folio
QStringList unit_folio
Definition: assignvariables.h:50
autonum::setSequentialToList
void setSequentialToList(QStringList &list, NumerotationContext &context, const QString &type)
setSequentialToList Append all sequential of type type owned by context in list
Definition: assignvariables.cpp:363
autonum::numerotationContextToFormula
QString numerotationContextToFormula(const NumerotationContext &nc)
numerotationContextToFormula
Definition: assignvariables.cpp:473
assignvariables.h
autonum::AssignVariables::assignSequence
void assignSequence()
Definition: assignvariables.cpp:320
NumerotationContext
Definition: numerotationcontext.h:31
BorderTitleBlock::additionalFields
DiagramContext additionalFields() const
Definition: bordertitleblock.h:127
Diagram::border_and_titleblock
BorderTitleBlock border_and_titleblock
Diagram dimensions and title block.
Definition: diagram.h:83
Diagram::project
QETProject * project() const
Diagram::project.
Definition: diagram.cpp:2326
NumerotationContext::size
int size() const
NumerotationContext::size.
Definition: numerotationcontext.cpp:93
qetapp.h
autonum::AssignVariables
The AssignVariables class This class assign variable of a formula string. Return the final string use...
Definition: assignvariables.h:63
QETXML::textToDomElement
QDomElement textToDomElement(QDomDocument &document, const QString &tag_name, const QString &value)
QETXML::textToDomElement Return a QDomElement, created from document, with tag name tag_name and text...
Definition: qetxml.cpp:296
autonum::AssignVariables::replaceVariable
static QString replaceVariable(const QString &formula, const DiagramContext &dc)
AssignVariables::replaceVariable Replace the variables in formula in form %{my-var} to the correspond...
Definition: assignvariables.cpp:208
Diagram
The Diagram class This class represents an electric diagram. It manages its various child elements,...
Definition: diagram.h:56
ElementsLocation::parent
ElementsLocation parent() const
ElementsLocation::parent.
Definition: elementslocation.cpp:346
autonum::AssignVariables::AssignVariables
AssignVariables(const QString &formula, const sequentialNumbers &seqStruct, Diagram *diagram, const Element *elmt=nullptr)
Definition: assignvariables.cpp:235
autonum::setSequential
void setSequential(const QString &label, sequentialNumbers &seqStruct, NumerotationContext &context, Diagram *diagram, const QString &hashKey)
setSequential Fill seqStruct
Definition: assignvariables.cpp:434
QETApp::commonElementsDir
static QString commonElementsDir()
QETApp::commonElementsDir.
Definition: qetapp.cpp:598
autonum::AssignVariables::assignTitleBlockVar
void assignTitleBlockVar()
Definition: assignvariables.cpp:292
Element::getPrefix
QString getPrefix() const
Element::getPrefix get Element Prefix.
Definition: element.cpp:1699
autonum::elementPrefixForLocation
QString elementPrefixForLocation(const ElementsLocation &location)
elementPrefixForLocation
Definition: assignvariables.cpp:553
autonum::sequentialNumbers::hundred_folio
QStringList hundred_folio
Definition: assignvariables.h:54
autonum::AssignVariables::m_seq_struct
sequentialNumbers m_seq_struct
Definition: assignvariables.h:77
autonum::AssignVariables::m_assigned_label
QString m_assigned_label
Definition: assignvariables.h:76
Diagram::convertPosition
DiagramPosition convertPosition(const QPointF &)
Diagram::convertPosition.
Definition: diagram.cpp:2223
element.h
numerotationcontext.h
DiagramContext::value
QVariant value(const QString &key) const
Definition: diagramcontext.cpp:100
Element
Definition: element.h:41
ElementsLocation::isProject
bool isProject() const
ElementsLocation::isProject.
Definition: elementslocation.cpp:459
autonum::AssignVariables::m_element
const Element * m_element
Definition: assignvariables.h:78
autonum::AssignVariables::formulaToLabel
static QString formulaToLabel(QString formula, sequentialNumbers &seqStruct, Diagram *diagram, const Element *elmt=nullptr)
AssignVariables::formulaToLabel Return the formula with variable assigned (ready to be displayed)
Definition: assignvariables.cpp:187
autonum::setFolioSequentialToHash
void setFolioSequentialToHash(QStringList &list, QHash< QString, QStringList > &hash, const QString &autoNumName)
setFolioSequentialToHash Insert all value of list in hash with key autoNumName
Definition: assignvariables.cpp:389
ElementsLocation
The ElementsLocation class This class represents the location, the location of an element or of a cat...
Definition: elementslocation.h:46
autonum::AssignVariables::assignProjectVar
void assignProjectVar()
Definition: assignvariables.cpp:306
Diagram::m_elmt_hundredfolio_max
QHash< QString, QStringList > m_elmt_hundredfolio_max
Definition: diagram.h:103
autonum::sequentialNumbers::operator=
sequentialNumbers & operator=(const sequentialNumbers &other)
Definition: assignvariables.cpp:49
autonum::sequentialNumbers::~sequentialNumbers
~sequentialNumbers()
Definition: assignvariables.cpp:47
NumerotationContext::itemAt
QStringList itemAt(const int) const
NumerotationContext::itemAt.
Definition: numerotationcontext.cpp:110
qetxml.h
autonum::sequentialNumbers::toXml
QDomElement toXml(QDomDocument &document, const QString &tag_name=QString("sequentialNumbers")) const
sequentialNumbers::toXml export this sequential numbers into a QDomElement.
Definition: assignvariables.cpp:94
diagramcontext.h
autonum::sequentialNumbers::ten_folio
QStringList ten_folio
Definition: assignvariables.h:52
autonum::AssignVariables::m_arg_formula
QString m_arg_formula
Definition: assignvariables.h:75
Diagram::m_elmt_unitfolio_max
QHash< QString, QStringList > m_elmt_unitfolio_max
Hash containing max values for folio sequential autonums in this diagram.
Definition: diagram.h:101
autonum
Definition: assignvariables.cpp:30
autonum::sequentialNumbers::operator==
bool operator==(const sequentialNumbers &other) const
Definition: assignvariables.cpp:65
autonum::sequentialNumbers::unit
QStringList unit
Definition: assignvariables.h:49
autonum::sequentialNumbers::ten
QStringList ten
Definition: assignvariables.h:51
DiagramContext
Definition: diagramcontext.h:56
diagram.h
autonum::sequentialNumbers::hundred
QStringList hundred
Definition: assignvariables.h:53