src/mainWindow.cc

changeset 840
d077dd19bf9a
parent 834
3e697ba996e8
child 841
1243abd47381
equal deleted inserted replaced
839:5f822ad61875 840:d077dd19bf9a
251 if (getCurrentDocument()) 251 if (getCurrentDocument())
252 { 252 {
253 title += ": "; 253 title += ": ";
254 title += getCurrentDocument()->getDisplayName(); 254 title += getCurrentDocument()->getDisplayName();
255 255
256 if (getCurrentDocument()->getObjectCount() > 0 && 256 if (getCurrentDocument()->getObjectCount() > 0 and
257 getCurrentDocument()->getObject (0)->type() == OBJ_Comment) 257 getCurrentDocument()->getObject (0)->type() == OBJ_Comment)
258 { 258 {
259 // Append title 259 // Append title
260 LDCommentPtr comm = getCurrentDocument()->getObject (0).staticCast<LDComment>(); 260 LDCommentPtr comm = getCurrentDocument()->getObject (0).staticCast<LDComment>();
261 title += format (": %1", comm->text()); 261 title += format (": %1", comm->text());
408 if (obj->type() == OBJ_Error) 408 if (obj->type() == OBJ_Error)
409 { 409 {
410 item->setBackground (QColor ("#AA0000")); 410 item->setBackground (QColor ("#AA0000"));
411 item->setForeground (QColor ("#FFAA00")); 411 item->setForeground (QColor ("#FFAA00"));
412 } 412 }
413 elif (cfg::colorizeObjectsList && obj->isColored() && 413 elif (cfg::colorizeObjectsList and obj->isColored() and
414 obj->color() != null && obj->color() != maincolor() && obj->color() != edgecolor()) 414 obj->color() != null and obj->color() != maincolor() and obj->color() != edgecolor())
415 { 415 {
416 // If the object isn't in the main or edge color, draw this 416 // If the object isn't in the main or edge color, draw this
417 // list entry in said color. 417 // list entry in said color.
418 item->setForeground (obj->color().faceColor()); 418 item->setForeground (obj->color().faceColor());
419 } 419 }
440 440
441 // ============================================================================= 441 // =============================================================================
442 // 442 //
443 void MainWindow::slot_selectionChanged() 443 void MainWindow::slot_selectionChanged()
444 { 444 {
445 if (g_isSelectionLocked == true || getCurrentDocument() == null) 445 if (g_isSelectionLocked == true or getCurrentDocument() == null)
446 return; 446 return;
447 447
448 LDObjectList priorSelection = selection(); 448 LDObjectList priorSelection = selection();
449 449
450 // Get the objects from the object list selection 450 // Get the objects from the object list selection
573 for (LDObjectPtr obj : selection()) 573 for (LDObjectPtr obj : selection())
574 { 574 {
575 if (not obj->isColored()) 575 if (not obj->isColored())
576 continue; // doesn't use color 576 continue; // doesn't use color
577 577
578 if (result != null && obj->color() != result) 578 if (result != null and obj->color() != result)
579 return null; // No consensus in object color 579 return null; // No consensus in object color
580 580
581 if (result == null) 581 if (result == null)
582 result = obj->color(); 582 result = obj->color();
583 } 583 }
621 } 621 }
622 } 622 }
623 623
624 QMenu* contextMenu = new QMenu; 624 QMenu* contextMenu = new QMenu;
625 625
626 if (single && singleObj->type() != OBJ_Empty) 626 if (single and singleObj->type() != OBJ_Empty)
627 { 627 {
628 contextMenu->addAction (ui->actionEdit); 628 contextMenu->addAction (ui->actionEdit);
629 contextMenu->addSeparator(); 629 contextMenu->addSeparator();
630 } 630 }
631 631
675 { 675 {
676 LDObjectList objs; 676 LDObjectList objs;
677 677
678 for (LDObjectPtr obj : getCurrentDocument()->objects()) 678 for (LDObjectPtr obj : getCurrentDocument()->objects())
679 { 679 {
680 if (not obj->isColored() || obj->color() != color) 680 if (not obj->isColored() or obj->color() != color)
681 continue; 681 continue;
682 682
683 objs << obj; 683 objs << obj;
684 } 684 }
685 685
717 bool MainWindow::save (LDDocumentPtr doc, bool saveAs) 717 bool MainWindow::save (LDDocumentPtr doc, bool saveAs)
718 { 718 {
719 QString path = doc->fullPath(); 719 QString path = doc->fullPath();
720 int64 savesize; 720 int64 savesize;
721 721
722 if (saveAs || path.isEmpty()) 722 if (saveAs or path.isEmpty())
723 { 723 {
724 QString name = doc->defaultName(); 724 QString name = doc->defaultName();
725 725
726 if (not doc->fullPath().isEmpty()) 726 if (not doc->fullPath().isEmpty())
727 name = doc->fullPath(); 727 name = doc->fullPath();
843 { 843 {
844 std::map<LDColor, int> counts; 844 std::map<LDColor, int> counts;
845 845
846 for (LDObjectPtr obj : getCurrentDocument()->objects()) 846 for (LDObjectPtr obj : getCurrentDocument()->objects())
847 { 847 {
848 if (not obj->isColored() || obj->color() == null) 848 if (not obj->isColored() or obj->color() == null)
849 continue; 849 continue;
850 850
851 if (counts.find (obj->color()) == counts.end()) 851 if (counts.find (obj->color()) == counts.end())
852 counts[obj->color()] = 1; 852 counts[obj->color()] = 1;
853 else 853 else
939 } 939 }
940 } 940 }
941 941
942 // If we picked the same file we're currently on, we don't need to do 942 // If we picked the same file we're currently on, we don't need to do
943 // anything. 943 // anything.
944 if (f == null || f == getCurrentDocument()) 944 if (f == null or f == getCurrentDocument())
945 return; 945 return;
946 946
947 LDDocument::setCurrent (f); 947 LDDocument::setCurrent (f);
948 } 948 }
949 949
965 965
966 // ============================================================================= 966 // =============================================================================
967 // 967 //
968 void MainWindow::updateActions() 968 void MainWindow::updateActions()
969 { 969 {
970 if (getCurrentDocument() != null && getCurrentDocument()->history() != null) 970 if (getCurrentDocument() != null and getCurrentDocument()->history() != null)
971 { 971 {
972 History* his = getCurrentDocument()->history(); 972 History* his = getCurrentDocument()->history();
973 int pos = his->position(); 973 int pos = his->position();
974 ui->actionUndo->setEnabled (pos != -1); 974 ui->actionUndo->setEnabled (pos != -1);
975 ui->actionRedo->setEnabled (pos < (long) his->getSize() - 1); 975 ui->actionRedo->setEnabled (pos < (long) his->getSize() - 1);

mercurial