[Uml-devel] KDE/kdesdk/umbrello/umbrello/widgets
Ralf Habacker
ralf.habacker at gmail.com
Thu Jun 7 21:21:18 UTC 2012
SVN commit 1298923 by habacker:
Separated minimum size calculation from content related to fix issues with widget construction size.
BUG:152757
M +36 -1 notewidget.cpp
M +1 -0 notewidget.h
M +15 -1 umlwidget.cpp
M +2 -0 umlwidget.h
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/notewidget.cpp #1298922:1298923
@@ -298,8 +298,43 @@
width = textWidth > widthtemp ? textWidth : widthtemp;
width += 10;
}
+ return UMLSceneSize(width, height);
+}
+
+/**
+ * Overrides method from UMLWidget.
+ */
+
+/**
+ * calculate content related size of widget.
+ * Overrides method from UMLWidget.
+ */
+UMLSceneSize NoteWidget::calculateSize()
+{
+ int width = this->width();
+ int height = this->height();
+ const QFontMetrics &fm = getFontMetrics(FT_NORMAL);
+ const int fontHeight = fm.lineSpacing();
+ const int margin = fm.width("W");
+ QSize size = fm.size (0, documentation());
+ const int textWidth = size.width();
+ const int textHeight = size.height();
+ if (m_noteType == PreCondition) {
+ const int widthtemp = fm.width("<< precondition >>");
+ width = textWidth > widthtemp ? textWidth : widthtemp;
+ width += 2 * margin;
+ }
+ else if (m_noteType == PostCondition) {
+ const int widthtemp = fm.width("<< postcondition >>");
+ width = textWidth > widthtemp ? textWidth : widthtemp;
+ width += 2 * margin;
+ }
+ else if (m_noteType == Transformation) {
+ const int widthtemp = fm.width("<< transformation >>");
+ width = textWidth > widthtemp ? textWidth : widthtemp;
+ width += 2 * margin;
+ }
else {
- // keep width and height unchanged
}
return UMLSceneSize(width, height);
}
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/notewidget.h #1298922:1298923
@@ -73,6 +73,7 @@
protected:
virtual UMLSceneSize minimumSize();
+ virtual UMLSceneSize calculateSize();
void drawText(QPainter * p = 0, int offsetX = 0, int offsetY = 0);
void drawTextWordWrap(QPainter * p = 0, int offsetX = 0, int offsetY = 0);
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/umlwidget.cpp #1298922:1298923
@@ -1049,6 +1049,16 @@
}
/**
+ * calculate content related size of widget.
+ *
+ * @return calculated widget size
+ */
+UMLSceneSize UMLWidget::calculateSize()
+{
+ return UMLSceneSize(width(), height());
+}
+
+/**
* Sets the state of whether the widget is selected.
*
* @param _select The state of whether the widget is selected.
@@ -1295,7 +1305,11 @@
{
if (m_doc->loading())
return;
- setSize(width(), height());
+ QSize size = calculateSize();
+ int clipWidth = size.width();
+ int clipHeight = size.height();
+ constrain(clipWidth, clipHeight);
+ setSize(clipWidth, clipHeight);
adjustAssocs(x(), y()); // adjust assoc lines
}
--- trunk/KDE/kdesdk/umbrello/umbrello/widgets/umlwidget.h #1298922:1298923
@@ -239,6 +239,8 @@
void setMaximumSize(const UMLSceneSize &size);
void setMaximumSize(UMLSceneValue width, UMLSceneValue height);
+ virtual UMLSceneSize calculateSize();
+
bool fixedAspectRatio()
{
return m_fixedAspectRatio;
More information about the umbrello-devel
mailing list