Thu, 19 Dec 2013 01:06:34 +0200
- history now works on object list moving as well
src/document.cc | file | annotate | diff | comparison | revisions | |
src/document.h | file | annotate | diff | comparison | revisions | |
src/ldtypes.cc | file | annotate | diff | comparison | revisions |
--- a/src/document.cc Thu Dec 19 00:59:49 2013 +0200 +++ b/src/document.cc Thu Dec 19 01:06:34 2013 +0200 @@ -1219,4 +1219,15 @@ // ----------------------------------------------------------------------------- const QList<LDObject*>& LDDocument::getSelection() const { return m_sel; +} + +// ============================================================================= +// ----------------------------------------------------------------------------- +void LDDocument::swapObjects (LDObject* one, LDObject* other) +{ int a = m_Objects.indexOf (one); + int b = m_Objects.indexOf (other); + assert (a != b != -1); + m_Objects[b] = one; + m_Objects[a] = other; + addToHistory (new SwapHistory (one->getID(), other->getID())); } \ No newline at end of file
--- a/src/document.h Thu Dec 19 00:59:49 2013 +0200 +++ b/src/document.h Thu Dec 19 01:06:34 2013 +0200 @@ -80,6 +80,7 @@ int getObjectCount() const; LDObject* getObject (int pos) const; bool save (str path = ""); // Saves this file to disk. + void swapObjects (LDObject* one, LDObject* other); bool isSafeToClose(); // Perform safety checks. Do this before closing any files! void setObject (int idx, LDObject* obj);
--- a/src/ldtypes.cc Thu Dec 19 00:59:49 2013 +0200 +++ b/src/ldtypes.cc Thu Dec 19 01:06:34 2013 +0200 @@ -237,18 +237,8 @@ // ============================================================================= // ----------------------------------------------------------------------------- void LDObject::swap (LDObject* other) -{ int i = 0; - - for (LDObject* obj : getFile()->getObjects()) - { if (obj == this) - getFile()->setObject (i, other); - elif (obj == other) - getFile()->setObject (i, this); - - ++i; - } - - getFile()->addToHistory (new SwapHistory (getID(), other->getID())); +{ assert (getFile() == other->getFile()); + getFile()->swapObjects (this, other); } // =============================================================================