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

Oliver Kellogg okellogg at users.sourceforge.net
Sun Sep 3 21:51:23 UTC 2006


SVN commit 580562 by okellogg:

Apply FixSelectionsPartly.diff by Achim Spangler as described at
 http://www.geeksoc.org/~jr/umbrello/uml-devel/9729.html
Many thanks Achim for your bug hunting.
CCBUG:126391


 M  +2 -2      associationwidget.cpp  
 M  +1 -1      messagewidget.cpp  
 M  +23 -9     toolbarstate.cpp  
 M  +28 -13    umlview.cpp  
 M  +7 -6      umlview.h  
 M  +5 -18     umlwidget.cpp  
 M  +5 -4      umlwidgetcontroller.cpp  


--- branches/KDE/3.5/kdesdk/umbrello/umbrello/associationwidget.cpp #580561:580562
@@ -2511,7 +2511,7 @@
         if( x - BOUNDARY <= p.x() && x + BOUNDARY >= p.x() &&
                 y - BOUNDARY <= p.y() && y + BOUNDARY >= p.y() ) {
             m_nMovingPoint = i;
-            i = size; //no need to check the rest
+            break; //no need to check the rest
         }//end if
     }//end for
 }
@@ -2532,7 +2532,7 @@
         m_LinePath.insertPoint( i + 1, me->pos() );
         m_nMovingPoint = i + 1;
     }
-    
+
     setSelected();
     //new position for point
     QPoint p = me->pos();
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/messagewidget.cpp #580561:580562
@@ -375,7 +375,7 @@
     calculateWidget();
     if( !m_pFText )
         return;
-    if( m_pView -> getSelectCount() > 1 )
+    if (m_pView->getSelectCount(true) > 1)
         return;
     setTextPosition();
 }
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/toolbarstate.cpp #580561:580562
@@ -1,8 +1,3 @@
-/*
- *  copyright (C) 2004
- *  Umbrello UML Modeller Authors <uml-devel@ uml.sf.net>
- */
-
 /***************************************************************************
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -10,11 +5,17 @@
  *   the Free Software Foundation; either version 2 of the License, or     *
  *   (at your option) any later version.                                   *
  *                                                                         *
+ *  copyright (C) 2004-2006                                                *
+ *  Umbrello UML Modeller Authors <uml-devel@ uml.sf.net>                  *
  ***************************************************************************/
+
+// own header
+#include "toolbarstate.h"
+// qt/kde includes
 #include <qwmatrix.h> // need for inverseWorldMatrix.map
 #include <qevent.h>
-
-#include "toolbarstate.h"
+#include <kdebug.h>
+// app includes
 #include "umlview.h"
 #include "umlwidget.h"
 #include "messagewidget.h"
@@ -166,7 +167,6 @@
 bool ToolBarState::setSelectedWidget(QMouseEvent * me)
 {
     m_pUMLView->setMoveAssoc(NULL);
-    m_pUMLView->setOnWidget(NULL);
 
     // Check associations.
     AssociationWidgetListIt assoc_it(m_pUMLView->getAssociationList());
@@ -188,6 +188,11 @@
     for (MessageWidgetListIt mit(m_pUMLView->getMessageList()); mit.current(); ++mit) {
         MessageWidget *obj = mit.current();
         if (obj->isVisible() && obj->onWidget(me->pos())) {
+            UMLWidget *bkgnd = m_pUMLView->getOnWidget();
+            if (bkgnd && obj != bkgnd) {   // change of selected object
+                bkgnd->setSelected(false);
+                m_pUMLView->setOnWidget(NULL);
+            }
             m_pUMLView->setOnWidget( obj );
             obj->mousePressEvent( me );
             m_bWidgetSelected = true;
@@ -211,14 +216,23 @@
         }
     }
     if (smallestObj) {
+        UMLWidget *bkgnd = m_pUMLView->getOnWidget();
+        if (bkgnd && smallestObj != bkgnd) {   // change of selected object
+            bkgnd->setSelected(false);
+            m_pUMLView->setOnWidget(NULL);
+        }
         m_pUMLView->setOnWidget(smallestObj);
         smallestObj->mousePressEvent(me);
         m_bWidgetSelected = true;
         return true;
     }
 
-    m_pUMLView->setOnWidget(NULL);
+    if (m_pUMLView->getOnWidget()) {   // clear selected object
+        m_pUMLView->getOnWidget()->setSelected(false);
+        m_pUMLView->setOnWidget(NULL);
+    }
 
     m_bWidgetSelected = false;
     return false;
 }
+
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umlview.cpp #580561:580562
@@ -238,12 +238,12 @@
     int marginY = pPrinter->margins().height();
 
     if(pPrinter->orientation() == KPrinter::Landscape) {
-      // we are printing in LANDSCAPE --> swap marginX and marginY
-      // this is needed, as KPrinter reports width margin strictly as printer
-      // default orientation margin - and not depend on LANDSCAPE/PORTRAIT
-      int temp = marginX;
-      marginX = marginY;
-      marginY = temp;
+        // we are printing in LANDSCAPE --> swap marginX and marginY
+        // this is needed, as KPrinter reports width margin strictly as printer
+        // default orientation margin - and not depend on LANDSCAPE/PORTRAIT
+        int temp = marginX;
+        marginX = marginY;
+        marginY = temp;
     }
 
     // The printer will probably use a different font with different font metrics,
@@ -1408,16 +1408,31 @@
     }//end while
 }
 
+int UMLView::getSelectCount(bool filterText) const {
+    if (!filterText)
+        return m_SelectedList.count();
+    int counter = 0;
+    const UMLWidget * temp = 0;
+    for (UMLWidgetListIt iter(m_SelectedList); (temp = iter.current()) != 0; ++iter) {
+        if (temp->getBaseType() == wt_Text) {
+            const FloatingTextWidget *ft = static_cast<const FloatingTextWidget*>(temp);
+            if (ft->getRole() == tr_Floating)
+                counter++;
+        } else {
+            counter++;
+        }
+    }
+    return counter;
+}
 
+
 bool UMLView::getSelectedWidgets(UMLWidgetList &WidgetList, bool filterText /*= true*/) {
-    UMLWidget * temp = 0;
-    int type;
-    for(temp=(UMLWidget *)m_SelectedList.first();temp;temp=(UMLWidget *)m_SelectedList.next()) {
-        type = temp->getBaseType();
-        if (filterText && type == wt_Text) {
-            if( ((FloatingTextWidget*)temp)->getRole() == tr_Floating ) {
+    const UMLWidget * temp = 0;
+    for (UMLWidgetListIt it(m_SelectedList); (temp = it.current()) != NULL; ++it) {
+        if (filterText && temp->getBaseType() == wt_Text) {
+            const FloatingTextWidget *ft = static_cast<const FloatingTextWidget*>(temp);
+            if (ft->getRole() == tr_Floating)
                 WidgetList.append(temp);
-            }
         } else {
             WidgetList.append(temp);
         }
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umlview.h #580561:580562
@@ -451,11 +451,12 @@
     /**
      * Return the amount of widgets selected.
      *
-     * @return Return the amount of widgets selected.
+     * @param filterText  When true, do NOT count floating text widgets that
+     *                    belong to other widgets (i.e. only count tr_Floating.)
+     *                    Default: Count all widgets.
+     * @return  Number of widgets selected.
      */
-    int getSelectCount() const {
-        return m_SelectedList.count();
-    }
+    int getSelectCount(bool filterText = false) const;
 
     /**
      * Set the useFillColor variable to all selected widgets
@@ -1127,7 +1128,7 @@
      */
     QRect getDiagramRect();
 
-    
+
     /**
      * Initializes key variables.
      */
@@ -1225,7 +1226,7 @@
      * Reset to false when clicking in an empty region of the view.
      */
     bool m_bChildDisplayedDoc;
-    
+
     ToolBarStateFactory* m_pToolBarStateFactory;
     ToolBarState* m_pToolBarState;
 
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umlwidget.cpp #580561:580562
@@ -609,30 +609,17 @@
     slotRemovePopupMenu();
 
     //if in a multi- selection to a specific m_pMenu for that
-    int count = m_pView -> getSelectCount();
+    // NEW: ask UMLView to count ONLY the widgets and not their floatingtextwidgets
+    int count = m_pView->getSelectCount(true);
     //a MessageWidget when selected will select its text widget and vice versa
     //so take that into account for popup menu.
 
     // determine multi state
-    bool multi = false;
+    bool multi = (m_bSelected && count > 1);
 
     // if multiple selected items have the same type
     bool unique = false;
 
-    if( m_bSelected )
-        if( m_pView -> getType() == dt_Sequence ) {
-            if( getBaseType() == wt_Message && count == 2 ) {
-                multi = false;
-            } else if( getBaseType() == wt_Text &&
-                       ((FloatingTextWidget*)this) -> getRole() == tr_Seq_Message && count == 2 ) {
-                multi = false;
-            } else if( count > 1 ) {
-                multi = true;
-            }
-        } else if( count > 1 ) {
-            multi = true;
-        }
-
     // if multiple items are selected, we have to check if they all have the same
     // base type
     if (multi == true)
@@ -712,9 +699,9 @@
 
     const QPoint pos(getX(), getY());
     UMLWidget *bkgnd = m_pView->testOnWidget(pos);
-    if (bkgnd) {
+    if (bkgnd && _select) {
         kdDebug() << "UMLWidget::setSelected: setting Z to "
-            << bkgnd->getZ() + 1 << endl;
+            << bkgnd->getZ() + 1 << ", SelectState: " << _select << endl;
         setZ( bkgnd->getZ() + 1 );
     } else {
         setZ( 0 );
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/umlwidgetcontroller.cpp #580561:580562
@@ -29,6 +29,7 @@
 #include "listpopupmenu.h"
 #include "classifierwidget.h"
 #include "associationwidget.h"
+#include "messagewidget.h"
 
 using namespace Uml;
 
@@ -92,9 +93,9 @@
 
     m_shiftPressed = false;
 
-    int count = m_widget->m_pView->getSelectCount();
+    int count = m_widget->m_pView->getSelectCount(true);
     if (me->button() == Qt::LeftButton) {
-        if (count > 1 && m_widget->m_bSelected == true) {
+        if (count > 1) {
             //Single selection is made in release event if the widget wasn't moved
             m_inMoveArea = true;
             return;
@@ -176,7 +177,7 @@
             widget->adjustAssocs(widget->getX(), widget->getY());
 
             //TODO check if this is needed. What it does?
-            //If needed, create an empty virtual method executed at this place 
+            //If needed, create an empty virtual method executed at this place
             //and override it in ClassifierWidgetController
 /*            if (widget->m_Type == Uml::wt_Class) {
                 ClassifierWidget *cw = static_cast<ClassifierWidget*>(widget);
@@ -203,7 +204,7 @@
                 m_leftButtonDown = false;
 
                 if (!m_moved && !m_resized) {
-                    if (!m_shiftPressed && m_widget->m_pView->getSelectCount() > 1) {
+                    if (!m_shiftPressed && (m_widget->m_pView->getSelectCount(true) > 1)) {
                         selectSingle(me);
                     } else if (!m_wasSelected) {
                         deselect(me);




More information about the umbrello-devel mailing list