]> Shamusworld >> Repos - architektonas/blobdiff - src/base/undo.cpp
Removed unnecessary RS_ prefix from classes and whatnot.
[architektonas] / src / base / undo.cpp
index 703449320e813cc0d2c9332eb444cbbe072e9966..441545505dec02f7b9778b17370cc2a8285ab807 100644 (file)
@@ -22,7 +22,7 @@
 /**
  * Default constructor.
  */
-RS_Undo::RS_Undo()
+Undo::Undo()
 {
 #warning "!!! Need to deal with setAutoDelete() Qt3->Qt4 !!!"
 //     undoList.setAutoDelete(true);
@@ -30,7 +30,7 @@ RS_Undo::RS_Undo()
        currentCycle = NULL;
 }
 
-/*virtual*/ RS_Undo::~RS_Undo()
+/*virtual*/ Undo::~Undo()
 {
        while (!undoList.isEmpty())
                delete undoList.takeFirst();
@@ -39,9 +39,9 @@ RS_Undo::RS_Undo()
 /**
  * @return Number of Cycles that can be undone.
  */
-int RS_Undo::countUndoCycles()
+int Undo::countUndoCycles()
 {
-       RS_DEBUG->print("RS_Undo::countUndoCycles");
+       DEBUG->print("Undo::countUndoCycles");
 
        return undoPointer + 1;
 }
@@ -49,9 +49,9 @@ int RS_Undo::countUndoCycles()
 /**
  * @return Number of Cycles that can be redone.
  */
-int RS_Undo::countRedoCycles()
+int Undo::countRedoCycles()
 {
-       RS_DEBUG->print("RS_Undo::countRedoCycles");
+       DEBUG->print("Undo::countRedoCycles");
 
        return (int)undoList.count() - 1 - undoPointer;
 }
@@ -61,32 +61,32 @@ int RS_Undo::countRedoCycles()
  * All Cycles after the new one are removed and the Undoabels
  * on them deleted.
  */
-void RS_Undo::addUndoCycle(RS_UndoCycle * i)
+void Undo::addUndoCycle(UndoCycle * i)
 {
-       RS_DEBUG->print("RS_Undo::addUndoCycle");
+       DEBUG->print("Undo::addUndoCycle");
 
        undoList.insert(++undoPointer, i);
 
-       RS_DEBUG->print("RS_Undo::addUndoCycle: ok");
+       DEBUG->print("Undo::addUndoCycle: ok");
 }
 
 /**
  * Starts a new cycle for one undo step. Every undoable that is
  * added after calling this method goes into this cycle.
  */
-void RS_Undo::startUndoCycle()
+void Undo::startUndoCycle()
 {
-       RS_DEBUG->print("RS_Undo::startUndoCycle");
+       DEBUG->print("Undo::startUndoCycle");
 
        // definitely delete Undo Cycles and all Undoables in them
        //   that cannot be redone now:
        while ((int)undoList.count() > undoPointer + 1 && (int)undoList.count() > 0)
        {
-               RS_UndoCycle * l = undoList.last();
+               UndoCycle * l = undoList.last();
 
                if (l != NULL)
                {
-                       RS_Undoable * u = NULL;
+                       Undoable * u = NULL;
                        bool done = false;
 
                        do
@@ -96,7 +96,7 @@ void RS_Undo::startUndoCycle()
                                if (u != NULL)
                                {
                                        // Remove the pointer from _all_ cycles:
-//                                     for(RS_UndoCycle * l2=undoList.first(); l2!=NULL; l2=undoList.next())
+//                                     for(UndoCycle * l2=undoList.first(); l2!=NULL; l2=undoList.next())
 //                                             l2->removeUndoable(u);
                                        for(int i=0; i<undoList.size(); i++)
                                                undoList[i]->removeUndoable(u);
@@ -119,15 +119,15 @@ void RS_Undo::startUndoCycle()
                undoList.removeLast();
        }
 
-       currentCycle = new RS_UndoCycle();
+       currentCycle = new UndoCycle();
 }
 
 /**
  * Adds an undoable to the current undo cycle.
  */
-void RS_Undo::addUndoable(RS_Undoable * u)
+void Undo::addUndoable(Undoable * u)
 {
-       RS_DEBUG->print("RS_Undo::addUndoable");
+       DEBUG->print("Undo::addUndoable");
 
        if (currentCycle != NULL)
        {
@@ -135,14 +135,14 @@ void RS_Undo::addUndoable(RS_Undoable * u)
        }
        else
        {
-               RS_DEBUG->print(RS_Debug::D_WARNING, "RS_Undo::addUndoable(): No undo cycle active.");
+               DEBUG->print(Debug::D_WARNING, "Undo::addUndoable(): No undo cycle active.");
        }
 }
 
 /**
  * Ends the current undo cycle.
  */
-void RS_Undo::endUndoCycle()
+void Undo::endUndoCycle()
 {
        addUndoCycle(currentCycle);
        currentCycle = NULL;
@@ -151,17 +151,17 @@ void RS_Undo::endUndoCycle()
 /**
  * Undoes the last undo cycle.
  */
-void RS_Undo::undo()
+void Undo::undo()
 {
-       RS_DEBUG->print("RS_Undo::undo");
+       DEBUG->print("Undo::undo");
 
        if (undoPointer >= 0)
        {
-               RS_UndoCycle * i = undoList.at(undoPointer);
+               UndoCycle * i = undoList.at(undoPointer);
 
                if (i != NULL)
                {
-//                     for(RS_Undoable * u=i->undoables.first(); u!=NULL; u=i->undoables.next())
+//                     for(Undoable * u=i->undoables.first(); u!=NULL; u=i->undoables.next())
 //                             u->changeUndoState();
                        for(int j=0; j<i->undoables.size(); j++)
                                i->undoables[j]->changeUndoState();
@@ -174,18 +174,18 @@ void RS_Undo::undo()
 /**
  * Redoes the undo cycle which was at last undone.
  */
-void RS_Undo::redo()
+void Undo::redo()
 {
-       RS_DEBUG->print("RS_Undo::redo");
+       DEBUG->print("Undo::redo");
 
        if (undoPointer + 1 < (int)undoList.count())
        {
                undoPointer++;
-               RS_UndoCycle * i = undoList.at(undoPointer);
+               UndoCycle * i = undoList.at(undoPointer);
 
                if (i != NULL)
                {
-//            for(RS_Undoable * u=i->undoables.first(); u!=NULL; u=i->undoables.next())
+//            for(Undoable * u=i->undoables.first(); u!=NULL; u=i->undoables.next())
 //                u->changeUndoState();
                        for(int j=0; j<i->undoables.size(); j++)
                                i->undoables[j]->changeUndoState();
@@ -197,16 +197,16 @@ void RS_Undo::redo()
  * @return The undo item that is next if we're about to undo
  * or NULL.
  */
-RS_UndoCycle * RS_Undo::getUndoCycle()
+UndoCycle * Undo::getUndoCycle()
 {
-       RS_UndoCycle * ret = NULL;
+       UndoCycle * ret = NULL;
 
-       RS_DEBUG->print("RS_Undo::getUndoCycle");
+       DEBUG->print("Undo::getUndoCycle");
 
        if (undoPointer >= 0 && undoPointer < (int)undoList.count())
                ret = undoList.at(undoPointer);
 
-       RS_DEBUG->print("RS_Undo::getUndoCycle: OK");
+       DEBUG->print("Undo::getUndoCycle: OK");
 
        return ret;
 }
@@ -215,9 +215,9 @@ RS_UndoCycle * RS_Undo::getUndoCycle()
  * @return The redo item that is next if we're about to redo
  * or NULL.
  */
-RS_UndoCycle * RS_Undo::getRedoCycle()
+UndoCycle * Undo::getRedoCycle()
 {
-       RS_DEBUG->print("RS_Undo::getRedoCycle");
+       DEBUG->print("Undo::getRedoCycle");
 
        if (undoPointer + 1 >= 0 && undoPointer + 1 < (int)undoList.count())
                return undoList.at(undoPointer + 1);
@@ -228,15 +228,15 @@ RS_UndoCycle * RS_Undo::getRedoCycle()
 /**
  * Dumps the undo list to stdout.
  */
-std::ostream & operator<<(std::ostream & os, RS_Undo & l)
+std::ostream & operator<<(std::ostream & os, Undo & l)
 {
        os << "Undo List: " <<  "\n";
        os << " Pointer is at: " << l.undoPointer << "\n";
 
-//     for(RS_UndoCycle * i=l.undoList.first(); i!=NULL; i=l.undoList.next())
+//     for(UndoCycle * i=l.undoList.first(); i!=NULL; i=l.undoList.next())
        for(int j=0; j<l.undoList.size(); j++)
        {
-               RS_UndoCycle * i = l.undoList[j];
+               UndoCycle * i = l.undoList[j];
 
 //             if (l.undoList.at() == l.undoPointer)
                if (j == l.undoPointer)
@@ -256,25 +256,25 @@ std::ostream & operator<<(std::ostream & os, RS_Undo & l)
 /**
  * Testing Undoables, Undo Cycles and the Undo container.
  */
-/*static*/ bool RS_Undo::test()
+/*static*/ bool Undo::test()
 {
        int i, k;
-       RS_UndoStub undo;
-       //RS_UndoCycle * c1;
-       RS_Undoable * u1;
+       UndoStub undo;
+       //UndoCycle * c1;
+       Undoable * u1;
 
-       std::cout << "Testing RS_Undo\n";
+       std::cout << "Testing Undo\n";
        std::cout << "  Adding 500 cycles..";
 
        // Add 500 Undo Cycles with i Undoables in every Cycle
        for(i=1; i<=500; ++i)
        {
-               //c1 = new RS_UndoCycle();
+               //c1 = new UndoCycle();
                undo.startUndoCycle();
 
                for(k=1; k<=i; ++k)
                {
-                       u1 = new RS_Undoable();
+                       u1 = new Undoable();
                        //c1->
                        undo.addUndoable(u1);
                }
@@ -325,12 +325,12 @@ std::ostream & operator<<(std::ostream & os, RS_Undo & l)
 
        for(i=1; i<=10; ++i)
        {
-               //c1 = new RS_UndoCycle();
+               //c1 = new UndoCycle();
                undo.startUndoCycle();
 
                for(k=1; k<=10; ++k)
                {
-                       u1 = new RS_Undoable();
+                       u1 = new Undoable();
                        //c1->addUndoable(u1);
                        undo.addUndoable(u1);
                }
@@ -378,12 +378,12 @@ std::ostream & operator<<(std::ostream & os, RS_Undo & l)
 
        for(i=1; i<=1; ++i)
        {
-               //c1 = new RS_UndoCycle();
+               //c1 = new UndoCycle();
                undo.startUndoCycle();
 
                for(k=1; k<=10; ++k)
                {
-                       u1 = new RS_Undoable();
+                       u1 = new Undoable();
                        //c1->addUndoable(u1);
                        undo.addUndoable(u1);
                }