mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-20 08:10:52 +01:00
La position des textes dans l'editeur d'element est desormais ajustee lorsqu'on change leur taille de police.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@841 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -63,6 +63,7 @@ void PartText::fromXml(const QDomElement &xml_element) {
|
|||||||
xml_element.attribute("x").toDouble(),
|
xml_element.attribute("x").toDouble(),
|
||||||
xml_element.attribute("y").toDouble()
|
xml_element.attribute("y").toDouble()
|
||||||
);
|
);
|
||||||
|
known_position_ = pos();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -195,6 +196,7 @@ void PartText::setProperty(const QString &property, const QVariant &value) {
|
|||||||
} else if (property == "size") {
|
} else if (property == "size") {
|
||||||
if (!value.canConvert(QVariant::Int)) return;
|
if (!value.canConvert(QVariant::Int)) return;
|
||||||
setFont(QETApp::diagramTextsFont(value.toInt()));
|
setFont(QETApp::diagramTextsFont(value.toInt()));
|
||||||
|
adjustItemPosition(0);
|
||||||
} else if (property == "text") {
|
} else if (property == "text") {
|
||||||
setPlainText(value.toString());
|
setPlainText(value.toString());
|
||||||
}
|
}
|
||||||
@@ -229,8 +231,13 @@ QVariant PartText::property(const QString &property) {
|
|||||||
@param value Valeur numerique relative au changement
|
@param value Valeur numerique relative au changement
|
||||||
*/
|
*/
|
||||||
QVariant PartText::itemChange(GraphicsItemChange change, const QVariant &value) {
|
QVariant PartText::itemChange(GraphicsItemChange change, const QVariant &value) {
|
||||||
if (scene()) {
|
if (change == QGraphicsItem::ItemPositionHasChanged || change == QGraphicsItem::ItemSceneHasChanged) {
|
||||||
if (change == QGraphicsItem::ItemPositionChange || change == QGraphicsItem::ItemSelectedChange) {
|
// memorise la nouvelle position "officielle" du champ de texte
|
||||||
|
// cette information servira a le recentrer en cas d'ajout / retrait de lignes
|
||||||
|
known_position_ = pos();
|
||||||
|
infos -> updateForm();
|
||||||
|
} else if (change == QGraphicsItem::ItemSelectedHasChanged) {
|
||||||
|
if (value.toBool() == true) {
|
||||||
infos -> updateForm();
|
infos -> updateForm();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -276,6 +283,18 @@ void PartText::paint(QPainter *painter, const QStyleOptionGraphicsItem *qsogi, Q
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Cette methode s'assure que la position du champ de texte est coherente
|
||||||
|
en repositionnant son origine (c-a-d le milieu du bord gauche du champ de
|
||||||
|
texte) a la position originale. Cela est notamment utile lorsque le champ
|
||||||
|
de texte est agrandi ou retreci verticalement (ajout ou retrait de lignes).
|
||||||
|
@param new_block_count Nombre de blocs dans le PartText
|
||||||
|
*/
|
||||||
|
void PartText::adjustItemPosition(int new_block_count) {
|
||||||
|
Q_UNUSED(new_block_count);
|
||||||
|
setPos(known_position_);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef QET_DEBUG_EDITOR_TEXTS
|
#ifdef QET_DEBUG_EDITOR_TEXTS
|
||||||
/**
|
/**
|
||||||
Dessine deux petites fleches pour mettre un point en valeur
|
Dessine deux petites fleches pour mettre un point en valeur
|
||||||
|
|||||||
@@ -56,6 +56,9 @@ class PartText : public QGraphicsTextItem, public CustomElementPart {
|
|||||||
virtual bool isUseless() const;
|
virtual bool isUseless() const;
|
||||||
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0 );
|
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0 );
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void adjustItemPosition(int);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void focusOutEvent(QFocusEvent *);
|
virtual void focusOutEvent(QFocusEvent *);
|
||||||
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *);
|
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *);
|
||||||
@@ -68,5 +71,6 @@ class PartText : public QGraphicsTextItem, public CustomElementPart {
|
|||||||
void drawPoint(QPainter *, const QPointF &);
|
void drawPoint(QPainter *, const QPointF &);
|
||||||
#endif
|
#endif
|
||||||
QString previous_text;
|
QString previous_text;
|
||||||
|
QPointF known_position_;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -242,6 +242,7 @@ void PartTextField::setProperty(const QString &property, const QVariant &value)
|
|||||||
} else if (property == "size") {
|
} else if (property == "size") {
|
||||||
if (!value.canConvert(QVariant::Int)) return;
|
if (!value.canConvert(QVariant::Int)) return;
|
||||||
setFont(QETApp::diagramTextsFont(value.toInt()));
|
setFont(QETApp::diagramTextsFont(value.toInt()));
|
||||||
|
adjustItemPosition(0);
|
||||||
} else if (property == "text") {
|
} else if (property == "text") {
|
||||||
setPlainText(value.toString());
|
setPlainText(value.toString());
|
||||||
} else if (property == "rotation angle") {
|
} else if (property == "rotation angle") {
|
||||||
@@ -343,7 +344,7 @@ void PartTextField::paint(QPainter *painter, const QStyleOptionGraphicsItem *qso
|
|||||||
en repositionnant son origine (c-a-d le milieu du bord gauche du champ de
|
en repositionnant son origine (c-a-d le milieu du bord gauche du champ de
|
||||||
texte) a la position originale. Cela est notamment utile lorsque le champ
|
texte) a la position originale. Cela est notamment utile lorsque le champ
|
||||||
de texte est agrandi ou retreci verticalement (ajout ou retrait de lignes).
|
de texte est agrandi ou retreci verticalement (ajout ou retrait de lignes).
|
||||||
@param new_bloc_count Nombre de blocs dans l'ElementTextItem
|
@param new_block_count Nombre de blocs dans le PartTextField
|
||||||
*/
|
*/
|
||||||
void PartTextField::adjustItemPosition(int new_block_count) {
|
void PartTextField::adjustItemPosition(int new_block_count) {
|
||||||
Q_UNUSED(new_block_count);
|
Q_UNUSED(new_block_count);
|
||||||
|
|||||||
Reference in New Issue
Block a user