96 { |
96 { |
97 for (LDSubfileReference* reference : filterByType<LDSubfileReference> (selectedObjects())) |
97 for (LDSubfileReference* reference : filterByType<LDSubfileReference> (selectedObjects())) |
98 { |
98 { |
99 // Get the index of the subfile so we know where to insert the |
99 // Get the index of the subfile so we know where to insert the |
100 // inlined contents. |
100 // inlined contents. |
101 int idx = reference->lineNumber(); |
101 int position = reference->lineNumber(); |
102 |
102 |
103 if (idx != -1) |
103 if (position != -1) |
104 { |
104 { |
105 Model inlined {m_documents}; |
105 Model inlined {m_documents}; |
106 reference->inlineContents(inlined, deep, false); |
106 reference->inlineContents(inlined, deep, false); |
107 |
107 currentDocument()->merge(inlined, position, nullptr, [&](LDObject* object, int) |
108 // Merge in the inlined objects |
|
109 for (LDObject* inlinedObject : inlined.objects()) |
|
110 { |
108 { |
111 currentDocument()->insertObject (idx++, inlinedObject); |
109 currentDocument()->addToSelection(object); |
112 currentDocument()->addToSelection(inlinedObject); |
110 }); |
113 } |
|
114 |
111 |
115 // Delete the subfile now as it's been inlined. |
112 // Delete the subfile now as it's been inlined. |
116 currentDocument()->remove(reference); |
113 currentDocument()->remove(reference); |
117 } |
114 } |
118 } |
115 } |