Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "mitkVerboseLimitedLinearUndo.h"
00020 #include "mitkOperationEvent.h"
00021
00022 mitk::VerboseLimitedLinearUndo::VerboseLimitedLinearUndo()
00023 {
00024 }
00025
00026 mitk::VerboseLimitedLinearUndo::~VerboseLimitedLinearUndo()
00027 {
00028 }
00029
00030 bool mitk::VerboseLimitedLinearUndo::SetOperationEvent(UndoStackItem* undoStackItem)
00031 {
00032 if (!undoStackItem) return false;
00033
00034
00035 if (!m_RedoList.empty())
00036 {
00037 this->ClearList(&m_RedoList);
00038 InvokeEvent( RedoEmptyEvent() );
00039 }
00040
00041 m_UndoList.push_back(undoStackItem);
00042
00043 InvokeEvent( UndoNotEmptyEvent() );
00044
00045 return true;
00046 }
00047
00048 mitk::VerboseLimitedLinearUndo::StackDescription mitk::VerboseLimitedLinearUndo::GetUndoDescriptions()
00049 {
00050 mitk::VerboseLimitedLinearUndo::StackDescription descriptions;
00051
00052 if(m_UndoList.empty()) return descriptions;
00053
00054 int oeid = m_UndoList.back()->GetObjectEventId();
00055 std::string currentDescription;
00056 int currentDescriptionCount(0);
00057 bool niceDescriptionFound(false);
00058 std::string lastDescription;
00059
00060 for ( std::vector<UndoStackItem*>::reverse_iterator iter = m_UndoList.rbegin(); iter != m_UndoList.rend(); ++iter )
00061 {
00062 if ( oeid != (*iter)->GetObjectEventId() )
00063 {
00064
00065 if ( currentDescription.empty() )
00066 currentDescription = "Some unnamed action";
00067
00068 descriptions.push_back( StackDescriptionItem(oeid,currentDescription) );
00069
00070 currentDescription = "";
00071 currentDescriptionCount = 0;
00072 niceDescriptionFound = false;
00073 oeid = (*iter)->GetObjectEventId();
00074 }
00075
00076 if ( !(*iter)->GetDescription().empty() )
00077 {
00078 if (!dynamic_cast<OperationEvent*>(*iter))
00079 {
00080
00081 currentDescription = (*iter)->GetDescription();
00082 niceDescriptionFound = true;
00083 }
00084 else if (!niceDescriptionFound)
00085 {
00086 if ( currentDescriptionCount )
00087 {
00088 if (lastDescription != (*iter)->GetDescription())
00089 {
00090
00091 currentDescription += " AND ";
00092 currentDescription += (*iter)->GetDescription();
00093 }
00094 }
00095 else
00096 {
00097 currentDescription += (*iter)->GetDescription();
00098 }
00099 }
00100 lastDescription = (*iter)->GetDescription();
00101 ++currentDescriptionCount;
00102 }
00103
00104 }
00105
00106
00107 if ( currentDescription.empty() )
00108 currentDescription = "Some unnamed action";
00109 descriptions.push_back( StackDescriptionItem( oeid, currentDescription) );
00110
00111 return descriptions;
00112 }
00113
00114 mitk::VerboseLimitedLinearUndo::StackDescription mitk::VerboseLimitedLinearUndo::GetRedoDescriptions()
00115 {
00116 mitk::VerboseLimitedLinearUndo::StackDescription descriptions;
00117
00118 if(m_RedoList.empty()) return descriptions;
00119
00120 int oeid = m_RedoList.back()->GetObjectEventId();
00121 std::string currentDescription;
00122 int currentDescriptionCount(0);
00123 bool niceDescriptionFound(false);
00124 std::string lastDescription;
00125
00126 for ( std::vector<UndoStackItem*>::reverse_iterator iter = m_RedoList.rbegin(); iter != m_RedoList.rend(); ++iter )
00127 {
00128 if ( oeid != (*iter)->GetObjectEventId() )
00129 {
00130
00131 if ( currentDescription.empty() )
00132 currentDescription = "Some unnamed action";
00133
00134 descriptions.push_back( StackDescriptionItem( oeid, currentDescription) );
00135
00136 currentDescription = "";
00137 currentDescriptionCount = 0;
00138 niceDescriptionFound = false;
00139 oeid = (*iter)->GetObjectEventId();
00140 }
00141
00142 if ( !(*iter)->GetDescription().empty() )
00143 {
00144
00145 if (!dynamic_cast<OperationEvent*>(*iter))
00146 {
00147
00148 currentDescription = (*iter)->GetDescription();
00149 niceDescriptionFound = true;
00150 }
00151 else if (!niceDescriptionFound)
00152 {
00153 if ( currentDescriptionCount )
00154 {
00155 if (lastDescription != (*iter)->GetDescription())
00156 {
00157
00158 currentDescription += " AND ";
00159 currentDescription += (*iter)->GetDescription();
00160 }
00161 }
00162 else
00163 {
00164 currentDescription += (*iter)->GetDescription();
00165 }
00166 }
00167 lastDescription = (*iter)->GetDescription();
00168 ++currentDescriptionCount;
00169 }
00170
00171 }
00172
00173
00174 if ( currentDescription.empty() )
00175 currentDescription = "Some unnamed action";
00176 descriptions.push_back( StackDescriptionItem( oeid, currentDescription) );
00177
00178 return descriptions;
00179 }
00180
00181