Element Autonumbering now has sequential variables and selectautonum widget. Renamed autonumbering variables.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4569 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
dfochi
2016-07-10 01:33:49 +00:00
parent 518f0efd46
commit f8a829d328
23 changed files with 746 additions and 311 deletions

View File

@@ -309,8 +309,8 @@ void CustomElement::parseLabels() {
prefix = rxml.readElementText();
DiagramContext &dc = this->rElementInformations();
//if there is a formula to assign, assign it
if (!location().project()->elementAutoNum().isEmpty() && this->linkType()!=Element::Slave) {
QString formula = location().project()->elementAutoNum();
if (!location().project()->elementAutoNumFormula().isEmpty() && this->linkType()!=Element::Slave) {
QString formula = location().project()->elementAutoNumFormula();
formula.replace("%prefix", prefix);
dc.addValue("label", formula);
this->setTaggedText("label",formula);
@@ -336,8 +336,8 @@ void CustomElement::parseLabels() {
}
//apply formula to specific label
else if ((this->taggedText("label")!= NULL) && (location().projectId()!=-1) &&
(!location().project()->elementAutoNum().isEmpty()) && (this->linkType()!=Element::Slave)) {
QString formula = location().project()->elementAutoNum();
(!location().project()->elementAutoNumFormula().isEmpty()) && (this->linkType()!=Element::Slave)) {
QString formula = location().project()->elementAutoNumFormula();
DiagramContext &dc = this->rElementInformations();
QString prefix = this->taggedText("label")->toPlainText();
formula.replace("%prefix", prefix);

View File

@@ -26,6 +26,7 @@
#include "terminal.h"
#include "PropertiesEditor/propertieseditordialog.h"
#include "elementpropertieswidget.h"
#include "numerotationcontextcommands.h"
/**
Constructeur pour un element sans scene ni parent
@@ -677,3 +678,69 @@ QString Element::assignVariables(QString label, Element *elmt){
label.replace("%total", QString::number(elmt->diagram()->border_and_titleblock.folioTotal()));
return label;
}
/**
* @brief Element::assignSeq()
* Assign sequential values to element label
*/
void Element::assignSeq() {
DiagramContext &dc = this->rElementInformations();
QString formula = diagram()->project()->elementAutoNumFormula();
QHash <QString,QString> hash = diagram()->project()->elementAutoNum_2();
QString formula_name = hash.key(formula);
QString label = dc["label"].toString();
qDebug() << "Label" << label;
NumerotationContext nc = diagram()->project()->elementAutoNum(formula_name);
NumerotationContextCommands ncc (nc);
if (!nc.isEmpty()) {
if (label.contains("%sequ_")) {
int count = 1;
for (int i = 0; i < nc.size(); i++) {
if (nc.itemAt(i).at(0) == "unit") {
label.replace("%sequ_" + QString::number(count), QString::number(nc.itemAt(i).at(1).toInt()));
count++;
}
}
}
if (label.contains("%seqt_")) {
int count = 1;
for (int i = 0; i < nc.size(); i++) {
if (nc.itemAt(i).at(0) == "ten") {
label.replace("%seqt_" + QString::number(count), QString::number(nc.itemAt(i).at(1).toInt()));
count++;
}
}
}
if (label.contains("%seqh_")) {
int count = 1;
for (int i = 0; i < nc.size(); i++) {
if (nc.itemAt(i).at(0) == "hundred") {
label.replace("%seqh_" + QString::number(count), QString::number(nc.itemAt(i).at(1).toInt()));
count++;
}
}
}
}
dc.addValue("label",label);
this->diagram()->project()->addElementAutoNum(formula_name,ncc.next());
this->setElementInformations(dc);
this->setTaggedText("label", label);
}
/**
* @brief ElementTextItem::setTaggedText
* Set text @newstr to the text tagged with @tagg.
* If tagg is found return the text item, else return NULL.
* @param tagg required tagg
* @param newstr new label
* @param noeditable set editable or not (by default, set editable)
*/
ElementTextItem* Element::setTaggedText(const QString &tagg, const QString &newstr, const bool noeditable) {
ElementTextItem *eti = taggedText(tagg);
if (eti) {
eti -> setPlainText(newstr);
eti -> setNoEditable(noeditable);
}
return eti;
}

View File

@@ -118,6 +118,7 @@ class Element : public QetGraphicsItem {
QList <QUuid> tmp_uuids_link;
QUuid uuid_;
kind link_type_;
ElementTextItem* setTaggedText(const QString &tagg, const QString &newstr, const bool noeditable=false);
signals:
void linkedElementChanged(); //This signal is emited when the linked elements with this element change
@@ -133,6 +134,7 @@ class Element : public QetGraphicsItem {
//about the herited class like contactelement for know
// kind of contact (simple tempo) or number of contact show by the element.
QString assignVariables (QString, Element *);
void assignSeq ();
//ATTRIBUTES
protected:

View File

@@ -128,7 +128,7 @@ void MasterElement::initLink(QETProject *project) {
*/
void MasterElement::changeElementInfo(){
QString temp_label = this->elementInformations()["label"].toString();
if (temp_label.contains("\%l")||temp_label.contains("\%c")||temp_label.contains("\%f")||temp_label.contains("\%F")) {
if (temp_label.contains("\%")) {
if (this->diagram()!=NULL)
this->updateLabel(this->elementInformations(),this->elementInformations());
}

View File

@@ -62,7 +62,7 @@ void SimpleElement::initLink(QETProject *project) {
*/
void SimpleElement::changeElementInfo(){
QString temp_label = this->elementInformations()["label"].toString();
if (temp_label.contains("\%l")||temp_label.contains("\%c")||temp_label.contains("\%f")||temp_label.contains("\%F")) {
if (temp_label.contains("\%")) {
if (this->diagram()!=NULL)
this->updateLabel(this->elementInformations(),this->elementInformations());
}