aboutsummaryrefslogtreecommitdiff
path: root/libqmenumodel/src/menunode.cpp
diff options
context:
space:
mode:
authorNick Dedekind <nicholas.dedekind@gmail.com>2013-08-08 16:12:57 +0100
committerNick Dedekind <nicholas.dedekind@gmail.com>2013-08-08 16:12:57 +0100
commitc6cb726c5694f8a35711a48a7bf5e2a6723aeba8 (patch)
tree509f5b5c2cf1223274034721a611c55c5039b0ab /libqmenumodel/src/menunode.cpp
parent52b17007596bcd29ec0fe01468d28fddfcc18785 (diff)
downloadqmenumodel-c6cb726c5694f8a35711a48a7bf5e2a6723aeba8.tar.gz
qmenumodel-c6cb726c5694f8a35711a48a7bf5e2a6723aeba8.tar.bz2
qmenumodel-c6cb726c5694f8a35711a48a7bf5e2a6723aeba8.zip
Glib callbacks send events through qt.
Diffstat (limited to 'libqmenumodel/src/menunode.cpp')
-rw-r--r--libqmenumodel/src/menunode.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/libqmenumodel/src/menunode.cpp b/libqmenumodel/src/menunode.cpp
index ed9a984..10313d5 100644
--- a/libqmenumodel/src/menunode.cpp
+++ b/libqmenumodel/src/menunode.cpp
@@ -21,6 +21,9 @@
#include <QMetaMethod>
#include <QDebug>
+#include <QCoreApplication>
+
+const QEvent::Type MenuNodeItemChangeEvent::eventType = static_cast<QEvent::Type>(QEvent::registerEventType());
MenuNode::MenuNode(const QString &linkType, GMenuModel *model, MenuNode *parent, int pos, QObject *listener)
: m_model(model),
@@ -242,15 +245,16 @@ void MenuNode::onItemsChanged(GMenuModel *model, gint position, gint removed, gi
self->m_currentOpAdded = added;
self->m_currentOpRemoved = removed;
- const QMetaObject *mobj = self->m_listener->metaObject();
- if (!mobj->invokeMethod(self->m_listener,
- "onItemsChanged",
- Q_ARG(MenuNode*, self),
- Q_ARG(int, position),
- Q_ARG(int, removed),
- Q_ARG(int, added)))
- {
- qWarning() << "Slot 'onItemsChanged(MenuNode*, int, int, int)' not found in" << self->m_listener;
- }
+ MenuNodeItemChangeEvent mnice(self, position, added, removed);
+ QCoreApplication::sendEvent(self->m_listener, &mnice);
+
self->commitOperation();
}
+
+MenuNodeItemChangeEvent::MenuNodeItemChangeEvent(MenuNode* _node, int _position, int _removed, int _added)
+ : QEvent(MenuNodeItemChangeEvent::eventType),
+ node(_node),
+ position(_position),
+ removed(_removed),
+ added(_added)
+{}