mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 16:20:52 +01:00
Nettoyage de la correction du conflit sur la touche Suppr (cf commit 154) git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@171 bfdf4180-ca20-0410-9c96-a3a8aa849046
50 lines
1.4 KiB
C++
50 lines
1.4 KiB
C++
#include "diagramtextitem.h"
|
|
#include "diagramcommands.h"
|
|
|
|
/**
|
|
Constructeur
|
|
@param parent Le QGraphicsItem parent du champ de texte
|
|
@param scene La scene a laquelle appartient le champ de texte
|
|
*/
|
|
DiagramTextItem::DiagramTextItem(QGraphicsItem *parent, QGraphicsScene *scene) :
|
|
QGraphicsTextItem(parent, scene)
|
|
{
|
|
setTextInteractionFlags(Qt::TextEditorInteraction);
|
|
}
|
|
|
|
/**
|
|
Constructeur
|
|
@param parent Le QGraphicsItem parent du champ de texte
|
|
@param scene La scene a laquelle appartient le champ de texte
|
|
@param text Le texte affiche par le champ de texte
|
|
*/
|
|
DiagramTextItem::DiagramTextItem(const QString &text, QGraphicsItem *parent, QGraphicsScene *scene) :
|
|
QGraphicsTextItem(text, parent, scene),
|
|
previous_text(text)
|
|
{
|
|
setTextInteractionFlags(Qt::TextEditorInteraction);
|
|
}
|
|
|
|
/// Destructeur
|
|
DiagramTextItem::~DiagramTextItem() {
|
|
}
|
|
|
|
/// @return le Diagram auquel ce texte appartient, ou 0 si ce texte est independant
|
|
Diagram *DiagramTextItem::diagram() const {
|
|
return(qobject_cast<Diagram *>(scene()));
|
|
}
|
|
|
|
/**
|
|
gere la perte de focus du champ de texte
|
|
*/
|
|
void DiagramTextItem::focusOutEvent(QFocusEvent *e) {
|
|
QGraphicsTextItem::focusOutEvent(e);
|
|
// si le texte a ete modifie
|
|
if (toPlainText() != previous_text) {
|
|
if (Diagram *dia = diagram()) {
|
|
dia -> undoStack().push(new ChangeDiagramTextCommand(this, previous_text, toPlainText()));
|
|
previous_text = toPlainText();
|
|
}
|
|
}
|
|
}
|