Element information : Check box "visible" for text re-work.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@3499 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2014-11-18 23:00:06 +00:00
parent 46100f0d94
commit a0ba343951
6 changed files with 42 additions and 23 deletions

View File

@@ -17,6 +17,7 @@
*/
#include "masterelement.h"
#include "crossrefitem.h"
#include "elementtextitem.h"
/**
* @brief MasterElement::MasterElement
@@ -31,7 +32,7 @@ MasterElement::MasterElement(const ElementsLocation &location, QGraphicsItem *qg
cri_ (nullptr)
{
link_type_ = Master;
connect(this, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
connect(this, SIGNAL(elementInfoChange(DiagramContext, DiagramContext)), this, SLOT(updateLabel(DiagramContext, DiagramContext)));
}
/**
@@ -97,13 +98,14 @@ void MasterElement::unlinkElement(Element *elmt) {
/**
* @brief MasterElement::initLink
* Initialise the links between this element and other element.
* @param project
* Call init Link from custom element and after
* call update label for setup it.
*/
void MasterElement::initLink(QETProject *project) {
//Create the link with other element if needed
CustomElement::initLink(project);
updateLabel();
updateLabel(DiagramContext(), elementInformations());
}
/**
@@ -111,13 +113,18 @@ void MasterElement::initLink(QETProject *project) {
* update label of this element
* and the comment item if he's displayed.
*/
void MasterElement::updateLabel() {
QString label = elementInformations()["label"].toString();
bool show = elementInformations().keyMustShow("label");
// setup the label
if (!label.isEmpty() && show) setTaggedText("label", label, true);
void MasterElement::updateLabel(DiagramContext old_info, DiagramContext new_info) {
//Label of element
if (old_info["label"].toString() != new_info["label"].toString()) {
if (new_info["label"].toString().isEmpty())
setTaggedText("label", "_", false);
else
setTaggedText("label", new_info["label"].toString(), true);
}
if (ElementTextItem *eti = taggedText("label")) {
new_info["label"].toString().isEmpty() ? eti->setVisible(true) : eti -> setVisible(new_info.keyMustShow("label"));
}
//Delete or update the xref
if (cri_) {