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

Oliver Kellogg okellogg at users.sourceforge.net
Tue Sep 18 18:55:09 UTC 2007


SVN commit 714102 by okellogg:

Patch from Andi Fischer fixes a crash when right-clicking on the tab of a diagram
and selecting an item of the popup menu.  Also removes some unneeded includes.
CCMAIL:andi.fischer at hispeed.ch


 M  +3 -1      listpopupmenu.cpp  
 M  +12 -2     umldoc.cpp  
 M  +8 -11     umldoc.h  
 M  +21 -22    umlview.cpp  
 M  +0 -1      umlview.h  


--- trunk/KDE/kdesdk/umbrello/umbrello/listpopupmenu.cpp #714101:714102
@@ -231,6 +231,7 @@
         break;
 
     default:
+        uWarning() << "unhandled ListView_Type " << type << endl;
         break;
     }
     setupMenu(mt);
@@ -249,7 +250,7 @@
         return;
     Uml::Widget_Type type = object->getBaseType();
     // uDebug() << "ListPopupMenu created with multi=" << multi << " , unique="
-    //         << unique << " for Widget_Type=" << type << endl;
+    //          << unique << " for Widget_Type=" << type << endl;
 
     if(multi) {
         ClassifierWidget *c = NULL;
@@ -528,6 +529,7 @@
         }
         break;
     default:
+        uWarning() << "unhandled Widget_Type " << type << endl;
         break;
     }//end switch
 
--- trunk/KDE/kdesdk/umbrello/umbrello/umldoc.cpp #714101:714102
@@ -2188,15 +2188,25 @@
         break;
 
     default:
-        uWarning() << "unknown diagram type in slotDiagramPopupMenu()";
-        break;
+        uWarning() << "unknown diagram type " << view->getType();
+        return;
     }//end switch
 
+    // uDebug() << "create popup for ListView_Type " << type;
     m_pTabPopupMenu = new ListPopupMenu(UMLApp::app()->getMainViewWidget(), type, 0);
     m_pTabPopupMenu->popup(point);
     connect(m_pTabPopupMenu, SIGNAL(triggered(QAction*)), view, SLOT(slotMenuSelection(QAction*)));
 }
 
+ListPopupMenu::Menu_Type UMLDoc::getPopupMenuSelection(QAction* action) {
+    if (m_pTabPopupMenu == NULL) {
+        return ListPopupMenu::mt_Undefined;
+    }
+    else {
+        return m_pTabPopupMenu->getMenuType(action);
+    }
+}
+
 void UMLDoc::addDefaultStereotypes() {
     CodeGenerator *gen = UMLApp::app()->getGenerator();
     if (gen)
--- trunk/KDE/kdesdk/umbrello/umbrello/umldoc.h #714101:714102
@@ -16,21 +16,12 @@
 #include <typeinfo>
 
 // qt includes
-#include <qdatastream.h>
-#include <qmap.h>
-#include <q3dict.h>
-#include <q3ptrstack.h>
-//Added by qt3to4:
-#include <Q3PtrList>
-#include <QUndoView>
 
 // kde includes
 #include <kurl.h>
-#include <k3dockwidget.h>
-#include <kmenu.h>
-#include <kundostack.h>
 
 // app includes
+#include "listpopupmenu.h"
 #include "umlnamespace.h"
 #include "optionstate.h"
 #include "umlobjectlist.h"
@@ -754,6 +745,12 @@
      */
     void resolveTypes();
 
+    /**
+     * Find and return the user selected type of the popup menu.
+     * See also m_pTabPopupMenu and slotDiagramPopupMenu
+     */
+    ListPopupMenu::Menu_Type getPopupMenuSelection(QAction* action);
+
 private:
     /**
      * Sets up the autosave timer.
@@ -824,7 +821,7 @@
      * the context menu on the tabs,
      * plugs into umlview::slotMenuSelection()
      */
-    KMenu* m_pTabPopupMenu;
+    ListPopupMenu* m_pTabPopupMenu;
 
     /**
      * Auxiliary variable for currentRoot():
--- trunk/KDE/kdesdk/umbrello/umbrello/umlview.cpp #714101:714102
@@ -17,25 +17,16 @@
 #include <math.h>
 
 // include files for Qt
-#include <qpixmap.h>
-#include <q3picture.h>
-#include <qprinter.h>
-#include <qpainter.h>
-#include <qstring.h>
-#include <qstringlist.h>
-#include <qobject.h>
-#include <q3objectdict.h>
-#include <q3dragobject.h>
-#include <qfileinfo.h>
-#include <q3ptrlist.h>
-#include <qcolor.h>
-#include <qmatrix.h>
-#include <qregexp.h>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QVector>
+#include <QtGui/QPixmap>
+#include <QtGui/QPainter>
+#include <QtGui/QColor>
+#include <QtGui/QMatrix>
 #include <q3paintdevicemetrics.h>
-#include <qvector.h>
 
 //Added by qt3to4:
-#include <QTextStream>
 #include <QHideEvent>
 #include <QCloseEvent>
 #include <QDropEvent>
@@ -2485,7 +2476,7 @@
 void UMLView::setMenu() {
     slotRemovePopupMenu();
     ListPopupMenu::Menu_Type menu = ListPopupMenu::mt_Undefined;
-    switch( getType() ) {
+    switch ( getType() ) {
     case dt_Class:
         menu = ListPopupMenu::mt_On_Class_Diagram;
         break;
@@ -2523,11 +2514,12 @@
         break;
 
     default:
-        uWarning() << "setMenu() called on unknown diagram type";
+        uWarning() << "unknown diagram type " << getType();
         menu = ListPopupMenu::mt_Undefined;
         break;
     }//end switch
-    if( menu != ListPopupMenu::mt_Undefined ) {
+    if (menu != ListPopupMenu::mt_Undefined) {
+        // uDebug() << "create popup for Menu_Type " << menu;
         m_pMenu = new ListPopupMenu(this, menu, this);
         connect(m_pMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotMenuSelection(QAction*)));
         m_pMenu->popup( mapToGlobal( contentsToViewport(worldMatrix().map(m_Pos)) ) );
@@ -2535,7 +2527,7 @@
 }
 
 void UMLView::slotRemovePopupMenu() {
-    if(m_pMenu) {
+    if (m_pMenu) {
         disconnect(m_pMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotMenuSelection(QAction*)));
         delete m_pMenu;
         m_pMenu = 0;
@@ -2543,8 +2535,14 @@
 }
 
 void UMLView::slotMenuSelection(QAction* action) {
-    ListPopupMenu::Menu_Type sel = m_pMenu->getMenuType(action);
-    switch(sel) {
+    ListPopupMenu::Menu_Type sel = ListPopupMenu::mt_Undefined;
+    if (m_pMenu != NULL) {  // popup from this class
+        sel = m_pMenu->getMenuType(action);
+    }
+    else {  // popup from umldoc
+        sel = m_pDoc->getPopupMenuSelection(action);
+    }
+    switch (sel) {
     case ListPopupMenu::mt_Undo:
         UMLApp::app()->undo();
         break;
@@ -2757,6 +2755,7 @@
         break;
 
     default:
+        uWarning() << "unknown ListPopupMenu::Menu_Type " << sel;
         break;
     }
 }
--- trunk/KDE/kdesdk/umbrello/umbrello/umlview.h #714101:714102
@@ -20,7 +20,6 @@
 #include <QPixmap>
 #include <QHideEvent>
 #include <QCloseEvent>
-#include <Q3PtrList>
 #include <QDropEvent>
 #include <QShowEvent>
 #include <QDragEnterEvent>




More information about the umbrello-devel mailing list