/**
* Default constructor.
*/
-RS_Undo::RS_Undo()
+Undo::Undo()
{
#warning "!!! Need to deal with setAutoDelete() Qt3->Qt4 !!!"
// undoList.setAutoDelete(true);
currentCycle = NULL;
}
-/*virtual*/ RS_Undo::~RS_Undo()
+/*virtual*/ Undo::~Undo()
{
while (!undoList.isEmpty())
delete undoList.takeFirst();
/**
* @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;
}
/**
* @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;
}
* 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
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);
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)
{
}
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;
/**
* 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();
/**
* 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();
* @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;
}
* @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);
/**
* 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)
/**
* 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);
}
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);
}
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);
}