void handleUndoManagerStateChanged(ChangeEventDetails* const details, Button* const undoButton, Button* const redoButton, DefaultListModel* const undoRedoListModel, UndoManagerPtr TheUndoManager) { while(undoRedoListModel->getSize()-1 > TheUndoManager->numberOfRedos() + TheUndoManager->numberOfUndos()) { undoRedoListModel->popBack(); } //Resize while(undoRedoListModel->getSize()-1 < TheUndoManager->numberOfRedos() + TheUndoManager->numberOfUndos()) { undoRedoListModel->pushBack(boost::any(std::string(""))); } UInt32 UndoCount(TheUndoManager->numberOfUndos()); for(UInt32 i(0) ; i<UndoCount ; ++i) { undoRedoListModel->set(i+1, boost::any(std::string(TheUndoManager->editToBeUndone(i)->getUndoPresentationName()))); } UInt32 RedoCount(TheUndoManager->numberOfRedos()); for(UInt32 i(0) ; i<RedoCount ; ++i) { undoRedoListModel->set(i+TheUndoManager->numberOfUndos()+1, boost::any(std::string(TheUndoManager->editToBeRedone(i)->getRedoPresentationName()))); } if((UndoCount == 0 && undoButton->getEnabled()) || (UndoCount != 0 && !undoButton->getEnabled()) ) { undoButton->setEnabled(UndoCount != 0); } if((RedoCount == 0 && redoButton->getEnabled()) || (RedoCount != 0 && !redoButton->getEnabled()) ) { redoButton->setEnabled(RedoCount != 0); } }
virtual void stateChanged(const ChangeEventUnrecPtr e) { while(UndoRedoListModel->getSize()-1 > TheUndoManager->numberOfRedos() + TheUndoManager->numberOfUndos()) { UndoRedoListModel->popBack(); } //Resize while(UndoRedoListModel->getSize()-1 < TheUndoManager->numberOfRedos() + TheUndoManager->numberOfUndos()) { UndoRedoListModel->pushBack(boost::any(std::string(""))); } UInt32 UndoCount(TheUndoManager->numberOfUndos()); for(UInt32 i(0) ; i<UndoCount ; ++i) { UndoRedoListModel->set(i+1, boost::any(std::string(TheUndoManager->editToBeUndone(i)->getUndoPresentationName()))); } UInt32 RedoCount(TheUndoManager->numberOfRedos()); for(UInt32 i(0) ; i<RedoCount ; ++i) { UndoRedoListModel->set(i+TheUndoManager->numberOfUndos()+1, boost::any(std::string(TheUndoManager->editToBeRedone(i)->getRedoPresentationName()))); } if((UndoCount == 0 && UndoButton->getEnabled()) || (UndoCount != 0 && !UndoButton->getEnabled()) ) { UndoButton->setEnabled(UndoCount != 0); } if((RedoCount == 0 && RedoButton->getEnabled()) || (RedoCount != 0 && !RedoButton->getEnabled()) ) { RedoButton->setEnabled(RedoCount != 0); } }