QElectroTech  0.70
assignvariables.h
Go to the documentation of this file.
1 /*
2  Copyright 2006-2019 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
const Element * m_element
static QString formulaToLabel(QString formula, sequentialNumbers &seqStruct, Diagram *diagram, const Element *elmt=nullptr)
AssignVariables::formulaToLabel Return the with variable assigned (ready to be displayed) ...
void setSequentialToList(QStringList &list, NumerotationContext &context, const QString &type)
setSequentialToList Append all sequential of type owned by in list
QDomElement toXml(QDomDocument &document, const QString &tag_name=QString("sequentialNumbers")) const
sequentialNumbers::toXml export this sequential numbers into a QDomElement.
void setSequential(const QString &label, sequentialNumbers &seqStruct, NumerotationContext &context, Diagram *diagram, const QString &hashKey)
setSequential Fill seqStruct
QString numerotationContextToFormula(const NumerotationContext &nc)
numerotationContextToFormula
bool operator==(const sequentialNumbers &other) const
AssignVariables(const QString &formula, const sequentialNumbers &seqStruct, Diagram *diagram, const Element *elmt=nullptr)
bool operator!=(const sequentialNumbers &other) const
QString elementPrefixForLocation(const ElementsLocation &location)
elementPrefixForLocation
sequentialNumbers & operator=(const sequentialNumbers &other)
void setFolioSequentialToHash(QStringList &list, QHash< QString, QStringList > &hash, const QString &autoNumName)
setFolioSequentialToHash Insert all value of in with key
sequentialNumbers m_seq_struct
void fromXml(const QDomElement &element)
sequentialNumbers::fromXml Import sequential values from a QDomElement
Q_DECLARE_METATYPE(NamesList)
The AssignVariables class This class assign variable of a formula string. Return the final string use...
sequentialNumbers()
sequentialNumbers::sequentialNumbers
static QString replaceVariable(const QString &formula, const DiagramContext &dc)
AssignVariables::replaceVariable Replace the variables in in form %{my-var} to the corresponding val...