mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
%seq is not hardcoded anymore. Autonums with the same formula are not conflicted anymore.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4577 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -233,6 +233,6 @@ void DiagramEventAddElement::addElement()
|
||||
can.numerate();
|
||||
};
|
||||
m_diagram -> undoStack().push(undo_object);
|
||||
element->assignSeq();
|
||||
element->setSeq();
|
||||
element->updateLabel();
|
||||
}
|
||||
|
||||
@@ -411,16 +411,19 @@ void ProjectAutoNumConfigPage::buildConnections() {
|
||||
connect(tab_widget,SIGNAL(currentChanged(int)),this,SLOT(tabChanged(int)));
|
||||
|
||||
//Conductor Tab
|
||||
connect (m_context_cb_conductor, SIGNAL (currentTextChanged(QString)), m_saw_conductor, SLOT(applyEnableOnContextChanged(QString)));
|
||||
connect (m_context_cb_conductor, SIGNAL (currentIndexChanged(QString)), this, SLOT (updateContext_conductor(QString)));
|
||||
connect (m_saw_conductor, SIGNAL (applyPressed()), this, SLOT (saveContext_conductor()));
|
||||
connect (m_remove_pb_conductor, SIGNAL (clicked()), this, SLOT (removeContext_conductor()));
|
||||
|
||||
//Element Tab
|
||||
connect (m_context_cb_element, SIGNAL (currentTextChanged(QString)), m_saw_element, SLOT(applyEnableOnContextChanged(QString)));
|
||||
connect (m_context_cb_element, SIGNAL (currentIndexChanged(QString)), this, SLOT (updateContext_element(QString)));
|
||||
connect (m_saw_element, SIGNAL (applyPressed()), this, SLOT (saveContext_element()));
|
||||
connect (m_remove_pb_element, SIGNAL (clicked()), this, SLOT (removeContext_element()));
|
||||
|
||||
//Folio Tab
|
||||
connect (m_context_cb_folio, SIGNAL (currentTextChanged(QString)), m_saw_folio, SLOT(applyEnableOnContextChanged(QString)));
|
||||
connect (m_context_cb_folio, SIGNAL (currentIndexChanged(QString)), this, SLOT (updateContext_folio(QString)));
|
||||
connect (m_saw_folio, SIGNAL (applyPressed()), this, SLOT (saveContext_folio()));
|
||||
connect (m_remove_pb_folio, SIGNAL (clicked()), this, SLOT (removeContext_folio()));
|
||||
@@ -516,21 +519,21 @@ void ProjectAutoNumConfigPage::saveContext_element() {
|
||||
if (m_context_cb_element -> currentText() == tr("Nom de la nouvelle numérotation")) {
|
||||
project_->addElementAutoNum (tr("Sans nom"), m_saw_element -> toNumContext());
|
||||
project()->addElementAutoNumFormula (tr("Sans nom"), m_saw_element->elementFormula()); //add hash <title, formula>
|
||||
project()->setElementAutoNumCurrentFormula (m_saw_element->elementFormula()); //add last added element formula to current formula
|
||||
project()->setElementAutoNumCurrentFormula (m_saw_element->elementFormula(),tr("Sans nom")); //add last added element formula to current formula
|
||||
m_context_cb_element -> addItem(tr("Sans nom"));
|
||||
}
|
||||
// If the text isn't yet to the autonum of the project, add this new item to the combo box.
|
||||
else if ( !project_ -> elementAutoNum().keys().contains( m_context_cb_element->currentText())) {
|
||||
project()->addElementAutoNum(m_context_cb_element->currentText(), m_saw_element->toNumContext()); //add hash <title, numcontext>
|
||||
project()->addElementAutoNumFormula (m_context_cb_element->currentText(), m_saw_element->elementFormula()); //add hash <title, formula>
|
||||
project()->setElementAutoNumCurrentFormula (m_saw_element->elementFormula()); //add last added element formula to current formula
|
||||
project()->setElementAutoNumCurrentFormula (m_saw_element->elementFormula(),m_context_cb_element->currentText()); //add last added element formula to current formula
|
||||
m_context_cb_element -> addItem(m_context_cb_element->currentText());
|
||||
}
|
||||
// Else, the text already exist in the autonum of the project, just update the context
|
||||
else {
|
||||
project_->addElementAutoNum (m_context_cb_element -> currentText(), m_saw_element -> toNumContext()); //add hash <title, numcontext>
|
||||
project()->addElementAutoNumFormula (m_context_cb_element->currentText(), m_saw_element->elementFormula()); //add hash <title, formula>
|
||||
project()->setElementAutoNumCurrentFormula (m_saw_element->elementFormula()); //add last added element formula to current formula
|
||||
project()->setElementAutoNumCurrentFormula (m_saw_element->elementFormula(), m_context_cb_element->currentText()); //add last added element formula to current formula
|
||||
}
|
||||
project()->elementAutoNumAdded();
|
||||
}
|
||||
|
||||
@@ -406,11 +406,32 @@ bool Element::fromXml(QDomElement &e, QHash<int, Terminal *> &table_id_adr, bool
|
||||
//load prefix
|
||||
m_prefix = e.attribute("prefix");
|
||||
|
||||
//Load Unit Sequential Values
|
||||
int i = 0;
|
||||
while (!e.attribute("sequ_" + QString::number(i+1)).isEmpty()) {
|
||||
seq_unit.append(e.attribute("sequ_" + QString::number(i+1)));
|
||||
i++;
|
||||
}
|
||||
|
||||
//Load Ten Sequential Values
|
||||
i = 0;
|
||||
while (!e.attribute("seqt_" + QString::number(i+1)).isEmpty()) {
|
||||
seq_ten.append(e.attribute("seqt_" + QString::number(i+1)));
|
||||
i++;
|
||||
}
|
||||
|
||||
//Load Hundred Sequential Values
|
||||
i = 0;
|
||||
while (!e.attribute("seqh_" + QString::number(i+1)).isEmpty()) {
|
||||
seq_hundred.append(e.attribute("seqh_" + QString::number(i+1)));
|
||||
i++;
|
||||
}
|
||||
|
||||
//load informations
|
||||
m_element_informations.fromXml(e.firstChildElement("elementInformations"), "elementInformation");
|
||||
|
||||
//Position and selection.
|
||||
//We directly call setPos from QGraphicsObject, because QetGraphicsItem will snap to grid
|
||||
//Position and selection.
|
||||
//We directly call setPos from QGraphicsObject, because QetGraphicsItem will snap to grid
|
||||
QGraphicsObject::setPos(e.attribute("x").toDouble(), e.attribute("y").toDouble());
|
||||
setFlags(QGraphicsItem::ItemIsMovable | QGraphicsItem::ItemIsSelectable);
|
||||
|
||||
@@ -443,6 +464,21 @@ QDomElement Element::toXml(QDomDocument &document, QHash<Terminal *, int> &table
|
||||
element.setAttribute("uuid", uuid().toString());
|
||||
// prefix
|
||||
element.setAttribute("prefix", m_prefix);
|
||||
|
||||
//Save Unit Sequential Values
|
||||
for (int i = 0; i < seq_unit.size(); i++) {
|
||||
element.setAttribute("sequ_" + QString::number(i+1),seq_unit.at(i));
|
||||
}
|
||||
|
||||
//Save Ten Sequential Values
|
||||
for (int i = 0; i < seq_ten.size(); i++) {
|
||||
element.setAttribute("seqt_" + QString::number(i+1),seq_ten.at(i));
|
||||
}
|
||||
|
||||
//Save Hundred Sequential Values
|
||||
for (int i = 0; i < seq_hundred.size(); i++) {
|
||||
element.setAttribute("seqh_" + QString::number(i+1),seq_hundred.at(i));
|
||||
}
|
||||
|
||||
// position, selection et orientation
|
||||
element.setAttribute("x", QString("%1").arg(pos().x()));
|
||||
@@ -684,56 +720,71 @@ QString Element::assignVariables(QString label, Element *elmt){
|
||||
label.replace("%prefix", elmt->getPrefix());
|
||||
if (label.contains("%prefix"))
|
||||
label.replace("%prefix",this->getPrefix());
|
||||
label = assignSeq(label);
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Element::assignSeq()
|
||||
* Assign sequential values to element label
|
||||
* @brief Element::setSeq()
|
||||
* Set sequential values to element
|
||||
*/
|
||||
void Element::assignSeq() {
|
||||
void Element::setSeq() {
|
||||
DiagramContext &dc = this->rElementInformations();
|
||||
QString element_currentAutoNum = diagram()->project()->elementCurrentAutoNum();
|
||||
QString formula = diagram()->project()->elementAutoNumFormula();
|
||||
QHash <QString,QString> hash = diagram()->project()->elementAutoNum_2();
|
||||
QString formula_name = hash.key(formula);
|
||||
QString label = dc["label"].toString();
|
||||
NumerotationContext nc = diagram()->project()->elementAutoNum(formula_name);
|
||||
NumerotationContext nc = diagram()->project()->elementAutoNum(element_currentAutoNum);
|
||||
NumerotationContextCommands ncc (nc);
|
||||
if (!nc.isEmpty()) {
|
||||
//Unit Format
|
||||
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++;
|
||||
seq_unit.append(QString::number(nc.itemAt(i).at(1).toInt()));
|
||||
}
|
||||
}
|
||||
}
|
||||
//Ten Format
|
||||
if (label.contains("%seqt_")) {
|
||||
int count = 1;
|
||||
for (int i = 0; i < nc.size(); i++) {
|
||||
if (nc.itemAt(i).at(0) == "ten") {
|
||||
QString number = QString("%1").arg(nc.itemAt(i).at(1).toInt(), 2, 10, QChar('0'));
|
||||
label.replace("%seqt_" + QString::number(count), number);
|
||||
count++;
|
||||
QString number = QString ("%1").arg(nc.itemAt(i).at(1).toInt(), 2, 10, QChar('0'));
|
||||
seq_ten.append(number);
|
||||
}
|
||||
}
|
||||
}
|
||||
//Hundred Format
|
||||
if (label.contains("%seqh_")) {
|
||||
int count = 1;
|
||||
for (int i = 0; i < nc.size(); i++) {
|
||||
if (nc.itemAt(i).at(0) == "hundred") {
|
||||
QString number = QString("%1").arg(nc.itemAt(i).at(1).toInt(), 3, 10, QChar('0'));
|
||||
label.replace("%seqh_" + QString::number(count), number);
|
||||
count++;
|
||||
QString number = QString ("%1").arg(nc.itemAt(i).at(1).toInt(), 3, 10, QChar('0'));
|
||||
seq_hundred.append(number);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dc.addValue("label",label);
|
||||
this->diagram()->project()->addElementAutoNum(formula_name,ncc.next());
|
||||
this->setElementInformations(dc);
|
||||
this->setTaggedText("label", label);
|
||||
this->diagram()->project()->addElementAutoNum(element_currentAutoNum,ncc.next());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Element::assignSeq
|
||||
* Replace sequential values to element label
|
||||
* @param label to be replaced
|
||||
* @return replaced label
|
||||
*/
|
||||
QString Element::assignSeq(QString label) {
|
||||
for (int i = 1; i <= qMax(seq_unit.size(),qMax(seq_hundred.size(),seq_ten.size())); i++) {
|
||||
if (label.contains("%sequ_" + QString::number(i))) {
|
||||
label.replace("%sequ_" + QString::number(i),seq_unit.at(i-1));
|
||||
}
|
||||
if (label.contains("%seqt_" + QString::number(i))) {
|
||||
label.replace("%seqt_" + QString::number(i),seq_ten.at(i-1));
|
||||
}
|
||||
if (label.contains("%seqh_" + QString::number(i))) {
|
||||
label.replace("%seqh_" + QString::number(i),seq_hundred.at(i-1));
|
||||
}
|
||||
}
|
||||
return label;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -134,7 +134,8 @@ 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 ();
|
||||
QString assignSeq (QString);
|
||||
void setSeq ();
|
||||
void setPrefix(QString);
|
||||
QString getPrefix();
|
||||
|
||||
@@ -199,6 +200,9 @@ class Element : public QetGraphicsItem {
|
||||
private:
|
||||
bool m_mouse_over;
|
||||
QString m_prefix;
|
||||
QStringList seq_unit;
|
||||
QStringList seq_ten;
|
||||
QStringList seq_hundred;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -444,6 +444,14 @@ QString QETProject::elementAutoNumFormula () const {
|
||||
return m_current_element_formula;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief QETProject::elementCurrentAutoNum
|
||||
* @return current element autonum title
|
||||
*/
|
||||
QString QETProject::elementCurrentAutoNum () const {
|
||||
return m_current_element_autonum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief QETProject::folioAutoNum
|
||||
* @return All value of folio autonum stored in project
|
||||
@@ -474,14 +482,15 @@ void QETProject::addElementAutoNumFormula(QString key, QString formula) {
|
||||
|
||||
/**
|
||||
* @brief QETProject::setElementAutoNumCurrentFormula
|
||||
* Add the formula to the current formula
|
||||
* Add the formula and title to the current formula and current autonum
|
||||
* @param formula
|
||||
* @param title
|
||||
*/
|
||||
void QETProject::setElementAutoNumCurrentFormula(QString formula) {
|
||||
void QETProject::setElementAutoNumCurrentFormula(QString formula, QString title) {
|
||||
m_current_element_formula = formula;
|
||||
m_current_element_autonum = title;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief QETProject::addElementAutoNum
|
||||
* Add a new element numerotation context. If key already exist,
|
||||
@@ -1321,6 +1330,7 @@ void QETProject::readDefaultPropertiesXml(QDomDocument &xml_project)
|
||||
}
|
||||
if (!element_autonums.isNull())
|
||||
{
|
||||
m_current_element_autonum = element_autonums.attribute("current_autonum");
|
||||
m_current_element_formula = element_autonums.attribute("current_formula");
|
||||
foreach (QDomElement elmt, QET::findInDomElement(element_autonums, "element_autonum"))
|
||||
{
|
||||
@@ -1402,6 +1412,7 @@ void QETProject::writeDefaultPropertiesXml(QDomElement &xml_element) {
|
||||
|
||||
//Export Element Autonums
|
||||
QDomElement element_autonums = xml_document.createElement("element_autonums");
|
||||
element_autonums.setAttribute("current_autonum", m_current_element_autonum);
|
||||
element_autonums.setAttribute("current_formula", m_current_element_formula);
|
||||
foreach (QString key, elementAutoNum().keys()) {
|
||||
QDomElement element_autonum = elementAutoNum(key).toXml(xml_document, "element_autonum");
|
||||
|
||||
@@ -113,7 +113,7 @@ class QETProject : public QObject
|
||||
void addConductorAutoNum (QString key, NumerotationContext context);
|
||||
void addElementAutoNum (QString key, NumerotationContext context);
|
||||
void addElementAutoNumFormula (QString key, QString formula);
|
||||
void setElementAutoNumCurrentFormula (QString formula);
|
||||
void setElementAutoNumCurrentFormula (QString formula, QString title);
|
||||
void addFolioAutoNum (QString key, NumerotationContext context);
|
||||
void removeConductorAutoNum (QString key);
|
||||
void removeElementAutoNum (QString key);
|
||||
@@ -123,6 +123,7 @@ class QETProject : public QObject
|
||||
NumerotationContext elementAutoNum(const QString &key) const;
|
||||
QString elementAutoNumFormula(const QString key) const; //returns Formula
|
||||
QString elementAutoNumFormula() const;
|
||||
QString elementCurrentAutoNum () const;
|
||||
|
||||
bool autoConductor () const;
|
||||
bool autoElement () const;
|
||||
@@ -244,6 +245,7 @@ class QETProject : public QObject
|
||||
QHash <QString, QString> m_element_autonum_formula; //Title and Formula hash
|
||||
QHash <QString, NumerotationContext> m_element_autonum; //Title and NumContext hash
|
||||
QString m_current_element_formula;
|
||||
QString m_current_element_autonum;
|
||||
/// Folio List Sheets quantity for this project.
|
||||
int folioSheetsQuantity;
|
||||
bool m_auto_conductor;
|
||||
|
||||
@@ -148,6 +148,7 @@ void AutoNumberingDockWidget::setActive() {
|
||||
ui->m_conductor_cb->setCurrentIndex(conductor_index);
|
||||
|
||||
//Element
|
||||
QString current_element_autonum = project_->elementCurrentAutoNum();
|
||||
QString element_formula = project_->elementAutoNumFormula();
|
||||
QString active_element_autonum = project_->elementAutoNum_2().key(element_formula);
|
||||
int el_index = ui->m_element_cb->findText(active_element_autonum);
|
||||
@@ -209,9 +210,10 @@ void AutoNumberingDockWidget::elementAutoNumChanged() {
|
||||
*/
|
||||
void AutoNumberingDockWidget::on_m_element_cb_activated(int) {
|
||||
QString current_autonum = ui->m_element_cb->currentText();
|
||||
QString current_formula = project_->elementAutoNumFormula(current_autonum);
|
||||
if (current_formula!=NULL)
|
||||
project_->setElementAutoNumCurrentFormula(current_formula);
|
||||
QString current_formula = project_->elementAutoNumFormula();
|
||||
if (current_formula!=NULL) {
|
||||
project_->setElementAutoNumCurrentFormula(current_formula, current_autonum);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -201,6 +201,14 @@ void SelectAutonumW::on_buttonBox_clicked(QAbstractButton *button) {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SelectAutonumW::applyEnableOnContextChanged
|
||||
* enable/disable the apply button after changing the autonum name
|
||||
*/
|
||||
void SelectAutonumW::applyEnableOnContextChanged(QString) {
|
||||
applyEnable(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SelectAutonumW::applyEnable
|
||||
* enable/disable the apply button
|
||||
|
||||
@@ -48,6 +48,9 @@ class SelectAutonumW : public QWidget
|
||||
void applyPressed();
|
||||
|
||||
//SLOT
|
||||
public slots:
|
||||
void applyEnableOnContextChanged(QString);
|
||||
|
||||
private slots:
|
||||
void on_add_button_clicked();
|
||||
void on_remove_button_clicked();
|
||||
|
||||
Reference in New Issue
Block a user