Back to index

scribus-ng  1.3.4.dfsg+svn20071115
Public Member Functions | Private Attributes
TransactionState Class Reference

TransactionState provides a container where multiple UndoStates can be stored. More...

#include <undomanager.h>

Collaboration diagram for TransactionState:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TransactionState ()
 Creates a new TransactionState instance.
 ~TransactionState ()
 Destroys the TransactionState instance.
void pushBack (UndoObject *target, UndoState *state)
 Add a new UndoState object to the transaction.
uint sizet ()
 Returns the count of the UndoState objects in this transaction.
void useActionName ()
 Use the name from last action added to this TransactionState
UndoState * at (int index)
 Returns an UndoState object at index.
bool contains (int uid) const
 Returns true if this transaction contains UndoObject with the id uid
bool containsOnly (int uid) const
 Tells if this transaction contains only UndoObject with ID uid.
UndoObject * replace (ulong uid, UndoObject *newUndoObject)
 Replace object with id uid with new UndoObject newUndoObject.
void undo ()
 undo all UndoStates in this transaction
void redo ()
 redo all UndoStates in this transaction

Private Attributes

uint size_
 Number of undo states stored in this transaction.
std::vector< UndoState * > states_
 vector to keep the states in

Detailed Description

TransactionState provides a container where multiple UndoStates can be stored.

as a single action which then appears in the attached UndoGuis.

Author:
Riku Leino riku@.nosp@m.scri.nosp@m.bus.i.nosp@m.nfo
Date:
January 2005

Definition at line 53 of file undomanager.h.


Constructor & Destructor Documentation

Creates a new TransactionState instance.

Definition at line 576 of file undomanager.cpp.

                                   : UndoState("")
{
       size_ = 0;
}

Destroys the TransactionState instance.

Definition at line 659 of file undomanager.cpp.

{
       for (uint i = 0; i < states_.size(); ++i)
       {
              if (states_[i])
              {
                     delete states_[i];
                     states_[i] = 0;
              }
       }
}

Member Function Documentation

UndoState * TransactionState::at ( int  index)

Returns an UndoState object at index.

Parameters:
indexindex from where an UndoState object is returned. If index is out of scope NULL will be rerturned.
Returns:
UndoState object from index or NULL if index is out of scope.

Definition at line 581 of file undomanager.cpp.

{
       if (index >= 0 && static_cast<uint>(index) < sizet())
              return states_[index];
       else
              return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Returns true if this transaction contains UndoObject with the id uid

otherwise returns false.

Returns:
true if this transaction contains UndoObject with the ide uid
otherwise returns false.

Definition at line 589 of file undomanager.cpp.

{
       for (uint i = 0; i < states_.size(); ++i)
       {
              if (states_[i]->undoObject()->getUId() == static_cast<uint>(uid))
                     return true;
       }
       return false;
}

Tells if this transaction contains only UndoObject with ID uid.

If a transaction contains only single UndoObject it will be safe to include it in the object specific undo.

Parameters:
uidUndoObject's id to look for
Returns:
true if this transaction only contains actions of the UndoObject whose id is uid

Definition at line 599 of file undomanager.cpp.

{
       for (uint i = 0; i < states_.size(); ++i)
       {
              if (states_[i]->undoObject()->getUId() != static_cast<uint>(uid))
                     return false;
       }
       return true;
}
void TransactionState::pushBack ( UndoObject *  target,
UndoState *  state 
)

Add a new UndoState object to the transaction.

Parameters:
statestate to be added to the transaction

Definition at line 609 of file undomanager.cpp.

{
       if (target && state)
       {
              state->setUndoObject(target);
              states_.push_back(state);
              ++size_;
       }
}

redo all UndoStates in this transaction

Definition at line 653 of file undomanager.cpp.

{
       for (uint i = 0; i < sizet(); ++i)
              at(i)->redo();
}

Here is the call graph for this function:

UndoObject * TransactionState::replace ( ulong  uid,
UndoObject *  newUndoObject 
)

Replace object with id uid with new UndoObject newUndoObject.

Parameters:
uidid of the object that is wanted to be replaced
newUndoObjectobject that is used for replacing
Returns:
UndoObject which was replaced

Definition at line 630 of file undomanager.cpp.

{
       UndoObject *tmp = 0;
       for (uint i = 0; i < states_.size(); ++i)
       {
              TransactionState *ts = dynamic_cast<TransactionState*>(states_[i]);
              if (ts) // are we having a transaction_inside a transaction
                     ts->replace(uid, newUndoObject);
              else if (states_[i]->undoObject() && states_[i]->undoObject()->getUId() == uid)
              {
                     tmp = states_[i]->undoObject();
                     states_[i]->setUndoObject(newUndoObject);
              }
       }
       return tmp;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Returns the count of the UndoState objects in this transaction.

Returns:
count of the UndoState objects in this transaction

Definition at line 619 of file undomanager.cpp.

{
       return size_;
}

Here is the caller graph for this function:

undo all UndoStates in this transaction

Definition at line 647 of file undomanager.cpp.

{
       for (int i = sizet() - 1; i > -1; --i)
              at(i)->undo();
}

Here is the call graph for this function:

Use the name from last action added to this TransactionState

Definition at line 624 of file undomanager.cpp.

{
       if (size_ > 0)
              setName(states_[size_ - 1]->getName());
}

Member Data Documentation

uint TransactionState::size_ [private]

Number of undo states stored in this transaction.

Definition at line 112 of file undomanager.h.

std::vector<UndoState*> TransactionState::states_ [private]

vector to keep the states in

Definition at line 114 of file undomanager.h.


The documentation for this class was generated from the following files: