mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 14:50:53 +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
|
// ajout du champ de texte editable
|
||||||
text_item = new DiagramTextItem();
|
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 -> setFlag(QGraphicsItem::ItemIsMovable, false);
|
||||||
text_item -> setTextInteractionFlags(Qt::TextEditorInteraction);
|
|
||||||
text_item -> setPlainText(properties_.text);
|
text_item -> setPlainText(properties_.text);
|
||||||
text_item -> previous_text = properties_.text;
|
text_item -> previous_text = properties_.text;
|
||||||
calculateTextItemPosition();
|
calculateTextItemPosition();
|
||||||
|
|||||||
@@ -112,12 +112,10 @@ void DiagramTextItem::focusOutEvent(QFocusEvent *e) {
|
|||||||
cursor.clearSelection();
|
cursor.clearSelection();
|
||||||
setTextCursor(cursor);
|
setTextCursor(cursor);
|
||||||
|
|
||||||
if (flags() & QGraphicsItem::ItemIsMovable) {
|
|
||||||
// hack a la con pour etre re-entrant
|
// hack a la con pour etre re-entrant
|
||||||
setTextInteractionFlags(Qt::NoTextInteraction);
|
setTextInteractionFlags(Qt::NoTextInteraction);
|
||||||
QTimer::singleShot(0, this, SIGNAL(lostFocus()));
|
QTimer::singleShot(0, this, SIGNAL(lostFocus()));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Permet de lire le texte a mettre dans le champ a partir d'un element XML.
|
Permet de lire le texte a mettre dans le champ a partir d'un element XML.
|
||||||
@@ -152,22 +150,12 @@ QDomElement DiagramTextItem::toXml(QDomDocument &document) const {
|
|||||||
@param event un QGraphicsSceneMouseEvent decrivant le double-clic
|
@param event un QGraphicsSceneMouseEvent decrivant le double-clic
|
||||||
*/
|
*/
|
||||||
void DiagramTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
|
void DiagramTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
|
||||||
if (flags() & QGraphicsItem::ItemIsMovable && !(textInteractionFlags() & Qt::TextEditable)) {
|
if (!(textInteractionFlags() & Qt::TextEditable)) {
|
||||||
// rend le champ de texte editable
|
// rend le champ de texte editable
|
||||||
setTextInteractionFlags(Qt::TextEditorInteraction);
|
setTextInteractionFlags(Qt::TextEditorInteraction);
|
||||||
|
|
||||||
// simule un clic simple, ce qui edite le champ de texte
|
// edite le champ de texte
|
||||||
QGraphicsSceneMouseEvent *mouseEvent = new QGraphicsSceneMouseEvent(QEvent::GraphicsSceneMousePress);
|
setFocus(Qt::MouseFocusReason);
|
||||||
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;
|
|
||||||
} else {
|
} else {
|
||||||
QGraphicsTextItem::mouseDoubleClickEvent(event);
|
QGraphicsTextItem::mouseDoubleClickEvent(event);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
/**
|
/**
|
||||||
Cette classe represente un champ de texte editable sur le schema.
|
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 {
|
class DiagramTextItem : public QGraphicsTextItem {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ ElementTextItem::ElementTextItem(QGraphicsItem *parent, QGraphicsScene *scene) :
|
|||||||
DiagramTextItem(parent, scene),
|
DiagramTextItem(parent, scene),
|
||||||
follow_parent_rotations(false)
|
follow_parent_rotations(false)
|
||||||
{
|
{
|
||||||
setFlags(QGraphicsItem::ItemIsSelectable);
|
// par defaut, les DiagramTextItem sont Selectable et Movable
|
||||||
setTextInteractionFlags(Qt::TextEditorInteraction);
|
// 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),
|
DiagramTextItem(text, parent, scene),
|
||||||
follow_parent_rotations(false)
|
follow_parent_rotations(false)
|
||||||
{
|
{
|
||||||
setFlags(QGraphicsItem::ItemIsSelectable);
|
// par defaut, les DiagramTextItem sont Selectable et Movable
|
||||||
setTextInteractionFlags(Qt::TextEditorInteraction);
|
// on desactive Movable pour les textes des elements
|
||||||
|
setFlag(QGraphicsItem::ItemIsMovable, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Destructeur
|
/// Destructeur
|
||||||
|
|||||||
Reference in New Issue
Block a user