diff --git a/sources/editor/editorcommands.cpp b/sources/editor/editorcommands.cpp index 221143c44..6edd57235 100644 --- a/sources/editor/editorcommands.cpp +++ b/sources/editor/editorcommands.cpp @@ -525,7 +525,11 @@ void RotateElementsCommand::undo() { if (item->type() == PartTerminal::Type) { PartTerminal* term = qgraphicsitem_cast(item); + if(m_items.size() == 1) { + term->previousOrientation(); + } else { term->setRotation(term->rotation()-90); + } } else if (item->type() == PartRectangle::Type) { PartRectangle* rect = qgraphicsitem_cast(item); @@ -570,7 +574,11 @@ void RotateElementsCommand::redo() { if (item->type() == PartTerminal::Type) { PartTerminal* term = qgraphicsitem_cast(item); + if (m_items.size() == 1) { + term->nextOrientation(); + } else { term->setRotation(term->rotation()+90); + } } else if (item->type() == PartRectangle::Type) { PartRectangle* rect = qgraphicsitem_cast(item); diff --git a/sources/editor/graphicspart/partterminal.cpp b/sources/editor/graphicspart/partterminal.cpp index af321e771..6ed10d0fd 100644 --- a/sources/editor/graphicspart/partterminal.cpp +++ b/sources/editor/graphicspart/partterminal.cpp @@ -224,6 +224,34 @@ void PartTerminal::mirror() { emit xChanged(); // all terminal-signals call "updateForm" } +void PartTerminal::nextOrientation() +{ + switch (d->m_orientation) { + case Qet::North : + setOrientation(Qet::East); break; + case Qet::East : + setOrientation(Qet::South); break; + case Qet::South : + setOrientation(Qet::West); break; + case Qet::West : + setOrientation(Qet::North); break; + } +} + +void PartTerminal::previousOrientation() +{ + switch (d->m_orientation) { + case Qet::North : + setOrientation(Qet::West); break; + case Qet::East : + setOrientation(Qet::North); break; + case Qet::South : + setOrientation(Qet::East); break; + case Qet::West : + setOrientation(Qet::South); break; + } +} + /** @brief PartTerminal::setTerminalName diff --git a/sources/editor/graphicspart/partterminal.h b/sources/editor/graphicspart/partterminal.h index 76d3cad21..aae26dbee 100644 --- a/sources/editor/graphicspart/partterminal.h +++ b/sources/editor/graphicspart/partterminal.h @@ -78,6 +78,8 @@ class PartTerminal : public CustomElementGraphicPart qreal rotation() const; void flip(); void mirror(); + void nextOrientation(); + void previousOrientation(); QString terminalName() const { return d -> m_name; }