diff --git a/sources/conductorautonumerotation.cpp b/sources/conductorautonumerotation.cpp index 225af7961..8901cb792 100644 --- a/sources/conductorautonumerotation.cpp +++ b/sources/conductorautonumerotation.cpp @@ -1,5 +1,5 @@ /* - Copyright 2006-2014 The QElectroTech Team + Copyright 2006-2014 The QElectroTech team This file is part of QElectroTech. QElectroTech is free software: you can redistribute it and/or modify @@ -79,6 +79,30 @@ void ConductorAutoNumerotation::numerateDiagram() { } } +/** + * @brief ConductorAutoNumerotation::checkPotential + * Check if text of this potential is identical. + * If not, ask user how to numerate + * @param conductor + * One conductor of this potential. + */ +void ConductorAutoNumerotation::checkPotential(Conductor *conductor) { + //fill list of potential + QSet c_list = conductor->relatedPotentialConductors(); + c_list << conductor; + //fill list of text + QStringList strl; + foreach (const Conductor *c, c_list) strl<<(c->text()); + + //check text list, isn't same in potential, ask user what to do + if (!eachIsEqual(strl)) { + ConductorAutoNumerotationWidget *canw = new ConductorAutoNumerotationWidget(conductor, c_list, conductor -> diagramEditor()); + ConductorAutoNumerotation can(conductor); + connect(canw, SIGNAL(textIsSelected(QString)), &can, SLOT(applyText(QString))); + canw -> exec(); + } +} + /** * @brief ConductorAutoNumerotation::applyText * apply the text @t to @conductor_ and all conductors at the same potential diff --git a/sources/conductorautonumerotation.h b/sources/conductorautonumerotation.h index 7f2bb2ffc..760e84e2d 100644 --- a/sources/conductorautonumerotation.h +++ b/sources/conductorautonumerotation.h @@ -1,5 +1,5 @@ /* - Copyright 2006-2014 The QElectroTech Team + Copyright 2006-2014 The QElectroTech team This file is part of QElectroTech. QElectroTech is free software: you can redistribute it and/or modify @@ -34,6 +34,7 @@ class ConductorAutoNumerotation: public AutoNumerotation void numerate(); void numerateDiagram(); void removeNumOfDiagram(); + static void checkPotential(Conductor *); public slots: void applyText(QString); diff --git a/sources/qetgraphicsitem/reportelement.cpp b/sources/qetgraphicsitem/reportelement.cpp index 5083e3337..697acb617 100644 --- a/sources/qetgraphicsitem/reportelement.cpp +++ b/sources/qetgraphicsitem/reportelement.cpp @@ -19,6 +19,7 @@ #include "elementtextitem.h" #include "diagramposition.h" #include "qetproject.h" +#include "conductorautonumerotation.h" ReportElement::ReportElement(const ElementsLocation &location, QString link_type,QGraphicsItem *qgi, Diagram *s, int *state) : CustomElement(location, qgi, s, state) @@ -56,8 +57,11 @@ void ReportElement::linkToElement(Element * elmt) { connect(elmt, SIGNAL(positionChange(QPointF)), this, SLOT(updateLabel())); connect(diagram()->project(), SIGNAL(projectDiagramsOrderChanged(QETProject*,int,int)), this, SLOT(updateLabel())); updateLabel(); - tmp_uuids_link.removeAll(elmt->uuid()); elmt->linkToElement(this); + //Check if text of this potential is identical. + if (conductors().count() && elmt->conductors().count()) { + ConductorAutoNumerotation::checkPotential(conductors().first()); + } } } @@ -117,14 +121,16 @@ void ReportElement::setLabel(QString label) { * ie the folio and position of the linked folio report */ void ReportElement::updateLabel() { + ElementTextItem *text = texts().first(); + if (!connected_elements.isEmpty()){ Element *elmt = connected_elements.at(0); QString label = label_; label.replace("%f", QString::number(elmt->diagram()->folioIndex()+1)); label.replace("%c", QString::number(elmt->diagram() -> convertPosition(elmt -> scenePos()).number())); label.replace("%l", elmt->diagram() -> convertPosition(elmt -> scenePos()).letter()); - texts().at(0)->setPlainText(label); + text->setPlainText(label); } else { - texts().at(0)->setPlainText("_"); + text->setPlainText("_"); } }