In my Qt application in the event handler for mouse press events I have such ugly code
void Render::Viewer::mousePressEvent(QMouseEvent* e)
{
switch (e->button())
{
case Qt::LeftButton:
switch (mode_)
{
case Render::Viewer::ModeView:
switch (e->modifiers())
{
case Qt::NoModifier:
...
break;
...
default:
break;
}
break;
case Render::Viewer::ModeEdit:
...
break;
}
break;
case Qt::RightButton:
...
break;
}
}
Even without switching on mode_ variable the code looks terrible. =( Two many degrees of freedom: button type, modifiers, ... Absolutely unreadable.
Is there any ways to overcome such a "heap of switches"?