[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [umbrello] umbrello: Merge in Qt5 variant of KMenu from frameworks branch.
From:       Ralf Habacker <ralf.habacker () freenet ! de>
Date:       2015-05-31 14:12:19
Message-ID: E1Yz3yN-0002ON-Ak () scm ! kde ! org
[Download RAW message or body]

Git commit 81dea33f05bc84a293f014935a95e48b6a6c1934 by Ralf Habacker.
Committed on 31/05/2015 at 13:55.
Pushed by habacker into branch 'master'.

Merge in Qt5 variant of KMenu from frameworks branch.

M  +12   -0    umbrello/dialogs/codeeditor.cpp
M  +4    -0    umbrello/dialogs/codeeditor.h
M  +4    -0    umbrello/dialogs/pages/constraintlistpage.h
M  +106  -5    umbrello/listpopupmenu.cpp
M  +22   -3    umbrello/listpopupmenu.h

http://commits.kde.org/umbrello/81dea33f05bc84a293f014935a95e48b6a6c1934

diff --git a/umbrello/dialogs/codeeditor.cpp b/umbrello/dialogs/codeeditor.cpp
index ff723ea..d445ad9 100644
--- a/umbrello/dialogs/codeeditor.cpp
+++ b/umbrello/dialogs/codeeditor.cpp
@@ -734,7 +734,11 @@ void CodeEditor::slotInsertCodeBlockAfterSelected()
  */
 void CodeEditor::contextMenuEvent(QContextMenuEvent * event)
 {
+#if QT_VERSION >= 0x050000
+    QMenu* menu = createPopup();
+#else
     KMenu* menu = createPopup();
+#endif
     menu->exec(event->globalPos());
     delete menu;
 }
@@ -743,11 +747,19 @@ void CodeEditor::contextMenuEvent(QContextMenuEvent * event)
  * Create the popup menu.
  * @return   the popup menu
  */
+#if QT_VERSION >= 0x050000
+QMenu * CodeEditor::createPopup()
+#else
 KMenu * CodeEditor::createPopup()
+#endif
 {
     DEBUG(DBG_SRC) << "called...";
 
+#if QT_VERSION >= 0x050000
+    QMenu * menu = new QMenu(this);
+#else
     KMenu * menu = new KMenu(this);
+#endif
 
     TextBlock * tb = m_selectedTextBlock;
     if (tb) {
diff --git a/umbrello/dialogs/codeeditor.h b/umbrello/dialogs/codeeditor.h
index 1dcee81..da994ca 100644
--- a/umbrello/dialogs/codeeditor.h
+++ b/umbrello/dialogs/codeeditor.h
@@ -97,7 +97,11 @@ protected:
 
     void loadFromDocument();
 
+#if QT_VERSION >= 0x050000
+    QMenu * createPopup();
+#else
     KMenu * createPopup();
+#endif
 
 private:
     QString            m_parentDocName;
diff --git a/umbrello/dialogs/pages/constraintlistpage.h b/umbrello/dialogs/pages/constraintlistpage.h
index 37e4518..fef0728 100644
--- a/umbrello/dialogs/pages/constraintlistpage.h
+++ b/umbrello/dialogs/pages/constraintlistpage.h
@@ -68,7 +68,11 @@ protected:
 
     bool greaterThan(UMLObject::ObjectType ct1, UMLObject::ObjectType ct2);
 
+#if QT_VERSION >= 0x050000
+    QMenu* buttonMenu;
+#else
     KMenu* buttonMenu;
+#endif
 
 };
 
diff --git a/umbrello/listpopupmenu.cpp b/umbrello/listpopupmenu.cpp
index d58db0b..a223055 100644
--- a/umbrello/listpopupmenu.cpp
+++ b/umbrello/listpopupmenu.cpp
@@ -56,8 +56,13 @@ const bool CHECKABLE = true;
  * @param type     The type of menu to display.
  * @param view     The UMLView object
  */
+
 ListPopupMenu::ListPopupMenu(QWidget *parent, MenuType type, UMLView * view)
-  : KMenu(parent),
+#if QT_VERSION >= 0x050000
+    : QMenu(parent),
+#else
+    : KMenu(parent),
+#endif
     m_isListView(false)
 {
     m_TriggerObject.m_View = view;
@@ -74,7 +79,11 @@ ListPopupMenu::ListPopupMenu(QWidget *parent, MenuType type, UMLView * view)
  * @param widget   The WidgetBase object.
  */
 ListPopupMenu::ListPopupMenu(QWidget *parent, MenuType type, WidgetBase *widget)
-  : KMenu(parent),
+#if QT_VERSION >= 0x050000
+    : QMenu(parent),
+#else
+    : KMenu(parent),
+#endif
     m_isListView(false)
 {
     m_TriggerObject.m_Widget = widget;
@@ -91,7 +100,11 @@ ListPopupMenu::ListPopupMenu(QWidget *parent, MenuType type, WidgetBase *widget)
  * @param object   The UMLObject of the ListViewItem
  */
 ListPopupMenu::ListPopupMenu(QWidget *parent, UMLListViewItem::ListViewType type, UMLObject* object)
-  : KMenu(parent),
+#if QT_VERSION >= 0x050000
+    : QMenu(parent),
+#else
+    : KMenu(parent),
+#endif
     m_isListView(true)
 {
     m_TriggerObject.m_Object = object;
@@ -328,7 +341,11 @@ ListPopupMenu::ListPopupMenu(QWidget *parent, UMLListViewItem::ListViewType type
  * @param uniqueType The type of widget shared by all selected widgets
  */
 ListPopupMenu::ListPopupMenu(QWidget * parent, WidgetBase * object, bool multi, WidgetBase::WidgetType uniqueType)
-  : KMenu(parent),
+#if QT_VERSION >= 0x050000
+    : QMenu(parent),
+#else
+    : KMenu(parent),
+#endif
     m_isListView(false)
 {
     m_TriggerObject.m_Widget = object;
@@ -387,7 +404,11 @@ void ListPopupMenu::insertSingleSelectionMenu(WidgetBase* object)
 
     case WidgetBase::wt_Category:
        {
+#if QT_VERSION >= 0x050000
+         QMenu* m = makeCategoryTypeMenu(
+#else
          KMenu* m = makeCategoryTypeMenu(
+#endif
                         static_cast<UMLCategory*>(object->umlObject()));
          m->setTitle(i18n("Category Type"));
          addMenu(m);
@@ -667,7 +688,11 @@ void ListPopupMenu::insertMultiSelectionMenu(WidgetBase::WidgetType uniqueType)
 {
     insertSubMenuAlign();
 
+#if QT_VERSION >= 0x050000
+    QMenu* color = new QMenu(i18nc("color menu", "Color"), this);
+#else
     KMenu* color = new KMenu(i18nc("color menu", "Color"), this);
+#endif
     insert(mt_Line_Color_Selection, color, Icon_Utils::SmallIcon(Icon_Utils::it_Color_Line), i18n("Line Color..."));
     insert(mt_Fill_Color_Selection, color, Icon_Utils::SmallIcon(Icon_Utils::it_Color_Fill), i18n("Fill Color..."));
     insert(mt_Set_Use_Fill_Color_Selection, color, i18n("Use Fill Color"));
@@ -787,7 +812,11 @@ void ListPopupMenu::insert(MenuType m)
  * @param m      The MenuType for which to insert a menu item.
  * @param menu   The KMenu for which to insert a menu item.
  */
+#if QT_VERSION >= 0x050000
+void ListPopupMenu::insert(const MenuType m, QMenu* menu)
+#else
 void ListPopupMenu::insert(const MenuType m, KMenu* menu)
+#endif
 {
     Q_ASSERT(menu != NULL);
     switch (m) {
@@ -899,7 +928,11 @@ void ListPopupMenu::insert(const MenuType m, const QString & text, const bool ch
  * @param icon   The icon for this action.
  * @param text   The text for this action.
  */
+#if QT_VERSION >= 0x050000
+void ListPopupMenu::insert(const MenuType m, QMenu* menu, const QIcon & icon, const QString & text)
+#else
 void ListPopupMenu::insert(const MenuType m, KMenu* menu, const QIcon & icon, const QString & text)
+#endif
 {
     m_actions[m] = menu->addAction(icon, text);
 }
@@ -912,7 +945,11 @@ void ListPopupMenu::insert(const MenuType m, KMenu* menu, const QIcon & icon, co
  * @param text   The text for this action.
  * @param checkable   Sets the action to checkable.
  */
+#if QT_VERSION >= 0x050000
+void ListPopupMenu::insert(const MenuType m, QMenu* menu, const QString & text, const bool checkable)
+#else
 void ListPopupMenu::insert(const MenuType m, KMenu* menu, const QString & text, const bool checkable)
+#endif
 {
     m_actions[m] = menu->addAction(text);
     if (checkable) {
@@ -958,7 +995,11 @@ void ListPopupMenu::insertStdItems(bool insertLeadingSeparator /* = true */,
  */
 void ListPopupMenu::insertContainerItems(bool folderAndDiagrams)
 {
+#if QT_VERSION >= 0x050000
+    QMenu* menu = new QMenu(i18nc("new container menu", "New"), this);
+#else
     KMenu* menu = new KMenu(i18nc("new container menu", "New"), this);
+#endif
     menu->setIcon(Icon_Utils::SmallIcon(Icon_Utils::it_New));
     if (folderAndDiagrams)
         insert(mt_Logical_Folder, menu, Icon_Utils::BarIcon(Icon_Utils::it_Folder), i18n("Folder"));
@@ -1051,7 +1092,11 @@ void ListPopupMenu::insertAssociationTextItem(const QString &label, MenuType mt)
  */
 void ListPopupMenu::insertSubMenuLayout(AssociationLine *associationLine)
 {
+#if QT_VERSION >= 0x050000
+    QMenu* layout = new QMenu(i18nc("Layout menu", "Layout"), this);
+#else
     KMenu* layout = new KMenu(i18nc("Layout menu", "Layout"), this);
+#endif
     insert(mt_LayoutPolyline, layout, i18n("Polyline"), true);
     insert(mt_LayoutDirect, layout, i18n("Direct"), true);
     insert(mt_LayoutSpline, layout, i18n("Spline"), true);
@@ -1152,7 +1197,11 @@ void ListPopupMenu::makeClassifierShowPopup(ClassifierWidget *c)
     WidgetBase::WidgetType type = c->baseType();
     ClassifierWidget *cls = NULL;
 
+#if QT_VERSION >= 0x050000
+    QMenu* show = new QMenu(i18n("Show"), this);
+#else
     KMenu* show = new KMenu(i18n("Show"), this);
+#endif
     show->setIcon(Icon_Utils::SmallIcon(Icon_Utils::it_Show));
     if (type == WidgetBase::wt_Class) {
         cls = static_cast<ClassifierWidget*>(c);
@@ -1189,10 +1238,18 @@ void ListPopupMenu::makeClassifierShowPopup(ClassifierWidget *c)
  */
 void ListPopupMenu::makeMultiClassifierShowPopup(WidgetBase::WidgetType type)
 {
+#if QT_VERSION >= 0x050000
+    QMenu* show = new QMenu(i18n("Show"), this);
+#else
     KMenu* show = new KMenu(i18n("Show"), this);
+#endif
     show->setIcon(Icon_Utils::SmallIcon(Icon_Utils::it_Show));
 
+#if QT_VERSION >= 0x050000
+    QMenu* attributes = new QMenu(i18n("Attributes"), this);
+#else
     KMenu* attributes = new KMenu(i18n("Attributes"), this);
+#endif
     if (type == WidgetBase::wt_Class) {
         insert(mt_Show_Attributes_Selection, attributes, i18n("Show"));
         insert(mt_Hide_Attributes_Selection, attributes, i18n("Hide"));
@@ -1201,27 +1258,43 @@ void ListPopupMenu::makeMultiClassifierShowPopup(WidgetBase::WidgetType type)
     }
     show->addMenu(attributes);
 
+#if QT_VERSION >= 0x050000
+    QMenu* operations = new QMenu(i18n("Operations"), this);
+#else
     KMenu* operations = new KMenu(i18n("Operations"), this);
+#endif
     insert(mt_Show_Operations_Selection, operations, i18n("Show"));
     insert(mt_Hide_Operations_Selection, operations, i18n("Hide"));
     insert(mt_Show_Operation_Signature_Selection, operations, i18n("Show Signatures"));
     insert(mt_Hide_Operation_Signature_Selection, operations, i18n("Hide Signatures"));
     show->addMenu(operations);
 
+#if QT_VERSION >= 0x050000
+    QMenu* visibility = new QMenu(i18n("Visibility"), this);
+#else
     KMenu* visibility = new KMenu(i18n("Visibility"), this);
+#endif
     insert(mt_Show_Visibility_Selection, visibility, i18n("Show"));
     insert(mt_Hide_Visibility_Selection, visibility, i18n("Hide"));
     insert(mt_Hide_NonPublic_Selection, visibility, i18n("Hide Non-public members"));
     insert(mt_Show_NonPublic_Selection, visibility, i18n("Show Non-public members"));
     show->addMenu(visibility);
 
+#if QT_VERSION >= 0x050000
+    QMenu* packages = new QMenu(i18n("Packages"), this);
+#else
     KMenu* packages = new KMenu(i18n("Packages"), this);
+#endif
     insert(mt_Show_Packages_Selection, packages, i18n("Show"));
     insert(mt_Hide_Packages_Selection, packages, i18n("Hide"));
     show->addMenu(packages);
 
     if (type == WidgetBase::wt_Class) {
+#if QT_VERSION >= 0x050000
+        QMenu* stereotypes = new QMenu(i18n("Stereotypes"), this);
+#else
         KMenu* stereotypes = new KMenu(i18n("Stereotypes"), this);
+#endif
         insert(mt_Show_Stereotypes_Selection, stereotypes, i18n("Show"));
         insert(mt_Hide_Stereotypes_Selection, stereotypes, i18n("Hide"));
         show->addMenu(stereotypes);
@@ -1235,7 +1308,11 @@ void ListPopupMenu::makeMultiClassifierShowPopup(WidgetBase::WidgetType type)
 void ListPopupMenu::makeClassifierPopup(ClassifierWidget *c)
 {
     WidgetBase::WidgetType type = c->baseType();
+#if QT_VERSION >= 0x050000
+    QMenu* menu = new QMenu(i18nc("new classifier menu", "New"), this);
+#else
     KMenu* menu = new KMenu(i18nc("new classifier menu", "New"), this);
+#endif
     menu->setIcon(Icon_Utils::SmallIcon(Icon_Utils::it_New));
     if (type == WidgetBase::wt_Class)
         insert(mt_Attribute, menu, Icon_Utils::SmallIcon(Icon_Utils::it_Public_Attribute), i18n("Attribute..."));
@@ -1288,7 +1365,11 @@ ListPopupMenu::MenuType ListPopupMenu::typeFromAction(QAction *action)
  */
 void ListPopupMenu::insertSubMenuAlign()
 {
+#if QT_VERSION >= 0x050000
+    QMenu* alignment = new QMenu(i18nc("align menu", "Align"), this);
+#else
     KMenu* alignment = new KMenu(i18nc("align menu", "Align"), this);
+#endif
     insert(mt_Align_Right, alignment, Icon_Utils::SmallIcon(Icon_Utils::it_Align_Right), i18n("Align Right"));
     insert(mt_Align_Left, alignment, Icon_Utils::SmallIcon(Icon_Utils::it_Align_Left), i18n("Align Left"));
     insert(mt_Align_Top, alignment, Icon_Utils::SmallIcon(Icon_Utils::it_Align_Top), i18n("Align Top"));
@@ -1309,7 +1390,11 @@ void ListPopupMenu::insertSubMenuAlign()
  */
 void ListPopupMenu::insertSubMenuColor(bool fc)
 {
+#if QT_VERSION >= 0x050000
+    QMenu* color = new QMenu(i18nc("color menu", "Color"), this);
+#else
     KMenu* color = new KMenu(i18nc("color menu", "Color"), this);
+#endif
     insert(mt_Line_Color, color, Icon_Utils::SmallIcon(Icon_Utils::it_Color_Line), i18n("Line Color..."));
     insert(mt_Fill_Color, color, Icon_Utils::SmallIcon(Icon_Utils::it_Color_Fill), i18n("Fill Color..."));
     insert(mt_Use_Fill_Color, color, i18n("Use Fill Color"), CHECKABLE);
@@ -1376,7 +1461,7 @@ ListPopupMenu* ListPopupMenu::menuFromAction(QAction *action)
 {
     if (action) {
         QVariant value = dataFromAction(dt_MenuPointer, action);
-        if (qVariantCanConvert<ListPopupMenu*>(value)) {
+        if (value.canConvert<ListPopupMenu*>()) {
             return qvariant_cast<ListPopupMenu*>(value);
         }
     }
@@ -1390,7 +1475,11 @@ ListPopupMenu* ListPopupMenu::menuFromAction(QAction *action)
  */
 void ListPopupMenu::insertSubMenuNew(MenuType type)
 {
+#if QT_VERSION >= 0x050000
+    QMenu* menu = new QMenu(i18nc("new sub menu", "New"), this);
+#else
     KMenu* menu = new KMenu(i18nc("new sub menu", "New"), this);
+#endif
     menu->setIcon(Icon_Utils::SmallIcon(Icon_Utils::it_New));
     switch (type) {
         case mt_Deployment_View:
@@ -1816,7 +1905,11 @@ void ListPopupMenu::setupMenu(MenuType type)
                 uError() << "Invalid Trigger Object Type Set for Use Case Diagram " << m_TriggerObjectType;
                 return;
             }
+#if QT_VERSION >= 0x050000
+            QMenu* menu = makeCategoryTypeMenu(static_cast<UMLCategory*>(m_TriggerObject.m_Object));
+#else
             KMenu* menu = makeCategoryTypeMenu(static_cast<UMLCategory*>(m_TriggerObject.m_Object));
+#endif
             menu->setTitle(i18n("Category Type"));
             addMenu(menu);
             insertStdItems(false);
@@ -2038,9 +2131,17 @@ void ListPopupMenu::setupDiagramMenu(UMLView* view)
  * Creates a popup menu for a single category Object
  * @param category The UMLCategory for which the category menu is created
  */
+#if QT_VERSION >= 0x050000
+QMenu* ListPopupMenu::makeCategoryTypeMenu(UMLCategory* category)
+#else
 KMenu* ListPopupMenu::makeCategoryTypeMenu(UMLCategory* category)
+#endif
 {
+#if QT_VERSION >= 0x050000
+    QMenu* catTypeMenu = new QMenu(this);
+#else
     KMenu* catTypeMenu = new KMenu(this);
+#endif
     insert(mt_DisjointSpecialisation, catTypeMenu, i18n("Disjoint(Specialisation)"), CHECKABLE);
     insert(mt_OverlappingSpecialisation, catTypeMenu, i18n("Overlapping(Specialisation)"), CHECKABLE);
     insert(mt_Union, catTypeMenu, i18n("Union"), CHECKABLE);
diff --git a/umbrello/listpopupmenu.h b/umbrello/listpopupmenu.h
index b23390a..093dad1 100644
--- a/umbrello/listpopupmenu.h
+++ b/umbrello/listpopupmenu.h
@@ -15,10 +15,14 @@
 #include "umllistviewitem.h"
 #include "umlobject.h"
 #include "widgetbase.h"
-
+#if QT_VERSION < 0x050000
 #include <kmenu.h>
+#endif
 
 #include <QHash>
+#if QT_VERSION >= 0x050000
+#include <QMenu>
+#endif
 
 class AssociationLine;
 class ClassifierWidget;
@@ -37,7 +41,11 @@ class UMLView;
  * @author Paul Hensgen <phensgen@techie.com>
  * Bugs and comments to umbrello-devel@kde.org or http://bugs.kde.org
  */
+#if QT_VERSION >= 0x050000
+class ListPopupMenu : public QMenu
+#else
 class ListPopupMenu : public KMenu
+#endif
 {
     Q_OBJECT
     Q_ENUMS(MenuType)
@@ -306,11 +314,18 @@ private:
     void insertMultiSelectionMenu(WidgetBase::WidgetType uniqueType);
 
     void insert(MenuType m);
+#if QT_VERSION >= 0x050000
+    void insert(const MenuType m, QMenu* menu);
+    void insert(const MenuType m, QMenu* menu, const QIcon & icon, const QString & text);
+    void insert(const MenuType m, QMenu* menu, const QString & text, const bool checkable = false);
+#else
     void insert(const MenuType m, KMenu* menu);
-    void insert(const MenuType m, const QIcon & icon, const QString & text);
-    void insert(const MenuType m, const QString & text, const bool checkable = false);
     void insert(const MenuType m, KMenu* menu, const QIcon & icon, const QString & text);
     void insert(const MenuType m, KMenu* menu, const QString & text, const bool checkable = false);
+#endif
+    void insert(const MenuType m, const QIcon & icon, const QString & text);
+    void insert(const MenuType m, const QString & text, const bool checkable = false);
+
 
     void insertStdItems(bool insertLeadingSeparator = true,
                         WidgetBase::WidgetType type = WidgetBase::wt_UMLWidget);
@@ -324,7 +339,11 @@ private:
     void makeClassifierPopup(ClassifierWidget *c);
     void makeMultiClassifierShowPopup(WidgetBase::WidgetType type);
     void makeClassifierShowPopup(ClassifierWidget *c);
+#if QT_VERSION >= 0x050000
+    QMenu* makeCategoryTypeMenu(UMLCategory* category);
+#else
     KMenu* makeCategoryTypeMenu(UMLCategory* category);
+#endif
 
     void insertSubMenuNew(MenuType type);
     void insertSubMenuAlign();

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic