src/actionsEdit.cc

changeset 946
9cbd658b63f9
parent 945
c310073e4f22
child 950
5df69eb50182
equal deleted inserted replaced
945:c310073e4f22 946:9cbd658b63f9
304 304
305 int ln = obj->lineNumber(); 305 int ln = obj->lineNumber();
306 306
307 for (int i = 0; i < obj->numVertices(); ++i) 307 for (int i = 0; i < obj->numVertices(); ++i)
308 { 308 {
309 QSharedPointer<LDVertex> vert (LDSpawn<LDVertex>()); 309 LDVertex* vertex = new LDVertex();
310 vert->pos = obj->vertex (i); 310 vertex->pos = obj->vertex (i);
311 vert->setColor (obj->color()); 311 vertex->setColor (obj->color());
312 CurrentDocument()->insertObj (++ln, vert); 312 CurrentDocument()->insertObj (++ln, vertex);
313 ++num; 313 ++num;
314 } 314 }
315 } 315 }
316 316
317 print (tr ("Added %1 vertices"), num); 317 print (tr ("Added %1 vertices"), num);
622 622
623 // ============================================================================= 623 // =============================================================================
624 // 624 //
625 void MainWindow::slot_actionAutocolor() 625 void MainWindow::slot_actionAutocolor()
626 { 626 {
627 int colnum = 0;
628 LDColor color; 627 LDColor color;
629 628
630 for (colnum = 0; 629 for (color = 0; color.isLDConfigColor(); ++color)
631 colnum < CountLDConfigColors() and 630 {
632 ((color = LDColor::fromIndex (colnum)) == null or 631 if (color.isValid() and not IsColorUsed (color))
633 IsColorUsed (color)); 632 break;
634 colnum++) {} 633 }
635 634
636 if (colnum >= CountLDConfigColors()) 635 if (not color.isLDConfigColor())
637 { 636 {
638 print (tr ("Cannot auto-color: all colors are in use!")); 637 print (tr ("Cannot auto-color: all colors are in use!"));
639 return; 638 return;
640 } 639 }
641 640
645 continue; 644 continue;
646 645
647 obj->setColor (color); 646 obj->setColor (color);
648 } 647 }
649 648
650 print (tr ("Auto-colored: new color is [%1] %2"), colnum, color.name()); 649 print (tr ("Auto-colored: new color is [%1] %2"), color.index(), color.name());
651 refresh(); 650 refresh();
652 } 651 }
653 652
654 // ============================================================================= 653 // =============================================================================
655 // 654 //
690 689
691 prevIsHistory = ishistory; 690 prevIsHistory = ishistory;
692 } 691 }
693 692
694 int idx = obj ? obj->lineNumber() : 0; 693 int idx = obj ? obj->lineNumber() : 0;
695 CurrentDocument()->insertObj (idx++, comm); 694 CurrentDocument()->insertObj (idx++, comment);
696 695
697 // If we're adding a history line right before a scemantic object, pad it 696 // If we're adding a history line right before a scemantic object, pad it
698 // an empty line 697 // an empty line
699 if (obj and obj->next() and obj->next()->isScemantic()) 698 if (obj and obj->next() and obj->next()->isScemantic())
700 CurrentDocument()->insertObj (idx, new LDEmpty); 699 CurrentDocument()->insertObj (idx, new LDEmpty);

mercurial