mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 14:50:53 +01:00
Moving elements with keyboard arrows scrolls editor and expands scene to right or below the editor. Element movement to the left and above the editor is impeded. Plus and Minus buttons zoom in and out of the editor.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@4549 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -235,11 +235,28 @@ void Diagram::keyPressEvent(QKeyEvent *e)
|
||||
bool transmit_event = true;
|
||||
if (!isReadOnly()) {
|
||||
QPointF movement;
|
||||
qreal top_position = 0;
|
||||
qreal left_position = 0;
|
||||
QList<Element*> selected_elmts = this->selectedContent().elements.toList();
|
||||
if (!this->selectedContent().elements.isEmpty()) {
|
||||
switch(e -> key()) {
|
||||
case Qt::Key_Left: movement = QPointF(-xGrid, 0.0); break;
|
||||
case Qt::Key_Left:
|
||||
foreach (QGraphicsItem *item, selected_elmts) {
|
||||
left_position = item->mapRectFromScene(item->boundingRect()).x();
|
||||
if (left_position >= this->sceneRect().left() - item->boundingRect().width())
|
||||
return;
|
||||
}
|
||||
movement = QPointF(-xGrid, 0.0);
|
||||
break;
|
||||
case Qt::Key_Right: movement = QPointF(+xGrid, 0.0); break;
|
||||
case Qt::Key_Up: movement = QPointF(0.0, -yGrid); break;
|
||||
case Qt::Key_Up:
|
||||
foreach (QGraphicsItem *item, selected_elmts) {
|
||||
top_position = item->mapRectFromScene(item->boundingRect()).y();
|
||||
if (top_position >= this->sceneRect().top() - item->boundingRect().height())
|
||||
return;
|
||||
}
|
||||
movement = QPointF(0.0, -yGrid);
|
||||
break;
|
||||
case Qt::Key_Down: movement = QPointF(0.0, +yGrid); break;
|
||||
}
|
||||
if (!movement.isNull() && !focusItem()) {
|
||||
|
||||
Reference in New Issue
Block a user