mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Fix regression : Autonum doesn't work for terminal element
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4924 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -33,10 +33,9 @@ TerminalElement::TerminalElement(const ElementsLocation &location, QGraphicsItem
|
|||||||
m_location_item (nullptr)
|
m_location_item (nullptr)
|
||||||
{
|
{
|
||||||
link_type_ = Terminale;
|
link_type_ = Terminale;
|
||||||
|
|
||||||
connect(this, SIGNAL(elementInfoChange(DiagramContext, DiagramContext)), this, SLOT(updateLabel(DiagramContext, DiagramContext)));
|
connect(this, SIGNAL(elementInfoChange(DiagramContext, DiagramContext)), this, SLOT(updateLabel(DiagramContext, DiagramContext)));
|
||||||
connect(this, SIGNAL(xChanged()),this, SLOT(changeElementInfo()));
|
connect(this, &Element::updateLabel, [this]() {this->updateLabel(this->elementInformations(), this->elementInformations());});
|
||||||
connect(this, SIGNAL(yChanged()),this, SLOT(changeElementInfo()));
|
|
||||||
connect(this, SIGNAL(updateLabel()),this,SLOT(changeElementInfo()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TerminalElement::~TerminalElement() {
|
TerminalElement::~TerminalElement() {
|
||||||
@@ -52,40 +51,36 @@ void TerminalElement::initLink(QETProject *project) {
|
|||||||
updateLabel(DiagramContext(), elementInformations());
|
updateLabel(DiagramContext(), elementInformations());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief SimpleElement::changeElementInfo()
|
|
||||||
* Update label if it contains %c, %l, %f or %F variables
|
|
||||||
*/
|
|
||||||
void TerminalElement::changeElementInfo(){
|
|
||||||
QString temp_label = this->elementInformations()["label"].toString();
|
|
||||||
if (temp_label.contains("\%")) {
|
|
||||||
if (this->diagram()!=NULL)
|
|
||||||
this->updateLabel(this->elementInformations(),this->elementInformations());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief SimpleElement::updateLabel
|
* @brief SimpleElement::updateLabel
|
||||||
* update label of this element
|
* update label of this element
|
||||||
*/
|
*/
|
||||||
void TerminalElement::updateLabel(DiagramContext old_info, DiagramContext new_info)
|
void TerminalElement::updateLabel(DiagramContext old_info, DiagramContext new_info)
|
||||||
{
|
{
|
||||||
QString label = autonum::AssignVariables::formulaToLabel(new_info["label"].toString(), m_autoNum_seq, diagram(), this);
|
QString old_formula = old_info["formula"].toString();
|
||||||
|
QString new_formula = new_info["formula"].toString();
|
||||||
|
|
||||||
//Label of element
|
setUpConnectionForFormula(old_formula, new_formula);
|
||||||
if (old_info["label"].toString() != label) {
|
|
||||||
if (new_info["label"].toString().isEmpty())
|
QString label = autonum::AssignVariables::formulaToLabel(new_formula, m_autoNum_seq, diagram(), this);
|
||||||
setTaggedText("label", "_", false);
|
|
||||||
else {
|
if (label.isEmpty())
|
||||||
setTaggedText("label", label, true);
|
{
|
||||||
}
|
setTaggedText("label", new_info["label"].toString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bool visible = m_element_informations.contains("label") ? m_element_informations.keyMustShow("label") : true;
|
||||||
|
m_element_informations.addValue("label", label, visible);
|
||||||
|
setTaggedText("label", label);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ElementTextItem *eti = taggedText("label")) {
|
if (ElementTextItem *eti = taggedText("label"))
|
||||||
|
{
|
||||||
new_info["label"].toString().isEmpty() ? eti->setVisible(true) : eti -> setVisible(new_info.keyMustShow("label"));
|
new_info["label"].toString().isEmpty() ? eti->setVisible(true) : eti -> setVisible(new_info.keyMustShow("label"));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Comment and Location of element
|
//Comment and Location of element
|
||||||
QString comment = new_info["comment"].toString();
|
QString comment = new_info["comment"].toString();
|
||||||
bool must_show = new_info.keyMustShow("comment");
|
bool must_show = new_info.keyMustShow("comment");
|
||||||
QString location = new_info["location"].toString();
|
QString location = new_info["location"].toString();
|
||||||
|
|||||||
@@ -30,12 +30,9 @@ class TerminalElement : public CustomElement
|
|||||||
TerminalElement(const ElementsLocation &, QGraphicsItem * = 0, int * = 0);
|
TerminalElement(const ElementsLocation &, QGraphicsItem * = 0, int * = 0);
|
||||||
~TerminalElement();
|
~TerminalElement();
|
||||||
virtual void initLink(QETProject *project);
|
virtual void initLink(QETProject *project);
|
||||||
|
|
||||||
signals:
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateLabel(DiagramContext old_info, DiagramContext new_info);
|
void updateLabel(DiagramContext old_info, DiagramContext new_info);
|
||||||
void changeElementInfo();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CommentItem *m_comment_item;
|
CommentItem *m_comment_item;
|
||||||
|
|||||||
Reference in New Issue
Block a user