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

Sharan Rao sharanrao at gmail.com
Fri Jul 20 11:33:15 UTC 2007


SVN commit 690217 by sharan:

*ability to set category type
and some tiny changes in ListPopupMenu



 M  +1 -0      category.cpp  
 M  +19 -1     categorywidget.cpp  
 M  +10 -0     categorywidget.h  
 M  +84 -15    listpopupmenu.cpp  
 M  +35 -3     listpopupmenu.h  
 M  +1 -1      umldoc.cpp  
 M  +24 -2     umllistview.cpp  


--- trunk/KDE/kdesdk/umbrello/umbrello/category.cpp #690216:690217
@@ -53,6 +53,7 @@
 
 void UMLCategory::setType(Category_Type type) {
     m_CategoryType = type;
+    emitModified();
 }
 
 
--- trunk/KDE/kdesdk/umbrello/umbrello/categorywidget.cpp #690216:690217
@@ -17,8 +17,8 @@
 // local includes
 #include "category.h"
 #include "umlview.h"
+#include "listpopupmenu.h"
 
-
 CategoryWidget::CategoryWidget(UMLView * view, UMLCategory *o) : UMLWidget(view, o) {
     UMLWidget::setBaseType(Uml::wt_Category);
     //updateComponentSize();  Doing this during loadFromXMI() gives futile updates.
@@ -86,3 +86,21 @@
     qElement.appendChild( categoryElement );
 }
 
+void CategoryWidget::slotMenuSelection(int sel){
+    UMLCategory* catObj = static_cast<UMLCategory*>(m_pObject);
+    switch(sel) {
+      case ListPopupMenu::mt_DisjointSpecialisation:
+          catObj->setType(UMLCategory::ct_Disjoint_Specialisation);
+          break;
+
+      case ListPopupMenu::mt_OverlappingSpecialisation:
+          catObj->setType(UMLCategory::ct_Overlapping_Specialisation);
+          break;
+
+      case ListPopupMenu::mt_Union:
+          catObj->setType(UMLCategory::ct_Union);
+          break;
+    }
+    UMLWidget::slotMenuSelection(sel);
+}
+
--- trunk/KDE/kdesdk/umbrello/umbrello/categorywidget.h #690216:690217
@@ -68,6 +68,16 @@
      * Overrides method from UMLWidget
      */
     QSize calculateSize();
+
+public slots:
+    /**
+     * Will be called when a menu selection has been made from the
+     * popup menu.
+     *
+     * @param sel       The selection id that has been selected.
+     */
+    void slotMenuSelection(int sel);
+
 };
 
 #endif
--- trunk/KDE/kdesdk/umbrello/umbrello/listpopupmenu.cpp #690216:690217
@@ -41,18 +41,23 @@
 #include "forkjoinwidget.h"
 #include "objectwidget.h"
 #include "pinwidget.h"
+#include "category.h"
 
 //ListPopupMenu for a UMLView (diagram)
 ListPopupMenu::ListPopupMenu(QWidget *parent, Menu_Type type, UMLView * view)
         : KMenu(parent) {
     init();
-    setupMenu(type, view);
+    m_TriggerObject.m_View = view;
+    m_TriggerObjectType = tot_View;
+    setupMenu(type);
 }
 
 //ListPopupMenu for the tree list view
-ListPopupMenu::ListPopupMenu(QWidget *parent, Uml::ListView_Type type)
+ListPopupMenu::ListPopupMenu(QWidget *parent, Uml::ListView_Type type, UMLObject* object)
         : KMenu(parent) {
     init();
+    m_TriggerObject.m_Object = object;
+    m_TriggerObjectType = tot_Object;
     Menu_Type mt = mt_Undefined;
     switch(type)
     {
@@ -236,6 +241,8 @@
         : KMenu(parent)
 {
     init();
+    m_TriggerObject.m_Widget = object;
+    m_TriggerObjectType = tot_Widget;
     //make the right menu for the type
     //make menu for logical view
     if(!object)
@@ -285,7 +292,6 @@
     switch(type) {
     case Uml::wt_Actor:
     case Uml::wt_UseCase:
-    case Uml::wt_Category:
         setupColor(object -> getUseFillColour());
         insertStdItems(true, type);
         insertStdItem(mt_Rename);
@@ -293,6 +299,19 @@
         insertStdItem(mt_Properties);
         break;
 
+    case Uml::wt_Category:
+       {
+         insertItem(i18n("Category Type"),makeCategoryTypeMenu(
+                                            static_cast<UMLCategory*>(object->getUMLObject())
+                                          )
+                    );
+
+         setupColor(object -> getUseFillColour());
+         insertStdItems(true, type);
+         insertStdItem(mt_Rename);
+         insertStdItem(mt_Change_Font);
+         break;
+       }
     case Uml::wt_Class:
     case Uml::wt_Interface:
         makeClassifierPopup(static_cast<ClassifierWidget*>(object));
@@ -900,7 +919,7 @@
     return type;
 }
 
-void ListPopupMenu::setupMenu(Menu_Type type, UMLView* view) {
+void ListPopupMenu::setupMenu(Menu_Type type) {
     //make the right menu for the type
     //make menu for logical view
     m_pInsert = 0;
@@ -1095,7 +1114,11 @@
         insertStdItem(mt_FloatText );
         insertFileNew();
         insertSeparator();
-        setupDiagramMenu(view);
+        if ( m_TriggerObjectType!= tot_View ) {
+            kError()<<k_funcinfo<<"Invalid Trigger Object Type Set for Use Case Diagram "<<m_TriggerObjectType<<endl;
+            return;
+        }
+        setupDiagramMenu(m_TriggerObject.m_View);
         break;
 
     case mt_On_Class_Diagram:
@@ -1108,7 +1131,11 @@
         insertStdItem(mt_FloatText);
         insertFileNew();
         insertSeparator();
-        setupDiagramMenu(view);
+        if ( m_TriggerObjectType!= tot_View ) {
+            kError()<<k_funcinfo<<"Invalid Trigger Object Type Set for Use Case Diagram "<<m_TriggerObjectType<<endl;
+            return;
+        }
+        setupDiagramMenu(m_TriggerObject.m_View);
         break;
 
     case mt_On_State_Diagram:
@@ -1119,7 +1146,11 @@
         insertStdItem(mt_FloatText);
         insertFileNew();
         insertSeparator();
-        setupDiagramMenu(view);
+        if ( m_TriggerObjectType!= tot_View ) {
+            kError()<<k_funcinfo<<"Invalid Trigger Object Type Set for Use Case Diagram "<<m_TriggerObjectType<<endl;
+            return;
+        }
+        setupDiagramMenu(m_TriggerObject.m_View);
         break;
 
     case mt_On_Activity_Diagram:
@@ -1131,7 +1162,11 @@
         insertStdItem(mt_FloatText);
         insertFileNew();
         insertSeparator();
-        setupDiagramMenu(view);
+        if ( m_TriggerObjectType!= tot_View ) {
+            kError()<<k_funcinfo<<"Invalid Trigger Object Type Set for Use Case Diagram "<<m_TriggerObjectType<<endl;
+            return;
+        }
+        setupDiagramMenu(m_TriggerObject.m_View);
         break;
 
     case mt_On_Component_Diagram:
@@ -1141,7 +1176,11 @@
         m_pInsert->insertItem(m_pixmap[pm_Artifact], i18n("Artifact..."), mt_Artifact);
         insertFileNew();
         insertSeparator();
-        setupDiagramMenu(view);
+        if ( m_TriggerObjectType!= tot_View ) {
+            kError()<<k_funcinfo<<"Invalid Trigger Object Type Set for Use Case Diagram "<<m_TriggerObjectType<<endl;
+            return;
+        }
+        setupDiagramMenu(m_TriggerObject.m_View);
         break;
 
     case mt_On_Deployment_Diagram:
@@ -1149,7 +1188,11 @@
         m_pInsert->insertItem(m_pixmap[pm_Node], i18n("Node..."), mt_Node);
         insertFileNew();
         insertSeparator();
-        setupDiagramMenu(view);
+        if ( m_TriggerObjectType!= tot_View ) {
+            kError()<<k_funcinfo<<"Invalid Trigger Object Type Set for Use Case Diagram "<<m_TriggerObjectType<<endl;
+            return;
+        }
+        setupDiagramMenu(m_TriggerObject.m_View);
         break;
 
     case mt_On_EntityRelationship_Diagram:
@@ -1157,7 +1200,11 @@
         m_pInsert->insertItem(m_pixmap[pm_Entity], i18n("Entity..."), mt_Entity);
         insertFileNew();
         insertSeparator();
-        setupDiagramMenu(view);
+        if ( m_TriggerObjectType!= tot_View ) {
+            kError()<<k_funcinfo<<"Invalid Trigger Object Type Set for Use Case Diagram "<<m_TriggerObjectType<<endl;
+            return;
+        }
+        setupDiagramMenu(m_TriggerObject.m_View);
         break;
 
     case mt_On_Sequence_Diagram:
@@ -1167,7 +1214,11 @@
         insertStdItem(mt_FloatText);
         insertFileNew();
         insertSeparator();
-        setupDiagramMenu(view);
+        if ( m_TriggerObjectType!= tot_View ) {
+            kError()<<k_funcinfo<<"Invalid Trigger Object Type Set for Use Case Diagram "<<m_TriggerObjectType<<endl;
+            return;
+        }
+        setupDiagramMenu(m_TriggerObject.m_View);
         break;
 
     case mt_Class:
@@ -1248,9 +1299,15 @@
     case mt_Operation:
     case mt_Template:
     case mt_Category:
-
+        if ( m_TriggerObjectType!= tot_Object ) {
+            kError()<<k_funcinfo<<"Invalid Trigger Object Type Set for Use Case Diagram "<<m_TriggerObjectType<<endl;
+            return;
+        }
+        insertItem(i18n("Category Type"),makeCategoryTypeMenu(
+                                            static_cast<UMLCategory*>(m_TriggerObject.m_Object)
+                                          )
+                    );
         insertStdItems(false);
-        insertStdItem(mt_Properties);
         break;
 
     case mt_UniqueConstraint:
@@ -1443,7 +1500,7 @@
         break;
     }//end switch
 
-    if( view ) {
+    if( m_TriggerObjectType == tot_View ) {
         bool bCutState = UMLApp::app() -> getCutCopyState();
         setItemEnabled( mt_Undo, UMLApp::app()->getUndoEnabled() );
         setItemEnabled( mt_Redo, UMLApp::app()->getRedoEnabled() );
@@ -1472,3 +1529,15 @@
     insertStdItem(mt_Properties);
 }
 
+KMenu* ListPopupMenu::makeCategoryTypeMenu(UMLCategory* category) {
+    KMenu* catTypeMenu = new KMenu(this);
+    catTypeMenu->insertItem(i18n("Disjoint(Specialisation)"), mt_DisjointSpecialisation );
+    catTypeMenu->insertItem(i18n("Overlapping(Specialisation)"), mt_OverlappingSpecialisation);
+    catTypeMenu->insertItem(i18n("Union"), mt_Union);
+    catTypeMenu->setItemChecked(mt_DisjointSpecialisation, category->getType()==UMLCategory::ct_Disjoint_Specialisation );
+    catTypeMenu->setItemChecked(mt_OverlappingSpecialisation, category->getType()==UMLCategory::ct_Overlapping_Specialisation );
+    catTypeMenu->setItemChecked(mt_Union, category->getType()==UMLCategory::ct_Union );
+
+    return catTypeMenu;
+}
+
--- trunk/KDE/kdesdk/umbrello/umbrello/listpopupmenu.h #690216:690217
@@ -18,6 +18,8 @@
 class UMLView;
 class UMLWidget;
 class ClassifierWidget;
+class UMLCategory;
+class UMLObject;
 
 /**
  * A popup menu that depending on what type it is set to will
@@ -84,6 +86,9 @@
         mt_CheckConstraint,
         mt_Object,
         mt_Category,
+        mt_DisjointSpecialisation,
+        mt_OverlappingSpecialisation,
+        mt_Union,
         mt_Initial_State,
         mt_End_State,
         mt_State,
@@ -214,8 +219,9 @@
      *
      * @param parent    The parent to ListPopupMenu.
      * @param type              The type of menu to display.
+     * @param object   The UMLObject of the ListViewItem
      */
-    ListPopupMenu(QWidget* parent, Uml::ListView_Type type);
+    ListPopupMenu(QWidget* parent, Uml::ListView_Type type, UMLObject* object);
 
     /**
      * Constructs the popup menu for a canvas widget.
@@ -307,14 +313,19 @@
      * Creates a popup menu for a single class or interface widgets.
      */
     void makeClassifierPopup(ClassifierWidget *c);
+ 
+    /**
+     * Creates a popup menu for a single category Object
+     * @param category The UMLCategory for which the category menu is created
+     */
+    KMenu* makeCategoryTypeMenu(UMLCategory* category);
 
     /**
      * Shortcut for commonly used menu initializations.
      *
      * @param type      The Menu_Type for which to set up the menu.
-     * @param view      The UMLView parent of the menu.
      */
-    void setupMenu(Menu_Type type, UMLView * view = 0);
+    void setupMenu(Menu_Type type);
 
     enum PixMap_Type {
         pm_Class,
@@ -342,6 +353,27 @@
     void setupColor(bool fc);
     void setupColorSelection(bool fc);
     void setupDiagramMenu(UMLView* view);
+ 
+    /**
+     * The List Popup Menu is triggered by either by right clicking on the 
+     * View, a ListViewItem ( Object ) , or a widget
+     */
+    union TriggerObject{
+	UMLView* m_View;
+        UMLObject* m_Object;
+        UMLWidget* m_Widget;
+    };
+    
+    /**
+     * Enum to keep track on TriggerObject Type
+     */
+    enum TriggerObjectType {
+        tot_View,tot_Object,tot_Widget
+    };
+
+    TriggerObject m_TriggerObject;
+    TriggerObjectType m_TriggerObjectType;
+ 
 };
 
 #endif
--- trunk/KDE/kdesdk/umbrello/umbrello/umldoc.cpp #690216:690217
@@ -2196,7 +2196,7 @@
         break;
     }//end switch
 
-    m_pTabPopupMenu = new ListPopupMenu(UMLApp::app()->getMainViewWidget(), type);
+    m_pTabPopupMenu = new ListPopupMenu(UMLApp::app()->getMainViewWidget(), type, 0);
     m_pTabPopupMenu->popup(point);
     connect(m_pTabPopupMenu, SIGNAL(activated(int)), view, SLOT(slotMenuSelection(int)));
 }
--- trunk/KDE/kdesdk/umbrello/umbrello/umllistview.cpp #690216:690217
@@ -162,7 +162,8 @@
             disconnect(m_pMenu, SIGNAL(activated(int)), this, SLOT(popupMenuSel(int)));
             delete m_pMenu;
         }
-        m_pMenu = new ListPopupMenu(this, Uml::lvt_Model);
+        UMLListViewItem * temp = (UMLListViewItem*)currentItem();
+        m_pMenu = new ListPopupMenu(this, Uml::lvt_Model, temp->getUMLObject());
         m_pMenu->popup(me->globalPos());
         connect(m_pMenu, SIGNAL(activated(int)), this, SLOT(popupMenuSel(int)));
         return true;
@@ -200,7 +201,7 @@
             m_pMenu = 0;
         }
         const Uml::ListView_Type type = item->getType();
-        m_pMenu = new ListPopupMenu(this, type);
+        m_pMenu = new ListPopupMenu(this, type, item->getUMLObject());
         m_pMenu->popup(me->globalPos());
         connect(m_pMenu, SIGNAL(activated(int)), this, SLOT(popupMenuSel(int)));
     }//end if right button
@@ -305,6 +306,27 @@
         addNewItem(temp, Uml::lvt_Category);
         break;
 
+    case ListPopupMenu::mt_DisjointSpecialisation:
+        {
+          UMLCategory* catObj = static_cast<UMLCategory*>(temp->getUMLObject());
+          catObj->setType(UMLCategory::ct_Disjoint_Specialisation);
+          break;
+        }
+
+    case ListPopupMenu::mt_OverlappingSpecialisation:
+        {
+          UMLCategory* catObj = static_cast<UMLCategory*>(temp->getUMLObject());
+          catObj->setType(UMLCategory::ct_Overlapping_Specialisation);
+          break;
+        }
+
+    case ListPopupMenu::mt_Union:
+        {
+          UMLCategory* catObj = static_cast<UMLCategory*>(temp->getUMLObject());
+          catObj->setType(UMLCategory::ct_Union);
+          break;
+        }
+
     case ListPopupMenu::mt_Datatype:
         addNewItem(temp, Uml::lvt_Datatype);
         break;




More information about the umbrello-devel mailing list