[Kst] branches/work/kst/portto4/kst/src/libkstapp

Adam Treat treat at kde.org
Sat Jun 9 01:02:25 CEST 2007


SVN commit 673082 by treat:

* Turn on debugging as I'm having a problem with
the drawing the true boundingRect.  Possibly a bug
with mapToScene()??



 M  +2 -2      labelitem.cpp  
 M  +6 -4      viewitem.cpp  
 M  +1 -1      viewitem.h  


--- branches/work/kst/portto4/kst/src/libkstapp/labelitem.cpp #673081:673082
@@ -40,11 +40,11 @@
   if (_parsed) {
     const qreal w = pen().widthF();
     painter->save();
-    QRect box = rect().adjusted(w, w, -w, -w).toRect();
+    QRectF box = rect().adjusted(w, w, -w, -w);
     QFont font;
     font.setPointSize(16);
     QFontMetrics fm(font);
-    painter->translate(QPoint(box.x(), box.y() + fm.ascent()));
+    painter->translate(QPointF(box.x(), box.y() + fm.ascent()));
     Label::RenderContext rc(font.family(), font.pointSize(), painter);
     Label::renderLabel(rc, _parsed->chunk);
 
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.cpp #673081:673082
@@ -50,16 +50,18 @@
 
 
 void ViewItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
+  QRectF bound = mapToScene(boundingRect()).boundingRect();
+  painter->save();
+  painter->resetTransform();
+//   painter->drawRect(bound);
 
 #ifdef DEBUG_GEOMETRY
   QColor semiRed(QColor(255, 0, 0, 50));
-  painter->save();
-  painter->resetTransform();
-  QRectF bound = mapToScene(boundingRect()).boundingRect();
   painter->fillRect(bound, semiRed);
-  painter->restore();
 #endif
 
+  painter->restore();
+
   QGraphicsRectItem::paint(painter, option, widget);
 }
 
--- branches/work/kst/portto4/kst/src/libkstapp/viewitem.h #673081:673082
@@ -19,7 +19,7 @@
 #include "viewcommand.h"
 #include "view.h" //forward declare, but enums??
 
-// #define DEBUG_GEOMETRY
+#define DEBUG_GEOMETRY
 
 namespace Kst {
 


More information about the Kst mailing list