Thu, 13 Jun 2013 01:13:06 +0300
Color changing is now logged into history
src/file.h | file | annotate | diff | comparison | revisions | |
src/gui.cpp | file | annotate | diff | comparison | revisions | |
src/history.cpp | file | annotate | diff | comparison | revisions | |
src/ldtypes.cpp | file | annotate | diff | comparison | revisions | |
src/ldtypes.h | file | annotate | diff | comparison | revisions |
--- a/src/file.h Thu Jun 13 00:48:53 2013 +0300 +++ b/src/file.h Thu Jun 13 01:13:06 2013 +0300 @@ -97,6 +97,7 @@ void undo () { m_history.undo (); } void redo () { m_history.redo (); } void clearHistory () { m_history.clear (); } + void addToHistory (AbstractHistoryEntry* entry) { m_history << entry; } }; // Close all current loaded files and start off blank.
--- a/src/gui.cpp Thu Jun 13 00:48:53 2013 +0300 +++ b/src/gui.cpp Thu Jun 13 01:13:06 2013 +0300 @@ -769,6 +769,7 @@ // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ============================================================================= void ForgeWindow::slot_quickColor () { + g_curfile->openHistory (); QToolButton* button = static_cast<QToolButton*> (sender ()); color* col = null; @@ -792,6 +793,7 @@ } fullRefresh (); + g_curfile->closeHistory (); } // =============================================================================
--- a/src/history.cpp Thu Jun 13 00:48:53 2013 +0300 +++ b/src/history.cpp Thu Jun 13 01:13:06 2013 +0300 @@ -137,4 +137,21 @@ delete obj; } -DelHistory::~DelHistory () {} \ No newline at end of file +DelHistory::~DelHistory () {} + +// ============================================================================= +void EditHistory::undo () const { + LDObject* obj = g_curfile->object (index ()); + LDObject* newobj = parseLine (oldCode ()); + obj->replace (newobj); + g_win->R ()->compileObject (newobj); +} + +void EditHistory::redo () const { + LDObject* obj = g_curfile->object (index ()); + LDObject* newobj = parseLine (newCode ()); + obj->replace (newobj); + g_win->R ()->compileObject (newobj); +} + +EditHistory::~EditHistory () {} \ No newline at end of file
--- a/src/ldtypes.cpp Thu Jun 13 00:48:53 2013 +0300 +++ b/src/ldtypes.cpp Thu Jun 13 01:13:06 2013 +0300 @@ -802,4 +802,17 @@ replace (repl); return repl; +} + +READ_ACCESSOR (short, LDObject::color) { return m_color; } +SET_ACCESSOR (short, LDObject::setColor) { + long idx; + if ((idx = getIndex (g_curfile)) != -1) { + str before = raw (); + m_color = val; + str after = raw (); + + g_curfile->addToHistory (new EditHistory (idx, before, after)); + } else + m_color = val; } \ No newline at end of file
--- a/src/ldtypes.h Thu Jun 13 00:48:53 2013 +0300 +++ b/src/ldtypes.h Thu Jun 13 01:13:06 2013 +0300 @@ -85,8 +85,8 @@ class LDObject { PROPERTY (bool, hidden, setHidden) PROPERTY (bool, selected, setSelected) - PROPERTY (short, color, setColor) PROPERTY (LDObject*, parent, setParent) + DECLARE_PROPERTY (short, color, setColor) public: // Object type codes. Codes are sorted in order of significance.