mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 23:20:52 +01:00
Suppr est desormais le raccourci clavier pour supprimer du texte ou des elements, sans conflit, dans l'editeur de schemas comme dans l'editeur d'elements. DEL/LED renommee en Voyant/Indicator. git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@154 bfdf4180-ca20-0410-9c96-a3a8aa849046
59 lines
1.6 KiB
C++
59 lines
1.6 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();
|
|
}
|
|
}
|
|
}
|
|
|
|
void DiagramTextItem::keyReleaseEvent(QKeyEvent *e) {
|
|
if (e -> key() == Qt::Key_Delete) {
|
|
QTextCursor text_cursor = textCursor();
|
|
text_cursor.deleteChar();
|
|
setTextCursor(text_cursor);
|
|
}
|
|
QGraphicsTextItem::keyReleaseEvent(e);
|
|
}
|