A limited linear undo model providing GUI elements with stack status information. More...
#include <mitkVerboseLimitedLinearUndo.h>
Public Types | |
typedef std::pair< int, std::string > | StackDescriptionItem |
typedef std::vector < StackDescriptionItem > | StackDescription |
Public Member Functions | |
mitkClassMacro (VerboseLimitedLinearUndo, LimitedLinearUndo) | |
virtual bool | SetOperationEvent (UndoStackItem *undoStackItem) |
a list of pairs (int,string), representing a stack with ObjectEventIDs and descriptions | |
virtual StackDescription | GetUndoDescriptions () |
virtual StackDescription | GetRedoDescriptions () |
Static Public Member Functions | |
static Pointer | New () |
Protected Member Functions | |
VerboseLimitedLinearUndo () | |
virtual | ~VerboseLimitedLinearUndo () |
A limited linear undo model providing GUI elements with stack status information.
Basically does the same, as LimitedLinearUndo class, but it allows you to retrieve a string list, which describes the undo stack or the redo stack. This can be used for display by GUI elements.
Definition at line 41 of file mitkVerboseLimitedLinearUndo.h.
typedef std::vector<StackDescriptionItem> mitk::VerboseLimitedLinearUndo::StackDescription |
Definition at line 48 of file mitkVerboseLimitedLinearUndo.h.
typedef std::pair<int,std::string> mitk::VerboseLimitedLinearUndo::StackDescriptionItem |
Definition at line 45 of file mitkVerboseLimitedLinearUndo.h.
mitk::VerboseLimitedLinearUndo::VerboseLimitedLinearUndo | ( | ) | [protected] |
Definition at line 22 of file mitkVerboseLimitedLinearUndo.cpp.
{ }
mitk::VerboseLimitedLinearUndo::~VerboseLimitedLinearUndo | ( | ) | [protected, virtual] |
Definition at line 26 of file mitkVerboseLimitedLinearUndo.cpp.
{ }
mitk::VerboseLimitedLinearUndo::StackDescription mitk::VerboseLimitedLinearUndo::GetRedoDescriptions | ( | ) | [virtual] |
Definition at line 114 of file mitkVerboseLimitedLinearUndo.cpp.
{ mitk::VerboseLimitedLinearUndo::StackDescription descriptions; if(m_RedoList.empty()) return descriptions; int oeid = m_RedoList.back()->GetObjectEventId(); // ObjectEventID of current group std::string currentDescription; // description of current group int currentDescriptionCount(0); // counter, how many items of the current group gave descriptions bool niceDescriptionFound(false); // have we yet seen a plain descriptive entry (not OperationEvent)? std::string lastDescription; // stores the last description to inhibit entries like "name AND name AND name..." if name is always the same for ( std::vector<UndoStackItem*>::reverse_iterator iter = m_RedoList.rbegin(); iter != m_RedoList.rend(); ++iter ) { if ( oeid != (*iter)->GetObjectEventId() ) { // current description complete, append to list if ( currentDescription.empty() ) currentDescription = "Some unnamed action"; // set a default description descriptions.push_back( StackDescriptionItem( oeid, currentDescription) ); currentDescription = ""; // prepare for next group currentDescriptionCount = 0; niceDescriptionFound = false; oeid = (*iter)->GetObjectEventId(); } if ( !(*iter)->GetDescription().empty() ) // if there is a description { if (!dynamic_cast<OperationEvent*>(*iter)) { // anything but an OperationEvent overrides the collected descriptions currentDescription = (*iter)->GetDescription(); niceDescriptionFound = true; } else if (!niceDescriptionFound) // mere descriptive items override OperationEvents' descriptions { if ( currentDescriptionCount ) // if we have already seen another description { if (lastDescription != (*iter)->GetDescription()) { //currentDescription += '\n'; // concatenate descriptions with newline currentDescription += " AND "; // this has to wait until the popup can process multiline items currentDescription += (*iter)->GetDescription(); } } else { currentDescription += (*iter)->GetDescription(); } } lastDescription = (*iter)->GetDescription(); ++currentDescriptionCount; } } // for // add last description to list if ( currentDescription.empty() ) currentDescription = "Some unnamed action"; descriptions.push_back( StackDescriptionItem( oeid, currentDescription) ); return descriptions; // list ready }
mitk::VerboseLimitedLinearUndo::StackDescription mitk::VerboseLimitedLinearUndo::GetUndoDescriptions | ( | ) | [virtual] |
Definition at line 48 of file mitkVerboseLimitedLinearUndo.cpp.
{ mitk::VerboseLimitedLinearUndo::StackDescription descriptions; if(m_UndoList.empty()) return descriptions; int oeid = m_UndoList.back()->GetObjectEventId(); // ObjectEventID of current group std::string currentDescription; // description of current group int currentDescriptionCount(0); // counter, how many items of the current group gave descriptions bool niceDescriptionFound(false); // have we yet seen a plain descriptive entry (not OperationEvent)? std::string lastDescription; // stores the last description to inhibit entries like "name AND name AND name..." if name is always the same for ( std::vector<UndoStackItem*>::reverse_iterator iter = m_UndoList.rbegin(); iter != m_UndoList.rend(); ++iter ) { if ( oeid != (*iter)->GetObjectEventId() ) { // current description complete, append to list if ( currentDescription.empty() ) currentDescription = "Some unnamed action"; // set a default description descriptions.push_back( StackDescriptionItem(oeid,currentDescription) ); currentDescription = ""; // prepare for next group currentDescriptionCount = 0; niceDescriptionFound = false; oeid = (*iter)->GetObjectEventId(); } if ( !(*iter)->GetDescription().empty() ) // if there is a description { if (!dynamic_cast<OperationEvent*>(*iter)) { // anything but an OperationEvent overrides the collected descriptions currentDescription = (*iter)->GetDescription(); niceDescriptionFound = true; } else if (!niceDescriptionFound) // mere descriptive items override OperationEvents' descriptions { if ( currentDescriptionCount ) // if we have already seen another description { if (lastDescription != (*iter)->GetDescription()) { //currentDescription += '\n'; // concatenate descriptions with newline currentDescription += " AND "; // this has to wait until the popup can process multiline items currentDescription += (*iter)->GetDescription(); } } else { currentDescription += (*iter)->GetDescription(); } } lastDescription = (*iter)->GetDescription(); ++currentDescriptionCount; } } // for // add last description to list if ( currentDescription.empty() ) currentDescription = "Some unnamed action"; descriptions.push_back( StackDescriptionItem( oeid, currentDescription) ); return descriptions; // list ready }
mitk::VerboseLimitedLinearUndo::mitkClassMacro | ( | VerboseLimitedLinearUndo | , |
LimitedLinearUndo | |||
) |
static Pointer mitk::VerboseLimitedLinearUndo::New | ( | ) | [static] |
Reimplemented from mitk::LimitedLinearUndo.
Referenced by mitk::UndoController::AddUndoModel(), and mitk::UndoController::UndoController().
bool mitk::VerboseLimitedLinearUndo::SetOperationEvent | ( | UndoStackItem * | undoStackItem ) | [virtual] |
a list of pairs (int,string), representing a stack with ObjectEventIDs and descriptions
Reimplemented from mitk::LimitedLinearUndo.
Definition at line 30 of file mitkVerboseLimitedLinearUndo.cpp.
{ if (!undoStackItem) return false; // clear the redolist, if a new operation is saved if (!m_RedoList.empty()) { this->ClearList(&m_RedoList); InvokeEvent( RedoEmptyEvent() ); } m_UndoList.push_back(undoStackItem); InvokeEvent( UndoNotEmptyEvent() ); return true; }