mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 13:30:34 +01:00
Conductor now support variables. (%F, %id, %total, %f and titleblock and project variables). Minor: labels that use %F update when folio field is changed
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4586 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -138,7 +138,10 @@ class BorderTitleBlock : public QObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// @param author the new value of the "Folio" field
|
/// @param author the new value of the "Folio" field
|
||||||
void setFolio(const QString &folio) { btb_folio_ = folio; }
|
void setFolio(const QString &folio) {
|
||||||
|
btb_folio_ = folio;
|
||||||
|
emit (titleBlockFolioChanged());
|
||||||
|
}
|
||||||
void setFolioData(int, int, QString = NULL, const DiagramContext & = DiagramContext());
|
void setFolioData(int, int, QString = NULL, const DiagramContext & = DiagramContext());
|
||||||
/// @param author the new value of the "File" field
|
/// @param author the new value of the "File" field
|
||||||
void setFileName(const QString &filename) { btb_filename_ = filename; }
|
void setFileName(const QString &filename) { btb_filename_ = filename; }
|
||||||
@@ -192,6 +195,12 @@ class BorderTitleBlock : public QObject
|
|||||||
*/
|
*/
|
||||||
void diagramTitleChanged(const QString &);
|
void diagramTitleChanged(const QString &);
|
||||||
|
|
||||||
|
/**
|
||||||
|
@brief titleBlockFolioChanged
|
||||||
|
Signal emitted after Folio has changed
|
||||||
|
*/
|
||||||
|
void titleBlockFolioChanged();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Signal emitted when the title block requires its data to be updated in order
|
Signal emitted when the title block requires its data to be updated in order
|
||||||
to generate the folio field.
|
to generate the folio field.
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ Diagram::Diagram(QETProject *project) :
|
|||||||
connect(&border_and_titleblock, SIGNAL(needTitleBlockTemplate(const QString &)), this, SLOT(setTitleBlockTemplate(const QString &)));
|
connect(&border_and_titleblock, SIGNAL(needTitleBlockTemplate(const QString &)), this, SLOT(setTitleBlockTemplate(const QString &)));
|
||||||
connect(&border_and_titleblock, SIGNAL(diagramTitleChanged(const QString &)), this, SLOT(titleChanged(const QString &)));
|
connect(&border_and_titleblock, SIGNAL(diagramTitleChanged(const QString &)), this, SLOT(titleChanged(const QString &)));
|
||||||
connect(&border_and_titleblock, SIGNAL(borderChanged(QRectF,QRectF)), this, SLOT(adjustSceneRect()));
|
connect(&border_and_titleblock, SIGNAL(borderChanged(QRectF,QRectF)), this, SLOT(adjustSceneRect()));
|
||||||
|
connect(&border_and_titleblock, SIGNAL(titleBlockFolioChanged()), this, SLOT(updateLabels()));
|
||||||
adjustSceneRect();
|
adjustSceneRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1056,6 +1057,22 @@ void Diagram::invertSelection() {
|
|||||||
emit(selectionChanged());
|
emit(selectionChanged());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Diagram::updateLabels
|
||||||
|
* Update elements and conductors that reference folio field
|
||||||
|
* in their labels.
|
||||||
|
*/
|
||||||
|
void Diagram::updateLabels() {
|
||||||
|
foreach (Element *elmt, elements()) {
|
||||||
|
if (elmt->elementInformations()["label"].toString().contains(("%F")))
|
||||||
|
elmt->updateLabel();
|
||||||
|
}
|
||||||
|
foreach (Conductor *cnd, content().conductors()) {
|
||||||
|
if (cnd->properties().text.contains("%F"))
|
||||||
|
cnd->setText(cnd->properties().text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@return le titre du cartouche
|
@return le titre du cartouche
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -215,6 +215,7 @@ class Diagram : public QGraphicsScene
|
|||||||
void titleBlockTemplateChanged(const QString &);
|
void titleBlockTemplateChanged(const QString &);
|
||||||
void titleBlockTemplateRemoved(const QString &, const QString & = QString());
|
void titleBlockTemplateRemoved(const QString &, const QString & = QString());
|
||||||
void setTitleBlockTemplate(const QString &);
|
void setTitleBlockTemplate(const QString &);
|
||||||
|
void updateLabels();
|
||||||
|
|
||||||
// methods related to graphics items selection
|
// methods related to graphics items selection
|
||||||
void selectAll();
|
void selectAll();
|
||||||
|
|||||||
@@ -1191,16 +1191,58 @@ ConductorProfile Conductor::profile(Qt::Corner path_type) const {
|
|||||||
|
|
||||||
/// @return le texte du conducteur
|
/// @return le texte du conducteur
|
||||||
QString Conductor::text() const {
|
QString Conductor::text() const {
|
||||||
return(text_item -> toPlainText());
|
QString label = text_item->toPlainText();
|
||||||
|
return(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Conductor::assignVariables
|
||||||
|
* Apply variables to conductor label
|
||||||
|
* @param label to be processed
|
||||||
|
* @return label with variables assigned
|
||||||
|
*/
|
||||||
|
QString Conductor::assignVariables(QString label) {
|
||||||
|
//Titleblock Variables
|
||||||
|
for (int i = 0; i < diagram()->border_and_titleblock.additionalFields().count(); i++)
|
||||||
|
{
|
||||||
|
QString folio_variable = diagram()->border_and_titleblock.additionalFields().keys().at(i);
|
||||||
|
QVariant folio_value = diagram()->border_and_titleblock.additionalFields().operator [](folio_variable);
|
||||||
|
|
||||||
|
if (label.contains(folio_variable)) {
|
||||||
|
label.replace("%{" + folio_variable + "}", folio_value.toString());
|
||||||
|
label.replace("%" + folio_variable , folio_value.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Project Variables
|
||||||
|
for (int i = 0; i < diagram()->project()->projectProperties().count(); i++)
|
||||||
|
{
|
||||||
|
QString folio_variable = diagram()->project()->projectProperties().keys().at(i);
|
||||||
|
QVariant folio_value = diagram()->project()->projectProperties().operator [](folio_variable);
|
||||||
|
|
||||||
|
if (label.contains(folio_variable)) {
|
||||||
|
label.replace("%{" + folio_variable + "}", folio_value.toString());
|
||||||
|
label.replace("%" + folio_variable , folio_value.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Default Variables
|
||||||
|
label.replace("%f", QString::number(diagram()->folioIndex()+1));
|
||||||
|
label.replace("%F", diagram() -> border_and_titleblock.folio());
|
||||||
|
label.replace("%id", QString::number(diagram()->folioIndex()+1));
|
||||||
|
label.replace("%total", QString::number(diagram()->border_and_titleblock.folioTotal()));
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Conductor::setText
|
* @brief Conductor::setText
|
||||||
* The text of this conductor
|
* The text of this conductor
|
||||||
* @param t
|
* @param t
|
||||||
*/
|
*/
|
||||||
void Conductor::setText(const QString &t) {
|
void Conductor::setText(const QString &t) {
|
||||||
text_item -> setPlainText(t);
|
QString label = assignVariables(t);
|
||||||
|
text_item -> setPlainText(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1269,7 +1311,7 @@ void Conductor::setHighlighted(Conductor::Highlight hl) {
|
|||||||
*/
|
*/
|
||||||
void Conductor::displayedTextChanged()
|
void Conductor::displayedTextChanged()
|
||||||
{
|
{
|
||||||
if ((text_item->toPlainText() == properties_.text) || !diagram()) return;
|
if ((text_item->toPlainText() == assignVariables(properties_.text)) || !diagram()) return;
|
||||||
|
|
||||||
QVariant old_value, new_value;
|
QVariant old_value, new_value;
|
||||||
old_value.setValue(properties_);
|
old_value.setValue(properties_);
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ class Conductor : public QObject, public QGraphicsPathItem
|
|||||||
ConductorSegment *middleSegment();
|
ConductorSegment *middleSegment();
|
||||||
QPointF posForText(Qt::Orientations &flag);
|
QPointF posForText(Qt::Orientations &flag);
|
||||||
QString text() const;
|
QString text() const;
|
||||||
|
QString assignVariables(QString) ;
|
||||||
void setText(const QString &);
|
void setText(const QString &);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user