[Uml-devel] branches/work/soc-umbrello/umbrello
Gopala Krishna A
krishna.ggk at gmail.com
Tue Sep 2 19:20:12 UTC 2008
SVN commit 856392 by gopala:
* Fixed alignment of PreconditionWidget when its associated
ObjectWidget's size changes.
* Stripped margin code from PreconditionWidget.
M +17 -1 objectwidget.cpp
M +2 -0 objectwidget.h
M +20 -4 preconditionwidget.cpp
M +1 -0 preconditionwidget.h
M +4 -0 seqlinewidget.cpp
--- branches/work/soc-umbrello/umbrello/objectwidget.cpp #856391:856392
@@ -16,6 +16,7 @@
#include "dialogs/classpropdlg.h"
#include "docwindow.h"
#include "listpopupmenu.h"
+#include "preconditionwidget.h"
#include "seqlinewidget.h"
#include "textitem.h"
#include "textitemgroup.h"
@@ -172,6 +173,19 @@
}
}
+/**
+ * Aligns all the PreconditionWidgets belonging to this widget.
+ */
+void ObjectWidget::alignPreconditionWidgets()
+{
+ foreach (QGraphicsItem *item, childItems()) {
+ PreconditionWidget *pre = dynamic_cast<PreconditionWidget*>(item);
+ if (pre) {
+ pre->alignToObjectLine();
+ }
+ }
+}
+
/// @return The 'X' coordinate corresponding to sequential line.
qreal ObjectWidget::sequentialLineX() const
{
@@ -438,9 +452,11 @@
if (m_sequentialLine) {
m_sequentialLine->setPos(r.center().x(), r.bottom());
}
- foreach(MessageWidget *msg, m_messages) {
+ foreach (MessageWidget *msg, m_messages) {
msg->handleObjectMove(this);
}
+
+ alignPreconditionWidgets();
// Now update text position and also the path.
// Reset the path
--- branches/work/soc-umbrello/umbrello/objectwidget.h #856391:856392
@@ -71,6 +71,8 @@
qreal lineEndYInParentCoords() const;
void setLineEndY(qreal yPosition);
+ void alignPreconditionWidgets();
+
qreal sequentialLineX() const;
void messageAdded(MessageWidget* message);
--- branches/work/soc-umbrello/umbrello/preconditionwidget.cpp #856391:856392
@@ -82,6 +82,25 @@
}
/**
+ * This is a utility method to align the PreconditionWidget to center
+ * of ObjectLine as well as ensure the presence of widget well with
+ * ObjectLine vertical dimentsion.
+ */
+void PreconditionWidget::alignToObjectLine()
+{
+ QPointF newPos = pos();
+ if (m_objectWidget) {
+ QRectF objectRect = m_objectWidget->rect();
+ newPos.setX(objectRect.center().x() - .5 * size().width());
+ }
+
+ newPos.ry() = qMax(newPos.y(), minY());
+ newPos.ry() = qMin(newPos.y(), maxY());
+
+ setPos(newPos);
+}
+
+/**
* Reimplemented from NewUMLRectWidget::paint to draw the rounded
* rect. The text is drawn by the TextItem.
*/
@@ -170,10 +189,7 @@
QVariant PreconditionWidget::attributeChange(WidgetAttributeChange change, const QVariant& oldValue)
{
if (change == SizeHasChanged) {
- const qreal m = margin();
- QRectF r = rect();
- r.adjust(+m, +m, -m, -m);
- textItemGroupAt(0)->setGroupGeometry(r);
+ textItemGroupAt(0)->setGroupGeometry(rect());
// Center the precondtion widget horizontally on sequential line.
if (m_objectWidget) {
--- branches/work/soc-umbrello/umbrello/preconditionwidget.h #856391:856392
@@ -38,6 +38,7 @@
qreal minY() const;
qreal maxY() const;
+ void alignToObjectLine();
virtual void paint(QPainter *p, const QStyleOptionGraphicsItem *option, QWidget *w);
virtual bool loadFromXMI( QDomElement & qElement );
--- branches/work/soc-umbrello/umbrello/seqlinewidget.cpp #856391:856392
@@ -98,6 +98,10 @@
m_sequentialLine.setP1(QPointF(0, 0));
m_sequentialLine.setP2(QPointF(0, m_length));
+ if (m_objectWidget) {
+ m_objectWidget->alignPreconditionWidgets();
+ }
+
updateDestructionBoxVisibility();
}
More information about the umbrello-devel
mailing list