[qet] [2558] bug fix, diagramContent: fix the bug about & and ==

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


Revision: 2558
Author:   blacksun
Date:     2013-09-26 11:27:55 +0200 (Thu, 26 Sep 2013)
Log Message:
-----------
bug fix, diagramContent: fix the bug about & and ==

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

Modified: trunk/sources/diagramcontent.cpp
===================================================================
--- trunk/sources/diagramcontent.cpp	2013-09-26 05:54:26 UTC (rev 2557)
+++ trunk/sources/diagramcontent.cpp	2013-09-26 09:27:55 UTC (rev 2558)
@@ -100,24 +100,18 @@
 */
 int DiagramContent::count(int filter) const {
 	int count = 0;
-	if (filter == SelectedOnly) {
-		if (filter == Elements)           foreach(Element *element,     elements)                  { if (element   -> isSelected()) ++ count; }
-		if (filter == TextFields)         foreach(DiagramTextItem *dti, textFields)                { if (dti       -> isSelected()) ++ count; }
-		if (filter == Images)             foreach(DiagramImageItem *dii, images)                   { if (dii       -> isSelected()) ++ count; }
-		if (filter == ConductorsToMove)   foreach(Conductor *conductor, conductorsToMove)          { if (conductor -> isSelected()) ++ count; }
-		if (filter == ConductorsToUpdate) foreach(Conductor *conductor, conductorsToUpdate)        { if (conductor -> isSelected()) ++ count; }
-		if (filter == OtherConductors)    foreach(Conductor *conductor, otherConductors)           { if (conductor -> isSelected()) ++ count; }
-	} else if (filter == All) {
-		count += elements.count();
-		count += textFields.count();
-		count += images.count();
-		count += conductorsToMove.count();
-		count += conductorsToUpdate.count();
-		count += otherConductors.count();
-	} else {
+	if (filter & SelectedOnly) {
+		if (filter & Elements)           foreach(Element *element,     elements)                  { if (element   -> isSelected()) ++ count; }
+		if (filter & TextFields)         foreach(DiagramTextItem *dti, textFields)                { if (dti       -> isSelected()) ++ count; }
+		if (filter & Images)             foreach(DiagramImageItem *dii, images)                   { if (dii       -> isSelected()) ++ count; }
+		if (filter & ConductorsToMove)   foreach(Conductor *conductor, conductorsToMove)          { if (conductor -> isSelected()) ++ count; }
+		if (filter & ConductorsToUpdate) foreach(Conductor *conductor, conductorsToUpdate)        { if (conductor -> isSelected()) ++ count; }
+		if (filter & OtherConductors)    foreach(Conductor *conductor, otherConductors)           { if (conductor -> isSelected()) ++ count; }
+	}
+	else {
 		if (filter & Elements)           count += elements.count();
 		if (filter & TextFields)         count += textFields.count();
-		if (filter == Images)            count += images.count();
+		if (filter & Images)             count += images.count();
 		if (filter & ConductorsToMove)   count += conductorsToMove.count();
 		if (filter & ConductorsToUpdate) count += conductorsToUpdate.count();
 		if (filter & OtherConductors)    count += otherConductors.count();

Modified: trunk/sources/diagramcontent.h
===================================================================
--- trunk/sources/diagramcontent.h	2013-09-26 05:54:26 UTC (rev 2557)
+++ trunk/sources/diagramcontent.h	2013-09-26 09:27:55 UTC (rev 2558)
@@ -41,13 +41,13 @@
 	enum Filter {
 		Elements = 1,
 		TextFields = 2,
-		Images = 3,
-		ConductorsToMove = 4,
-		ConductorsToUpdate = 8,
-		OtherConductors = 16,
-		AnyConductor = 28,
-		All = 31,
-		SelectedOnly = 32
+		Images = 4,
+		ConductorsToMove = 8,
+		ConductorsToUpdate = 16,
+		OtherConductors = 32,
+		AnyConductor = 56,
+		All = 63,
+		SelectedOnly = 64
 	};
 	
 	/// Hold electrical elements

Modified: trunk/sources/qetdiagrameditor.cpp
===================================================================
--- trunk/sources/qetdiagrameditor.cpp	2013-09-26 05:54:26 UTC (rev 2557)
+++ trunk/sources/qetdiagrameditor.cpp	2013-09-26 09:27:55 UTC (rev 2558)
@@ -1533,7 +1533,7 @@
 void QETDiagramEditor::slot_editSelection() {
 	if (DiagramView *dv = currentDiagram()) {
 		DiagramContent dc = dv -> diagram() -> selectedContent();
-		if (dc.count() != 1) return;
+		if (dc.count(DiagramContent::SelectedOnly | DiagramContent::All) != 1) return;
 
 		if (dc.count(DiagramContent::Elements)) {
 			findSelectedElementInPanel();


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