mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 13:30:34 +01:00
Added position and folios variables handling to Elements (Master, Slave and Simple) Label
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4514 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -382,7 +382,6 @@ void ProjectAutoNumConfigPage::buildConnections() {
|
|||||||
|
|
||||||
// Auto Folio Numbering
|
// Auto Folio Numbering
|
||||||
connect (m_faw, SIGNAL (applyPressed()), this, SLOT (applyAutoNum()));
|
connect (m_faw, SIGNAL (applyPressed()), this, SLOT (applyAutoNum()));
|
||||||
connect (m_faw, SIGNAL (m_autonumber_tabs_rb_clicked()), this, SLOT (tabChanged(int)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include "elementdefinition.h"
|
#include "elementdefinition.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
|
#include "diagramposition.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur de la classe CustomElement. Permet d'instancier un element
|
Constructeur de la classe CustomElement. Permet d'instancier un element
|
||||||
@@ -986,3 +987,11 @@ ElementTextItem* CustomElement::taggedText(const QString &tagg) const {
|
|||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CustomElement::assignVariables(QString label, Element *elmt){
|
||||||
|
label.replace("%f", QString::number(elmt->diagram()->folioIndex()+1));
|
||||||
|
label.replace("%F", elmt->diagram() -> border_and_titleblock.folio());
|
||||||
|
label.replace("%c", QString::number(elmt->diagram() -> convertPosition(elmt -> scenePos()).number()));
|
||||||
|
label.replace("%l", elmt->diagram() -> convertPosition(elmt -> scenePos()).letter());
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ class CustomElement : public FixedElement
|
|||||||
virtual bool validOrientationAttribute(const QDomElement &);
|
virtual bool validOrientationAttribute(const QDomElement &);
|
||||||
virtual void setPainterStyle(QDomElement &, QPainter &);
|
virtual void setPainterStyle(QDomElement &, QPainter &);
|
||||||
ElementTextItem* setTaggedText(const QString &tagg, const QString &newstr, const bool noeditable=false);
|
ElementTextItem* setTaggedText(const QString &tagg, const QString &newstr, const bool noeditable=false);
|
||||||
|
QString assignVariables (QString, Element *);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ MasterElement::MasterElement(const ElementsLocation &location, QGraphicsItem *qg
|
|||||||
{
|
{
|
||||||
link_type_ = Master;
|
link_type_ = Master;
|
||||||
connect(this, SIGNAL(elementInfoChange(DiagramContext, DiagramContext)), this, SLOT(updateLabel(DiagramContext, DiagramContext)));
|
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()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -117,18 +119,35 @@ void MasterElement::initLink(QETProject *project) {
|
|||||||
updateLabel(DiagramContext(), elementInformations());
|
updateLabel(DiagramContext(), elementInformations());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief MasterElement::changeElementInfo()
|
||||||
|
* Update label if it contains %c, %l, %f or %F variables
|
||||||
|
*/
|
||||||
|
void MasterElement::changeElementInfo(){
|
||||||
|
QString temp_label = this->elementInformations()["label"].toString();
|
||||||
|
if (temp_label.contains("\%l")||temp_label.contains("\%c")||temp_label.contains("\%f")||temp_label.contains("\%F")) {
|
||||||
|
if (this->diagram()!=NULL)
|
||||||
|
this->updateLabel(this->elementInformations(),this->elementInformations());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief MasterElement::updateLabel
|
* @brief MasterElement::updateLabel
|
||||||
* 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(DiagramContext old_info, DiagramContext new_info) {
|
void MasterElement::updateLabel(DiagramContext old_info, DiagramContext new_info) {
|
||||||
|
QString newstr = new_info["label"].toString();
|
||||||
|
Element *elmt = this;
|
||||||
|
newstr = assignVariables(newstr, elmt);
|
||||||
|
|
||||||
//Label of element
|
//Label of element
|
||||||
if (old_info["label"].toString() != new_info["label"].toString()) {
|
if (old_info["label"].toString() != newstr) {
|
||||||
if (new_info["label"].toString().isEmpty())
|
if (new_info["label"].toString().isEmpty())
|
||||||
setTaggedText("label", "_", false);
|
setTaggedText("label", "_", false);
|
||||||
else
|
else {
|
||||||
setTaggedText("label", new_info["label"].toString(), true);
|
setTaggedText("label", newstr, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ElementTextItem *eti = taggedText("label")) {
|
if (ElementTextItem *eti = taggedText("label")) {
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ class MasterElement : public CustomElement
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateLabel(DiagramContext old_info, DiagramContext new_info);
|
void updateLabel(DiagramContext old_info, DiagramContext new_info);
|
||||||
|
void changeElementInfo();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool aboutDeleteXref ();
|
bool aboutDeleteXref ();
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include "simpleelement.h"
|
#include "simpleelement.h"
|
||||||
#include "commentitem.h"
|
#include "commentitem.h"
|
||||||
#include "elementtextitem.h"
|
#include "elementtextitem.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief SimpleElement::SimpleElement
|
* @brief SimpleElement::SimpleElement
|
||||||
* @param location
|
* @param location
|
||||||
@@ -31,6 +32,8 @@ SimpleElement::SimpleElement(const ElementsLocation &location, QGraphicsItem *qg
|
|||||||
{
|
{
|
||||||
link_type_ = Simple;
|
link_type_ = Simple;
|
||||||
connect(this, SIGNAL(elementInfoChange(DiagramContext, DiagramContext)), this, SLOT(updateLabel(DiagramContext, DiagramContext)));
|
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()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,17 +54,34 @@ void SimpleElement::initLink(QETProject *project) {
|
|||||||
updateLabel(DiagramContext(), elementInformations());
|
updateLabel(DiagramContext(), elementInformations());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief SimpleElement::changeElementInfo()
|
||||||
|
* Update label if it contains %c, %l, %f or %F variables
|
||||||
|
*/
|
||||||
|
void SimpleElement::changeElementInfo(){
|
||||||
|
QString temp_label = this->elementInformations()["label"].toString();
|
||||||
|
if (temp_label.contains("\%l")||temp_label.contains("\%c")||temp_label.contains("\%f")||temp_label.contains("\%F")) {
|
||||||
|
if (this->diagram()!=NULL)
|
||||||
|
this->updateLabel(this->elementInformations(),this->elementInformations());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief SimpleElement::updateLabel
|
* @brief SimpleElement::updateLabel
|
||||||
* update label of this element
|
* update label of this element
|
||||||
*/
|
*/
|
||||||
void SimpleElement::updateLabel(DiagramContext old_info, DiagramContext new_info) {
|
void SimpleElement::updateLabel(DiagramContext old_info, DiagramContext new_info) {
|
||||||
|
QString label = new_info["label"].toString();
|
||||||
|
Element *elmt = this;
|
||||||
|
label = assignVariables(label,elmt);
|
||||||
|
|
||||||
//Label of element
|
//Label of element
|
||||||
if (old_info["label"].toString() != new_info["label"].toString()) {
|
if (old_info["label"].toString() != label) {
|
||||||
if (new_info["label"].toString().isEmpty())
|
if (new_info["label"].toString().isEmpty())
|
||||||
setTaggedText("label", "_", false);
|
setTaggedText("label", "_", false);
|
||||||
else
|
else {
|
||||||
setTaggedText("label", new_info["label"].toString(), true);
|
setTaggedText("label", label, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ElementTextItem *eti = taggedText("label")) {
|
if (ElementTextItem *eti = taggedText("label")) {
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ class SimpleElement : public CustomElement {
|
|||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateLabel(DiagramContext old_info, DiagramContext new_info);
|
void updateLabel(DiagramContext old_info, DiagramContext new_info);
|
||||||
|
void changeElementInfo();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CommentItem *m_comment_item;
|
CommentItem *m_comment_item;
|
||||||
|
|||||||
@@ -134,10 +134,8 @@ void SlaveElement::updateLabel() {
|
|||||||
label = elmt -> elementInformations()["label"].toString();
|
label = elmt -> elementInformations()["label"].toString();
|
||||||
XRefProperties xrp = elmt->diagram()->defaultXRefProperties(elmt->kindInformations()["type"].toString());
|
XRefProperties xrp = elmt->diagram()->defaultXRefProperties(elmt->kindInformations()["type"].toString());
|
||||||
Xreflabel = xrp.slaveLabel();
|
Xreflabel = xrp.slaveLabel();
|
||||||
Xreflabel.replace("%f", QString::number(elmt->diagram()->folioIndex()+1));
|
Xreflabel = assignVariables(Xreflabel, elmt);
|
||||||
Xreflabel.replace("%F", elmt->diagram() -> border_and_titleblock.folio());
|
label = assignVariables(label, elmt);
|
||||||
Xreflabel.replace("%c", QString::number(elmt->diagram() -> convertPosition(elmt -> scenePos()).number()));
|
|
||||||
Xreflabel.replace("%l", elmt->diagram() -> convertPosition(elmt -> scenePos()).letter());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the new label
|
// set the new label
|
||||||
|
|||||||
Reference in New Issue
Block a user