[qet] [2180] add condition to enable the richtext menu entry

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


Revision: 2180
Author:   blacksun
Date:     2013-05-28 18:50:35 +0200 (Tue, 28 May 2013)
Log Message:
-----------
add condition to enable the richtext menu entry

Modified Paths:
--------------
    trunk/sources/diagram.cpp
    trunk/sources/diagram.h
    trunk/sources/qetdiagrameditor.cpp

Modified: trunk/sources/diagram.cpp
===================================================================
--- trunk/sources/diagram.cpp	2013-05-25 15:57:03 UTC (rev 2179)
+++ trunk/sources/diagram.cpp	2013-05-28 16:50:35 UTC (rev 2180)
@@ -1066,6 +1066,20 @@
 	return(selected_texts);
 }
 
+/**
+ * @brief Diagram::selectedConductorTexts
+ * @return the list of conductor texts selected
+ */
+QSet<ConductorTextItem *> Diagram::selectedConductorTexts() const {
+	QSet<ConductorTextItem *> selected_texts;
+	foreach(QGraphicsItem *item, selectedItems()) {
+		if (ConductorTextItem *cti = qgraphicsitem_cast<ConductorTextItem *>(item)) {
+			selected_texts << cti;
+		}
+	}
+	return(selected_texts);
+}
+
 /// @return true si le presse-papier semble contenir un schema
 bool Diagram::clipboardMayContainDiagram() {
 	QString clipboard_text = QApplication::clipboard() -> text().trimmed();

Modified: trunk/sources/diagram.h
===================================================================
--- trunk/sources/diagram.h	2013-05-25 15:57:03 UTC (rev 2179)
+++ trunk/sources/diagram.h	2013-05-28 16:50:35 UTC (rev 2180)
@@ -39,6 +39,7 @@
 class IndependentTextItem;
 class QETProject;
 class Terminal;
+class ConductorTextItem;
 /**
 	This class represents an electric diagram. It manages its various child
 	elements, conductors and texts and handles their graphic rendering.
@@ -162,6 +163,7 @@
 	
 	QList<CustomElement *> customElements() const;
 	QSet<DiagramTextItem *> selectedTexts() const;
+	QSet<ConductorTextItem *> selectedConductorTexts() const;
 	QSet<Conductor *> selectedConductors() const;
 	DiagramContent content() const;
 	DiagramContent selectedContent();

Modified: trunk/sources/qetdiagrameditor.cpp
===================================================================
--- trunk/sources/qetdiagrameditor.cpp	2013-05-25 15:57:03 UTC (rev 2179)
+++ trunk/sources/qetdiagrameditor.cpp	2013-05-28 16:50:35 UTC (rev 2180)
@@ -1201,9 +1201,10 @@
 	prj_diagramNum   -> setEnabled(editable_diagram);
 	
 	// actions ayant besoin de textes selectionnes
-	bool selected_texts = dv ? (dv -> diagram() -> selectedTexts().count()) : 0;
+	int selected_texts = dv ? (dv -> diagram() -> selectedTexts().count()) : 0;
+	int selected_conductor_texts = dv ? (dv -> diagram() -> selectedConductorTexts().count()) : 0;
 	rotate_texts -> setEnabled(editable_diagram && selected_texts);
-	add_edittext -> setEnabled(editable_diagram && selected_texts);
+	add_edittext -> setEnabled(editable_diagram && selected_texts == 1 && !selected_conductor_texts);
 }
 
 


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