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
|
* @param dc
|
||||||
*/
|
*/
|
||||||
void Element::setElementInformations(DiagramContext dc) {
|
void Element::setElementInformations(DiagramContext dc) {
|
||||||
|
DiagramContext old_info = element_informations_;
|
||||||
element_informations_ = dc;
|
element_informations_ = dc;
|
||||||
emit elementInfoChange(element_informations_);
|
emit elementInfoChange(old_info, element_informations_);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ class Element : public QetGraphicsItem {
|
|||||||
kind link_type_;
|
kind link_type_;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void elementInfoChange(DiagramContext);
|
void elementInfoChange(DiagramContext old_info, DiagramContext new_info);
|
||||||
|
|
||||||
//METHODS related to information
|
//METHODS related to information
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "masterelement.h"
|
#include "masterelement.h"
|
||||||
#include "crossrefitem.h"
|
#include "crossrefitem.h"
|
||||||
|
#include "elementtextitem.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief MasterElement::MasterElement
|
* @brief MasterElement::MasterElement
|
||||||
@@ -31,7 +32,7 @@ MasterElement::MasterElement(const ElementsLocation &location, QGraphicsItem *qg
|
|||||||
cri_ (nullptr)
|
cri_ (nullptr)
|
||||||
{
|
{
|
||||||
link_type_ = Master;
|
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
|
* @brief MasterElement::initLink
|
||||||
* Initialise the links between this element and other element.
|
|
||||||
* @param project
|
* @param project
|
||||||
|
* Call init Link from custom element and after
|
||||||
|
* call update label for setup it.
|
||||||
*/
|
*/
|
||||||
void MasterElement::initLink(QETProject *project) {
|
void MasterElement::initLink(QETProject *project) {
|
||||||
//Create the link with other element if needed
|
//Create the link with other element if needed
|
||||||
CustomElement::initLink(project);
|
CustomElement::initLink(project);
|
||||||
updateLabel();
|
updateLabel(DiagramContext(), elementInformations());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -111,13 +113,18 @@ void MasterElement::initLink(QETProject *project) {
|
|||||||
* update label of this element
|
* update label of this element
|
||||||
* and the comment item if he's displayed.
|
* and the comment item if he's displayed.
|
||||||
*/
|
*/
|
||||||
void MasterElement::updateLabel() {
|
void MasterElement::updateLabel(DiagramContext old_info, DiagramContext new_info) {
|
||||||
QString label = elementInformations()["label"].toString();
|
//Label of element
|
||||||
bool show = elementInformations().keyMustShow("label");
|
if (old_info["label"].toString() != new_info["label"].toString()) {
|
||||||
|
if (new_info["label"].toString().isEmpty())
|
||||||
// setup the label
|
setTaggedText("label", "_", false);
|
||||||
if (!label.isEmpty() && show) setTaggedText("label", label, true);
|
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
|
//Delete or update the xref
|
||||||
if (cri_) {
|
if (cri_) {
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class MasterElement : public CustomElement
|
|||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateLabel();
|
void updateLabel(DiagramContext old_info, DiagramContext new_info);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool aboutDeleteXref ();
|
bool aboutDeleteXref ();
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "simpleelement.h"
|
#include "simpleelement.h"
|
||||||
#include "commentitem.h"
|
#include "commentitem.h"
|
||||||
|
#include "elementtextitem.h"
|
||||||
/**
|
/**
|
||||||
* @brief SimpleElement::SimpleElement
|
* @brief SimpleElement::SimpleElement
|
||||||
* @param location
|
* @param location
|
||||||
@@ -29,37 +30,47 @@ SimpleElement::SimpleElement(const ElementsLocation &location, QGraphicsItem *qg
|
|||||||
m_comment_item (nullptr)
|
m_comment_item (nullptr)
|
||||||
{
|
{
|
||||||
link_type_ = Simple;
|
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
|
* @brief SimpleElement::~SimpleElement
|
||||||
*/
|
*/
|
||||||
SimpleElement::~SimpleElement() {
|
SimpleElement::~SimpleElement() {
|
||||||
disconnect(this, SIGNAL(elementInfoChange(DiagramContext)), this, SLOT(updateLabel()));
|
|
||||||
if (m_comment_item) delete m_comment_item;
|
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) {
|
void SimpleElement::initLink(QETProject *project) {
|
||||||
CustomElement::initLink(project);
|
CustomElement::initLink(project);
|
||||||
updateLabel();
|
updateLabel(DiagramContext(), elementInformations());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief SimpleElement::updateLabel
|
* @brief SimpleElement::updateLabel
|
||||||
* update label of this element
|
* update label of this element
|
||||||
*/
|
*/
|
||||||
void SimpleElement::updateLabel() {
|
void SimpleElement::updateLabel(DiagramContext old_info, DiagramContext new_info) {
|
||||||
//Label of element
|
//Label of element
|
||||||
QString label = elementInformations()["label"].toString();
|
if (old_info["label"].toString() != new_info["label"].toString()) {
|
||||||
bool show = elementInformations().keyMustShow("label");
|
if (new_info["label"].toString().isEmpty())
|
||||||
|
setTaggedText("label", "_", false);
|
||||||
|
else
|
||||||
|
setTaggedText("label", new_info["label"].toString(), true);
|
||||||
|
}
|
||||||
|
|
||||||
// setup the label
|
if (ElementTextItem *eti = taggedText("label")) {
|
||||||
if (!label.isEmpty() && show) setTaggedText("label", label, true);
|
new_info["label"].toString().isEmpty() ? eti->setVisible(true) : eti -> setVisible(new_info.keyMustShow("label"));
|
||||||
|
}
|
||||||
|
|
||||||
//Comment of element
|
//Comment of element
|
||||||
QString comment = elementInformations()["comment"].toString();
|
QString comment = new_info["comment"].toString();
|
||||||
bool must_show = elementInformations().keyMustShow("comment");
|
bool must_show = new_info.keyMustShow("comment");
|
||||||
|
|
||||||
if (!(comment.isEmpty() || !must_show) && !m_comment_item) {
|
if (!(comment.isEmpty() || !must_show) && !m_comment_item) {
|
||||||
m_comment_item = new CommentItem(this);
|
m_comment_item = new CommentItem(this);
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ class SimpleElement : public CustomElement {
|
|||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateLabel();
|
void updateLabel(DiagramContext old_info, DiagramContext new_info);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CommentItem *m_comment_item;
|
CommentItem *m_comment_item;
|
||||||
|
|||||||
Reference in New Issue
Block a user