119 |
119 |
120 // ============================================================================= |
120 // ============================================================================= |
121 // |
121 // |
122 static void DoInline (bool deep) |
122 static void DoInline (bool deep) |
123 { |
123 { |
124 LDObjectList sel = Selection(); |
|
125 |
|
126 for (LDObjectIterator<LDSubfile> it (Selection()); it.isValid(); ++it) |
124 for (LDObjectIterator<LDSubfile> it (Selection()); it.isValid(); ++it) |
127 { |
125 { |
128 // Get the index of the subfile so we know where to insert the |
126 // Get the index of the subfile so we know where to insert the |
129 // inlined contents. |
127 // inlined contents. |
130 long idx = it->lineNumber(); |
128 int idx = it->lineNumber(); |
131 |
129 |
132 assert (idx != -1); |
130 if (idx != -1) |
133 LDObjectList objs = it->inlineContents (deep, false); |
131 { |
134 |
132 LDObjectList objs = it->inlineContents (deep, false); |
135 // Merge in the inlined objects |
133 |
136 for (LDObject* inlineobj : objs) |
134 // Merge in the inlined objects |
137 { |
135 for (LDObject* inlineobj : objs) |
138 QString line = inlineobj->asText(); |
136 { |
139 inlineobj->destroy(); |
137 QString line = inlineobj->asText(); |
140 LDObject* newobj = ParseLine (line); |
138 inlineobj->destroy(); |
141 CurrentDocument()->insertObj (idx++, newobj); |
139 LDObject* newobj = ParseLine (line); |
142 newobj->select(); |
140 CurrentDocument()->insertObj (idx++, newobj); |
143 } |
141 newobj->select(); |
144 |
142 } |
145 // Delete the subfile now as it's been inlined. |
143 |
146 it->destroy(); |
144 // Delete the subfile now as it's been inlined. |
|
145 it->destroy(); |
|
146 } |
147 } |
147 } |
148 } |
148 } |
149 |
149 |
150 void MainWindow::slot_actionInline() |
150 void MainWindow::slot_actionInline() |
151 { |
151 { |