mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Desormais, tous les champs de texte (elements, conducteurs, independants) reagissent de la meme facon :
* clic simple : selection * double clic : edition git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@809 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -81,8 +81,9 @@ Conductor::Conductor(Terminal *p1, Terminal* p2, Element *parent, QGraphicsScene
|
||||
|
||||
// ajout du champ de texte editable
|
||||
text_item = new DiagramTextItem();
|
||||
// par defaut, les DiagramTextItem sont Selectable et Movable
|
||||
// on desactive Movable pour les textes des conducteurs
|
||||
text_item -> setFlag(QGraphicsItem::ItemIsMovable, false);
|
||||
text_item -> setTextInteractionFlags(Qt::TextEditorInteraction);
|
||||
text_item -> setPlainText(properties_.text);
|
||||
text_item -> previous_text = properties_.text;
|
||||
calculateTextItemPosition();
|
||||
|
||||
@@ -112,11 +112,9 @@ void DiagramTextItem::focusOutEvent(QFocusEvent *e) {
|
||||
cursor.clearSelection();
|
||||
setTextCursor(cursor);
|
||||
|
||||
if (flags() & QGraphicsItem::ItemIsMovable) {
|
||||
// hack a la con pour etre re-entrant
|
||||
setTextInteractionFlags(Qt::NoTextInteraction);
|
||||
QTimer::singleShot(0, this, SIGNAL(lostFocus()));
|
||||
}
|
||||
// hack a la con pour etre re-entrant
|
||||
setTextInteractionFlags(Qt::NoTextInteraction);
|
||||
QTimer::singleShot(0, this, SIGNAL(lostFocus()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,22 +150,12 @@ QDomElement DiagramTextItem::toXml(QDomDocument &document) const {
|
||||
@param event un QGraphicsSceneMouseEvent decrivant le double-clic
|
||||
*/
|
||||
void DiagramTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
|
||||
if (flags() & QGraphicsItem::ItemIsMovable && !(textInteractionFlags() & Qt::TextEditable)) {
|
||||
if (!(textInteractionFlags() & Qt::TextEditable)) {
|
||||
// rend le champ de texte editable
|
||||
setTextInteractionFlags(Qt::TextEditorInteraction);
|
||||
|
||||
// simule un clic simple, ce qui edite le champ de texte
|
||||
QGraphicsSceneMouseEvent *mouseEvent = new QGraphicsSceneMouseEvent(QEvent::GraphicsSceneMousePress);
|
||||
mouseEvent -> setAccepted(true);
|
||||
mouseEvent -> setPos(event -> pos());
|
||||
mouseEvent -> setScenePos(event -> scenePos());
|
||||
mouseEvent -> setScreenPos(event -> screenPos());
|
||||
mouseEvent -> setButtonDownPos(Qt::LeftButton, event -> buttonDownPos(Qt::LeftButton));
|
||||
mouseEvent -> setButtonDownScreenPos(Qt::LeftButton, event -> buttonDownScreenPos(Qt::LeftButton));
|
||||
mouseEvent -> setButtonDownScenePos(Qt::LeftButton, event -> buttonDownScenePos(Qt::LeftButton));
|
||||
mouseEvent -> setWidget(event -> widget());
|
||||
QGraphicsTextItem::mousePressEvent(mouseEvent);
|
||||
delete mouseEvent;
|
||||
// edite le champ de texte
|
||||
setFocus(Qt::MouseFocusReason);
|
||||
} else {
|
||||
QGraphicsTextItem::mouseDoubleClickEvent(event);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
#include "diagram.h"
|
||||
/**
|
||||
Cette classe represente un champ de texte editable sur le schema.
|
||||
Par defaut, les DiagramTextItem sont Selectable et Movable.
|
||||
@see QGraphicsItem::GraphicsItemFlags
|
||||
*/
|
||||
class DiagramTextItem : public QGraphicsTextItem {
|
||||
Q_OBJECT
|
||||
|
||||
@@ -28,8 +28,9 @@ ElementTextItem::ElementTextItem(QGraphicsItem *parent, QGraphicsScene *scene) :
|
||||
DiagramTextItem(parent, scene),
|
||||
follow_parent_rotations(false)
|
||||
{
|
||||
setFlags(QGraphicsItem::ItemIsSelectable);
|
||||
setTextInteractionFlags(Qt::TextEditorInteraction);
|
||||
// par defaut, les DiagramTextItem sont Selectable et Movable
|
||||
// on desactive Movable pour les textes des elements
|
||||
setFlag(QGraphicsItem::ItemIsMovable, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,8 +43,9 @@ ElementTextItem::ElementTextItem(const QString &text, QGraphicsItem *parent, QGr
|
||||
DiagramTextItem(text, parent, scene),
|
||||
follow_parent_rotations(false)
|
||||
{
|
||||
setFlags(QGraphicsItem::ItemIsSelectable);
|
||||
setTextInteractionFlags(Qt::TextEditorInteraction);
|
||||
// par defaut, les DiagramTextItem sont Selectable et Movable
|
||||
// on desactive Movable pour les textes des elements
|
||||
setFlag(QGraphicsItem::ItemIsMovable, false);
|
||||
}
|
||||
|
||||
/// Destructeur
|
||||
|
||||
Reference in New Issue
Block a user