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
|
||||
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 <iostream>
|
||||
#include "terminal.h"
|
||||
#include "diagramposition.h"
|
||||
|
||||
/**
|
||||
Constructeur de la classe CustomElement. Permet d'instancier un element
|
||||
@@ -986,3 +987,11 @@ ElementTextItem* CustomElement::taggedText(const QString &tagg) const {
|
||||
}
|
||||
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 void setPainterStyle(QDomElement &, QPainter &);
|
||||
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;
|
||||
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());
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
* update label of this element
|
||||
* and the comment item if he's displayed.
|
||||
*/
|
||||
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
|
||||
if (old_info["label"].toString() != new_info["label"].toString()) {
|
||||
if (old_info["label"].toString() != newstr) {
|
||||
if (new_info["label"].toString().isEmpty())
|
||||
setTaggedText("label", "_", false);
|
||||
else
|
||||
setTaggedText("label", new_info["label"].toString(), true);
|
||||
else {
|
||||
setTaggedText("label", newstr, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (ElementTextItem *eti = taggedText("label")) {
|
||||
|
||||
@@ -45,6 +45,7 @@ class MasterElement : public CustomElement
|
||||
|
||||
public slots:
|
||||
void updateLabel(DiagramContext old_info, DiagramContext new_info);
|
||||
void changeElementInfo();
|
||||
|
||||
private:
|
||||
bool aboutDeleteXref ();
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "simpleelement.h"
|
||||
#include "commentitem.h"
|
||||
#include "elementtextitem.h"
|
||||
|
||||
/**
|
||||
* @brief SimpleElement::SimpleElement
|
||||
* @param location
|
||||
@@ -31,6 +32,8 @@ SimpleElement::SimpleElement(const ElementsLocation &location, QGraphicsItem *qg
|
||||
{
|
||||
link_type_ = Simple;
|
||||
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());
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
* update label of this element
|
||||
*/
|
||||
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
|
||||
if (old_info["label"].toString() != new_info["label"].toString()) {
|
||||
if (old_info["label"].toString() != label) {
|
||||
if (new_info["label"].toString().isEmpty())
|
||||
setTaggedText("label", "_", false);
|
||||
else
|
||||
setTaggedText("label", new_info["label"].toString(), true);
|
||||
else {
|
||||
setTaggedText("label", label, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (ElementTextItem *eti = taggedText("label")) {
|
||||
|
||||
@@ -41,6 +41,7 @@ class SimpleElement : public CustomElement {
|
||||
|
||||
public slots:
|
||||
void updateLabel(DiagramContext old_info, DiagramContext new_info);
|
||||
void changeElementInfo();
|
||||
|
||||
private:
|
||||
CommentItem *m_comment_item;
|
||||
|
||||
@@ -134,10 +134,8 @@ void SlaveElement::updateLabel() {
|
||||
label = elmt -> elementInformations()["label"].toString();
|
||||
XRefProperties xrp = elmt->diagram()->defaultXRefProperties(elmt->kindInformations()["type"].toString());
|
||||
Xreflabel = xrp.slaveLabel();
|
||||
Xreflabel.replace("%f", QString::number(elmt->diagram()->folioIndex()+1));
|
||||
Xreflabel.replace("%F", elmt->diagram() -> border_and_titleblock.folio());
|
||||
Xreflabel.replace("%c", QString::number(elmt->diagram() -> convertPosition(elmt -> scenePos()).number()));
|
||||
Xreflabel.replace("%l", elmt->diagram() -> convertPosition(elmt -> scenePos()).letter());
|
||||
Xreflabel = assignVariables(Xreflabel, elmt);
|
||||
label = assignVariables(label, elmt);
|
||||
}
|
||||
|
||||
// set the new label
|
||||
|
||||
Reference in New Issue
Block a user