82 if (dlg->exec() == false) |
82 if (dlg->exec() == false) |
83 return; |
83 return; |
84 |
84 |
85 newFile(); |
85 newFile(); |
86 |
86 |
87 const LDBFC::Type BFCType = |
87 const LDBFC::Statement BFCType = |
88 ui.rb_bfc_ccw->isChecked() ? LDBFC::CertifyCCW : |
88 ui.rb_bfc_ccw->isChecked() ? LDBFC::CertifyCCW : |
89 ui.rb_bfc_cw->isChecked() ? LDBFC::CertifyCW : LDBFC::NoCertify; |
89 ui.rb_bfc_cw->isChecked() ? LDBFC::CertifyCW : LDBFC::NoCertify; |
90 |
90 |
91 const QString license = |
91 const QString license = |
92 ui.rb_license_ca->isChecked() ? CALicense : |
92 ui.rb_license_ca->isChecked() ? CALicense : |
256 { |
256 { |
257 if (selection().size() != 1) |
257 if (selection().size() != 1) |
258 return; |
258 return; |
259 |
259 |
260 LDObject* obj = selection() [0]; |
260 LDObject* obj = selection() [0]; |
261 AddObjectDialog::staticDialog (obj->getType(), obj); |
261 AddObjectDialog::staticDialog (obj->type(), obj); |
262 } |
262 } |
263 |
263 |
264 // ============================================================================= |
264 // ============================================================================= |
265 // ----------------------------------------------------------------------------- |
265 // ----------------------------------------------------------------------------- |
266 DEFINE_ACTION (Help, KEY (F1)) |
266 DEFINE_ACTION (Help, KEY (F1)) |
433 return; |
433 return; |
434 } |
434 } |
435 |
435 |
436 for (LDObject* obj : selection()) |
436 for (LDObject* obj : selection()) |
437 { |
437 { |
438 QString contents = obj->raw(); |
438 QString contents = obj->asText(); |
439 QByteArray data = contents.toUtf8(); |
439 QByteArray data = contents.toUtf8(); |
440 file.write (data, data.size()); |
440 file.write (data, data.size()); |
441 file.write ("\r\n", 2); |
441 file.write ("\r\n", 2); |
442 } |
442 } |
443 } |
443 } |
688 bool ok; |
688 bool ok; |
689 int defval = 0; |
689 int defval = 0; |
690 LDObject* obj; |
690 LDObject* obj; |
691 |
691 |
692 if (selection().size() == 1) |
692 if (selection().size() == 1) |
693 defval = selection()[0]->getIndex(); |
693 defval = selection()[0]->lineNumber(); |
694 |
694 |
695 int idx = QInputDialog::getInt (null, "Go to line", "Go to line:", defval, |
695 int idx = QInputDialog::getInt (null, "Go to line", "Go to line:", defval, |
696 1, getCurrentDocument()->getObjectCount(), 1, &ok); |
696 1, getCurrentDocument()->getObjectCount(), 1, &ok); |
697 |
697 |
698 if (!ok || (obj = getCurrentDocument()->getObject (idx - 1)) == null) |
698 if (!ok || (obj = getCurrentDocument()->getObject (idx - 1)) == null) |
711 return; |
711 return; |
712 |
712 |
713 QString parentpath = getCurrentDocument()->getFullPath(); |
713 QString parentpath = getCurrentDocument()->getFullPath(); |
714 |
714 |
715 // BFC type of the new subfile - it shall inherit the BFC type of the parent document |
715 // BFC type of the new subfile - it shall inherit the BFC type of the parent document |
716 LDBFC::Type bfctype = LDBFC::NoCertify; |
716 LDBFC::Statement bfctype = LDBFC::NoCertify; |
717 |
717 |
718 // Dirname of the new subfile |
718 // Dirname of the new subfile |
719 QString subdirname = dirname (parentpath); |
719 QString subdirname = dirname (parentpath); |
720 |
720 |
721 // Title of the new subfile |
721 // Title of the new subfile |
732 |
732 |
733 // Full path of the subfile to be |
733 // Full path of the subfile to be |
734 QString fullsubname; |
734 QString fullsubname; |
735 |
735 |
736 // Where to insert the subfile reference? |
736 // Where to insert the subfile reference? |
737 int refidx = selection()[0]->getIndex(); |
737 int refidx = selection()[0]->lineNumber(); |
738 |
738 |
739 // Determine title of subfile |
739 // Determine title of subfile |
740 if (titleobj != null) |
740 if (titleobj != null) |
741 subtitle = "~" + titleobj->text; |
741 subtitle = "~" + titleobj->text; |
742 else |
742 else |
800 LDBFC* bfc = dynamic_cast<LDBFC*> (obj); |
800 LDBFC* bfc = dynamic_cast<LDBFC*> (obj); |
801 |
801 |
802 if (!bfc) |
802 if (!bfc) |
803 continue; |
803 continue; |
804 |
804 |
805 LDBFC::Type a = bfc->type; |
805 LDBFC::Statement a = bfc->m_statement; |
806 |
806 |
807 if (a == LDBFC::CertifyCCW || a == LDBFC::CertifyCW || a == LDBFC::NoCertify) |
807 if (a == LDBFC::CertifyCCW || a == LDBFC::CertifyCW || a == LDBFC::NoCertify) |
808 { |
808 { |
809 bfctype = a; |
809 bfctype = a; |
810 break; |
810 break; |
811 } |
811 } |
812 } |
812 } |
813 |
813 |
814 // Get the body of the document in LDraw code |
814 // Get the body of the document in LDraw code |
815 for (LDObject* obj : selection()) |
815 for (LDObject* obj : selection()) |
816 code << obj->raw(); |
816 code << obj->asText(); |
817 |
817 |
818 // Create the new subfile document |
818 // Create the new subfile document |
819 LDDocument* doc = new LDDocument; |
819 LDDocument* doc = new LDDocument; |
820 doc->setImplicit (false); |
820 doc->setImplicit (false); |
821 doc->setFullPath (fullsubname); |
821 doc->setFullPath (fullsubname); |