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

List:       kde-commits
Subject:    KDE/kdelibs/kdeui/widgets
From:       David Faure <faure () kde ! org>
Date:       2010-11-17 15:17:32
Message-ID: 20101117151732.A6B62AC8A0 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1198145 by dfaure:

Merge EventSniffer and MenuPrivate to save a new/delete and to simplify the code.


 M  +25 -38    kmenu.cpp  


--- trunk/KDE/kdelibs/kdeui/widgets/kmenu.cpp #1198144:1198145
@@ -44,6 +44,7 @@
 static const char KMENU_TITLE[] = "kmenu_title";
 
 class KMenu::KMenuPrivate
+    : public QObject
 {
 public:
     KMenuPrivate (KMenu *_parent);
@@ -54,50 +55,16 @@
     void showCtxMenu(const QPoint &pos);
     void skipTitles(QKeyEvent *event);
 
-    KMenu *parent;
-
-    // variables for keyboard navigation
-    QTimer clearTimer;
-
-    bool noMatches : 1;
-    bool shortcuts : 1;
-    bool autoExec : 1;
-
-    QString keySeq;
-    QString originalText;
-
-    QAction* lastHitAction;
-    QAction* lastHoveredAction;
-    Qt::MouseButtons mouseButtons;
-    Qt::KeyboardModifiers keyboardModifiers;
-
-    // support for RMB menus on menus
-    QMenu* ctxMenu;
-    QPointer<QAction> highlightedAction;
-
-    class EventSniffer;
-    EventSniffer *eventSniffer;
-};
-
 /**
   * @internal
   *
-  * This event sniffer is an event filter which will be installed
+     * This event filter which is installed
   * on the title of the menu, which is a QToolButton. This will
   * prevent clicks (what would change down and focus properties on
   * the title) on the title of the menu.
   *
   * @author Rafael Fernández López <ereslibre@kde.org>
   */
-class KMenu::KMenuPrivate::EventSniffer
-    : public QObject
-{
-public:
-    EventSniffer(QObject *parent = 0)
-        : QObject(parent) { }
-
-    ~EventSniffer() { }
-
     bool eventFilter(QObject *object, QEvent *event)
     {
         Q_UNUSED(object);
@@ -111,6 +78,28 @@
         event->accept();
         return true;
     }
+
+    KMenu *parent;
+
+    // variables for keyboard navigation
+    QTimer clearTimer;
+
+    bool noMatches : 1;
+    bool shortcuts : 1;
+    bool autoExec : 1;
+
+    QString keySeq;
+    QString originalText;
+
+    QAction* lastHitAction;
+    QAction* lastHoveredAction;
+    Qt::MouseButtons mouseButtons;
+    Qt::KeyboardModifiers keyboardModifiers;
+
+    // support for RMB menus on menus
+    QMenu* ctxMenu;
+    QPointer<QAction> highlightedAction;
+
 };
 
 KMenu::KMenuPrivate::KMenuPrivate (KMenu *_parent)
@@ -124,7 +113,6 @@
     , keyboardModifiers(Qt::NoModifier)
     , ctxMenu(0)
     , highlightedAction(0)
-    , eventSniffer(new EventSniffer)
 {
     resetKeyboardVars();
     KAcceleratorManager::manage(parent);
@@ -133,7 +121,6 @@
 KMenu::KMenuPrivate::~KMenuPrivate ()
 {
     delete ctxMenu;
-    delete eventSniffer;
 }
 
 
@@ -196,7 +183,7 @@
     QWidgetAction *action = new QWidgetAction(this);
     action->setObjectName(KMENU_TITLE);
     QToolButton *titleButton = new QToolButton(this);
-    titleButton->installEventFilter(d->eventSniffer); // prevent clicks on the title of the menu
+    titleButton->installEventFilter(d); // prevent clicks on the title of the menu
     titleButton->setDefaultAction(buttonAction);
     titleButton->setDown(true); // prevent hover style changes in some styles
     titleButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
[prev in list] [next in list] [prev in thread] [next in thread] 

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