227 } |
227 } |
228 } |
228 } |
229 |
229 |
230 QByteArray data; |
230 QByteArray data; |
231 |
231 |
232 if (sizeptr) |
|
233 *sizeptr = 0; |
|
234 |
|
235 // File is open, now save the model to it. Note that LDraw requires files to have DOS line endings. |
232 // File is open, now save the model to it. Note that LDraw requires files to have DOS line endings. |
236 for (LDObject* obj : objects()) |
233 for (LDObject* obj : objects()) |
237 { |
234 { |
238 QByteArray subdata ((obj->asText() + "\r\n").toUtf8()); |
235 if (obj->isInverted()) |
239 data.append (subdata); |
236 data += "0 BFC INVERTNEXT\r\n"; |
240 |
237 |
241 if (sizeptr) |
238 data += (obj->asText() + "\r\n").toUtf8(); |
242 *sizeptr += countof(subdata); |
|
243 } |
239 } |
244 |
240 |
245 QFile f (path); |
241 QFile f (path); |
246 |
242 |
247 if (not f.open (QIODevice::WriteOnly)) |
243 if (not f.open (QIODevice::WriteOnly)) |
248 return false; |
244 return false; |
|
245 |
|
246 if (sizeptr) |
|
247 *sizeptr = data.size(); |
249 |
248 |
250 f.write (data); |
249 f.write (data); |
251 f.close(); |
250 f.close(); |
252 |
251 |
253 // We have successfully saved, update the save position now. |
252 // We have successfully saved, update the save position now. |
442 { |
441 { |
443 if (not m_selection.contains(obj) and obj->model() == this) |
442 if (not m_selection.contains(obj) and obj->model() == this) |
444 { |
443 { |
445 m_selection.insert(obj); |
444 m_selection.insert(obj); |
446 emit objectModified(obj); |
445 emit objectModified(obj); |
447 |
|
448 // If this object is inverted with INVERTNEXT, select the INVERTNEXT as well. |
|
449 LDBfc* invertnext; |
|
450 |
|
451 if (obj->previousIsInvertnext(invertnext)) |
|
452 addToSelection(invertnext); |
|
453 } |
446 } |
454 } |
447 } |
455 |
448 |
456 // ============================================================================= |
449 // ============================================================================= |
457 // |
450 // |
459 { |
452 { |
460 if (m_selection.contains(obj)) |
453 if (m_selection.contains(obj)) |
461 { |
454 { |
462 m_selection.remove(obj); |
455 m_selection.remove(obj); |
463 emit objectModified(obj); |
456 emit objectModified(obj); |
464 |
|
465 // If this object is inverted with INVERTNEXT, deselect the INVERTNEXT as well. |
|
466 LDBfc* invertnext; |
|
467 |
|
468 if (obj->previousIsInvertnext(invertnext)) |
|
469 removeFromSelection(invertnext); |
|
470 } |
457 } |
471 } |
458 } |
472 |
459 |
473 // ============================================================================= |
460 // ============================================================================= |
474 // |
461 // |