mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 20:50:34 +01:00
Retour arriere sur l'utilisation de QGraphicsItem::ItemSceneHasChanged pour detecter les changements de QGraphicsScene.
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@983 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -40,7 +40,6 @@ Conductor::Conductor(Terminal *p1, Terminal* p2, Diagram *parent_diagram) :
|
|||||||
QGraphicsPathItem(0, parent_diagram),
|
QGraphicsPathItem(0, parent_diagram),
|
||||||
terminal1(p1),
|
terminal1(p1),
|
||||||
terminal2(p2),
|
terminal2(p2),
|
||||||
parent_diagram_(parent_diagram),
|
|
||||||
destroyed(false),
|
destroyed(false),
|
||||||
text_item(0),
|
text_item(0),
|
||||||
segments(NULL),
|
segments(NULL),
|
||||||
@@ -543,7 +542,7 @@ void Conductor::destroy() {
|
|||||||
|
|
||||||
/// @return le Diagram auquel ce conducteur appartient, ou 0 si ce conducteur est independant
|
/// @return le Diagram auquel ce conducteur appartient, ou 0 si ce conducteur est independant
|
||||||
Diagram *Conductor::diagram() const {
|
Diagram *Conductor::diagram() const {
|
||||||
return(parent_diagram_);
|
return(qobject_cast<Diagram *>(scene()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -746,10 +745,6 @@ QVariant Conductor::itemChange(GraphicsItemChange change, const QVariant &value)
|
|||||||
setZValue(previous_z_value);
|
setZValue(previous_z_value);
|
||||||
}
|
}
|
||||||
} else if (change == QGraphicsItem::ItemSceneHasChanged) {
|
} else if (change == QGraphicsItem::ItemSceneHasChanged) {
|
||||||
// prend en compte le changement de schema
|
|
||||||
QGraphicsScene *qgscene = value.value<QGraphicsScene *>();
|
|
||||||
parent_diagram_ = static_cast<Diagram *>(qgscene);
|
|
||||||
|
|
||||||
// permet de positionner correctement le texte du conducteur lors de son ajout a un schema
|
// permet de positionner correctement le texte du conducteur lors de son ajout a un schema
|
||||||
calculateTextItemPosition();
|
calculateTextItemPosition();
|
||||||
} else if (change == QGraphicsItem::ItemVisibleHasChanged) {
|
} else if (change == QGraphicsItem::ItemVisibleHasChanged) {
|
||||||
|
|||||||
@@ -96,8 +96,6 @@ class Conductor : public QObject, public QGraphicsPathItem {
|
|||||||
virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
|
virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Schema auquel ce conducteur est rattache
|
|
||||||
Diagram *parent_diagram_;
|
|
||||||
/// caracteristiques du conducteur
|
/// caracteristiques du conducteur
|
||||||
ConductorProperties properties_;
|
ConductorProperties properties_;
|
||||||
/// booleen indiquant si le fil est encore valide
|
/// booleen indiquant si le fil est encore valide
|
||||||
|
|||||||
@@ -27,7 +27,6 @@
|
|||||||
*/
|
*/
|
||||||
DiagramTextItem::DiagramTextItem(QGraphicsItem *parent, Diagram *parent_diagram) :
|
DiagramTextItem::DiagramTextItem(QGraphicsItem *parent, Diagram *parent_diagram) :
|
||||||
QGraphicsTextItem(parent, parent_diagram),
|
QGraphicsTextItem(parent, parent_diagram),
|
||||||
parent_diagram_(parent_diagram),
|
|
||||||
previous_text_(),
|
previous_text_(),
|
||||||
rotation_angle_(0.0)
|
rotation_angle_(0.0)
|
||||||
{
|
{
|
||||||
@@ -48,7 +47,6 @@ DiagramTextItem::DiagramTextItem(QGraphicsItem *parent, Diagram *parent_diagram)
|
|||||||
*/
|
*/
|
||||||
DiagramTextItem::DiagramTextItem(const QString &text, QGraphicsItem *parent, Diagram *parent_diagram) :
|
DiagramTextItem::DiagramTextItem(const QString &text, QGraphicsItem *parent, Diagram *parent_diagram) :
|
||||||
QGraphicsTextItem(text, parent, parent_diagram),
|
QGraphicsTextItem(text, parent, parent_diagram),
|
||||||
parent_diagram_(parent_diagram),
|
|
||||||
previous_text_(text),
|
previous_text_(text),
|
||||||
rotation_angle_(0.0)
|
rotation_angle_(0.0)
|
||||||
{
|
{
|
||||||
@@ -70,7 +68,7 @@ DiagramTextItem::~DiagramTextItem() {
|
|||||||
rattache a aucun schema
|
rattache a aucun schema
|
||||||
*/
|
*/
|
||||||
Diagram *DiagramTextItem::diagram() const {
|
Diagram *DiagramTextItem::diagram() const {
|
||||||
return(parent_diagram_);
|
return(qobject_cast<Diagram *>(scene()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -180,19 +178,6 @@ QPointF DiagramTextItem::mapMovementFromParent(const QPointF &movement) const {
|
|||||||
return(local_movement_point - local_origin);
|
return(local_movement_point - local_origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
Gere les changements dont ce champ de texte est informe
|
|
||||||
@param change Type de changement
|
|
||||||
@param value Valeur relative au changement
|
|
||||||
*/
|
|
||||||
QVariant DiagramTextItem::itemChange(GraphicsItemChange change, const QVariant &value) {
|
|
||||||
if (change == QGraphicsItem::ItemSceneHasChanged) {
|
|
||||||
QGraphicsScene *qgscene = value.value<QGraphicsScene *>();
|
|
||||||
parent_diagram_ = static_cast<Diagram *>(qgscene);
|
|
||||||
}
|
|
||||||
return(QGraphicsTextItem::itemChange(change, value));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Gere la prise de focus du champ de texte
|
Gere la prise de focus du champ de texte
|
||||||
@param e Objet decrivant la prise de focus
|
@param e Objet decrivant la prise de focus
|
||||||
|
|||||||
@@ -58,7 +58,6 @@ class DiagramTextItem : public QGraphicsTextItem {
|
|||||||
QPointF mapMovementFromParent(const QPointF &) const;
|
QPointF mapMovementFromParent(const QPointF &) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual QVariant itemChange(GraphicsItemChange, const QVariant &);
|
|
||||||
virtual void focusInEvent(QFocusEvent *);
|
virtual void focusInEvent(QFocusEvent *);
|
||||||
virtual void focusOutEvent(QFocusEvent *);
|
virtual void focusOutEvent(QFocusEvent *);
|
||||||
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *);
|
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *);
|
||||||
@@ -80,8 +79,6 @@ class DiagramTextItem : public QGraphicsTextItem {
|
|||||||
|
|
||||||
// attributs prives
|
// attributs prives
|
||||||
private:
|
private:
|
||||||
/// Schema auquel ce texte est rattache
|
|
||||||
Diagram *parent_diagram_;
|
|
||||||
/// Texte precedent
|
/// Texte precedent
|
||||||
QString previous_text_;
|
QString previous_text_;
|
||||||
/// angle de rotation du champ de texte
|
/// angle de rotation du champ de texte
|
||||||
|
|||||||
Reference in New Issue
Block a user