[Uml-devel] branches/KDE/3.5/kdesdk/umbrello/umbrello
Oliver Kellogg
okellogg at users.sourceforge.net
Sat Feb 3 22:25:35 UTC 2007
SVN commit 629858 by okellogg:
ObjectWidget::getSeqLine(): New.
UMLView::m_SeqLineList: Remove. Get SeqLineWidget via ObjectWidget::getSeqLine().
UMLView::slotObjectCreated(): Invoke updateComponentSize() on the newWidget and
let an ObjectWidget recompute its SeqLineWidget position via moveEvent().
SeqLineWidget::DestructionBox: Factor methods setLine{1,2}Points().
SeqLineWidget::m_pDestructionBox: Rename to m_DestructionBox, it's not a pointer.
M +12 -3 objectwidget.cpp
M +8 -1 objectwidget.h
M +20 -25 seqlinewidget.cpp
M +13 -6 seqlinewidget.h
M +28 -10 umlview.cpp
M +1 -21 umlview.h
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/objectwidget.cpp #629857:629858
@@ -5,7 +5,7 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
- * copyright (C) 2002-2006 *
+ * copyright (C) 2002-2007 *
* Umbrello UML Modeller Authors <uml-devel at uml.sf.net> *
***************************************************************************/
@@ -181,8 +181,13 @@
void ObjectWidget::moveEvent(QMoveEvent */*m*/) {
emit sigWidgetMoved( m_nLocalID );
- if( m_pLine )
- m_pLine -> setStartPoint( getX() + width() / 2, getY() + height() );
+ if (m_pLine) {
+ const int x = getX(); // for debugging: gdb has a problem evaluating getX() etc
+ const int w = width();
+ const int y = getY();
+ const int h = height();
+ m_pLine->setStartPoint(x + w / 2, y + h);
+ }
}
void ObjectWidget::slotColorChanged(Uml::IDType /*viewID*/) {
@@ -364,6 +369,10 @@
return false;
}
+SeqLineWidget *ObjectWidget::getSeqLine() {
+ return m_pLine;
+}
+
void ObjectWidget::saveToXMI( QDomDocument & qDoc, QDomElement & qElement ) {
QDomElement objectElement = qDoc.createElement( "objectwidget" );
UMLWidget::saveToXMI( qDoc, objectElement );
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/objectwidget.h #629857:629858
@@ -5,7 +5,7 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
- * copyright (C) 2002-2006 *
+ * copyright (C) 2002-2007 *
* Umbrello UML Modeller Authors <uml-devel at uml.sf.net> *
***************************************************************************/
@@ -225,6 +225,13 @@
bool messageOverlap(int y, MessageWidget* messageWidget);
/**
+ * Return the SeqLineWidget.
+ * Returns a non NULL pointer if this ObjectWidget is part of a
+ * sequence diagram.
+ */
+ SeqLineWidget *getSeqLine();
+
+ /**
* Saves to the <objectwidget> XMI element.
*/
void saveToXMI( QDomDocument & qDoc, QDomElement & qElement );
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/seqlinewidget.cpp #629857:629858
@@ -5,7 +5,7 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
- * copyright (C) 2002-2006 *
+ * copyright (C) 2002-2007 *
* Umbrello UML Modeller Authors <uml-devel at uml.sf.net> *
***************************************************************************/
@@ -27,10 +27,9 @@
setPen( QPen( m_pObject->getLineColor(), 0, Qt::DashLine ) );
setZ( 0 );
setVisible( true );
- m_pDestructionBox.line1 = 0;
+ m_DestructionBox.line1 = 0;
m_nLengthY = 250;
setupDestructionBox();
- m_pView -> addSeqLine( this );
}
SeqLineWidget::~SeqLineWidget() {}
@@ -51,7 +50,6 @@
void SeqLineWidget::cleanup() {
cleanupDestructionBox();
- m_pView->removeSeqLine( this );
}
void SeqLineWidget::setStartPoint( int startX, int startY ) {
@@ -62,11 +60,11 @@
}
void SeqLineWidget::cleanupDestructionBox() {
- if ( m_pDestructionBox.line1 ) {
- delete m_pDestructionBox.line1;
- m_pDestructionBox.line1 = 0;
- delete m_pDestructionBox.line2;
- m_pDestructionBox.line2 = 0;
+ if ( m_DestructionBox.line1 ) {
+ delete m_DestructionBox.line1;
+ m_DestructionBox.line1 = 0;
+ delete m_DestructionBox.line2;
+ m_DestructionBox.line2 = 0;
}
}
@@ -81,22 +79,21 @@
rect.setWidth( 14 );
rect.setHeight( 14 );
- m_pDestructionBox.line1 = new QCanvasLine( m_pView->canvas() );
- m_pDestructionBox.line1->setPoints( rect.x(), rect.y(),
- rect.x() + rect.width(), rect.y() + rect.height() );
- m_pDestructionBox.line1->setVisible( true );
- m_pDestructionBox.line1->setPen( QPen(m_pObject->getLineColor(), 2) );
- m_pDestructionBox.line1->setZ( 3 );
+ m_DestructionBox.line1 = new QCanvasLine( m_pView->canvas() );
+ m_DestructionBox.setLine1Points(rect);
+ m_DestructionBox.line1->setVisible( true );
+ m_DestructionBox.line1->setPen( QPen(m_pObject->getLineColor(), 2) );
+ m_DestructionBox.line1->setZ( 3 );
- m_pDestructionBox.line2 = new QCanvasLine( m_pView -> canvas() );
- m_pDestructionBox.line2->setPoints( rect.x(), rect.y() + rect.height(), rect.x() + rect.width(), rect.y() );
- m_pDestructionBox.line2->setVisible( true );
- m_pDestructionBox.line2->setPen( QPen(m_pObject->getLineColor(), 2) );
- m_pDestructionBox.line2->setZ( 3 );
+ m_DestructionBox.line2 = new QCanvasLine( m_pView -> canvas() );
+ m_DestructionBox.setLine2Points(rect);
+ m_DestructionBox.line2->setVisible( true );
+ m_DestructionBox.line2->setPen( QPen(m_pObject->getLineColor(), 2) );
+ m_DestructionBox.line2->setZ( 3 );
}
void SeqLineWidget::moveDestructionBox() {
- if( !m_pDestructionBox.line1 ) {
+ if( !m_DestructionBox.line1 ) {
return;
}
QRect rect;
@@ -104,10 +101,8 @@
rect.setY( m_pObject->getY() + m_pObject->getHeight() + m_nLengthY - 7 );
rect.setWidth( 14 );
rect.setHeight( 14 );
- m_pDestructionBox.line1->setPoints( rect.x(), rect.y(),
- rect.x() + rect.width(), rect.y() + rect.height() );
- m_pDestructionBox.line2->setPoints( rect.x(), rect.y() + rect.height(),
- rect.x() + rect.width(), rect.y() );
+ m_DestructionBox.setLine1Points(rect);
+ m_DestructionBox.setLine2Points(rect);
}
void SeqLineWidget::setEndOfLine(int yPosition) {
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/seqlinewidget.h #629857:629858
@@ -5,15 +5,15 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
- * copyright (C) 2002-2006 *
+ * copyright (C) 2002-2007 *
* Umbrello UML Modeller Authors <uml-devel at uml.sf.net> *
***************************************************************************/
-
#ifndef SEQLINEWIDGET_H
#define SEQLINEWIDGET_H
-//app includes
+#include <qcanvas.h>
+
class UMLView;
class ObjectWidget;
@@ -108,11 +108,18 @@
UMLView * m_pView;
/// The destruction box.
- struct {
- QCanvasRectangle * rect;
+ struct DestructionBox {
QCanvasLine * line1;
QCanvasLine * line2;
- } m_pDestructionBox;
+ void setLine1Points(QRect rect) {
+ line1->setPoints( rect.x(), rect.y(),
+ rect.x() + rect.width(), rect.y() + rect.height() );
+ }
+ void setLine2Points(QRect rect) {
+ line2->setPoints( rect.x(), rect.y() + rect.height(),
+ rect.x() + rect.width(), rect.y() );
+ }
+ } m_DestructionBox;
/**
* The length of the line.
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umlview.cpp #629857:629858
@@ -452,6 +452,14 @@
newWidget->setFont( getFont() );
newWidget->slotColorChanged( getID() );
newWidget->slotLineWidthChanged( getID() );
+ newWidget->updateComponentSize();
+ if (m_Type == Uml::dt_Sequence) {
+ // Set proper position on the sequence line widget which is
+ // attached to the object widget.
+ ObjectWidget *ow = dynamic_cast<ObjectWidget*>(newWidget);
+ if (ow)
+ ow->moveEvent(NULL);
+ }
m_bCreateObject = false;
m_WidgetList.append(newWidget);
switch (o->getBaseType()) {
@@ -634,11 +642,19 @@
}
ObjectWidget * UMLView::onWidgetLine( const QPoint &point ) {
- SeqLineWidget * pLine = 0;
- for( pLine = m_SeqLineList.first(); pLine; pLine = m_SeqLineList.next() ) {
- if( pLine -> onWidget( point ) ) {
- return pLine -> getObjectWidget();
+ UMLWidget *obj;
+ for (UMLWidgetListIt it(m_WidgetList); (obj = it.current()) != NULL; ++it) {
+ ObjectWidget *ow = dynamic_cast<ObjectWidget*>(obj);
+ if (ow == NULL)
+ continue;
+ SeqLineWidget *pLine = ow->getSeqLine();
+ if (pLine == NULL) {
+ kError() << "UMLView::onWidgetLine: SeqLineWidget of " << ow->getName()
+ << " (id=" << ID2STR(ow->getLocalID()) << ") is NULL" << endl;
+ continue;
}
+ if (pLine->onWidget(point))
+ return ow;
}
return 0;
}
@@ -874,13 +890,15 @@
endy = objEndY;
}
//if seq. diagram, make sure print all of the lines
- if(getType() == dt_Sequence ) {
- SeqLineWidget * pLine = 0;
- for( pLine = m_SeqLineList.first(); pLine; pLine = m_SeqLineList.next() ) {
- int y = pLine -> getObjectWidget() -> getEndLineY();
- endy = endy < y?y:endy;
+ if (getType() == dt_Sequence ) {
+ for (UMLWidgetListIt it(m_WidgetList); (obj = it.current()) != NULL; ++it) {
+ ObjectWidget *ow = dynamic_cast<ObjectWidget*>(obj);
+ if (ow == NULL)
+ continue;
+ int y = ow->getEndLineY();
+ if (endy < y)
+ endy = y;
}
-
}
/* now we need another look at the associations, because they are no
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umlview.h #629857:629858
@@ -5,7 +5,7 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
- * copyright (C) 2002-2006 *
+ * copyright (C) 2002-2007 *
* Umbrello UML Modeller Authors <uml-devel at uml.sf.net> *
***************************************************************************/
@@ -34,7 +34,6 @@
class IDChangeLog;
class ListPopupMenu;
class FloatingTextWidget;
-class SeqLineWidget;
class ObjectWidget;
class UMLFolder;
class UMLApp;
@@ -768,20 +767,6 @@
bool checkUniqueSelection();
/**
- * Adds a sequence line to the list.
- */
- void addSeqLine( SeqLineWidget * pLine ) {
- m_SeqLineList.append( pLine );
- }
-
- /**
- * Removes a sequence line from the list.
- */
- void removeSeqLine(SeqLineWidget* pLine) {
- m_SeqLineList.remove(pLine);
- }
-
- /**
* Asks for confirmation and clears everything on the diagram.
* Called from menus.
*/
@@ -1165,11 +1150,6 @@
QPoint m_PastePoint;
/**
- * Holds a list of all the sequence lines on a sequence diagram.
- */
- QPtrList<SeqLineWidget> m_SeqLineList;
-
- /**
* Pointer to the UMLDoc
*/
UMLDoc* m_pDoc;
More information about the umbrello-devel
mailing list