87 const LDBFC::Statement 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() ? g_CALicense : |
93 ui.rb_license_nonca->isChecked() ? NonCALicense : ""; |
93 ui.rb_license_nonca->isChecked() ? g_nonCALicense : ""; |
94 |
94 |
95 getCurrentDocument()->addObjects ( |
95 getCurrentDocument()->addObjects ( |
96 { |
96 { |
97 new LDComment (ui.le_title->text()), |
97 new LDComment (ui.le_title->text()), |
98 new LDComment ("Name: <untitled>.dat"), |
98 new LDComment ("Name: <untitled>.dat"), |
325 // be uniform. |
325 // be uniform. |
326 QString refName; |
326 QString refName; |
327 |
327 |
328 if (type == LDObject::ESubfile) |
328 if (type == LDObject::ESubfile) |
329 { |
329 { |
330 refName = static_cast<LDSubfile*> (selection()[0])->getFileInfo()->getName(); |
330 refName = static_cast<LDSubfile*> (selection()[0])->fileInfo()->name(); |
331 |
331 |
332 for (LDObject* obj : selection()) |
332 for (LDObject* obj : selection()) |
333 if (static_cast<LDSubfile*> (obj)->getFileInfo()->getName() != refName) |
333 if (static_cast<LDSubfile*> (obj)->fileInfo()->name() != refName) |
334 return; |
334 return; |
335 } |
335 } |
336 |
336 |
337 getCurrentDocument()->clearSelection(); |
337 getCurrentDocument()->clearSelection(); |
338 |
338 |
339 for (LDObject* obj : getCurrentDocument()->getObjects()) |
339 for (LDObject* obj : getCurrentDocument()->objects()) |
340 { |
340 { |
341 if (obj->type() != type) |
341 if (obj->type() != type) |
342 continue; |
342 continue; |
343 |
343 |
344 if (type == LDObject::ESubfile && static_cast<LDSubfile*> (obj)->getFileInfo()->getName() != refName) |
344 if (type == LDObject::ESubfile && static_cast<LDSubfile*> (obj)->fileInfo()->name() != refName) |
345 continue; |
345 continue; |
346 |
346 |
347 obj->select(); |
347 obj->select(); |
348 } |
348 } |
349 |
349 |
487 |
487 |
488 int w, h; |
488 int w, h; |
489 uchar* imgdata = R()->getScreencap (w, h); |
489 uchar* imgdata = R()->getScreencap (w, h); |
490 QImage img = imageFromScreencap (imgdata, w, h); |
490 QImage img = imageFromScreencap (imgdata, w, h); |
491 |
491 |
492 QString root = basename (getCurrentDocument()->getName()); |
492 QString root = basename (getCurrentDocument()->name()); |
493 |
493 |
494 if (root.right (4) == ".dat") |
494 if (root.right (4) == ".dat") |
495 root.chop (4); |
495 root.chop (4); |
496 |
496 |
497 QString defaultname = (root.length() > 0) ? fmt ("%1.png", root) : ""; |
497 QString defaultname = (root.length() > 0) ? fmt ("%1.png", root) : ""; |
517 // ============================================================================= |
517 // ============================================================================= |
518 // |
518 // |
519 DEFINE_ACTION (VisibilityToggle, 0) |
519 DEFINE_ACTION (VisibilityToggle, 0) |
520 { |
520 { |
521 for (LDObject* obj : selection()) |
521 for (LDObject* obj : selection()) |
522 obj->toggleHidden(); |
522 obj->setHidden (!obj->isHidden()); |
523 |
523 |
524 refresh(); |
524 refresh(); |
525 } |
525 } |
526 |
526 |
527 // ============================================================================= |
527 // ============================================================================= |
708 DEFINE_ACTION (SubfileSelection, 0) |
708 DEFINE_ACTION (SubfileSelection, 0) |
709 { |
709 { |
710 if (selection().size() == 0) |
710 if (selection().size() == 0) |
711 return; |
711 return; |
712 |
712 |
713 QString parentpath = getCurrentDocument()->getFullPath(); |
713 QString parentpath = getCurrentDocument()->fullPath(); |
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::Statement bfctype = LDBFC::NoCertify; |
716 LDBFC::Statement bfctype = LDBFC::NoCertify; |
717 |
717 |
718 // Dirname of the new subfile |
718 // Dirname of the new subfile |
736 // Where to insert the subfile reference? |
736 // Where to insert the subfile reference? |
737 int refidx = selection()[0]->lineNumber(); |
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 |
743 subtitle = "~subfile"; |
743 subtitle = "~subfile"; |
744 |
744 |
745 // Remove duplicate tildes |
745 // Remove duplicate tildes |
746 while (subtitle[0] == '~' && subtitle[1] == '~') |
746 while (subtitle[0] == '~' && subtitle[1] == '~') |
747 subtitle.remove (0, 1); |
747 subtitle.remove (0, 1); |
748 |
748 |
749 // If this the parent document isn't already in s/, we need to stuff it into |
749 // If this the parent document isn't already in s/, we need to stuff it into |
750 // a subdirectory named s/. Ensure it exists! |
750 // a subdirectory named s/. Ensure it exists! |
751 QString topdirname = basename (dirname (getCurrentDocument()->getFullPath())); |
751 QString topdirname = basename (dirname (getCurrentDocument()->fullPath())); |
752 |
752 |
753 if (topdirname != "s") |
753 if (topdirname != "s") |
754 { |
754 { |
755 QString desiredPath = subdirname + "/s"; |
755 QString desiredPath = subdirname + "/s"; |
756 QString title = tr ("Create subfile directory?"); |
756 QString title = tr ("Create subfile directory?"); |
793 } while (findDocument ("s\\" + basename (fullsubname)) != null || QFile (fullsubname).exists()); |
793 } while (findDocument ("s\\" + basename (fullsubname)) != null || QFile (fullsubname).exists()); |
794 } |
794 } |
795 |
795 |
796 // Determine the BFC winding type used in the main document - it is to |
796 // Determine the BFC winding type used in the main document - it is to |
797 // be carried over to the subfile. |
797 // be carried over to the subfile. |
798 for (LDObject* obj : getCurrentDocument()->getObjects()) |
798 for (LDObject* obj : getCurrentDocument()->objects()) |
799 { |
799 { |
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::Statement a = bfc->m_statement; |
805 LDBFC::Statement a = bfc->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; |
845 // Remove the selection now |
845 // Remove the selection now |
846 for (LDObject* obj : selection()) |
846 for (LDObject* obj : selection()) |
847 obj->destroy(); |
847 obj->destroy(); |
848 |
848 |
849 // Compile all objects in the new subfile |
849 // Compile all objects in the new subfile |
850 for (LDObject* obj : doc->getObjects()) |
850 for (LDObject* obj : doc->objects()) |
851 R()->compileObject (obj); |
851 R()->compileObject (obj); |
852 |
852 |
853 g_loadedFiles << doc; |
853 g_loadedFiles << doc; |
854 |
854 |
855 // Add a reference to the new subfile to where the selection was |
855 // Add a reference to the new subfile to where the selection was |