mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 22:00:35 +01:00
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:
@@ -518,8 +518,9 @@ void Element::initLink(QETProject *prj) {
|
||||
* @param dc
|
||||
*/
|
||||
void Element::setElementInformations(DiagramContext dc) {
|
||||
DiagramContext old_info = element_informations_;
|
||||
element_informations_ = dc;
|
||||
emit elementInfoChange(element_informations_);
|
||||
emit elementInfoChange(old_info, element_informations_);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -121,7 +121,7 @@ class Element : public QetGraphicsItem {
|
||||
kind link_type_;
|
||||
|
||||
signals:
|
||||
void elementInfoChange(DiagramContext);
|
||||
void elementInfoChange(DiagramContext old_info, DiagramContext new_info);
|
||||
|
||||
//METHODS related to information
|
||||
public:
|
||||
|
||||
@@ -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_) {
|
||||
|
||||
@@ -44,7 +44,7 @@ class MasterElement : public CustomElement
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void updateLabel();
|
||||
void updateLabel(DiagramContext old_info, DiagramContext new_info);
|
||||
|
||||
private:
|
||||
bool aboutDeleteXref ();
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
#include "simpleelement.h"
|
||||
#include "commentitem.h"
|
||||
#include "elementtextitem.h"
|
||||
/**
|
||||
* @brief SimpleElement::SimpleElement
|
||||
* @param location
|
||||
@@ -29,37 +30,47 @@ SimpleElement::SimpleElement(const ElementsLocation &location, QGraphicsItem *qg
|
||||
m_comment_item (nullptr)
|
||||
{
|
||||
link_type_ = Simple;
|
||||
connect(this, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
|
||||
connect(this, SIGNAL(elementInfoChange(DiagramContext, DiagramContext)), this, SLOT(updateLabel(DiagramContext, DiagramContext)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SimpleElement::~SimpleElement
|
||||
*/
|
||||
SimpleElement::~SimpleElement() {
|
||||
disconnect(this, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
|
||||
if (m_comment_item) delete m_comment_item;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SimpleElement::initLink
|
||||
* @param project
|
||||
* Call init Link from custom element and after
|
||||
* call update label for setup it.
|
||||
*/
|
||||
void SimpleElement::initLink(QETProject *project) {
|
||||
CustomElement::initLink(project);
|
||||
updateLabel();
|
||||
updateLabel(DiagramContext(), elementInformations());
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief SimpleElement::updateLabel
|
||||
* update label of this element
|
||||
*/
|
||||
void SimpleElement::updateLabel() {
|
||||
void SimpleElement::updateLabel(DiagramContext old_info, DiagramContext new_info) {
|
||||
//Label of element
|
||||
QString label = elementInformations()["label"].toString();
|
||||
bool show = elementInformations().keyMustShow("label");
|
||||
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);
|
||||
}
|
||||
|
||||
// setup the label
|
||||
if (!label.isEmpty() && show) setTaggedText("label", label, true);
|
||||
if (ElementTextItem *eti = taggedText("label")) {
|
||||
new_info["label"].toString().isEmpty() ? eti->setVisible(true) : eti -> setVisible(new_info.keyMustShow("label"));
|
||||
}
|
||||
|
||||
//Comment of element
|
||||
QString comment = elementInformations()["comment"].toString();
|
||||
bool must_show = elementInformations().keyMustShow("comment");
|
||||
QString comment = new_info["comment"].toString();
|
||||
bool must_show = new_info.keyMustShow("comment");
|
||||
|
||||
if (!(comment.isEmpty() || !must_show) && !m_comment_item) {
|
||||
m_comment_item = new CommentItem(this);
|
||||
|
||||
@@ -40,7 +40,7 @@ class SimpleElement : public CustomElement {
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
void updateLabel();
|
||||
void updateLabel(DiagramContext old_info, DiagramContext new_info);
|
||||
|
||||
private:
|
||||
CommentItem *m_comment_item;
|
||||
|
||||
Reference in New Issue
Block a user