mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 13:30:34 +01:00
Ajout de methodes pour aider au debuggage des champs de texte dans l'editeur
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/branches/0.3@743 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -240,3 +240,44 @@ QRectF PartText::boundingRect() const {
|
|||||||
bool PartText::isUseless() const {
|
bool PartText::isUseless() const {
|
||||||
return(toPlainText().isEmpty());
|
return(toPlainText().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Dessine le texte statique.
|
||||||
|
@param painter QPainter a utiliser pour effectuer le rendu
|
||||||
|
@param qsogi Pptions de dessin
|
||||||
|
@param widget Widget sur lequel on dessine (facultatif)
|
||||||
|
*/
|
||||||
|
void PartText::paint(QPainter *painter, const QStyleOptionGraphicsItem *qsogi, QWidget *widget) {
|
||||||
|
QGraphicsTextItem::paint(painter, qsogi, widget);
|
||||||
|
|
||||||
|
#ifdef QET_DEBUG_EDITOR_TEXTS
|
||||||
|
painter -> setPen(Qt::blue);
|
||||||
|
painter -> drawRect(boundingRect());
|
||||||
|
|
||||||
|
painter -> setPen(Qt::red);
|
||||||
|
drawPoint(painter, QPointF(0, 0));
|
||||||
|
|
||||||
|
painter -> setPen(Qt::green);
|
||||||
|
drawPoint(painter, mapFromScene(pos()));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef QET_DEBUG_EDITOR_TEXTS
|
||||||
|
/**
|
||||||
|
Dessine deux petites fleches pour mettre un point en valeur
|
||||||
|
@param painter QPainter a utiliser pour effectuer le rendu
|
||||||
|
@param point Point a dessiner
|
||||||
|
*/
|
||||||
|
void PartText::drawPoint(QPainter *painter, const QPointF &point) {
|
||||||
|
qreal px = point.x();
|
||||||
|
qreal py = point.y();
|
||||||
|
qreal size_1 = 5.0;
|
||||||
|
qreal size_2 = 1.0;
|
||||||
|
painter -> drawLine(px, py, px + size_1, py);
|
||||||
|
painter -> drawLine(px + size_1 - size_2, py - size_2, px + size_1, py);
|
||||||
|
painter -> drawLine(px + size_1 - size_2, py + size_2, px + size_1, py);
|
||||||
|
painter -> drawLine(px, py, px, py + size_1);
|
||||||
|
painter -> drawLine(px, py + size_1, px - size_2, py + size_1 - size_2);
|
||||||
|
painter -> drawLine(px, py + size_1, px + size_2, py + size_1 - size_2);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ class PartText : public QGraphicsTextItem, public CustomElementPart {
|
|||||||
virtual void setProperty(const QString &, const QVariant &);
|
virtual void setProperty(const QString &, const QVariant &);
|
||||||
virtual QVariant property(const QString &);
|
virtual QVariant property(const QString &);
|
||||||
virtual bool isUseless() const;
|
virtual bool isUseless() const;
|
||||||
|
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0 );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void focusOutEvent(QFocusEvent *);
|
virtual void focusOutEvent(QFocusEvent *);
|
||||||
@@ -63,6 +64,9 @@ class PartText : public QGraphicsTextItem, public CustomElementPart {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QPointF margin() const;
|
QPointF margin() const;
|
||||||
|
#ifdef QET_DEBUG_EDITOR_TEXTS
|
||||||
|
void drawPoint(QPainter *, const QPointF &);
|
||||||
|
#endif
|
||||||
QString previous_text;
|
QString previous_text;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -266,3 +266,44 @@ QRectF PartTextField::boundingRect() const {
|
|||||||
bool PartTextField::isUseless() const {
|
bool PartTextField::isUseless() const {
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Dessine le texte statique.
|
||||||
|
@param painter QPainter a utiliser pour effectuer le rendu
|
||||||
|
@param qsogi Pptions de dessin
|
||||||
|
@param widget Widget sur lequel on dessine (facultatif)
|
||||||
|
*/
|
||||||
|
void PartTextField::paint(QPainter *painter, const QStyleOptionGraphicsItem *qsogi, QWidget *qw) {
|
||||||
|
QGraphicsTextItem::paint(painter, qsogi, qw);
|
||||||
|
|
||||||
|
#ifdef QET_DEBUG_EDITOR_TEXTS
|
||||||
|
painter -> setPen(Qt::blue);
|
||||||
|
painter -> drawRect(boundingRect());
|
||||||
|
|
||||||
|
painter -> setPen(Qt::red);
|
||||||
|
drawPoint(painter, QPointF(0, 0));
|
||||||
|
|
||||||
|
painter -> setPen(Qt::green);
|
||||||
|
drawPoint(painter, mapFromScene(pos()));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef QET_DEBUG_EDITOR_TEXTS
|
||||||
|
/**
|
||||||
|
Dessine deux petites fleches pour mettre un point en valeur
|
||||||
|
@param painter QPainter a utiliser pour effectuer le rendu
|
||||||
|
@param point Point a dessiner
|
||||||
|
*/
|
||||||
|
void PartTextField::drawPoint(QPainter *painter, const QPointF &point) {
|
||||||
|
qreal px = point.x();
|
||||||
|
qreal py = point.y();
|
||||||
|
qreal size_1 = 5.0;
|
||||||
|
qreal size_2 = 1.0;
|
||||||
|
painter -> drawLine(px, py, px + size_1, py);
|
||||||
|
painter -> drawLine(px + size_1 - size_2, py - size_2, px + size_1, py);
|
||||||
|
painter -> drawLine(px + size_1 - size_2, py + size_2, px + size_1, py);
|
||||||
|
painter -> drawLine(px, py, px, py + size_1);
|
||||||
|
painter -> drawLine(px, py + size_1, px - size_2, py + size_1 - size_2);
|
||||||
|
painter -> drawLine(px, py + size_1, px + size_2, py + size_1 - size_2);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ class PartTextField : public QGraphicsTextItem, public CustomElementPart {
|
|||||||
virtual void setProperty(const QString &, const QVariant &);
|
virtual void setProperty(const QString &, const QVariant &);
|
||||||
virtual QVariant property(const QString &);
|
virtual QVariant property(const QString &);
|
||||||
virtual bool isUseless() const;
|
virtual bool isUseless() const;
|
||||||
|
virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0 );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void focusOutEvent(QFocusEvent *);
|
virtual void focusOutEvent(QFocusEvent *);
|
||||||
@@ -69,6 +70,9 @@ class PartTextField : public QGraphicsTextItem, public CustomElementPart {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QPointF margin() const;
|
QPointF margin() const;
|
||||||
|
#ifdef QET_DEBUG_EDITOR_TEXTS
|
||||||
|
void drawPoint(QPainter *, const QPointF &);
|
||||||
|
#endif
|
||||||
QString previous_text;
|
QString previous_text;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user