From 1a1dbbc3bea8ec96769cafd75188d9288a646b44 Mon Sep 17 00:00:00 2001 From: blacksun Date: Mon, 31 Mar 2014 16:02:47 +0000 Subject: [PATCH] master element: add auto label when "comment" isn't empty and must show element info widget -> comment line: must show is checked by default git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2951 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/qetgraphicsitem/masterelement.cpp | 16 ++++++++++++++++ sources/qetgraphicsitem/masterelement.h | 2 +- sources/ui/elementinfowidget.cpp | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/sources/qetgraphicsitem/masterelement.cpp b/sources/qetgraphicsitem/masterelement.cpp index 98cc6c1f0..71aa72558 100644 --- a/sources/qetgraphicsitem/masterelement.cpp +++ b/sources/qetgraphicsitem/masterelement.cpp @@ -30,6 +30,7 @@ MasterElement::MasterElement(const ElementsLocation &location, QGraphicsItem *qg { link_type_ = Master; cri_ = 0; + connect(this, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel())); } /** @@ -38,6 +39,7 @@ MasterElement::MasterElement(const ElementsLocation &location, QGraphicsItem *qg */ MasterElement::~MasterElement() { unlinkAllElements(); + disconnect(this, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel())); } /** @@ -92,3 +94,17 @@ void MasterElement::unlinkElement(Element *elmt) { } } } + +/** + * @brief MasterElement::updateLabel + * update label of this element + */ +void MasterElement::updateLabel() { + QString label = elementInformations()["label"].toString(); + bool show = elementInformations().keyMustShow("label"); + + // setup the label + (label.isEmpty() || !show)? + setTaggedText("label", "_", false): + setTaggedText("label", label, true); +} diff --git a/sources/qetgraphicsitem/masterelement.h b/sources/qetgraphicsitem/masterelement.h index 508e1e070..32d1170c5 100644 --- a/sources/qetgraphicsitem/masterelement.h +++ b/sources/qetgraphicsitem/masterelement.h @@ -35,10 +35,10 @@ class MasterElement : public CustomElement signals: public slots: + void updateLabel(); private: CrossRefItem *cri_; - }; #endif // MASTERELEMENT_H diff --git a/sources/ui/elementinfowidget.cpp b/sources/ui/elementinfowidget.cpp index 1eec80920..9116e0032 100644 --- a/sources/ui/elementinfowidget.cpp +++ b/sources/ui/elementinfowidget.cpp @@ -86,5 +86,7 @@ void ElementInfoWidget::fillInfo() { //check "show" if this eipw is label and if elmt_info haven't got value for label. if (eipw->key() == "label" && (elmt_info["label"].toString().isEmpty())) eipw->setShow(true); + else if (eipw->key() == "comment" && (elmt_info["comment"].toString().isEmpty())) + eipw->setShow(true); } }