106 |
106 |
107 connect (qApp, SIGNAL (aboutToQuit()), this, SLOT (slot_lastSecondCleanup())); |
107 connect (qApp, SIGNAL (aboutToQuit()), this, SLOT (slot_lastSecondCleanup())); |
108 |
108 |
109 // Connect all actions |
109 // Connect all actions |
110 for (QAction* act : findChildren<QAction*>()) |
110 for (QAction* act : findChildren<QAction*>()) |
111 if (!act->objectName().isEmpty()) |
111 if (not act->objectName().isEmpty()) |
112 connect (act, SIGNAL (triggered()), this, SLOT (slot_action())); |
112 connect (act, SIGNAL (triggered()), this, SLOT (slot_action())); |
113 } |
113 } |
114 |
114 |
115 // ============================================================================= |
115 // ============================================================================= |
116 // |
116 // |
307 |
307 |
308 // ============================================================================= |
308 // ============================================================================= |
309 // |
309 // |
310 void MainWindow::buildObjList() |
310 void MainWindow::buildObjList() |
311 { |
311 { |
312 if (!getCurrentDocument()) |
312 if (not getCurrentDocument()) |
313 return; |
313 return; |
314 |
314 |
315 // Lock the selection while we do this so that refreshing the object list |
315 // Lock the selection while we do this so that refreshing the object list |
316 // doesn't trigger selection updating so that the selection doesn't get lost |
316 // doesn't trigger selection updating so that the selection doesn't get lost |
317 // while this is done. |
317 // while this is done. |
521 |
521 |
522 int newColor = col->index; |
522 int newColor = col->index; |
523 |
523 |
524 for (LDObject* obj : selection()) |
524 for (LDObject* obj : selection()) |
525 { |
525 { |
526 if (obj->isColored() == false) |
526 if (not obj->isColored()) |
527 continue; // uncolored object |
527 continue; // uncolored object |
528 |
528 |
529 obj->setColor (newColor); |
529 obj->setColor (newColor); |
530 R()->compileObject (obj); |
530 R()->compileObject (obj); |
531 } |
531 } |
537 // ============================================================================= |
537 // ============================================================================= |
538 // |
538 // |
539 int MainWindow::getInsertionPoint() |
539 int MainWindow::getInsertionPoint() |
540 { |
540 { |
541 // If we have a selection, put the item after it. |
541 // If we have a selection, put the item after it. |
542 if (!selection().isEmpty()) |
542 if (not selection().isEmpty()) |
543 return selection().last()->lineNumber() + 1; |
543 return selection().last()->lineNumber() + 1; |
544 |
544 |
545 // Otherwise place the object at the end. |
545 // Otherwise place the object at the end. |
546 return getCurrentDocument()->getObjectCount(); |
546 return getCurrentDocument()->getObjectCount(); |
547 } |
547 } |
592 { |
592 { |
593 int result = -1; |
593 int result = -1; |
594 |
594 |
595 for (LDObject* obj : selection()) |
595 for (LDObject* obj : selection()) |
596 { |
596 { |
597 if (obj->isColored() == false) |
597 if (not obj->isColored()) |
598 continue; // doesn't use color |
598 continue; // doesn't use color |
599 |
599 |
600 if (result != -1 && obj->color() != result) |
600 if (result != -1 && obj->color() != result) |
601 return -1; // No consensus in object color |
601 return -1; // No consensus in object color |
602 |
602 |
744 |
744 |
745 if (saveAs || path.isEmpty()) |
745 if (saveAs || path.isEmpty()) |
746 { |
746 { |
747 QString name = doc->defaultName(); |
747 QString name = doc->defaultName(); |
748 |
748 |
749 if (!doc->fullPath().isEmpty()) |
749 if (not doc->fullPath().isEmpty()) |
750 name = doc->fullPath(); |
750 name = doc->fullPath(); |
751 elif (!doc->name().isEmpty()) |
751 elif (not doc->name().isEmpty()) |
752 name = doc->name(); |
752 name = doc->name(); |
753 |
753 |
754 name.replace ("\\", "/"); |
754 name.replace ("\\", "/"); |
755 path = QFileDialog::getSaveFileName (g_win, tr ("Save As"), |
755 path = QFileDialog::getSaveFileName (g_win, tr ("Save As"), |
756 name, tr ("LDraw files (*.dat *.ldr)")); |
756 name, tr ("LDraw files (*.dat *.ldr)")); |
866 { |
866 { |
867 std::map<int, int> counts; |
867 std::map<int, int> counts; |
868 |
868 |
869 for (LDObject* obj : getCurrentDocument()->objects()) |
869 for (LDObject* obj : getCurrentDocument()->objects()) |
870 { |
870 { |
871 if (!obj->isColored()) |
871 if (not obj->isColored()) |
872 continue; |
872 continue; |
873 |
873 |
874 if (counts.find (obj->color()) == counts.end()) |
874 if (counts.find (obj->color()) == counts.end()) |
875 counts[obj->color()] = 1; |
875 counts[obj->color()] = 1; |
876 else |
876 else |
904 m_tabs->removeTab (0); |
904 m_tabs->removeTab (0); |
905 |
905 |
906 for (LDDocument* f : g_loadedFiles) |
906 for (LDDocument* f : g_loadedFiles) |
907 { |
907 { |
908 // Don't list implicit files unless explicitly desired. |
908 // Don't list implicit files unless explicitly desired. |
909 if (f->isImplicit() && !gui_implicitfiles) |
909 if (f->isImplicit() && not gui_implicitfiles) |
910 continue; |
910 continue; |
911 |
911 |
912 // Add an item to the list for this file and store the tab index |
912 // Add an item to the list for this file and store the tab index |
913 // in the document so we can find documents by tab index. |
913 // in the document so we can find documents by tab index. |
914 f->setTabIndex (m_tabs->addTab ("")); |
914 f->setTabIndex (m_tabs->addTab ("")); |