aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libqmenumodel/src/CMakeLists.txt1
-rw-r--r--libqmenumodel/src/menunode.cpp11
-rw-r--r--libqmenumodel/src/menunode.h14
-rw-r--r--libqmenumodel/src/qdbusactiongroup.cpp22
-rw-r--r--libqmenumodel/src/qdbusactiongroup.h30
-rw-r--r--libqmenumodel/src/qdbusmenumodel.cpp1
-rw-r--r--libqmenumodel/src/qdbusobject.cpp20
-rw-r--r--libqmenumodel/src/qdbusobject.h12
-rw-r--r--libqmenumodel/src/qmenumodel.cpp20
-rw-r--r--libqmenumodel/src/qmenumodel.h13
-rw-r--r--libqmenumodel/src/qmenumodelevents.cpp96
-rw-r--r--libqmenumodel/src/qmenumodelevents.h99
12 files changed, 203 insertions, 136 deletions
diff --git a/libqmenumodel/src/CMakeLists.txt b/libqmenumodel/src/CMakeLists.txt
index 1fb89df..2f7aac8 100644
--- a/libqmenumodel/src/CMakeLists.txt
+++ b/libqmenumodel/src/CMakeLists.txt
@@ -8,6 +8,7 @@ set(QMENUMODEL_SRC
qdbusobject.cpp
qdbusmenumodel.cpp
qdbusactiongroup.cpp
+ qmenumodelevents.cpp
qstateaction.cpp
)
diff --git a/libqmenumodel/src/menunode.cpp b/libqmenumodel/src/menunode.cpp
index 10313d5..f244f40 100644
--- a/libqmenumodel/src/menunode.cpp
+++ b/libqmenumodel/src/menunode.cpp
@@ -18,13 +18,12 @@
*/
#include "menunode.h"
+#include "qmenumodelevents.h"
#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),
m_parent(parent),
@@ -250,11 +249,3 @@ void MenuNode::onItemsChanged(GMenuModel *model, gint position, gint removed, gi
self->commitOperation();
}
-
-MenuNodeItemChangeEvent::MenuNodeItemChangeEvent(MenuNode* _node, int _position, int _removed, int _added)
- : QEvent(MenuNodeItemChangeEvent::eventType),
- node(_node),
- position(_position),
- removed(_removed),
- added(_added)
-{}
diff --git a/libqmenumodel/src/menunode.h b/libqmenumodel/src/menunode.h
index 9e22e82..21fc5bc 100644
--- a/libqmenumodel/src/menunode.h
+++ b/libqmenumodel/src/menunode.h
@@ -24,7 +24,6 @@
#include <QPointer>
#include <QMap>
#include <QVariant>
-#include <QEvent>
extern "C" {
#include <gio/gio.h>
@@ -74,17 +73,4 @@ private:
static void onItemsChanged(GMenuModel *model, gint position, gint removed, gint added, gpointer data);
};
-class MenuNodeItemChangeEvent : public QEvent
-{
-public:
- static const QEvent::Type eventType;
-
- MenuNodeItemChangeEvent(MenuNode* node, int position, int removed, int added);
-
- MenuNode* node;
- int position;
- int removed;
- int added;
-};
-
#endif
diff --git a/libqmenumodel/src/qdbusactiongroup.cpp b/libqmenumodel/src/qdbusactiongroup.cpp
index 72e3302..5000470 100644
--- a/libqmenumodel/src/qdbusactiongroup.cpp
+++ b/libqmenumodel/src/qdbusactiongroup.cpp
@@ -20,6 +20,7 @@
#include "qdbusactiongroup.h"
#include "qstateaction.h"
#include "converter.h"
+#include "qmenumodelevents.h"
// Qt
#include <QCoreApplication>
@@ -29,9 +30,6 @@ extern "C" {
#include <gio/gio.h>
}
-const QEvent::Type DBusActionStateEvent::eventType = static_cast<QEvent::Type>(QEvent::registerEventType());
-const QEvent::Type DBusActionVisiblityEvent::eventType = static_cast<QEvent::Type>(QEvent::registerEventType());
-
/*!
\qmltype QDBusActionGroup
\inherits QDBusObject
@@ -272,21 +270,3 @@ void QDBusActionGroup::onActionStateChanged(GDBusActionGroup *, gchar *name, GVa
DBusActionStateEvent dase(name, Converter::toQVariant(value));
QCoreApplication::sendEvent(self, &dase);
}
-
-DBusActionEvent::DBusActionEvent(const QString& _name, QEvent::Type type)
- : QEvent(type),
- name(_name)
-{
-}
-
-DBusActionVisiblityEvent::DBusActionVisiblityEvent(const QString& _name, bool _visible)
- : DBusActionEvent(_name, DBusActionVisiblityEvent::eventType),
- visible(_visible)
-{
-}
-
-DBusActionStateEvent::DBusActionStateEvent(const QString& _name, const QVariant& _state)
- : DBusActionEvent(_name, DBusActionStateEvent::eventType),
- state(_state)
-{
-}
diff --git a/libqmenumodel/src/qdbusactiongroup.h b/libqmenumodel/src/qdbusactiongroup.h
index dde33a4..f369a4e 100644
--- a/libqmenumodel/src/qdbusactiongroup.h
+++ b/libqmenumodel/src/qdbusactiongroup.h
@@ -24,7 +24,6 @@
#include <QObject>
#include <QVariant>
-#include <QEvent>
class QStateAction;
@@ -92,33 +91,4 @@ private:
static void onActionStateChanged(GDBusActionGroup *ag, gchar *name, GVariant *value, gpointer data);
};
-class DBusActionEvent : public QEvent
-{
-public:
- QString name;
-
-protected:
- DBusActionEvent(const QString& name, QEvent::Type type);
-};
-
-class DBusActionVisiblityEvent : public DBusActionEvent
-{
-public:
- static const QEvent::Type eventType;
- DBusActionVisiblityEvent(const QString& name, bool visible);
-
- bool visible;
-};
-
-
-class DBusActionStateEvent : public DBusActionEvent
-{
-public:
- static const QEvent::Type eventType;
-
- DBusActionStateEvent(const QString& name, const QVariant& state);
-
- QVariant state;
-};
-
#endif // QDBUSACTIONGROUP_H
diff --git a/libqmenumodel/src/qdbusmenumodel.cpp b/libqmenumodel/src/qdbusmenumodel.cpp
index 29ee364..f8b4a51 100644
--- a/libqmenumodel/src/qdbusmenumodel.cpp
+++ b/libqmenumodel/src/qdbusmenumodel.cpp
@@ -22,6 +22,7 @@ extern "C" {
}
#include "qdbusmenumodel.h"
+#include "qmenumodelevents.h"
#include <QCoreApplication>
diff --git a/libqmenumodel/src/qdbusobject.cpp b/libqmenumodel/src/qdbusobject.cpp
index f289bf9..be9fb93 100644
--- a/libqmenumodel/src/qdbusobject.cpp
+++ b/libqmenumodel/src/qdbusobject.cpp
@@ -23,12 +23,11 @@ extern "C" {
}
#include "qdbusobject.h"
+#include "qmenumodelevents.h"
#include <QDebug>
#include <QCoreApplication>
-const QEvent::Type DbusObjectServiceEvent::eventType = static_cast<QEvent::Type>(QEvent::registerEventType());
-
/*!
\qmltype QDBusObject
\brief The QDBusObject is a base class
@@ -216,20 +215,3 @@ bool QDBusObject::event(QEvent* e)
}
return false;
}
-
-DbusObjectServiceEvent::DbusObjectServiceEvent(GDBusConnection* _connection, bool _visible)
- : QEvent(DbusObjectServiceEvent::eventType),
- connection(_connection),
- visible(_visible)
-{
- if (connection) {
- g_object_ref(connection);
- }
-}
-
-DbusObjectServiceEvent::~DbusObjectServiceEvent()
-{
- if (connection) {
- g_object_unref(connection);
- }
-}
diff --git a/libqmenumodel/src/qdbusobject.h b/libqmenumodel/src/qdbusobject.h
index 3a00301..1a87844 100644
--- a/libqmenumodel/src/qdbusobject.h
+++ b/libqmenumodel/src/qdbusobject.h
@@ -21,7 +21,6 @@
#define QDBUSOBJECT_H
#include <QString>
-#include <QEvent>
#include "dbus-enums.h"
@@ -78,15 +77,4 @@ private:
static void onServiceVanished(GDBusConnection *connection, const gchar *name, gpointer data);
};
-class DbusObjectServiceEvent : public QEvent
-{
-public:
- static const QEvent::Type eventType;
- DbusObjectServiceEvent(GDBusConnection* connection, bool visible);
- ~DbusObjectServiceEvent();
-
- GDBusConnection* connection;
- bool visible;
-};
-
#endif
diff --git a/libqmenumodel/src/qmenumodel.cpp b/libqmenumodel/src/qmenumodel.cpp
index 2b1397a..e77419f 100644
--- a/libqmenumodel/src/qmenumodel.cpp
+++ b/libqmenumodel/src/qmenumodel.cpp
@@ -25,11 +25,11 @@ extern "C" {
#include "qmenumodel.h"
#include "menunode.h"
#include "converter.h"
+#include "qmenumodelevents.h"
+
#include <QCoreApplication>
#include <QThread>
-const QEvent::Type MenuModelEvent::eventType = static_cast<QEvent::Type>(QEvent::registerEventType());
-
/*!
\qmltype QMenuModel
\brief The QMenuModel class implements the base list model for menus
@@ -303,19 +303,3 @@ bool QMenuModel::hasLink(MenuNode *node, int row, const QString &linkType) const
MenuNode *child = node->child(row);
return (child && (child->linkType() == linkType));
}
-
-MenuModelEvent::MenuModelEvent(GMenuModel* _model)
- : QEvent(MenuModelEvent::eventType),
- model(_model)
-{
- if (model) {
- g_object_ref(model);
- }
-}
-
-MenuModelEvent::~MenuModelEvent()
-{
- if (model) {
- g_object_unref(model);
- }
-}
diff --git a/libqmenumodel/src/qmenumodel.h b/libqmenumodel/src/qmenumodel.h
index 54c09f5..bbb35a0 100644
--- a/libqmenumodel/src/qmenumodel.h
+++ b/libqmenumodel/src/qmenumodel.h
@@ -21,7 +21,6 @@
#define QMENUTREEMODEL_H
#include <QAbstractItemModel>
-#include <QEvent>
class MenuNode;
typedef struct _GMenuModel GMenuModel;
@@ -29,6 +28,7 @@ typedef struct _GMenuModel GMenuModel;
class QMenuModel : public QAbstractItemModel
{
Q_OBJECT
+
public:
enum MenuRoles {
Action = Qt::DisplayRole + 1,
@@ -73,15 +73,4 @@ private:
void clearModel();
};
-class MenuModelEvent : public QEvent
-{
-public:
- static const QEvent::Type eventType;
-
- MenuModelEvent(GMenuModel *model);
- ~MenuModelEvent();
-
- GMenuModel *model;
-};
-
#endif
diff --git a/libqmenumodel/src/qmenumodelevents.cpp b/libqmenumodel/src/qmenumodelevents.cpp
new file mode 100644
index 0000000..c705d5c
--- /dev/null
+++ b/libqmenumodel/src/qmenumodelevents.cpp
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2013 Canonical Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Nicholas Dedekind <nick.dedekind@canonical.com
+ */
+
+extern "C" {
+#include <glib-object.h>
+#include <gio/gio.h>
+}
+
+#include "qmenumodelevents.h"
+
+const QEvent::Type MenuNodeItemChangeEvent::eventType = static_cast<QEvent::Type>(QEvent::registerEventType());
+const QEvent::Type DBusActionStateEvent::eventType = static_cast<QEvent::Type>(QEvent::registerEventType());
+const QEvent::Type DBusActionVisiblityEvent::eventType = static_cast<QEvent::Type>(QEvent::registerEventType());
+const QEvent::Type MenuModelEvent::eventType = static_cast<QEvent::Type>(QEvent::registerEventType());
+const QEvent::Type DbusObjectServiceEvent::eventType = static_cast<QEvent::Type>(QEvent::registerEventType());
+
+MenuNodeItemChangeEvent::MenuNodeItemChangeEvent(MenuNode* _node, int _position, int _removed, int _added)
+ : QEvent(MenuNodeItemChangeEvent::eventType),
+ node(_node),
+ position(_position),
+ removed(_removed),
+ added(_added)
+{}
+
+
+DBusActionEvent::DBusActionEvent(const QString& _name, QEvent::Type type)
+ : QEvent(type),
+ name(_name)
+{
+}
+
+
+DBusActionVisiblityEvent::DBusActionVisiblityEvent(const QString& _name, bool _visible)
+ : DBusActionEvent(_name, DBusActionVisiblityEvent::eventType),
+ visible(_visible)
+{
+}
+
+
+DBusActionStateEvent::DBusActionStateEvent(const QString& _name, const QVariant& _state)
+ : DBusActionEvent(_name, DBusActionStateEvent::eventType),
+ state(_state)
+{
+}
+
+
+DbusObjectServiceEvent::DbusObjectServiceEvent(GDBusConnection* _connection, bool _visible)
+ : QEvent(DbusObjectServiceEvent::eventType),
+ connection(_connection),
+ visible(_visible)
+{
+ if (connection) {
+ g_object_ref(connection);
+ }
+}
+
+
+DbusObjectServiceEvent::~DbusObjectServiceEvent()
+{
+ if (connection) {
+ g_object_unref(connection);
+ }
+}
+
+
+MenuModelEvent::MenuModelEvent(GMenuModel* _model)
+ : QEvent(MenuModelEvent::eventType),
+ model(_model)
+{
+ if (model) {
+ g_object_ref(model);
+ }
+}
+
+MenuModelEvent::~MenuModelEvent()
+{
+ if (model) {
+ g_object_unref(model);
+ }
+}
diff --git a/libqmenumodel/src/qmenumodelevents.h b/libqmenumodel/src/qmenumodelevents.h
new file mode 100644
index 0000000..be8f80d
--- /dev/null
+++ b/libqmenumodel/src/qmenumodelevents.h
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2013 Canonical Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Nicholas Dedekind <nick.dedekind@canonical.com
+ */
+
+#ifndef QMENUMODELEVENTS_H
+#define QMENUMODELEVENTS_H
+
+#include <QEvent>
+#include <QVariant>
+
+class MenuNode;
+typedef struct _GDBusConnection GDBusConnection;
+typedef struct _GMenuModel GMenuModel;
+
+/* Event for a connection update for a dbus object */
+class DbusObjectServiceEvent : public QEvent
+{
+public:
+ static const QEvent::Type eventType;
+ DbusObjectServiceEvent(GDBusConnection* connection, bool visible);
+ ~DbusObjectServiceEvent();
+
+ GDBusConnection* connection;
+ bool visible;
+};
+
+/* Event for an update to the gmenumodel */
+class MenuModelEvent : public QEvent
+{
+public:
+ static const QEvent::Type eventType;
+
+ MenuModelEvent(GMenuModel *model);
+ ~MenuModelEvent();
+
+ GMenuModel *model;
+};
+
+/* Event for a GAction (base) */
+class DBusActionEvent : public QEvent
+{
+public:
+ QString name;
+
+protected:
+ DBusActionEvent(const QString& name, QEvent::Type type);
+};
+
+/* Event for a GAction add/remove */
+class DBusActionVisiblityEvent : public DBusActionEvent
+{
+public:
+ static const QEvent::Type eventType;
+ DBusActionVisiblityEvent(const QString& name, bool visible);
+
+ bool visible;
+};
+
+/* Event for a GAction state value update */
+class DBusActionStateEvent : public DBusActionEvent
+{
+public:
+ static const QEvent::Type eventType;
+
+ DBusActionStateEvent(const QString& name, const QVariant& state);
+
+ QVariant state;
+};
+
+/* Event for changing gmenumodel entries */
+class MenuNodeItemChangeEvent : public QEvent
+{
+public:
+ static const QEvent::Type eventType;
+
+ MenuNodeItemChangeEvent(MenuNode* node, int position, int removed, int added);
+
+ MenuNode* node;
+ int position;
+ int removed;
+ int added;
+};
+
+#endif //QMENUMODELEVENTS_H