diff --git a/sources/diagramcontent.cpp b/sources/diagramcontent.cpp index 699c1361d..bf99ecf6f 100644 --- a/sources/diagramcontent.cpp +++ b/sources/diagramcontent.cpp @@ -100,24 +100,18 @@ QList DiagramContent::items(int filter) const { */ 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(); diff --git a/sources/diagramcontent.h b/sources/diagramcontent.h index 701d3ad09..489780bea 100644 --- a/sources/diagramcontent.h +++ b/sources/diagramcontent.h @@ -41,13 +41,13 @@ class DiagramContent { 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 diff --git a/sources/qetdiagrameditor.cpp b/sources/qetdiagrameditor.cpp index ac65bbefc..1d08580e2 100644 --- a/sources/qetdiagrameditor.cpp +++ b/sources/qetdiagrameditor.cpp @@ -1533,7 +1533,7 @@ void QETDiagramEditor::slot_addImage() { 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();