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)
|
||||
{
|
||||
link_type_ = Terminale;
|
||||
|
||||
connect(this, SIGNAL(elementInfoChange(DiagramContext, DiagramContext)), this, SLOT(updateLabel(DiagramContext, DiagramContext)));
|
||||
connect(this, SIGNAL(xChanged()),this, SLOT(changeElementInfo()));
|
||||
connect(this, SIGNAL(yChanged()),this, SLOT(changeElementInfo()));
|
||||
connect(this, SIGNAL(updateLabel()),this,SLOT(changeElementInfo()));
|
||||
connect(this, &Element::updateLabel, [this]() {this->updateLabel(this->elementInformations(), this->elementInformations());});
|
||||
}
|
||||
|
||||
TerminalElement::~TerminalElement() {
|
||||
@@ -52,36 +51,32 @@ void TerminalElement::initLink(QETProject *project) {
|
||||
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
|
||||
* update label of this element
|
||||
*/
|
||||
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
|
||||
if (old_info["label"].toString() != label) {
|
||||
if (new_info["label"].toString().isEmpty())
|
||||
setTaggedText("label", "_", false);
|
||||
else {
|
||||
setTaggedText("label", label, true);
|
||||
setUpConnectionForFormula(old_formula, new_formula);
|
||||
|
||||
QString label = autonum::AssignVariables::formulaToLabel(new_formula, m_autoNum_seq, diagram(), this);
|
||||
|
||||
if (label.isEmpty())
|
||||
{
|
||||
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"));
|
||||
}
|
||||
|
||||
|
||||
@@ -31,11 +31,8 @@ class TerminalElement : public CustomElement
|
||||
~TerminalElement();
|
||||
virtual void initLink(QETProject *project);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void updateLabel(DiagramContext old_info, DiagramContext new_info);
|
||||
void changeElementInfo();
|
||||
|
||||
private:
|
||||
CommentItem *m_comment_item;
|
||||
|
||||
Reference in New Issue
Block a user