diff --git a/elements/06renvoi/01previous_folio.elmt b/elements/06renvoi/01previous_folio.elmt index edb65110e..a5c678cdb 100644 --- a/elements/06renvoi/01previous_folio.elmt +++ b/elements/06renvoi/01previous_folio.elmt @@ -1,5 +1,4 @@ - + الصفحة السابقة Vorherige Seite @@ -9,15 +8,15 @@ link_type="previous_report"> Folio précédent Wejście adresowe folio anterior - Předchozí list Referentie Vorig + Předchozí list Author: The QElectroTech team License: see http://qelectrotech.org/wiki/doc/elements_license - - + + diff --git a/elements/06renvoi/02next_folio.elmt b/elements/06renvoi/02next_folio.elmt index 6164a2e2d..b22c40cfd 100644 --- a/elements/06renvoi/02next_folio.elmt +++ b/elements/06renvoi/02next_folio.elmt @@ -1,5 +1,4 @@ - + الصفحة التالية Nächste Seite @@ -9,15 +8,15 @@ link_type="next_report"> Folio suivant Wyjście adresowe Folio siguiente - Další list Referentie volgend + Další list Author: The QElectroTech team License: see http://qelectrotech.org/wiki/doc/elements_license - - + + diff --git a/sources/editor/qetelementeditor.cpp b/sources/editor/qetelementeditor.cpp index d29aebecf..24eab7d31 100644 --- a/sources/editor/qetelementeditor.cpp +++ b/sources/editor/qetelementeditor.cpp @@ -637,7 +637,8 @@ bool QETElementEditor::checkElement() { /// Check master, slave and simple element if(ce_scene -> elementType() == "master" || ce_scene -> elementType() == "slave" || - ce_scene -> elementType() == "simple" ) { + ce_scene -> elementType() == "simple" || + ce_scene -> elementType().contains("report")) { bool wrng = true; foreach (CustomElementPart *cep, ce_scene->primitives()) { @@ -647,7 +648,7 @@ bool QETElementEditor::checkElement() { if (wrng) { errors << qMakePair( tr("Absence de champ texte 'label'", "warning title"), - tr("Les \351l\351ments ma\356tres, esclaves et simple doivent poss\351der " + tr("Les \351l\351ments ma\356tres, esclaves, simple et renvoie de folio doivent poss\351der " "un champ texte comportant le tagg 'label'", "warning description")); } } diff --git a/sources/qetgraphicsitem/elementtextitem.cpp b/sources/qetgraphicsitem/elementtextitem.cpp index 4f754f9c3..6b821b60d 100644 --- a/sources/qetgraphicsitem/elementtextitem.cpp +++ b/sources/qetgraphicsitem/elementtextitem.cpp @@ -179,7 +179,21 @@ void ElementTextItem::adjustItemPosition(int new_block_count) { */ void ElementTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) { - if ( (tagg_ == "label" || parent_element_ -> linkType() & Element::AllReport) && !parent_element_ -> isFree()) + /* + * Before revision 3559, report element haven't got text tagged label + * so if parent is a report and haven't got text tagged label, + * we know if this text is used has tagged label. + */ + bool report_text = false; + if (parent_element_ -> linkType() & Element::AllReport && !parent_element_ -> taggedText("label")) + { + //This is the first of list, so this text is used to display + //pos of linked report. + if (parent_element_ -> texts().first() == this) + report_text = true; + } + + if ( (tagg_ == "label" || report_text) && !parent_element_ -> isFree()) { //If parent is linked, show the linked element if ( parent_element_ -> linkType() & (Element::AllReport | Element::Slave) ) @@ -289,10 +303,24 @@ void ElementTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { * @brief ElementTextItem::hoverEnterEvent * @param event */ -void ElementTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { - - if (tagg_ == "label" || parent_element_ -> linkType() & Element::AllReport) { +void ElementTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) +{ + /* + * Before revision 3559, report element haven't got text tagged label + * so if parent is a report and haven't got text tagged label, + * we know if this text is used has tagged label. + */ + bool report_text = false; + if (parent_element_ -> linkType() & Element::AllReport && !parent_element_ -> taggedText("label")) + { + //This is the first of list, so this text is used to display + //pos of linked report. + if (parent_element_ -> texts().first() == this) + report_text = true; + } + if (tagg_ == "label" || report_text) + { if (parent_element_ -> linkType() & (Element::AllReport | Element::Slave) && !parent_element_->isFree()) { setDefaultTextColor(Qt::blue); @@ -312,10 +340,24 @@ void ElementTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { * @brief ElementTextItem::hoverLeaveEvent * @param event */ -void ElementTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { - - if (tagg_ == "label" || parent_element_ -> linkType() & Element::AllReport) { +void ElementTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) +{ + /* + * Before revision 3559, report element haven't got text tagged label + * so if parent is a report and haven't got text tagged label, + * we know if this text is used has tagged label. + */ + bool report_text = false; + if (parent_element_ -> linkType() & Element::AllReport && !parent_element_ -> taggedText("label")) + { + //This is the first of list, so this text is used to display + //pos of linked report. + if (parent_element_ -> texts().first() == this) + report_text = true; + } + if (tagg_ == "label" || report_text) + { if (defaultTextColor() != Qt::black) setDefaultTextColor(Qt::black); diff --git a/sources/qetgraphicsitem/reportelement.cpp b/sources/qetgraphicsitem/reportelement.cpp index d1b612434..334219821 100644 --- a/sources/qetgraphicsitem/reportelement.cpp +++ b/sources/qetgraphicsitem/reportelement.cpp @@ -22,10 +22,21 @@ #include "diagram.h" ReportElement::ReportElement(const ElementsLocation &location, QString link_type,QGraphicsItem *qgi, int *state) : - CustomElement(location, qgi, state) -{ - if (!texts().isEmpty()) - texts().first()->setNoEditable(); + CustomElement(location, qgi, state), + m_text_field (nullptr) +{ + /* + * Get text tagged label. This is work for report + * create after the revision 3559. + * for report create before, we take the first text field + * because report haven't got a text field tagged label + */ + m_text_field = taggedText("label"); + if (!m_text_field && !texts().isEmpty()) + m_text_field = texts().first(); + if (m_text_field) + m_text_field -> setNoEditable(); + link_type == "next_report"? link_type_=NextReport : link_type_=PreviousReport; link_type == "next_report"? inverse_report=PreviousReport : inverse_report=NextReport; } @@ -121,18 +132,21 @@ void ReportElement::setLabel(QString label) { * Update the displayed label. * ie the folio and position of the linked folio report */ -void ReportElement::updateLabel() { - if (texts().isEmpty()) return; - ElementTextItem *text = texts().first(); +void ReportElement::updateLabel() +{ + if (!m_text_field) return; - if (!connected_elements.isEmpty()){ + if (!connected_elements.isEmpty()) + { Element *elmt = connected_elements.at(0); QString label = label_; label.replace("%f", QString::number(elmt->diagram()->folioIndex()+1)); label.replace("%c", QString::number(elmt->diagram() -> convertPosition(elmt -> scenePos()).number())); label.replace("%l", elmt->diagram() -> convertPosition(elmt -> scenePos()).letter()); - text->setPlainText(label); - } else { - text->setPlainText("/"); + m_text_field -> setPlainText(label); + } + else + { + m_text_field -> setPlainText("/"); } } diff --git a/sources/qetgraphicsitem/reportelement.h b/sources/qetgraphicsitem/reportelement.h index b9505acf6..1af2a24d4 100644 --- a/sources/qetgraphicsitem/reportelement.h +++ b/sources/qetgraphicsitem/reportelement.h @@ -20,6 +20,8 @@ #include "customelement.h" +class ElementTextItem; + /** * @brief The ReportElement class *this class represent an element that can be linked to an other ReportElement @@ -37,8 +39,9 @@ class ReportElement : public CustomElement { virtual void unlinkElement(Element *elmt); private: - int inverse_report; - QString label_; + int inverse_report; + QString label_; + ElementTextItem *m_text_field; signals: