[Uml-devel] KDE/kdesdk/umbrello/umbrello/widgets

Oliver Kellogg okellogg at users.sourceforge.net
Wed Mar 21 19:19:21 UTC 2012


SVN commit 1286610 by okellogg:

Address https://bugs.kde.org/show_bug.cgi?id=296331#c5 as follows:

StateWidget::paint (case {Deep,Shallow}History):
- Consider font metrics in calculation of drawText() x and y args.

StateWidget::minimumSize (case {Deep,Shallow}History):
- Set width and height to active QFontMetrics::lineSpacing().

StateWidget::maximumSize (case {Deep,Shallow}History):
- Allow for enlarging to active QFontMetrics::lineSpacing() + 10.

CCBUG: 296331


 M  +29 -7     statewidget.cpp  


--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/statewidget.cpp #1286609:1286610
@@ -139,8 +139,15 @@
             p.setBrush(Qt::white);
             p.drawEllipse(rect());
             p.setPen(Qt::black);
-            p.drawText(rect().x() +  3, rect().y() + 13, "H");
-            p.drawText(rect().x() + 11, rect().y() + 12, "*");
+            p.setFont( UMLWidget::font() );
+            const QFontMetrics &fm = getFontMetrics(FT_NORMAL);
+            const int fontHeight  = fm.lineSpacing() / 2;
+            const int xStar = fm.boundingRect("H").width();
+            const int yStar = fontHeight / 4;
+            p.drawText(offsetX + (w / 6),
+                       offsetY + (h / 4) + fontHeight, "H");
+            p.drawText(offsetX + (w / 6) + xStar,
+                       offsetY + (h / 4) + fontHeight - yStar, "*");
         }
         break;
     case StateWidget::ShallowHistory:
@@ -148,7 +155,11 @@
             p.setBrush(Qt::white);
             p.drawEllipse(rect());
             p.setPen(Qt::black);
-            p.drawText(rect().x() + 5, rect().y() + 13, "H");
+            p.setFont( UMLWidget::font() );
+            const QFontMetrics &fm = getFontMetrics(FT_NORMAL);
+            const int fontHeight  = fm.lineSpacing() / 2;
+            p.drawText(offsetX + (w / 6),
+                       offsetY + (h / 4) + fontHeight, "H");
         }
         break;
     case StateWidget::Choice:
@@ -214,11 +225,16 @@
             }
             break;
         case StateWidget::Junction:
-        case StateWidget::DeepHistory:
-        case StateWidget::ShallowHistory:
             width = 18;
             height = 18;
             break;
+        case StateWidget::DeepHistory:
+        case StateWidget::ShallowHistory:
+            {
+                const QFontMetrics &fm = getFontMetrics(FT_NORMAL);
+                width = height = fm.lineSpacing();
+            }
+            break;
         case StateWidget::Choice:
             width = 25;
             height = 25;
@@ -239,11 +255,17 @@
         case StateWidget::Initial:
         case StateWidget::End:
         case StateWidget::Junction:
-        case StateWidget::DeepHistory:
-        case StateWidget::ShallowHistory:
         case StateWidget::Choice:
             return UMLSceneSize(35, 35);
             break;
+        case StateWidget::DeepHistory:
+        case StateWidget::ShallowHistory:
+            {
+                const QFontMetrics &fm = getFontMetrics(FT_NORMAL);
+                const int fontHeight  = fm.lineSpacing();
+                return UMLSceneSize(fontHeight + 10, fontHeight + 10);
+            }
+            break;
         default:
             break;
     }




More information about the umbrello-devel mailing list