19 #include <QAbstractButton> |
19 #include <QAbstractButton> |
20 #include <qboxlayout.h> |
20 #include <qboxlayout.h> |
21 #include "zz_setContentsDialog.h" |
21 #include "zz_setContentsDialog.h" |
22 #include "file.h" |
22 #include "file.h" |
23 #include "gui.h" |
23 #include "gui.h" |
|
24 #include "history.h" |
24 |
25 |
25 // ============================================================================= |
26 // ============================================================================= |
26 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
27 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
27 // ============================================================================= |
28 // ============================================================================= |
28 SetContentsDialog::SetContentsDialog (LDObject* obj, QWidget* parent) : QDialog(parent) { |
29 SetContentsDialog::SetContentsDialog (LDObject* obj, QWidget* parent) : QDialog(parent) { |
79 } |
80 } |
80 |
81 |
81 // ============================================================================= |
82 // ============================================================================= |
82 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
83 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
83 // ============================================================================= |
84 // ============================================================================= |
84 void SetContentsDialog::staticDialog (LDObject* obj, ForgeWindow* parent) { |
85 void SetContentsDialog::staticDialog (LDObject* obj) { |
85 if (!obj) |
86 if (!obj) |
86 return; |
87 return; |
87 |
88 |
88 SetContentsDialog dlg (obj, parent); |
89 SetContentsDialog dlg (obj, g_ForgeWindow); |
89 if (dlg.exec ()) { |
90 if (dlg.exec () == false) |
90 LDObject* oldobj = obj; |
91 return; |
91 |
92 |
92 // Reinterpret it from the text of the input field |
93 LDObject* oldobj = obj; |
93 obj = parseLine (dlg.qContents->text ().toStdString ().c_str ()); |
94 |
94 oldobj->replace (obj); |
95 // Reinterpret it from the text of the input field |
95 |
96 obj = parseLine (dlg.qContents->text ().toStdString ().c_str ()); |
96 // Rebuild stuff after this |
97 |
97 parent->refresh (); |
98 // Mark down the history now before we perform the replacement (which |
98 } |
99 // destroys the old object) |
|
100 History::addEntry (new SetContentsHistory (oldobj->getIndex (g_CurrentFile), |
|
101 oldobj->clone (), obj->clone ())); |
|
102 |
|
103 oldobj->replace (obj); |
|
104 |
|
105 // Rebuild stuff after this |
|
106 g_ForgeWindow->refresh (); |
99 } |
107 } |