mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-21 08:40:53 +01:00
ElementEditor: decorator: got rid of calls to grabKeyboard()
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2030 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -107,7 +107,9 @@ void ElementPrimitiveDecorator::setItems(const QList<CustomElementPart *> &items
|
||||
end_setItems:
|
||||
adjust();
|
||||
show();
|
||||
grabKeyboard();
|
||||
if (focusItem() != this) {
|
||||
setFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -347,7 +349,7 @@ void ElementPrimitiveDecorator::keyPressEvent(QKeyEvent *e) {
|
||||
case Qt::Key_Up: movement = QPointF(0.0, -movement_length); break;
|
||||
case Qt::Key_Down: movement = QPointF(0.0, +movement_length); break;
|
||||
}
|
||||
if (!movement.isNull() && !focusItem()) {
|
||||
if (!movement.isNull() && focusItem() == this) {
|
||||
if (!moving_by_keys_) {
|
||||
moving_by_keys_ = true;
|
||||
keys_movement_ = movement;
|
||||
@@ -385,7 +387,7 @@ void ElementPrimitiveDecorator::keyReleaseEvent(QKeyEvent *e) {
|
||||
Initialize an ElementPrimitiveDecorator
|
||||
*/
|
||||
void ElementPrimitiveDecorator::init() {
|
||||
//setAcceptedMouseButtons(Qt::LeftButton);
|
||||
setFlag(QGraphicsItem::ItemIsFocusable, true);
|
||||
grid_step_x_ = grid_step_y_ = 1;
|
||||
setAcceptHoverEvents(true);
|
||||
}
|
||||
@@ -414,7 +416,6 @@ void ElementPrimitiveDecorator::startMovement() {
|
||||
adjust();
|
||||
|
||||
foreach(CustomElementPart *item, decorated_items_) {
|
||||
qDebug() << Q_FUNC_INFO << "starting movement with rect" << original_bounding_rect_ << "i.e. in scene coordinates " << mapToScene(original_bounding_rect_).boundingRect();
|
||||
item -> startUserTransformation(mapToScene(original_bounding_rect_).boundingRect());
|
||||
}
|
||||
}
|
||||
@@ -497,8 +498,6 @@ void ElementPrimitiveDecorator::scaleItems(const QRectF &original_rect, const QR
|
||||
|
||||
QRectF scene_original_rect = mapToScene(original_rect).boundingRect();
|
||||
QRectF scene_new_rect = mapToScene(new_rect).boundingRect();
|
||||
qDebug() << Q_FUNC_INFO << "from " << original_rect << " to " << new_rect;
|
||||
qDebug() << Q_FUNC_INFO << "from " << scene_original_rect << " to " << scene_new_rect << "(scene coordinates)";
|
||||
|
||||
foreach(CustomElementPart *item, decorated_items_) {
|
||||
item -> handleUserTransformation(scene_original_rect, scene_new_rect);
|
||||
|
||||
@@ -178,6 +178,20 @@ void PartText::focusOutEvent(QFocusEvent *e) {
|
||||
endEdition();
|
||||
}
|
||||
|
||||
/**
|
||||
@reimp QGraphicsTextItem::keyPressEvent()
|
||||
Used to handle the escape key when the event is delivered to the field, not
|
||||
to the decorator.
|
||||
*/
|
||||
void PartText::keyPressEvent(QKeyEvent *event) {
|
||||
if (event -> key() == Qt::Key_Escape) {
|
||||
endEdition();
|
||||
}
|
||||
else {
|
||||
QGraphicsTextItem::keyPressEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Permet a l'element texte de devenir editable lorsqu'on double-clique dessus
|
||||
@param e Le QGraphicsSceneMouseEvent qui decrit le double-clic
|
||||
|
||||
@@ -78,6 +78,7 @@ class PartText : public QGraphicsTextItem, public CustomElementPart {
|
||||
virtual bool sceneEventFilter(QGraphicsItem *, QEvent *);
|
||||
virtual void focusInEvent(QFocusEvent *);
|
||||
virtual void focusOutEvent(QFocusEvent *);
|
||||
virtual void keyPressEvent(QKeyEvent *);
|
||||
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *);
|
||||
virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
|
||||
QRectF boundingRect() const;
|
||||
|
||||
@@ -220,6 +220,20 @@ void PartTextField::focusOutEvent(QFocusEvent *e) {
|
||||
endEdition();
|
||||
}
|
||||
|
||||
/**
|
||||
@reimp QGraphicsTextItem::keyPressEvent()
|
||||
Used to handle the escape key when the event is delivered to the field, not
|
||||
to the decorator.
|
||||
*/
|
||||
void PartTextField::keyPressEvent(QKeyEvent *event) {
|
||||
if (event -> key() == Qt::Key_Escape) {
|
||||
endEdition();
|
||||
}
|
||||
else {
|
||||
QGraphicsTextItem::keyPressEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Permet a l'element texte de devenir editable lorsqu'on double-clique dessus
|
||||
@param e Le QGraphicsSceneMouseEvent qui decrit le double-clic
|
||||
|
||||
@@ -84,6 +84,7 @@ class PartTextField : public QGraphicsTextItem, public CustomElementPart {
|
||||
virtual bool sceneEventFilter(QGraphicsItem *, QEvent *);
|
||||
virtual void focusInEvent(QFocusEvent *);
|
||||
virtual void focusOutEvent(QFocusEvent *);
|
||||
virtual void keyPressEvent(QKeyEvent *);
|
||||
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *);
|
||||
virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
|
||||
QRectF boundingRect() const;
|
||||
|
||||
Reference in New Issue
Block a user