[qet] [3560] Report element : minor improvement about text ( text used to display the position of linked report is now tagged "label")

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 3560
Author:   blacksun
Date:     2014-12-18 11:51:08 +0100 (Thu, 18 Dec 2014)
Log Message:
-----------
Report element : minor improvement about text (text used to display the position of linked report is now tagged "label")

Modified Paths:
--------------
    trunk/elements/06renvoi/01previous_folio.elmt
    trunk/elements/06renvoi/02next_folio.elmt
    trunk/sources/editor/qetelementeditor.cpp
    trunk/sources/qetgraphicsitem/elementtextitem.cpp
    trunk/sources/qetgraphicsitem/reportelement.cpp
    trunk/sources/qetgraphicsitem/reportelement.h

Modified: trunk/elements/06renvoi/01previous_folio.elmt
===================================================================
--- trunk/elements/06renvoi/01previous_folio.elmt	2014-12-17 18:07:39 UTC (rev 3559)
+++ trunk/elements/06renvoi/01previous_folio.elmt	2014-12-18 10:51:08 UTC (rev 3560)
@@ -1,5 +1,4 @@
-<definition width="70" version="0.3" hotspot_x="49" hotspot_y="15" height="30" type="element" ic="true" orientation="dyyy"
-link_type="previous_report">
+<definition width="20" version="0.4" hotspot_x="3" hotspot_y="10" height="20" link_type="previous_report" type="element" ic="true" orientation="dyyy">
     <names>
         <name lang="ar">الصفحة السابقة</name>
         <name lang="de">Vorherige Seite</name>
@@ -9,15 +8,15 @@
         <name lang="fr">Folio précédent</name>
         <name lang="pl">Wejście adresowe</name>
         <name lang="es">folio anterior</name>
-        <name lang="cs">Předchozí list</name>
         <name lang="nl">Referentie Vorig</name>
+        <name lang="cs">Předchozí list</name>
     </names>
     <informations>Author: The QElectroTech team
 License: see http://qelectrotech.org/wiki/doc/elements_license</informations>
     <description>
         <polygon x4="-1" antialias="true" style="line-style:normal;line-weight:normal;filling:black;color:black" closed="false" y1="-4" x1="-1" y2="4" x2="-1" y3="0" x3="9" y4="-4"/>
         <line length1="1.5" length2="1.5" antialias="false" end1="none" end2="none" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="9" y2="0" x2="12"/>
-        <input x="-44" y="0" size="9" rotate="true" text="/"/>
-        <terminal x="13" y="0" nameHidden="0" number="" name="" orientation="e"/>
+        <input x="-44" y="0" size="9" rotate="true" text="/" tagg="label"/>
+        <terminal x="13" y="0" orientation="e"/>
     </description>
 </definition>

Modified: trunk/elements/06renvoi/02next_folio.elmt
===================================================================
--- trunk/elements/06renvoi/02next_folio.elmt	2014-12-17 18:07:39 UTC (rev 3559)
+++ trunk/elements/06renvoi/02next_folio.elmt	2014-12-18 10:51:08 UTC (rev 3560)
@@ -1,5 +1,4 @@
-<definition width="40" version="0.3" hotspot_x="18" hotspot_y="15" height="30" type="element" ic="true" orientation="dyyy"
-link_type="next_report">
+<definition width="30" version="0.4" hotspot_x="21" hotspot_y="10" height="20" link_type="next_report" type="element" ic="true" orientation="dyyy">
     <names>
         <name lang="ar">الصفحة التالية</name>
         <name lang="de">Nächste Seite</name>
@@ -9,15 +8,15 @@
         <name lang="fr">Folio suivant</name>
         <name lang="pl">Wyjście adresowe</name>
         <name lang="es">Folio siguiente</name>
-        <name lang="cs">Další list</name>
         <name lang="nl">Referentie volgend</name>
+        <name lang="cs">Další list</name>
     </names>
     <informations>Author: The QElectroTech team
 License: see http://qelectrotech.org/wiki/doc/elements_license</informations>
     <description>
         <polygon x4="-9" antialias="true" style="line-style:normal;line-weight:normal;filling:black;color:black" closed="false" y1="-4" x1="-9" y2="4" x2="-9" y3="0" x3="2" y4="-4"/>
         <line length1="1.5" length2="1.5" antialias="false" end1="none" end2="none" style="line-style:normal;line-weight:normal;filling:none;color:black" y1="0" x1="-9" y2="0" x2="-12"/>
-        <input x="6" y="0" size="9" rotate="true" text="/"/>
-        <terminal x="-13" y="0" nameHidden="0" number="" name="" orientation="w"/>
+        <input x="6" y="0" size="9" rotate="true" text="/" tagg="label"/>
+        <terminal x="-13" y="0" orientation="w"/>
     </description>
 </definition>

Modified: trunk/sources/editor/qetelementeditor.cpp
===================================================================
--- trunk/sources/editor/qetelementeditor.cpp	2014-12-17 18:07:39 UTC (rev 3559)
+++ trunk/sources/editor/qetelementeditor.cpp	2014-12-18 10:51:08 UTC (rev 3560)
@@ -637,7 +637,8 @@
 	/// 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 @@
 		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"));
 		}
 	}

Modified: trunk/sources/qetgraphicsitem/elementtextitem.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/elementtextitem.cpp	2014-12-17 18:07:39 UTC (rev 3559)
+++ trunk/sources/qetgraphicsitem/elementtextitem.cpp	2014-12-18 10:51:08 UTC (rev 3560)
@@ -179,8 +179,22 @@
  */
 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 @@
  * @brief ElementTextItem::hoverEnterEvent
  * @param event
  */
-void ElementTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) {
+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" || parent_element_ -> linkType() & Element::AllReport) {
-
+	if (tagg_ == "label" || report_text)
+	{
 		if (parent_element_ -> linkType() & (Element::AllReport | Element::Slave) && !parent_element_->isFree()) {
 
 			setDefaultTextColor(Qt::blue);
@@ -312,10 +340,24 @@
  * @brief ElementTextItem::hoverLeaveEvent
  * @param event
  */
-void ElementTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) {
+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" || parent_element_ -> linkType() & Element::AllReport) {
-
+	if (tagg_ == "label" || report_text)
+	{
 		if (defaultTextColor() != Qt::black)
 			setDefaultTextColor(Qt::black);
 

Modified: trunk/sources/qetgraphicsitem/reportelement.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/reportelement.cpp	2014-12-17 18:07:39 UTC (rev 3559)
+++ trunk/sources/qetgraphicsitem/reportelement.cpp	2014-12-18 10:51:08 UTC (rev 3560)
@@ -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 @@
  * 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("/");
+	}
 }

Modified: trunk/sources/qetgraphicsitem/reportelement.h
===================================================================
--- trunk/sources/qetgraphicsitem/reportelement.h	2014-12-17 18:07:39 UTC (rev 3559)
+++ trunk/sources/qetgraphicsitem/reportelement.h	2014-12-18 10:51:08 UTC (rev 3560)
@@ -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 @@
 	virtual void unlinkElement(Element *elmt);
 
 	private:
-	int inverse_report;
-	QString label_;
+	int              inverse_report;
+	QString          label_;
+	ElementTextItem *m_text_field;
 
 	signals:
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/