Skip to content

Commit

Permalink
Use namespaced enum instead of defines for undo handler
Browse files Browse the repository at this point in the history
  • Loading branch information
robbr48 committed May 23, 2024
1 parent 39a2962 commit b48af80
Show file tree
Hide file tree
Showing 8 changed files with 204 additions and 200 deletions.
2 changes: 1 addition & 1 deletion HopsanGUI/Dialogs/ComponentPropertiesDialog3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@ bool VariableTableWidget::setStartValues()
// Add an undo post (but only one for all values changed this time
if(!addedUndoPost)
{
mpModelObject->getParentSystemObject()->getUndoStackPtr()->newPost(UNDO_CHANGEDPARAMETERS);
mpModelObject->getParentSystemObject()->getUndoStackPtr()->newPost(undo::changedparameters);
addedUndoPost = true;
}
// Register the change in undo stack
Expand Down
16 changes: 8 additions & 8 deletions HopsanGUI/GUIObjects/GUIContainerObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,7 @@ void SystemObject::cutSelected(CopyStack *xmlStack)
}

this->copySelected(xmlStack);
this->mpUndoStack->newPost(UNDO_CUT);
this->mpUndoStack->newPost(undo::cut);
emit deleteSelected();
mpModelWidget->getGraphicsView()->updateViewPort();
}
Expand Down Expand Up @@ -1604,7 +1604,7 @@ void SystemObject::paste(CopyStack *xmlStack)
}

bool didPaste = false;
mpUndoStack->newPost(UNDO_PASTE);
mpUndoStack->newPost(undo::paste);

QDomElement *copyRoot;
if(xmlStack == nullptr) {
Expand Down Expand Up @@ -1798,7 +1798,7 @@ void SystemObject::alignX()

if(mSelectedModelObjectsList.size()+mSelectedWidgetsList.size() > 1)
{
mpUndoStack->newPost(UNDO_ALIGNX);
mpUndoStack->newPost(undo::alignx);
for(int i=0; i<mSelectedModelObjectsList.size()-1; ++i)
{
QPointF oldPos = mSelectedModelObjectsList.at(i)->pos();
Expand Down Expand Up @@ -1841,7 +1841,7 @@ void SystemObject::alignY()

if(mSelectedModelObjectsList.size()+mSelectedWidgetsList.size() > 1)
{
mpUndoStack->newPost(UNDO_ALIGNY);
mpUndoStack->newPost(undo::aligny);
for(int i=0; i<mSelectedModelObjectsList.size()-1; ++i)
{
QPointF oldPos = mSelectedModelObjectsList.at(i)->pos();
Expand Down Expand Up @@ -1886,7 +1886,7 @@ void SystemObject::distributeX()
double max = tempList.last()->getCenterPos().x();
double diff = (max-min)/(tempList.size()-1.0);

mpUndoStack->newPost(UNDO_DISTRIBUTEX);
mpUndoStack->newPost(undo::distributex);
double pos = min+diff;
for(int i=1; i<tempList.size()-1; ++i)
{
Expand Down Expand Up @@ -1928,7 +1928,7 @@ void SystemObject::distributeY()
double max = tempList.last()->getCenterPos().y();
double diff = (max-min)/(tempList.size()-1.0);

mpUndoStack->newPost(UNDO_DISTRIBUTEY);
mpUndoStack->newPost(undo::distributey);
double pos = min+diff;
for(int i=1; i<tempList.size()-1; ++i)
{
Expand Down Expand Up @@ -2115,7 +2115,7 @@ void SystemObject::deselectAll()
//! @see showNames()
void SystemObject::hideNames()
{
mpUndoStack->newPost(UNDO_HIDEALLNAMES);
mpUndoStack->newPost(undo::hideallnames);
emit deselectAllNameText();
emit hideAllNameText();
}
Expand All @@ -2125,7 +2125,7 @@ void SystemObject::hideNames()
//! @see hideNames()
void SystemObject::showNames()
{
mpUndoStack->newPost(UNDO_SHOWALLNAMES);
mpUndoStack->newPost(undo::showallnames);
emit showAllNameText();
}

Expand Down
2 changes: 1 addition & 1 deletion HopsanGUI/GUIObjects/GUIModelObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,7 @@ void ModelObject::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if(mpParentSystemObject->getSelectedModelObjectPtrs().size() > 1)
{
mpParentSystemObject->getUndoStackPtr()->newPost(UNDO_MOVEDMULTIPLE);
mpParentSystemObject->getUndoStackPtr()->newPost(undo::movedmultiple);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion HopsanGUI/GUIObjects/GUIWidgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void Widget::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
if(mpParentSystemObject->getSelectedGUIWidgetPtrs().size() > 1)
{
mpParentSystemObject->getUndoStackPtr()->newPost(UNDO_MOVEDMULTIPLEWIDGETS);
mpParentSystemObject->getUndoStackPtr()->newPost(undo::movedmultiplewidgets);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion HopsanGUI/GraphicsView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ void GraphicsView::mouseReleaseEvent(QMouseEvent *event)
mpParentModelWidget->hasChanged();
if(!createdUndoPost)
{
mpContainerObject->getUndoStackPtr()->newPost(UNDO_MOVEDMULTIPLE);
mpContainerObject->getUndoStackPtr()->newPost(undo::movedmultiple);
createdUndoPost = true;
}
mpContainerObject->getUndoStackPtr()->registerMovedObject(pSelectedMO->getPreviousPos(), pSelectedMO->pos(), pSelectedMO->getName());
Expand Down
Loading

0 comments on commit b48af80

Please sign in to comment.