[qet] [743] Ajout de methodes pour aider au debuggage des champs de texte dans l' editeur

[ Thread Index | Date Index | More lists.tuxfamily.org/qet Archives ]


Revision: 743
Author:   xavier
Date:     2009-08-26 01:25:28 +0200 (Wed, 26 Aug 2009)
Log Message:
-----------
Ajout de methodes pour aider au debuggage des champs de texte dans l'editeur

Modified Paths:
--------------
    branches/0.3/sources/editor/parttext.cpp
    branches/0.3/sources/editor/parttext.h
    branches/0.3/sources/editor/parttextfield.cpp
    branches/0.3/sources/editor/parttextfield.h

Modified: branches/0.3/sources/editor/parttext.cpp
===================================================================
--- branches/0.3/sources/editor/parttext.cpp	2009-08-20 20:43:51 UTC (rev 742)
+++ branches/0.3/sources/editor/parttext.cpp	2009-08-25 23:25:28 UTC (rev 743)
@@ -240,3 +240,44 @@
 bool PartText::isUseless() const {
 	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

Modified: branches/0.3/sources/editor/parttext.h
===================================================================
--- branches/0.3/sources/editor/parttext.h	2009-08-20 20:43:51 UTC (rev 742)
+++ branches/0.3/sources/editor/parttext.h	2009-08-25 23:25:28 UTC (rev 743)
@@ -54,6 +54,7 @@
 	virtual void setProperty(const QString &, const QVariant &);
 	virtual QVariant property(const QString &);
 	virtual bool isUseless() const;
+	virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0 );
 	
 	protected:
 	virtual void focusOutEvent(QFocusEvent *);
@@ -63,6 +64,9 @@
 	
 	private:
 	QPointF margin() const;
+#ifdef QET_DEBUG_EDITOR_TEXTS
+	void drawPoint(QPainter *, const QPointF &);
+#endif
 	QString previous_text;
 };
 #endif

Modified: branches/0.3/sources/editor/parttextfield.cpp
===================================================================
--- branches/0.3/sources/editor/parttextfield.cpp	2009-08-20 20:43:51 UTC (rev 742)
+++ branches/0.3/sources/editor/parttextfield.cpp	2009-08-25 23:25:28 UTC (rev 743)
@@ -266,3 +266,44 @@
 bool PartTextField::isUseless() const {
 	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

Modified: branches/0.3/sources/editor/parttextfield.h
===================================================================
--- branches/0.3/sources/editor/parttextfield.h	2009-08-20 20:43:51 UTC (rev 742)
+++ branches/0.3/sources/editor/parttextfield.h	2009-08-25 23:25:28 UTC (rev 743)
@@ -60,6 +60,7 @@
 	virtual void setProperty(const QString &, const QVariant &);
 	virtual QVariant property(const QString &);
 	virtual bool isUseless() const;
+	virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget * = 0 );
 	
 	protected:
 	virtual void focusOutEvent(QFocusEvent *);
@@ -69,6 +70,9 @@
 	
 	private:
 	QPointF margin() const;
+#ifdef QET_DEBUG_EDITOR_TEXTS
+	void drawPoint(QPainter *, const QPointF &);
+#endif
 	QString previous_text;
 };
 #endif


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/