41 void ViewToolset::selectByColor() |
41 void ViewToolset::selectByColor() |
42 { |
42 { |
43 if (selectedObjects().isEmpty()) |
43 if (selectedObjects().isEmpty()) |
44 return; |
44 return; |
45 |
45 |
46 QList<LDColor> colors; |
46 QSet<LDColor> colors; |
47 |
47 |
48 for (LDObject* obj : selectedObjects()) |
48 for (LDObject* obj : selectedObjects()) |
49 { |
49 { |
50 if (obj->isColored()) |
50 if (obj->isColored()) |
51 colors << obj->color(); |
51 colors << obj->color(); |
52 } |
52 } |
53 |
53 |
54 removeDuplicates (colors); |
|
55 currentDocument()->clearSelection(); |
54 currentDocument()->clearSelection(); |
56 |
55 |
57 for (LDObject* obj : currentDocument()->objects()) |
56 for (LDObject* obj : currentDocument()->objects()) |
58 { |
57 { |
59 if (colors.contains (obj->color())) |
58 if (colors.contains (obj->color())) |
64 void ViewToolset::selectByType() |
63 void ViewToolset::selectByType() |
65 { |
64 { |
66 if (selectedObjects().isEmpty()) |
65 if (selectedObjects().isEmpty()) |
67 return; |
66 return; |
68 |
67 |
69 QList<LDObjectType> types; |
68 QSet<LDObjectType> types; |
70 QStringList subfilenames; |
69 QSet<QString> subfilenames; |
71 |
70 |
72 for (LDObject* obj : selectedObjects()) |
71 for (LDObject* obj : selectedObjects()) |
73 { |
72 { |
74 types << obj->type(); |
73 types << obj->type(); |
75 |
74 |
76 if (types.last() == OBJ_SubfileReference) |
75 if (obj->type() == OBJ_SubfileReference) |
77 subfilenames << static_cast<LDSubfileReference*> (obj)->fileInfo()->name(); |
76 subfilenames << static_cast<LDSubfileReference*> (obj)->fileInfo()->name(); |
78 } |
77 } |
79 |
78 |
80 removeDuplicates (types); |
|
81 removeDuplicates (subfilenames); |
|
82 currentDocument()->clearSelection(); |
79 currentDocument()->clearSelection(); |
83 |
80 |
84 for (LDObject* obj : currentDocument()->objects()) |
81 for (LDObject* obj : currentDocument()->objects()) |
85 { |
82 { |
86 LDObjectType type = obj->type(); |
83 LDObjectType type = obj->type(); |