26 #include <QStringList> 51 if (&other ==
this || other == *
this)
94 QDomElement element = document.createElement(tag_name);
119 if (!element.hasChildNodes())
124 from = element.firstChildElement(
"unit");
125 unit = from.text().split(
";");
127 from = element.firstChildElement(
"unitFolio");
130 from = element.firstChildElement(
"ten");
131 ten = from.text().split(
";");
133 from = element.firstChildElement(
"tenFolio");
136 from = element.firstChildElement(
"hundred");
137 hundred = from.text().split(
";");
139 from = element.firstChildElement(
"hundredFolio");
179 QString str = formula;
180 str.replace(
"%{label}", dc.
value(
"label").toString());
181 str.replace(
"%{plant}", dc.
value(
"plant").toString());
182 str.replace(
"%{comment}", dc.
value(
"comment").toString());
183 str.replace(
"%{description}", dc.
value(
"description").toString());
184 str.replace(
"%{designation}", dc.
value(
"designation").toString());
185 str.replace(
"%{manufacturer}", dc.
value(
"manufacturer").toString());
186 str.replace(
"%{manufacturer-reference}", dc.
value(
"manufacturer-reference").toString());
187 str.replace(
"%{supplier}", dc.
value(
"supplier").toString());
188 str.replace(
"%{quantity}", dc.
value(
"quantity").toString());
189 str.replace(
"%{unity}", dc.
value(
"unity").toString());
190 str.replace(
"%{auxiliary1}", dc.
value(
"auxiliary1").toString());
191 str.replace(
"%{auxiliary2}", dc.
value(
"auxiliary2").toString());
192 str.replace(
"%{machine-manufacturer-reference}", dc.
value(
"machine-manufacturer-reference").toString());
193 str.replace(
"%{location}", dc.
value(
"location").toString());
194 str.replace(
"%{function}", dc.
value(
"function").toString());
195 str.replace(
"%{void}", QString());
203 m_arg_formula(formula),
204 m_assigned_label(formula),
205 m_seq_struct(seqStruct),
221 if (settings.value(
"border-columns_0",
true).toBool()){
244 m_assigned_label.replace(
"%{" + folio_variable +
"}", folio_value.toString());
258 m_assigned_label.replace(
"%{" + folio_variable +
"}", folio_value.toString());
276 for (
int i=1; i<=max ; i++)
308 for (
int i = 0; i < context.
size(); i++)
310 if (context.
itemAt(i).at(0) == type)
313 if (type ==
"ten" || type ==
"tenfolio")
314 number = QString(
"%1").arg(context.
itemAt(i).at(1).toInt(), 2, 10, QChar(
'0'));
315 else if (type ==
"hundred" || type ==
"hundredfolio")
316 number = QString(
"%1").arg(context.
itemAt(i).at(1).toInt(), 3, 10, QChar(
'0'));
317 else number = QString::number(context.
itemAt(i).at(1).toInt());
332 if (hash.isEmpty() || !hash.contains(autoNumName))
335 for (
int i = 0; i < list.size(); i++)
337 max.append(list.at(i));
339 hash.insert(autoNumName,max);
341 else if (hash.contains(autoNumName))
344 QStringList max = hash.value(autoNumName);
345 for (
int i = 0; i < list.size(); i++)
347 if ((list.at(i).toInt()) > max.at(i).toInt())
349 max.replace(i,list.at(i));
350 hash.remove(autoNumName);
351 hash.insert(autoNumName,max);
371 if (label.contains(
"%sequ_"))
375 if (label.contains(
"%sequf_"))
380 if (label.contains(
"%seqt_"))
384 if (label.contains(
"%seqtf_"))
389 if (label.contains(
"%seqh_"))
393 if (label.contains(
"%seqhf_"))
415 int count_hundred = 0;
416 int count_hundredf = 0;
418 for(
int i=0 ; i<nc.
size() ; i++)
420 type = nc.
itemAt(i).at(0);
421 value = nc.
itemAt(i).at(1);
423 if (type ==
"idfolio") {
424 formula.append(
"%id");
426 else if (type ==
"folio") {
427 formula.append(
"%F");
429 else if (type ==
"plant") {
430 formula.append(
"%M");
432 else if (type ==
"locmach") {
433 formula.append(
"%LM");
437 else if (type ==
"elementcolumn") {
438 formula.append(
"%c");
440 else if (type ==
"elementline") {
441 formula.append(
"%l");
443 else if (type ==
"elementprefix") {
444 formula.append(
"%prefix");
446 else if (type ==
"string") {
447 formula.append(value);
449 else if (type ==
"unit") {
451 formula.append(
"%sequ_" + QString::number(count_unit));
453 else if (type ==
"unitfolio") {
455 formula.append(
"%sequf_" + QString::number(count_unitf));
457 else if (type ==
"ten") {
459 formula.append(
"%seqt_" + QString::number(count_ten));
461 else if (type ==
"tenfolio") {
463 formula.append(
"%seqtf_" + QString::number(count_tenf));
465 else if (type ==
"hundred") {
467 formula.append(
"%seqh_" + QString::number(count_hundred));
469 else if (type ==
"hundredfolio") {
471 formula.append(
"%seqhf_" + QString::number(count_hundredf));
489 QXmlStreamReader rxml;
496 while((current_location.
parent() != current_location) && (current_location.
parent().
fileName() !=
"import"))
499 path[i]=current_location.
fileName();
500 current_location = current_location.
parent();
507 path[i]=current_location.
fileName();
508 current_location = current_location.
parent();
513 if (current_location.
fileName() !=
"10_electric"){
514 QString custom_labels =
"qet_labels.xml";
517 QFile file(customfilepath);
519 if (!file.open(QFile::ReadOnly | QFile::Text))
521 rxml.setDevice(&file);
526 if (rxml.attributes().value(
"name").toString() == path[i])
533 for (
int j=i; j<= dirLevel; j = j +1)
536 if(rxml.name()==
"prefix")
538 return rxml.readElementText();
543 while (rxml.readNextStartElement() && rxml.name()!=
"prefix")
545 rxml.skipCurrentElement();
557 QString qet_labels =
"10_electric/qet_labels.xml";
559 QFile file(filepath);
561 if (!file.open(QFile::ReadOnly | QFile::Text))
564 rxml.setDevice(&file);
569 if (rxml.attributes().value(
"name").toString() == path[i])
576 for (
int j=i; j<= dirLevel; j = j +1)
579 if(rxml.name()==
"prefix")
581 return rxml.readElementText();
586 while (rxml.readNextStartElement() && rxml.name()!=
"prefix")
588 rxml.skipCurrentElement();
const Element * m_element
bool isProject() const
ElementsLocation::isProject.
static QString formulaToLabel(QString formula, sequentialNumbers &seqStruct, Diagram *diagram, const Element *elmt=nullptr)
AssignVariables::formulaToLabel Return the with variable assigned (ready to be displayed) ...
QStringList itemAt(const int) const
NumerotationContext::itemAt.
static QString customElementsDir()
QETApp::customElementsDir.
void setSequentialToList(QStringList &list, NumerotationContext &context, const QString &type)
setSequentialToList Append all sequential of type owned by in list
QHash< QString, QStringList > m_elmt_unitfolio_max
Hash containing max values for folio sequential autonums in this diagram.
QString fileName() const
ElementLocation::fileName.
QVariant value(const QString &key) const
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)
QList< QString > keys(KeyOrder=None) const
int size() const
NumerotationContext::size.
DiagramContext projectProperties()
bool operator!=(const sequentialNumbers &other) const
DiagramContext additionalFields() const
QString elementPrefixForLocation(const ElementsLocation &location)
elementPrefixForLocation
sequentialNumbers & operator=(const sequentialNumbers &other)
DiagramPosition convertPosition(const QPointF &)
QHash< QString, QStringList > m_elmt_hundredfolio_max
void setFolioSequentialToHash(QStringList &list, QHash< QString, QStringList > &hash, const QString &autoNumName)
setFolioSequentialToHash Insert all value of in with key
QHash< QString, QStringList > m_elmt_tenfolio_max
bool isEmpty() const
NumerotationContext::isEmpty.
sequentialNumbers m_seq_struct
void fromXml(const QDomElement &element)
sequentialNumbers::fromXml Import sequential values from a QDomElement
QStringList hundred_folio
QString getPrefix() const
Element::getPrefix get Element Prefix.
QDomElement textToDomElement(QDomDocument &document, const QString &tag_name, const QString &value)
QETXML::textToDomElement Return a QDomElement, created from , with tag name and text ...
static QString commonElementsDir()
QETApp::commonElementsDir.
void assignTitleBlockVar()
BorderTitleBlock border_and_titleblock
Diagram dimensions and title block.
The AssignVariables class This class assign variable of a formula string. Return the final string use...
QETProject * project() const
ElementsLocation parent() const
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...