443 |
443 |
444 // ============================================================================= |
444 // ============================================================================= |
445 // |
445 // |
446 String LDObject::describeObjects (const LDObjectList& objs) |
446 String LDObject::describeObjects (const LDObjectList& objs) |
447 { |
447 { |
448 bool firstDetails = true; |
448 String text; |
449 String text = ""; |
|
450 |
449 |
451 if (objs.isEmpty()) |
450 if (objs.isEmpty()) |
452 return "nothing"; // :) |
451 return "nothing"; // :) |
453 |
452 |
454 for (long i = 0; i < ENumTypes; ++i) |
453 for (Type objType = EFirstType; objType < ENumTypes; ++objType) |
455 { |
454 { |
456 Type objType = (Type) i; |
|
457 int count = 0; |
455 int count = 0; |
458 |
456 |
459 for (LDObject * obj : objs) |
457 for (LDObject * obj : objs) |
460 if (obj->type() == objType) |
458 if (obj->type() == objType) |
461 count++; |
459 count++; |
462 |
460 |
463 if (count == 0) |
461 if (count == 0) |
464 continue; |
462 continue; |
465 |
463 |
466 if (not firstDetails) |
464 if (not text.isEmpty()) |
467 text += ", "; |
465 text += ", "; |
468 |
466 |
469 String noun = format ("%1%2", typeName (objType), plural (count)); |
467 String noun = format ("%1%2", typeName (objType), plural (count)); |
470 |
468 |
471 // Plural of "vertex" is "vertices", correct that |
469 // Plural of "vertex" is "vertices", correct that |
472 if (objType == EVertex && count != 1) |
470 if (objType == EVertex && count != 1) |
473 noun = "vertices"; |
471 noun = "vertices"; |
474 |
472 |
475 text += format ("%1 %2", count, noun); |
473 text += format ("%1 %2", count, noun); |
476 firstDetails = false; |
|
477 } |
474 } |
478 |
475 |
479 return text; |
476 return text; |
480 } |
477 } |
481 |
478 |