88 if (dlg->exec() == QDialog::Rejected) |
88 if (dlg->exec() == QDialog::Rejected) |
89 return; |
89 return; |
90 |
90 |
91 newFile(); |
91 newFile(); |
92 |
92 |
93 const LDBFC::Statement bfctype = |
93 BFCStatement const bfctype = ui.rb_bfc_ccw->isChecked() ? BFCStatement::CertifyCCW |
94 ui.rb_bfc_ccw->isChecked() ? LDBFC::CertifyCCW : |
94 : ui.rb_bfc_cw->isChecked() ? BFCStatement::CertifyCW |
95 ui.rb_bfc_cw->isChecked() ? LDBFC::CertifyCW : LDBFC::NoCertify; |
95 : BFCStatement::NoCertify; |
96 |
96 |
97 const QString license = |
97 QString const license = |
98 ui.rb_license_ca->isChecked() ? g_CALicense : |
98 ui.rb_license_ca->isChecked() ? g_CALicense : |
99 ui.rb_license_nonca->isChecked() ? g_nonCALicense : ""; |
99 ui.rb_license_nonca->isChecked() ? g_nonCALicense : ""; |
100 |
100 |
101 LDObjectList objs; |
101 LDObjectList objs; |
102 objs << spawn<LDComment> (ui.le_title->text()); |
102 objs << spawn<LDComment> (ui.le_title->text()); |
108 objs << spawn<LDComment> (license); |
108 objs << spawn<LDComment> (license); |
109 |
109 |
110 objs << spawn<LDEmpty>(); |
110 objs << spawn<LDEmpty>(); |
111 objs << spawn<LDBFC> (bfctype); |
111 objs << spawn<LDBFC> (bfctype); |
112 objs << spawn<LDEmpty>(); |
112 objs << spawn<LDEmpty>(); |
113 |
|
114 getCurrentDocument()->addObjects (objs); |
113 getCurrentDocument()->addObjects (objs); |
115 |
|
116 doFullRefresh(); |
114 doFullRefresh(); |
117 } |
115 } |
118 |
116 |
119 // ============================================================================= |
117 // ============================================================================= |
120 // |
118 // |
739 void MainWindow::slot_actionSubfileSelection() |
737 void MainWindow::slot_actionSubfileSelection() |
740 { |
738 { |
741 if (selection().size() == 0) |
739 if (selection().size() == 0) |
742 return; |
740 return; |
743 |
741 |
744 QString parentpath = getCurrentDocument()->fullPath(); |
742 QString parentpath (getCurrentDocument()->fullPath()); |
745 |
743 |
746 // BFC type of the new subfile - it shall inherit the BFC type of the parent document |
744 // BFC type of the new subfile - it shall inherit the BFC type of the parent document |
747 LDBFC::Statement bfctype = LDBFC::NoCertify; |
745 BFCStatement bfctype (BFCStatement::NoCertify); |
748 |
746 |
749 // Dirname of the new subfile |
747 // Dirname of the new subfile |
750 QString subdirname = dirname (parentpath); |
748 QString subdirname (dirname (parentpath)); |
751 |
749 |
752 // Title of the new subfile |
750 // Title of the new subfile |
753 QString subtitle; |
751 QString subtitle; |
754 |
752 |
755 // Comment containing the title of the parent document |
753 // Comment containing the title of the parent document |
756 LDCommentPtr titleobj = getCurrentDocument()->getObject (0).dynamicCast<LDComment>(); |
754 LDCommentPtr titleobj (getCurrentDocument()->getObject (0).dynamicCast<LDComment>()); |
757 |
755 |
758 // License text for the subfile |
756 // License text for the subfile |
759 QString license = getLicenseText (cfg::defaultLicense); |
757 QString license (getLicenseText (cfg::defaultLicense)); |
760 |
758 |
761 // LDraw code body of the new subfile (i.e. code of the selection) |
759 // LDraw code body of the new subfile (i.e. code of the selection) |
762 QStringList code; |
760 QStringList code; |
763 |
761 |
764 // Full path of the subfile to be |
762 // Full path of the subfile to be |
765 QString fullsubname; |
763 QString fullsubname; |
766 |
764 |
767 // Where to insert the subfile reference? |
765 // Where to insert the subfile reference? |
768 int refidx = selection()[0]->lineNumber(); |
766 int refidx (selection()[0]->lineNumber()); |
769 |
767 |
770 // Determine title of subfile |
768 // Determine title of subfile |
771 if (titleobj != null) |
769 if (titleobj != null) |
772 subtitle = "~" + titleobj->text(); |
770 subtitle = "~" + titleobj->text(); |
773 else |
771 else |
834 for (LDObjectPtr obj : getCurrentDocument()->objects()) |
832 for (LDObjectPtr obj : getCurrentDocument()->objects()) |
835 { |
833 { |
836 if (obj->type() != OBJ_BFC) |
834 if (obj->type() != OBJ_BFC) |
837 continue; |
835 continue; |
838 |
836 |
839 LDBFC::Statement a = obj.staticCast<LDBFC>()->statement(); |
837 BFCStatement a = obj.staticCast<LDBFC>()->statement(); |
840 |
838 |
841 if (a == LDBFC::CertifyCCW or a == LDBFC::CertifyCW or a == LDBFC::NoCertify) |
839 if (eq (a, BFCStatement::CertifyCCW, BFCStatement::CertifyCW, BFCStatement::NoCertify)) |
842 { |
840 { |
843 bfctype = a; |
841 bfctype = a; |
844 break; |
842 break; |
845 } |
843 } |
846 } |
844 } |