[Uml-devel] branches/KDE/3.5/kdesdk/umbrello/umbrello

Oliver Kellogg okellogg at users.sourceforge.net
Fri Dec 23 09:21:02 UTC 2005


SVN commit 490911 by okellogg:

UMLWidget::m_bResizable: New. Set to false to inhibit resizing, such as
for ActivityWidget types Initial, End, and Branch.


 M  +3 -2      activitywidget.cpp  
 M  +1 -0      floatingtext.cpp  
 M  +1 -5      forkjoinwidget.cpp  
 M  +1 -1      forkjoinwidget.h  
 M  +6 -3      messagewidget.cpp  
 M  +7 -4      umlwidget.cpp  
 M  +2 -2      umlwidget.h  


--- branches/KDE/3.5/kdesdk/umbrello/umbrello/activitywidget.cpp #490910:490911
@@ -27,8 +27,8 @@
 ActivityWidget::ActivityWidget(UMLView * view, ActivityType activityType, Uml::IDType id )
         : UMLWidget(view, id)
 {
-    m_ActivityType = activityType;
     UMLWidget::setBaseType( Uml::wt_Activity );
+    setActivityType( activityType );
     updateComponentSize();
 }
 
@@ -115,6 +115,7 @@
 
 void ActivityWidget::setActivityType( ActivityType activityType ) {
     m_ActivityType = activityType;
+    UMLWidget::m_bResizable = (m_ActivityType == Normal);
 }
 
 void ActivityWidget::slotMenuSelection(int sel) {
@@ -195,7 +196,7 @@
     m_Text = qElement.attribute( "activityname", "" );
     m_Doc = qElement.attribute( "documentation", "" );
     QString type = qElement.attribute( "activitytype", "1" );
-    m_ActivityType = (ActivityType)type.toInt();
+    setActivityType( (ActivityType)type.toInt() );
     return true;
 }
 
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/floatingtext.cpp #490910:490911
@@ -57,6 +57,7 @@
     m_Type = Uml::wt_Text;
     // initialize non-saved (i.e. volatile) data
     m_pLink = NULL;
+    UMLWidget::m_bResizable = false;
 }
 
 FloatingText::~FloatingText() {
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/forkjoinwidget.cpp #490910:490911
@@ -52,11 +52,7 @@
     }
 }
 
-void ForkJoinWidget::drawSelected(QPainter * p, int offsetX, int offsetY, bool resizeable) {
-    if (! resizeable) {
-        UMLWidget::drawSelected(p, offsetX, offsetY, false);
-        return;
-    }
+void ForkJoinWidget::drawSelected(QPainter *, int /*offsetX*/, int /*offsetY*/) {
 }
 
 void ForkJoinWidget::constrain(int& width, int& height) {
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/forkjoinwidget.h #490910:490911
@@ -79,7 +79,7 @@
      * Although the ForkJoinWidget supports resizing, we suppress the
      * resize corner because it is too large for this very slim widget.
      */
-    void drawSelected(QPainter * p, int offsetX, int offsetY, bool resizeable = true);
+    void drawSelected(QPainter * p, int offsetX, int offsetY);
 
     /**
     * Overrides the function from UMLWidget.
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/messagewidget.cpp #490910:490911
@@ -41,6 +41,7 @@
         y -= m_pOw[Uml::B]->getHeight() / 2;
         m_pOw[Uml::B]->setY(y);
     }
+    UMLWidget::m_bResizable = (m_pOw[Uml::A] == m_pOw[Uml::B]);
 
     calculateWidget();
     y = y < getMinHeight() ? getMinHeight() : y;
@@ -213,7 +214,7 @@
     }
 
     if (m_bSelected)
-        drawSelected(&p, offsetX, offsetY, m_pOw[Uml::A] == m_pOw[Uml::B]);
+        drawSelected(&p, offsetX, offsetY);
 }
 
 void MessageWidget::drawCreation(QPainter& p, int offsetX, int offsetY) {
@@ -242,7 +243,7 @@
     }
 
     if (m_bSelected)
-        drawSelected(&p, offsetX, offsetY, false);
+        drawSelected(&p, offsetX, offsetY);
 }
 
 int MessageWidget::onWidget(const QPoint & p) {
@@ -335,7 +336,7 @@
     emit sigMessageMoved();
 }
 
-void MessageWidget::resizeEvent(QResizeEvent */*re*/) {
+void MessageWidget::resizeEvent(QResizeEvent* /*re*/) {
 }
 
 void MessageWidget::calculateWidget() {
@@ -736,6 +737,7 @@
 
 void MessageWidget::setWidget(ObjectWidget * ow, Uml::Role_Type role) {
     m_pOw[role] = ow;
+    UMLWidget::m_bResizable = (m_pOw[Uml::A] == m_pOw[Uml::B]);
 }
 
 ObjectWidget* MessageWidget::getWidget(Uml::Role_Type role) {
@@ -803,6 +805,7 @@
         << ID2STR(bId) << " is not an ObjectWidget" << endl;
         return false;
     }
+    UMLWidget::m_bResizable = (m_pOw[Uml::A] == m_pOw[Uml::B]);
 
     UMLClassifier *c = dynamic_cast<UMLClassifier*>( pWB->getUMLObject() );
     if (c) {
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umlwidget.cpp #490910:490911
@@ -103,6 +103,7 @@
     m_pObject = other.m_pObject;
     m_pView = other.m_pView;
     m_pMenu = other.m_pMenu;
+    m_bResizable = other.m_bResizable;
     m_bResizing = other.m_bResizing;
     m_nPressOffsetX = other.m_nPressOffsetX;
     m_nPressOffsetY = other.m_nPressOffsetY;
@@ -344,8 +345,9 @@
     m_nOldH = height();
     const int m = 10;
     //see if clicked on bottom right corner
-    if( (m_nOldX + m_nPressOffsetX) >= (getX() + width() - m) &&
-        (m_nOldY + m_nPressOffsetY) >= (getY() + height() - m) && me->button() == Qt::LeftButton) {
+    if( m_bResizable && me->button() == Qt::LeftButton &&
+        (m_nOldX + m_nPressOffsetX) >= (getX() + width() - m) &&
+        (m_nOldY + m_nPressOffsetY) >= (getY() + height() - m)) {
         m_bResizing = true;
         m_pView->setCursor(WidgetBase::m_Type == Uml::wt_Message ?
                            KCursor::sizeVerCursor() : KCursor::sizeFDiagCursor());
@@ -446,6 +448,7 @@
     for (int i = 0; i < (int)FT_INVALID; ++i)
         m_pFontMetrics[(UMLWidget::FontType)i] = 0;
 
+    m_bResizable = true;
     m_bResizing = false;
     m_bMouseOver = false;
 
@@ -675,7 +678,7 @@
     update();
 }
 
-void UMLWidget::drawSelected(QPainter * p, int offsetX, int offsetY, bool resizeable) {
+void UMLWidget::drawSelected(QPainter * p, int offsetX, int offsetY) {
     int w = width();
     int h = height();
     int s = 4;
@@ -685,7 +688,7 @@
     p -> fillRect(offsetX + w - s, offsetY, s, s, brush);
 
     // Draw the resize anchor in the lower right corner.
-    if (resizeable) {
+    if (m_bResizable) {
         brush.setColor(Qt::red);
         const int right = offsetX + w;
         const int bottom = offsetY + h;
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umlwidget.h #490910:490911
@@ -533,7 +533,7 @@
      * @param offsetX The x-coordinate for drawing.
      * @param offsetY The y-coordinate for drawing.
      */
-    virtual void drawSelected(QPainter * p, int offsetX, int offsetY, bool resizeable = true);
+    virtual void drawSelected(QPainter * p, int offsetX, int offsetY);
 
     /**
      * Overrides default method.
@@ -654,7 +654,7 @@
     int            m_nOldX, m_nOldY, m_nPosX, m_origZ;
     ListPopupMenu *m_pMenu;
     UMLDoc        *m_pDoc;  ///< shortcut for UMLApp::app()->getDocument()
-    bool           m_bResizing;
+    bool           m_bResizable, m_bResizing;
     int            m_nPressOffsetX, m_nPressOffsetY;
     int            m_nOldH, m_nOldW;
     QFontMetrics  *m_pFontMetrics[FT_INVALID];




More information about the umbrello-devel mailing list