src/toolsets/algorithmtoolset.cpp

changeset 1288
d1e45f90654b
parent 1269
ec691d9472b3
child 1293
52732b1db3f0
equal deleted inserted replaced
1287:f1da43b7f5c6 1288:d1e45f90654b
33 #include "../linetypes/conditionaledge.h" 33 #include "../linetypes/conditionaledge.h"
34 #include "../linetypes/edgeline.h" 34 #include "../linetypes/edgeline.h"
35 #include "../linetypes/empty.h" 35 #include "../linetypes/empty.h"
36 #include "../linetypes/quadrilateral.h" 36 #include "../linetypes/quadrilateral.h"
37 #include "../linetypes/triangle.h" 37 #include "../linetypes/triangle.h"
38 #include "../parser.h"
38 #include "ui_replacecoordinatesdialog.h" 39 #include "ui_replacecoordinatesdialog.h"
39 #include "ui_editrawdialog.h" 40 #include "ui_editrawdialog.h"
40 #include "ui_flipdialog.h" 41 #include "ui_flipdialog.h"
41 #include "ui_addhistorylinedialog.h" 42 #include "ui_addhistorylinedialog.h"
42 #include "algorithmtoolset.h" 43 #include "algorithmtoolset.h"
83 print ("%1 quadrilaterals split", count); 84 print ("%1 quadrilaterals split", count);
84 } 85 }
85 86
86 void AlgorithmToolset::editRaw() 87 void AlgorithmToolset::editRaw()
87 { 88 {
88 if (countof(selectedObjects()) != 1) 89 if (countof(m_window->selectedIndexes()) != 1)
89 return; 90 return;
90 91
91 LDObject* object = *(selectedObjects().begin()); 92 QModelIndex index = *(m_window->selectedIndexes().begin());
93 LDObject* object = currentDocument()->lookup(index);
92 QDialog dialog; 94 QDialog dialog;
93 Ui::EditRawUI ui; 95 Ui::EditRawUI ui;
94 ui.setupUi(&dialog); 96 ui.setupUi(&dialog);
95 ui.code->setText (object->asText()); 97 ui.code->setText (object->asText());
96 98
105 } 107 }
106 108
107 if (dialog.exec() == QDialog::Accepted) 109 if (dialog.exec() == QDialog::Accepted)
108 { 110 {
109 // Reinterpret it from the text of the input field 111 // Reinterpret it from the text of the input field
110 currentDocument()->replaceWithFromString(object, ui.code->text()); 112 int row = index.row();
113 currentDocument()->removeAt(row);
114 Parser::parseFromString(*currentDocument(), row, ui.code->text());
111 } 115 }
112 } 116 }
113 117
114 void AlgorithmToolset::makeBorders() 118 void AlgorithmToolset::makeBorders()
115 { 119 {
541 header.emplace<LDEmpty>(); 545 header.emplace<LDEmpty>();
542 subfile->merge(header); 546 subfile->merge(header);
543 547
544 // Copy the body over to the new document 548 // Copy the body over to the new document
545 for (LDObject* object : selectedObjects()) 549 for (LDObject* object : selectedObjects())
546 subfile->addFromString(object->asText()); 550 Parser::parseFromString(*subfile, Parser::EndOfModel, object->asText());
547 551
548 // Try save it 552 // Try save it
549 if (m_window->save(subfile, true)) 553 if (m_window->save(subfile, true))
550 { 554 {
551 // Where to insert the subfile reference? 555 // Where to insert the subfile reference?

mercurial