aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.bzrignore30
-rw-r--r--CMakeLists.txt3
-rw-r--r--README54
-rw-r--r--TODO8
-rw-r--r--cmake/lcov.cmake2
-rw-r--r--debian/changelog6
-rw-r--r--debian/control13
-rw-r--r--doc/CMakeLists.txt2
-rw-r--r--doc/qmenumodel.qdocconf.in4
-rw-r--r--examples/CMakeLists.txt4
-rw-r--r--examples/README11
-rwxr-xr-xexamples/exportactiongroup.py57
-rwxr-xr-xexamples/exportmenu.py63
-rw-r--r--examples/render-menumodel.qml136
-rwxr-xr-xexamples/run-example.sh.in1
-rw-r--r--libqmenumodel/CMakeLists.txt4
-rw-r--r--libqmenumodel/QMenuModel/CMakeLists.txt (renamed from src/QMenuModel/CMakeLists.txt)31
-rw-r--r--libqmenumodel/QMenuModel/plugin.cpp (renamed from src/QMenuModel/plugin.cpp)2
-rw-r--r--libqmenumodel/QMenuModel/plugin.h (renamed from src/QMenuModel/plugin.h)0
-rw-r--r--libqmenumodel/QMenuModel/qmldir1
-rw-r--r--libqmenumodel/src/CMakeLists.txt (renamed from src/common/CMakeLists.txt)22
-rw-r--r--libqmenumodel/src/converter.cpp (renamed from src/common/converter.cpp)22
-rw-r--r--libqmenumodel/src/converter.h (renamed from src/common/converter.h)13
-rw-r--r--libqmenumodel/src/dbus-enums.h53
-rw-r--r--libqmenumodel/src/qdbusactiongroup.cpp (renamed from src/common/qdbusactiongroup.cpp)8
-rw-r--r--libqmenumodel/src/qdbusactiongroup.h (renamed from src/common/qdbusactiongroup.h)9
-rw-r--r--libqmenumodel/src/qdbusmenumodel.cpp (renamed from src/common/qdbusmenumodel.cpp)5
-rw-r--r--libqmenumodel/src/qdbusmenumodel.h (renamed from src/common/qdbusmenumodel.h)8
-rw-r--r--libqmenumodel/src/qdbusobject.cpp (renamed from src/common/qdbusobject.cpp)40
-rw-r--r--libqmenumodel/src/qdbusobject.h (renamed from src/common/qdbusobject.h)39
-rw-r--r--libqmenumodel/src/qmenumodel.cpp (renamed from src/common/qmenumodel.cpp)6
-rw-r--r--libqmenumodel/src/qmenumodel.h (renamed from src/common/qmenumodel.h)4
-rw-r--r--libqmenumodel/src/qstateaction.cpp (renamed from src/common/qstateaction.cpp)0
-rw-r--r--libqmenumodel/src/qstateaction.h (renamed from src/common/qstateaction.h)0
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/QMenuModel/qmldir1
-rw-r--r--tests/client/CMakeLists.txt6
-rw-r--r--tests/client/actiongrouptest.cpp22
-rw-r--r--tests/client/convertertest.cpp4
-rw-r--r--tests/client/menuchangestest.cpp2
-rw-r--r--tests/client/modeltest.cpp26
-rw-r--r--tests/client/servicetest.cpp20
-rw-r--r--tests/script/menuscript.py2
43 files changed, 571 insertions, 177 deletions
diff --git a/.bzrignore b/.bzrignore
new file mode 100644
index 0000000..fe5eb7b
--- /dev/null
+++ b/.bzrignore
@@ -0,0 +1,30 @@
+CMakeCache.txt
+CMakeFiles/
+CTestTestfile.cmake
+Makefile
+Testing/
+cmake_install.cmake
+install_manifest.txt
+
+moc_*.cxx
+
+coverage/
+
+tests/client/*.moc
+tests/client/actiongrouptest
+tests/client/convertertest
+tests/client/menuchangestest
+tests/client/modeltest
+tests/client/servicetest
+
+doc/html/
+doc/qmenumodel.qdocconf
+
+obj-*
+debian/files
+debian/qmenumodel-qml
+debian/*.debhelper
+debian/*.debhelper.log
+debian/*.substvars
+debian/stamp-*
+
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fe36672..4cba967 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,8 +25,7 @@ if(BUILD_WITH_COVERAGE)
include(${CMAKE_SOURCE_DIR}/cmake/lcov.cmake)
endif()
-add_subdirectory(src)
-add_subdirectory(examples)
+add_subdirectory(libqmenumodel)
# Tests Tools
if(NOT DBUS_RUNNER)
diff --git a/README b/README
new file mode 100644
index 0000000..e8e6b75
--- /dev/null
+++ b/README
@@ -0,0 +1,54 @@
+QMenuModel - a Qt/QML binding for GMenuModel
+(see http://developer.gnome.org/gio/unstable/GMenuModel.html)
+
+
+= Building =
+
+The build system uses cmake.
+To compile, simply invoke cmake and then make, e.g.:
+
+ $ cmake .
+ $ make
+
+
+= Running unit tests =
+
+To run the unit tests, you will need dbus-test-runner. If it wasn’t previously
+installed, install it and then re-run cmake. Then run either of these commands:
+
+ $ make test
+
+ - or -
+
+ $ ctest
+
+
+= Getting code coverage information =
+
+To run the unit tests and generate code coverage information, you need to re-run
+cmake with BUILD_WITH_COVERAGE set to ON and then invoke `make lcov`.
+This requires lcov to be installed.
+
+ $ cmake -DBUILD_WITH_COVERAGE=ON .
+ $ make lcov
+
+This will generate a report (coverage/index.html) which you can view in a
+browser.
+
+
+= API documentation =
+
+To generate API documentation, you need to re-run cmake with GENERATE_DOC set to
+ON and then invoke `make qdoc`. This requires qdoc3 to be installed.
+
+ $ cmake -DGENERATE_DOC=ON .
+ $ make qdoc
+
+The documentation is generated in the HTML format under doc/html/.
+
+
+= Examples =
+
+There are examples of how to use QDBusMenuModel in QML, refer to the README file
+under the examples/ directory for instructions.
+
diff --git a/TODO b/TODO
new file mode 100644
index 0000000..cb3cfe6
--- /dev/null
+++ b/TODO
@@ -0,0 +1,8 @@
+= TODO =
+
+ • Expose a plain Qt library as well as the QML plugin, so that QDBusMenuModel
+ can be used from C++ too
+ • Use PIMPLs to clean up the headers (see point above)
+ • Add a server-side API to allow applications to export their menus on the bus
+ • …
+
diff --git a/cmake/lcov.cmake b/cmake/lcov.cmake
index 5758859..a422094 100644
--- a/cmake/lcov.cmake
+++ b/cmake/lcov.cmake
@@ -63,6 +63,4 @@ ADD_CUSTOM_COMMAND(TARGET lcov
COMMAND echo "Open ${CMAKE_BINARY_DIR}/coverage/index.html to view the coverage analysis results."
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
-ADD_DEPENDENCIES(lcov helloworld)
-
diff --git a/debian/changelog b/debian/changelog
index e178128..c855594 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+qmenumodel (0.1.1) UNRELEASED; urgency=low
+
+ * Renaming source package to qmenumodel
+
+ -- Olivier Tilloy <olivier.tilloy@canonical.com> Thu, 04 Oct 2012 17:37:23 +0200
+
qmenumodel-qml (0.1.0) quantal; urgency=low
* Initial package;
diff --git a/debian/control b/debian/control
index c28f2b5..e07ea3a 100644
--- a/debian/control
+++ b/debian/control
@@ -1,19 +1,18 @@
-Source: qmenumodel-qml
+Source: qmenumodel
Section: libs
Priority: optional
Maintainer: Renato Araujo Oliveira Filho <renato@canonical.com>
-Build-Depends: debhelper (>= 7.0.50~),
- libqt4-dev,
+Build-Depends: debhelper (>= 8.0.0),
cdbs,
cmake,
libglib2.0-dev,
- dbus-test-runner,
- lcov,
- zip
+ libqt4-dev,
Standards-Version: 3.9.2
Package: qmenumodel-qml
+Section: libs
Architecture: any
Depends: ${shlibs:Depends},
- ${misc:Depends}
+ ${misc:Depends},
Description: QML bindings for GMenuModel
+
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index e5772ba..ea5b1cb 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -7,4 +7,4 @@ add_custom_target(qdoc)
add_custom_command(TARGET qdoc
COMMAND ${QDOC_BIN} ${QMENUMODEL_DOC_FILE}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- COMMENT "QDoc working...")
+ COMMENT "QDoc running...")
diff --git a/doc/qmenumodel.qdocconf.in b/doc/qmenumodel.qdocconf.in
index 3070b1e..97b560c 100644
--- a/doc/qmenumodel.qdocconf.in
+++ b/doc/qmenumodel.qdocconf.in
@@ -1,5 +1,5 @@
-project = QMenuModel QLM elements
-sourcedirs = @qmenumodelcommon_SOURCE_DIR@
+project = QMenuModel QML elements
+sourcedirs = @src_SOURCE_DIR@
sources.fileextensions = "*.cpp"
outputdir = html
outputformats = HTML
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
deleted file mode 100644
index fda5683..0000000
--- a/examples/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-project(examples)
-
-configure_file("${CMAKE_CURRENT_SOURCE_DIR}/run-example.sh.in"
- "${CMAKE_CURRENT_BINARY_DIR}/run-example.sh" @ONLY)
diff --git a/examples/README b/examples/README
new file mode 100644
index 0000000..c2516e3
--- /dev/null
+++ b/examples/README
@@ -0,0 +1,11 @@
+This directory contains examples that demonstrate how to use the QMenuModel
+QML binding in applications.
+
+To export an example menu model on the bus, run 'exportmenu.py'.
+
+To render this menu in a QML application, run 'render-menumodel.qml' in
+qmlviewer. You will need to inform qmlviewer of the location of the QMenuModel
+if it’s not installed system-wide, e.g.:
+
+ qmlviewer -I libqmenumodel examples/render-menumodel.qml
+
diff --git a/examples/exportactiongroup.py b/examples/exportactiongroup.py
new file mode 100755
index 0000000..f69416e
--- /dev/null
+++ b/examples/exportactiongroup.py
@@ -0,0 +1,57 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+
+"""
+This example script exports an action group on the session bus under the name
+com.canonical.testactiongroup and at the object path
+/com/canonical/testactiongroup.
+"""
+
+import sys
+
+from gi.repository import Gio
+from gi.repository import GLib
+
+
+BUS_NAME = 'com.canonical.testactiongroup'
+BUS_OBJECT_PATH = '/com/canonical/testactiongroup'
+
+
+def action_activated(action, data):
+ name = action.get_name()
+ if action.get_state_type() is None:
+ print 'stateless action activated: %s' % name
+ else:
+ print 'stateful action activated: %s (current state: %s)' %
+ (name, action.get_state())
+
+
+if __name__ == '__main__':
+ bus = Gio.bus_get_sync(Gio.BusType.SESSION, None)
+ # Claim well-known bus name and ensure only one instance of self is running
+ # at any given time.
+ # http://dbus.freedesktop.org/doc/dbus-specification.html#message-bus-names
+ proxy = Gio.DBusProxy.new_sync(bus, 0, None,
+ 'org.freedesktop.DBus',
+ '/org/freedesktop/DBus',
+ 'org.freedesktop.DBus', None)
+ result = proxy.RequestName('(su)', BUS_NAME, 0x4)
+ if result != 1 :
+ print >> sys.stderr, ("Name '%s' is already owned on the session bus."
+ "Aborting.") % BUS_NAME
+ sys.exit(1)
+
+ group = Gio.SimpleActionGroup()
+ foo = Gio.SimpleAction.new('foo', None)
+ group.insert(foo)
+ bar = Gio.SimpleAction.new_stateful('bar', None, GLib.Variant.new_boolean(False))
+ group.insert(bar)
+ bleh = Gio.SimpleAction.new_stateful('bleh', None, GLib.Variant.new_string('bleh'))
+ group.insert(bleh)
+ for name in group.list_actions():
+ action = group.lookup_action(name)
+ action.connect('activate', action_activated)
+ bus.export_action_group(BUS_OBJECT_PATH, group)
+
+ GLib.MainLoop().run()
+
diff --git a/examples/exportmenu.py b/examples/exportmenu.py
new file mode 100755
index 0000000..831f995
--- /dev/null
+++ b/examples/exportmenu.py
@@ -0,0 +1,63 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+
+"""
+This example script exports a menu model on the session bus under the name
+com.canonical.testmenu and at the object path /com/canonical/testmenu.
+The menu model contains items that have attributes with custom values, as well
+as sub-menus.
+"""
+
+import sys
+
+from gi.repository import Gio
+from gi.repository import GLib
+
+
+BUS_NAME = 'com.canonical.testmenu'
+BUS_OBJECT_PATH = '/com/canonical/testmenu'
+
+
+if __name__ == '__main__':
+ bus = Gio.bus_get_sync(Gio.BusType.SESSION, None)
+ # Claim well-known bus name and ensure only one instance of self is running
+ # at any given time.
+ # http://dbus.freedesktop.org/doc/dbus-specification.html#message-bus-names
+ proxy = Gio.DBusProxy.new_sync(bus, 0, None,
+ 'org.freedesktop.DBus',
+ '/org/freedesktop/DBus',
+ 'org.freedesktop.DBus', None)
+ result = proxy.RequestName('(su)', BUS_NAME, 0x4)
+ if result != 1 :
+ print >> sys.stderr, ("Name '%s' is already owned on the session bus."
+ "Aborting.") % BUS_NAME
+ sys.exit(1)
+
+ menu = Gio.Menu()
+ foo = Gio.MenuItem.new('foo', 'app.foo')
+ foo.set_attribute_value('x-additionaltext',
+ GLib.Variant.new_string('lorem ipsum'))
+ foo.set_attribute_value('x-enabled', GLib.Variant.new_boolean(True))
+ menu.append_item(foo)
+ bar = Gio.MenuItem.new('bar', 'app.bar')
+ bar.set_attribute_value('x-defaultvalue',
+ GLib.Variant.new_string('Hello World!'))
+ bar.set_attribute_value('x-canonical-currentvalue',
+ GLib.Variant.new_string('awesome'))
+ bar.set_attribute_value('x-velocity', GLib.Variant.new_uint64(83374))
+ menu.append_item(bar)
+ menu.append('bleh', 'app.bleh')
+ submenu = Gio.Menu()
+ submenu.append('submenu A', 'app.suba')
+ submenu2 = Gio.Menu()
+ submenu2.append('submenu2 A', 'app.sub2a')
+ submenu2.append('submenu2 B', 'app.sub2b')
+ submenu2.append('submenu2 C', 'app.sub2c')
+ submenu.append_submenu('submenu submenu', submenu2)
+ submenu.append('submenu C', 'app.subc')
+ menu.append_submenu('submenu', submenu)
+ menu.append('baz', 'app.baz')
+ bus.export_menu_model(BUS_OBJECT_PATH, menu)
+
+ GLib.MainLoop().run()
+
diff --git a/examples/render-menumodel.qml b/examples/render-menumodel.qml
new file mode 100644
index 0000000..45daf0d
--- /dev/null
+++ b/examples/render-menumodel.qml
@@ -0,0 +1,136 @@
+// This example QML application renders a menu model exposed on the session bus
+// under the well-known name com.canonical.testmenu and at the object path
+// /com/canonical/testmenu.
+
+import QtQuick 1.1
+import QMenuModel 0.1
+
+Item {
+ id: container
+ width: 300
+ height: 300
+
+ QDBusMenuModel {
+ id: menuModel
+ busType: DBus.SessionBus
+ busName: "com.canonical.testmenu"
+ objectPath: "/com/canonical/testmenu"
+ onStatusChanged: console.log("status of menu model changed to", status)
+ }
+
+ ListView {
+ id: view
+ property variant __back: []
+ anchors.left: parent.left
+ anchors.right:parent.right
+ anchors.top: parent.top
+ anchors.bottom: backbutton.top
+ anchors.margins: 10
+ spacing: 3
+ model: menuModel
+ Component.onCompleted: menuModel.start()
+ delegate: Rectangle {
+ width: parent.width
+ height: 30
+ radius: 3
+ color: {
+ if (linkSubMenu == null) return "lightgrey"
+ if (delegatearea.containsMouse) return "steelblue"
+ return "lightsteelblue"
+ }
+ Text {
+ anchors.fill: parent
+ anchors.margins: 5
+ verticalAlignment: Text.AlignVCenter
+ color: (linkSubMenu == null) ? "grey" : "black"
+ text: {
+ if (linkSubMenu == null) return "%1 (%2)".arg(label).arg(action)
+ else return "submenu"
+ }
+ }
+ MouseArea {
+ id: delegatearea
+ anchors.fill: parent
+ hoverEnabled: true
+ onClicked: {
+ if (linkSubMenu == null) return
+ var newback = view.__back
+ newback.push(view.model)
+ view.__back = newback
+ view.model = linkSubMenu
+ }
+ onEntered: {
+ var text = ""
+ for (var prop in extra) {
+ text += "%1 = %2\n".arg(prop).arg(extra[prop].toString())
+ }
+ if (text != "") {
+ tooltip.text = text
+ tooltip.visible = true
+ }
+ }
+ onExited: {
+ tooltip.visible = false
+ }
+ onPositionChanged: {
+ var pos = container.mapFromItem(delegatearea, mouse.x, mouse.y)
+ tooltip.x = pos.x + 10
+ tooltip.y = pos.y + 10
+ }
+ }
+ }
+ function goback() {
+ var newback = view.__back
+ model = newback[newback.length - 1]
+ newback.pop()
+ view.__back = newback
+ }
+ }
+
+ Rectangle {
+ id: backbutton
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.bottom: parent.bottom
+ anchors.margins: 5
+ radius: 4
+ height: 50
+ color: (mousearea.enabled && mousearea.containsMouse) ? "steelblue" : "lightsteelblue"
+ Text {
+ anchors.fill: parent
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ text: "back"
+ color: mousearea.enabled ? "black" : "grey"
+ }
+ MouseArea {
+ id: mousearea
+ anchors.fill: parent
+ enabled: view.__back.length > 0
+ hoverEnabled: true
+ onClicked: {
+ view.goback()
+ }
+ }
+ }
+
+ Rectangle {
+ id: tooltip
+ property alias text: t.text
+ visible: false
+ width: t.width + 10
+ height: t.height + 10
+ radius: 4
+ color: "lightyellow"
+ Text {
+ id: t
+ height: paintedHeight
+ width: paintedWidth
+ x: 5
+ y: 5
+ anchors.margins: 4
+ font.pixelSize: 12
+ }
+ }
+}
+
diff --git a/examples/run-example.sh.in b/examples/run-example.sh.in
deleted file mode 100755
index 4843f49..0000000
--- a/examples/run-example.sh.in
+++ /dev/null
@@ -1 +0,0 @@
-gdb --args qmlviewer -I @src_BINARY_DIR@ $1
diff --git a/libqmenumodel/CMakeLists.txt b/libqmenumodel/CMakeLists.txt
new file mode 100644
index 0000000..d01cf10
--- /dev/null
+++ b/libqmenumodel/CMakeLists.txt
@@ -0,0 +1,4 @@
+project(libqmenumodel)
+
+add_subdirectory(src)
+add_subdirectory(QMenuModel)
diff --git a/src/QMenuModel/CMakeLists.txt b/libqmenumodel/QMenuModel/CMakeLists.txt
index bf3bb5a..5fb1d9f 100644
--- a/src/QMenuModel/CMakeLists.txt
+++ b/libqmenumodel/QMenuModel/CMakeLists.txt
@@ -1,26 +1,25 @@
+project(qmlplugin)
-project(qmenumodelqmlplugin)
-
-set(QMENUMODEL_SRC
+set(QMLPLUGIN_SRC
plugin.cpp
)
-set(QMENUMODEL_HEADERS
+set(QMLPLUGIN_HEADERS
plugin.h
)
-qt4_wrap_cpp(QMENUMODEL_MOC
- ${QMENUMODEL_HEADERS}
+qt4_wrap_cpp(QMLPLUGIN_MOC
+ ${QMLPLUGIN_HEADERS}
)
-add_library(qmenumodel MODULE
- ${QMENUMODEL_SRC}
- ${QMENUMODEL_MOC}
+add_library(qmenumodel-qml MODULE
+ ${QMLPLUGIN_SRC}
+ ${QMLPLUGIN_MOC}
)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
- ${qmenumodelcommon_SOURCE_DIR}
+ ${src_SOURCE_DIR}
${QT_INCLUDE_DIR}
${QT_QTCORE_INCLUDE_DIR}
${QT_QTGUI_INCLUDE_DIR}
@@ -29,10 +28,9 @@ include_directories(
${GIO_INCLUDE_DIRS}
)
-target_link_libraries(qmenumodel
- qmenumodelcommon
+target_link_libraries(qmenumodel-qml
+ qmenumodel
${QT_QTCORE_LIBRARY}
- ${QT_QTGUI_LIBRARY}
${QT_QTDCLARATIVE_LIBRARY}
${GLIB_LDFLAGS}
${GIO_LDFLAGS}
@@ -41,6 +39,7 @@ target_link_libraries(qmenumodel
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/qmldir"
"${CMAKE_CURRENT_BINARY_DIR}/qmldir")
-set(QMENUMODEL_INSTALL_PREFIX "${QT_IMPORTS_DIR}/Ubuntu/QMenuModel/")
-install(TARGETS qmenumodel DESTINATION ${QMENUMODEL_INSTALL_PREFIX})
-install(FILES qmldir DESTINATION ${QMENUMODEL_INSTALL_PREFIX})
+set(QMLPLUGIN_INSTALL_PREFIX "${QT_IMPORTS_DIR}/QMenuModel")
+install(TARGETS qmenumodel-qml DESTINATION ${QMLPLUGIN_INSTALL_PREFIX})
+install(FILES qmldir DESTINATION ${QMLPLUGIN_INSTALL_PREFIX})
+
diff --git a/src/QMenuModel/plugin.cpp b/libqmenumodel/QMenuModel/plugin.cpp
index 494dd2c..ec51ae9 100644
--- a/src/QMenuModel/plugin.cpp
+++ b/libqmenumodel/QMenuModel/plugin.cpp
@@ -32,6 +32,8 @@ void QMenuModelQmlPlugin::registerTypes(const char *uri)
"QMenuModel is a interface");
qmlRegisterUncreatableType<QStateAction>(uri, 0, 1, "QStateAction",
"QStateAction must be created by QDBusActionGroup::action");
+ qmlRegisterUncreatableType<DBusEnums>(uri, 0, 1, "DBus",
+ "DBus is only a namespace");
qmlRegisterType<QDBusMenuModel>(uri, 0, 1, "QDBusMenuModel");
qmlRegisterType<QDBusActionGroup>(uri, 0, 1, "QDBusActionGroup");
diff --git a/src/QMenuModel/plugin.h b/libqmenumodel/QMenuModel/plugin.h
index e9d6850..e9d6850 100644
--- a/src/QMenuModel/plugin.h
+++ b/libqmenumodel/QMenuModel/plugin.h
diff --git a/libqmenumodel/QMenuModel/qmldir b/libqmenumodel/QMenuModel/qmldir
new file mode 100644
index 0000000..32de804
--- /dev/null
+++ b/libqmenumodel/QMenuModel/qmldir
@@ -0,0 +1 @@
+plugin qmenumodel-qml
diff --git a/src/common/CMakeLists.txt b/libqmenumodel/src/CMakeLists.txt
index ad3343a..17d11f1 100644
--- a/src/common/CMakeLists.txt
+++ b/libqmenumodel/src/CMakeLists.txt
@@ -1,6 +1,6 @@
-project(qmenumodelcommon)
+project(src)
-set(QMENUMODELCOMMON_SRC
+set(QMENUMODEL_SRC
converter.cpp
qmenumodel.cpp
qdbusobject.cpp
@@ -9,8 +9,9 @@ set(QMENUMODELCOMMON_SRC
qstateaction.cpp
)
-set(QMENUMODELCOMMON_HEADERS
+set(QMENUMODEL_HEADERS
converter.h
+ dbus-enums.h
qmenumodel.h
qdbusobject.h
qdbusmenumodel.h
@@ -18,16 +19,16 @@ set(QMENUMODELCOMMON_HEADERS
qstateaction.h
)
-qt4_wrap_cpp(QMENUMODELCOMMON_MOC
- ${QMENUMODELCOMMON_HEADERS}
+qt4_wrap_cpp(QMENUMODEL_MOC
+ ${QMENUMODEL_HEADERS}
)
-add_library(qmenumodelcommon STATIC
- ${QMENUMODELCOMMON_SRC}
- ${QMENUMODELCOMMON_MOC}
+add_library(qmenumodel STATIC
+ ${QMENUMODEL_SRC}
+ ${QMENUMODEL_MOC}
)
-set_target_properties(qmenumodelcommon PROPERTIES COMPILE_FLAGS -fPIC)
+set_target_properties(qmenumodel PROPERTIES COMPILE_FLAGS -fPIC)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
@@ -38,9 +39,8 @@ include_directories(
${GIO_INCLUDE_DIRS}
)
-target_link_libraries(qmenumodelcommon
+target_link_libraries(qmenumodel
${QT_QTCORE_LIBRARY}
- ${QT_QTGUI_LIBRARY}
${GLIB_LDFLAGS}
${GIO_LDFLAGS}
)
diff --git a/src/common/converter.cpp b/libqmenumodel/src/converter.cpp
index 54d4665..452f68c 100644
--- a/src/common/converter.cpp
+++ b/libqmenumodel/src/converter.cpp
@@ -1,6 +1,11 @@
+extern "C" {
+#include <glib.h>
+}
+
#include "converter.h"
#include <QDebug>
+#include <QVariant>
/*! \internal */
QVariant Converter::toQVariant(GVariant *value)
@@ -16,17 +21,17 @@ QVariant Converter::toQVariant(GVariant *value)
} else if (g_variant_type_equal(type, G_VARIANT_TYPE_BYTE)) {
result.setValue(g_variant_get_byte(value));
} else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT16)) {
- result.setValue(g_variant_get_int16(value));
+ result.setValue(qint16(g_variant_get_int16(value)));
} else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT16)) {
- result.setValue(g_variant_get_uint16(value));
+ result.setValue(quint16(g_variant_get_uint16(value)));
} else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT32)) {
- result.setValue(g_variant_get_int32(value));
+ result.setValue(qint32(g_variant_get_int32(value)));
} else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT32)) {
- result.setValue(g_variant_get_uint32(value));
+ result.setValue(quint32(g_variant_get_uint32(value)));
} else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT64)) {
- result.setValue(g_variant_get_int64(value));
+ result.setValue(qint64(g_variant_get_int64(value)));
} else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT64)) {
- result.setValue(g_variant_get_uint64(value));
+ result.setValue(quint64(g_variant_get_uint64(value)));
} else if (g_variant_type_equal(type, G_VARIANT_TYPE_DOUBLE)) {
result.setValue(g_variant_get_double(value));
} else if (g_variant_type_equal(type, G_VARIANT_TYPE_STRING)) {
@@ -60,7 +65,7 @@ QVariant Converter::toQVariant(GVariant *value)
return result;
}
-GVariant* Converter::toGVariant(const QString &typeName, const QVariant &value)
+static GVariant* toGVariant(const QString &typeName, const QVariant &value)
{
if (typeName == "uchar") {
return g_variant_new_byte(value.value<uchar>());
@@ -105,8 +110,9 @@ GVariant* Converter::toGVariant(const QVariant &value)
result = g_variant_new_uint32(value.toUInt());
break;
default:
- result = toGVariant(value.typeName(), value);
+ result = ::toGVariant(value.typeName(), value);
}
return result;
}
+
diff --git a/src/common/converter.h b/libqmenumodel/src/converter.h
index 3029b0d..5f05bc7 100644
--- a/src/common/converter.h
+++ b/libqmenumodel/src/converter.h
@@ -20,20 +20,15 @@
#ifndef CONVERTER_H
#define CONVERTER_H
-#include <QVariant>
-#include <glib.h>
+typedef struct _GVariant GVariant;
+class QVariant;
class Converter
{
public:
static QVariant toQVariant(GVariant *value);
static GVariant* toGVariant(const QVariant &value);
-
-private:
- Converter();
- Converter(const Converter &other);
-
- static GVariant* toGVariant(const QString &typeName, const QVariant &value);
};
-#endif
+#endif // CONVERTER_H
+
diff --git a/libqmenumodel/src/dbus-enums.h b/libqmenumodel/src/dbus-enums.h
new file mode 100644
index 0000000..76149da
--- /dev/null
+++ b/libqmenumodel/src/dbus-enums.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2012 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:
+ * Olivier Tilloy <olivier.tilloy@canonical.com>
+ */
+
+#ifndef __DBUS_ENUMS__
+#define __DBUS_ENUMS__
+
+#include <QObject>
+
+// This class acts as a namespace only, with the addition that its enums
+// are registered to be exposed on the QML side.
+class DBusEnums : public QObject
+{
+ Q_OBJECT
+
+ Q_ENUMS(BusType)
+ Q_ENUMS(ConnectionStatus)
+
+public:
+ enum BusType {
+ None = 0,
+ SessionBus,
+ SystemBus,
+ LastBusType
+ };
+
+ enum ConnectionStatus {
+ Disconnected = 0,
+ Connecting,
+ Connected
+ };
+
+private:
+ DBusEnums() {}
+};
+
+#endif // __DBUS_ENUMS__
+
diff --git a/src/common/qdbusactiongroup.cpp b/libqmenumodel/src/qdbusactiongroup.cpp
index 629915b..5a9e0bd 100644
--- a/src/common/qdbusactiongroup.cpp
+++ b/libqmenumodel/src/qdbusactiongroup.cpp
@@ -21,9 +21,9 @@
#include "qstateaction.h"
#include "converter.h"
-#include <QDebug>
-
+extern "C" {
#include <gio/gio.h>
+}
/*!
\qmlclass QDBusActionGroup
@@ -143,8 +143,8 @@ void QDBusActionGroup::stop()
/*! \internal */
void QDBusActionGroup::setIntBusType(int busType)
{
- if ((busType > None) && (busType < LastBusType)) {
- setBusType(static_cast<BusType>(busType));
+ if ((busType > DBusEnums::None) && (busType < DBusEnums::LastBusType)) {
+ setBusType(static_cast<DBusEnums::BusType>(busType));
}
}
diff --git a/src/common/qdbusactiongroup.h b/libqmenumodel/src/qdbusactiongroup.h
index 2f46f8f..518f78c 100644
--- a/src/common/qdbusactiongroup.h
+++ b/libqmenumodel/src/qdbusactiongroup.h
@@ -23,8 +23,7 @@
#include "qdbusobject.h"
#include <QObject>
-#include <QAction>
-#include <QSet>
+#include <QVariant>
class QStateAction;
@@ -47,10 +46,10 @@ public:
Q_INVOKABLE QVariant actionState(const QString &name);
Q_SIGNALS:
- void busTypeChanged(BusType type);
+ void busTypeChanged(DBusEnums::BusType type);
void busNameChanged(const QString &busNameChanged);
void objectPathChanged(const QString &objectPath);
- void statusChanged(ConnectionStatus status);
+ void statusChanged(DBusEnums::ConnectionStatus status);
void actionAppear(const QString &name);
void actionVanish(const QString &name);
void actionStateChanged(const QString &name, QVariant state);
@@ -69,7 +68,7 @@ private:
int m_signalActionRemovedId;
int m_signalStateChangedId;
- // workaround to support int as bustType
+ // workaround to support int as busType
void setIntBusType(int busType);
void setActionGroup(GDBusActionGroup *ag);
diff --git a/src/common/qdbusmenumodel.cpp b/libqmenumodel/src/qdbusmenumodel.cpp
index 9b824b4..88a6084 100644
--- a/src/common/qdbusmenumodel.cpp
+++ b/libqmenumodel/src/qdbusmenumodel.cpp
@@ -18,7 +18,6 @@
*/
#include "qdbusmenumodel.h"
-#include <QDebug>
/*!
\qmlclass QDBusMenuModel
@@ -104,7 +103,7 @@ void QDBusMenuModel::serviceAppear(GDBusConnection *connection)
/*! \internal */
void QDBusMenuModel::setIntBusType(int busType)
{
- if ((busType > None) && (busType < LastBusType)) {
- setBusType(static_cast<BusType>(busType));
+ if ((busType > DBusEnums::None) && (busType < DBusEnums::LastBusType)) {
+ setBusType(static_cast<DBusEnums::BusType>(busType));
}
}
diff --git a/src/common/qdbusmenumodel.h b/libqmenumodel/src/qdbusmenumodel.h
index 8308268..fdf23f7 100644
--- a/src/common/qdbusmenumodel.h
+++ b/libqmenumodel/src/qdbusmenumodel.h
@@ -23,7 +23,9 @@
#include "qdbusobject.h"
#include "qmenumodel.h"
+extern "C" {
#include <gio/gio.h>
+}
class QDBusMenuModel : public QMenuModel, public QDBusObject
{
@@ -38,10 +40,10 @@ public:
~QDBusMenuModel();
Q_SIGNALS:
- void busTypeChanged(BusType type);
+ void busTypeChanged(DBusEnums::BusType type);
void busNameChanged(const QString &busNameChanged);
void objectPathChanged(const QString &objectPath);
- void statusChanged(QDBusObject::ConnectionStatus status);
+ void statusChanged(DBusEnums::ConnectionStatus status);
public Q_SLOTS:
void start();
@@ -52,7 +54,7 @@ protected:
virtual void serviceVanish(GDBusConnection *connection);
private:
- // workaround to support int as bustType
+ // workaround to support int as busType
void setIntBusType(int busType);
};
diff --git a/src/common/qdbusobject.cpp b/libqmenumodel/src/qdbusobject.cpp
index d5ac44b..abc68b4 100644
--- a/src/common/qdbusobject.cpp
+++ b/libqmenumodel/src/qdbusobject.cpp
@@ -70,10 +70,10 @@
QDBusObject::QDBusObject()
:m_watchId(0),
- m_busType(None),
- m_status(QDBusObject::Disconnected)
+ m_busType(DBusEnums::None),
+ m_status(DBusEnums::Disconnected)
{
- qRegisterMetaType<QDBusObject::ConnectionStatus>("QDBusObject::ConnectionStatus");
+ qRegisterMetaType<DBusEnums::ConnectionStatus>("DBusEnums::ConnectionStatus");
}
QDBusObject::~QDBusObject()
@@ -84,15 +84,15 @@ QDBusObject::~QDBusObject()
}
}
-QDBusObject::BusType QDBusObject::busType() const
+DBusEnums::BusType QDBusObject::busType() const
{
return m_busType;
}
-void QDBusObject::setBusType(QDBusObject::BusType type)
+void QDBusObject::setBusType(DBusEnums::BusType type)
{
if (m_busType != type) {
- if (m_status != QDBusObject::Disconnected)
+ if (m_status != DBusEnums::Disconnected)
disconnect();
m_busType = type;
busTypeChanged(m_busType);
@@ -107,7 +107,7 @@ QString QDBusObject::busName() const
void QDBusObject::setBusName(const QString &busName)
{
if (m_busName != busName) {
- if (m_status != QDBusObject::Disconnected)
+ if (m_status != DBusEnums::Disconnected)
disconnect();
m_busName = busName;
busNameChanged(m_busName);
@@ -122,14 +122,14 @@ QString QDBusObject::objectPath() const
void QDBusObject::setObjectPath(const QString &objectPath)
{
if (m_objectPath != objectPath) {
- if (m_status != QDBusObject::Disconnected)
+ if (m_status != DBusEnums::Disconnected)
disconnect();
m_objectPath = objectPath;
objectPathChanged(m_objectPath);
}
}
-void QDBusObject::setStatus(QDBusObject::ConnectionStatus status)
+void QDBusObject::setStatus(DBusEnums::ConnectionStatus status)
{
if (m_status != status) {
m_status = status;
@@ -137,26 +137,26 @@ void QDBusObject::setStatus(QDBusObject::ConnectionStatus status)
}
}
-QDBusObject::ConnectionStatus QDBusObject::status() const
+DBusEnums::ConnectionStatus QDBusObject::status() const
{
return m_status;
}
void QDBusObject::connect()
{
- if (m_status != QDBusObject::Disconnected) {
+ if (m_status != DBusEnums::Disconnected) {
return;
- } else if ((m_busType > None) && !m_objectPath.isEmpty() && !m_busName.isEmpty()) {
- GBusType type = m_busType == SessionBus ? G_BUS_TYPE_SESSION : G_BUS_TYPE_SYSTEM;
+ } else if ((m_busType > DBusEnums::None) && !m_objectPath.isEmpty() && !m_busName.isEmpty()) {
+ GBusType type = m_busType == DBusEnums::SessionBus ? G_BUS_TYPE_SESSION : G_BUS_TYPE_SYSTEM;
m_watchId = g_bus_watch_name (type,
m_busName.toLatin1(),
G_BUS_NAME_WATCHER_FLAGS_NONE,
QDBusObject::onServiceAppeared,
- QDBusObject::onServiceFanished,
+ QDBusObject::onServiceVanished,
this,
NULL);
- setStatus(QDBusObject::Connecting);
+ setStatus(DBusEnums::Connecting);
} else {
qWarning() << "Invalid dbus connection args";
}
@@ -164,10 +164,10 @@ void QDBusObject::connect()
void QDBusObject::disconnect()
{
- if (m_status != QDBusObject::Disconnected) {
+ if (m_status != DBusEnums::Disconnected) {
g_bus_unwatch_name (m_watchId);
m_watchId = 0;
- setStatus(QDBusObject::Disconnected);
+ setStatus(DBusEnums::Disconnected);
}
}
@@ -175,14 +175,14 @@ void QDBusObject::onServiceAppeared(GDBusConnection *connection, const gchar *,
{
QDBusObject *self = reinterpret_cast<QDBusObject*>(data);
- self->setStatus(QDBusObject::Connected);
+ self->setStatus(DBusEnums::Connected);
self->serviceAppear(connection);
}
-void QDBusObject::onServiceFanished(GDBusConnection *connection, const gchar *, gpointer data)
+void QDBusObject::onServiceVanished(GDBusConnection *connection, const gchar *, gpointer data)
{
QDBusObject *self = reinterpret_cast<QDBusObject*>(data);
- self->setStatus(QDBusObject::Connecting);
+ self->setStatus(DBusEnums::Connecting);
self->serviceVanish(connection);
}
diff --git a/src/common/qdbusobject.h b/libqmenumodel/src/qdbusobject.h
index c50d540..ef2b42f 100644
--- a/src/common/qdbusobject.h
+++ b/libqmenumodel/src/qdbusobject.h
@@ -20,31 +20,22 @@
#ifndef QDBUSOBJECT_H
#define QDBUSOBJECT_H
-#include <QObject>
-
+extern "C" {
#include <gio/gio.h>
+}
+
+#include <QString>
+
+#include "dbus-enums.h"
class QDBusObject
{
public:
- enum BusType {
- None = 0,
- SessionBus,
- SystemBus,
- LastBusType
- };
-
- enum ConnectionStatus {
- Disconnected = 0,
- Connecting,
- Connected
- };
-
QDBusObject();
~QDBusObject();
- BusType busType() const;
- void setBusType(BusType type);
+ DBusEnums::BusType busType() const;
+ void setBusType(DBusEnums::BusType type);
QString busName() const;
void setBusName(const QString &busName);
@@ -52,7 +43,7 @@ public:
QString objectPath() const;
void setObjectPath(const QString &busName);
- ConnectionStatus status() const;
+ DBusEnums::ConnectionStatus status() const;
void connect();
void disconnect();
@@ -62,23 +53,23 @@ protected:
virtual void serviceVanish(GDBusConnection *connection) = 0;
// notify functions
- virtual void busTypeChanged(BusType type) = 0;
+ virtual void busTypeChanged(DBusEnums::BusType type) = 0;
virtual void busNameChanged(const QString &busNameChanged) = 0;
virtual void objectPathChanged(const QString &objectPath) = 0;
- virtual void statusChanged(ConnectionStatus status) = 0;
+ virtual void statusChanged(DBusEnums::ConnectionStatus status) = 0;
private:
guint m_watchId;
- BusType m_busType;
+ DBusEnums::BusType m_busType;
QString m_busName;
QString m_objectPath;
- ConnectionStatus m_status;
+ DBusEnums::ConnectionStatus m_status;
- void setStatus(ConnectionStatus status);
+ void setStatus(DBusEnums::ConnectionStatus status);
// glib slots
static void onServiceAppeared(GDBusConnection *connection, const gchar *name, const gchar *name_owner, gpointer data);
- static void onServiceFanished(GDBusConnection *connection, const gchar *name, gpointer data);
+ static void onServiceVanished(GDBusConnection *connection, const gchar *name, gpointer data);
};
#endif
diff --git a/src/common/qmenumodel.cpp b/libqmenumodel/src/qmenumodel.cpp
index cc760c1..e88bc66 100644
--- a/src/common/qmenumodel.cpp
+++ b/libqmenumodel/src/qmenumodel.cpp
@@ -91,12 +91,6 @@ GMenuModel *QMenuModel::menuModel() const
}
/*! \internal */
-int QMenuModel::columnCount(const QModelIndex &) const
-{
- return 1;
-}
-
-/*! \internal */
QVariant QMenuModel::data(const QModelIndex &index, int role) const
{
QVariant attribute;
diff --git a/src/common/qmenumodel.h b/libqmenumodel/src/qmenumodel.h
index ba5696d..7520480 100644
--- a/src/common/qmenumodel.h
+++ b/libqmenumodel/src/qmenumodel.h
@@ -21,7 +21,10 @@
#define QMENUMODEL_H
#include <QAbstractListModel>
+
+extern "C" {
#include <gio/gio.h>
+}
class QMenuModel : public QAbstractListModel
{
@@ -39,7 +42,6 @@ public:
~QMenuModel();
/* QAbstractItemModel */
- int columnCount(const QModelIndex &parent = QModelIndex()) const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
QModelIndex parent (const QModelIndex &index) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
diff --git a/src/common/qstateaction.cpp b/libqmenumodel/src/qstateaction.cpp
index 3629fce..3629fce 100644
--- a/src/common/qstateaction.cpp
+++ b/libqmenumodel/src/qstateaction.cpp
diff --git a/src/common/qstateaction.h b/libqmenumodel/src/qstateaction.h
index 1a5a0fa..1a5a0fa 100644
--- a/src/common/qstateaction.h
+++ b/libqmenumodel/src/qstateaction.h
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
deleted file mode 100644
index 7215efc..0000000
--- a/src/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-project(src)
-
-add_subdirectory(common)
-add_subdirectory(QMenuModel)
diff --git a/src/QMenuModel/qmldir b/src/QMenuModel/qmldir
deleted file mode 100644
index c8f525f..0000000
--- a/src/QMenuModel/qmldir
+++ /dev/null
@@ -1 +0,0 @@
-plugin qmenumodel
diff --git a/tests/client/CMakeLists.txt b/tests/client/CMakeLists.txt
index c427f54..2c48a07 100644
--- a/tests/client/CMakeLists.txt
+++ b/tests/client/CMakeLists.txt
@@ -4,7 +4,7 @@ macro(declare_test testname)
add_executable(${testname} ${testname}.cpp ${TEST_MOC_FILE})
target_link_libraries(${testname}
- qmenumodelcommon
+ qmenumodel
dbusmenuscript
${QT_QTTEST_LIBRARY}
${QT_QTCORE_LIBRARY}
@@ -30,7 +30,7 @@ macro(declare_simple_test testname)
add_executable(${testname} ${testname}.cpp ${TEST_MOC_FILE})
target_link_libraries(${testname}
- qmenumodelcommon
+ qmenumodel
${QT_QTTEST_LIBRARY}
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
@@ -45,7 +45,7 @@ macro(declare_simple_test testname)
TIMEOUT ${CTEST_TESTING_TIMEOUT})
endmacro(declare_simple_test testname)
-include_directories(${qmenumodelcommon_SOURCE_DIR}
+include_directories(${src_SOURCE_DIR}
${dbusmenuscript_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${QT_INCLUDE_DIR}
diff --git a/tests/client/actiongrouptest.cpp b/tests/client/actiongrouptest.cpp
index c77c3d5..116bd44 100644
--- a/tests/client/actiongrouptest.cpp
+++ b/tests/client/actiongrouptest.cpp
@@ -49,12 +49,12 @@ private Q_SLOTS:
void init()
{
m_model.stop();
- m_model.setBusType(QDBusObject::SessionBus);
+ m_model.setBusType(DBusEnums::SessionBus);
m_model.setBusName(MENU_SERVICE_NAME);
m_model.setObjectPath(MENU_OBJECT_PATH);
m_actionGroup.stop();
- m_actionGroup.setBusType(QDBusObject::SessionBus);
+ m_actionGroup.setBusType(DBusEnums::SessionBus);
m_actionGroup.setBusName(MENU_SERVICE_NAME);
m_actionGroup.setObjectPath(MENU_OBJECT_PATH);
}
@@ -70,16 +70,16 @@ private Q_SLOTS:
void testBusTypeProperty()
{
m_actionGroup.setProperty("busType", 1);
- QCOMPARE(m_actionGroup.busType(), QDBusObject::SessionBus);
+ QCOMPARE(m_actionGroup.busType(), DBusEnums::SessionBus);
m_actionGroup.setProperty("busType", 2);
- QCOMPARE(m_actionGroup.busType(), QDBusObject::SystemBus);
+ QCOMPARE(m_actionGroup.busType(), DBusEnums::SystemBus);
m_actionGroup.setProperty("busType", 0);
- QCOMPARE(m_actionGroup.busType(), QDBusObject::SystemBus);
+ QCOMPARE(m_actionGroup.busType(), DBusEnums::SystemBus);
m_actionGroup.setProperty("busType", 10);
- QCOMPARE(m_actionGroup.busType(), QDBusObject::SystemBus);
+ QCOMPARE(m_actionGroup.busType(), DBusEnums::SystemBus);
}
/*
@@ -90,12 +90,12 @@ private Q_SLOTS:
{
m_model.start();
m_actionGroup.start();
- QCOMPARE(m_actionGroup.status(), QDBusObject::Connecting);
+ QCOMPARE(m_actionGroup.status(), DBusEnums::Connecting);
// Make menu available
m_script.publishMenu();
- QCOMPARE(m_actionGroup.status(), QDBusObject::Connected);
+ QCOMPARE(m_actionGroup.status(), DBusEnums::Connected);
}
/*
@@ -109,17 +109,17 @@ private Q_SLOTS:
// Make menu available
m_script.publishMenu();
- QCOMPARE(m_actionGroup.status(), QDBusObject::Connected);
+ QCOMPARE(m_actionGroup.status(), DBusEnums::Connected);
// Append menus
m_script.walk(2);
// Remove menu from dbus
m_script.unpublishMenu();
- QCOMPARE(m_actionGroup.status(), QDBusObject::Connecting);
+ QCOMPARE(m_actionGroup.status(), DBusEnums::Connecting);
m_actionGroup.stop();
- QCOMPARE(m_actionGroup.status(), QDBusObject::Disconnected);
+ QCOMPARE(m_actionGroup.status(), DBusEnums::Disconnected);
}
/*
diff --git a/tests/client/convertertest.cpp b/tests/client/convertertest.cpp
index 496b62a..72b6a87 100644
--- a/tests/client/convertertest.cpp
+++ b/tests/client/convertertest.cpp
@@ -17,6 +17,10 @@
* Renato Araujo Oliveira Filho <renato@canonical.com>
*/
+extern "C" {
+#include <glib.h>
+}
+
#include "converter.h"
#include <QObject>
diff --git a/tests/client/menuchangestest.cpp b/tests/client/menuchangestest.cpp
index 64c1729..2015582 100644
--- a/tests/client/menuchangestest.cpp
+++ b/tests/client/menuchangestest.cpp
@@ -46,7 +46,7 @@ private Q_SLOTS:
void init()
{
m_model.stop();
- m_model.setBusType(QDBusObject::SessionBus);
+ m_model.setBusType(DBusEnums::SessionBus);
m_model.setBusName(MENU_SERVICE_NAME);
m_model.setObjectPath(MENU_OBJECT_PATH);
}
diff --git a/tests/client/modeltest.cpp b/tests/client/modeltest.cpp
index ee3e0f4..9f6ee76 100644
--- a/tests/client/modeltest.cpp
+++ b/tests/client/modeltest.cpp
@@ -46,7 +46,7 @@ private Q_SLOTS:
void init()
{
m_model.stop();
- m_model.setBusType(QDBusObject::SessionBus);
+ m_model.setBusType(DBusEnums::SessionBus);
m_model.setBusName(MENU_SERVICE_NAME);
m_model.setObjectPath(MENU_OBJECT_PATH);
}
@@ -57,14 +57,6 @@ private Q_SLOTS:
}
/*
- * Test if columnCount is always 1
- */
- void testColumnCount()
- {
- QCOMPARE(m_model.columnCount(), 1);
- }
-
- /*
* Test if parent function always return a empty QModelIndex
*/
void testParent()
@@ -78,16 +70,16 @@ private Q_SLOTS:
void testBusTypeProperty()
{
m_model.setProperty("busType", 1);
- QCOMPARE(m_model.busType(), QDBusObject::SessionBus);
+ QCOMPARE(m_model.busType(), DBusEnums::SessionBus);
m_model.setProperty("busType", 2);
- QCOMPARE(m_model.busType(), QDBusObject::SystemBus);
+ QCOMPARE(m_model.busType(), DBusEnums::SystemBus);
m_model.setProperty("busType", 0);
- QCOMPARE(m_model.busType(), QDBusObject::SystemBus);
+ QCOMPARE(m_model.busType(), DBusEnums::SystemBus);
m_model.setProperty("busType", 10);
- QCOMPARE(m_model.busType(), QDBusObject::SystemBus);
+ QCOMPARE(m_model.busType(), DBusEnums::SystemBus);
}
@@ -106,7 +98,7 @@ private Q_SLOTS:
// Wait for dbus sync
QTest::qWait(500);
- QCOMPARE(m_model.status(), QDBusObject::Connected);
+ QCOMPARE(m_model.status(), DBusEnums::Connected);
QCOMPARE(m_model.rowCount(), 4);
// Label (String)
@@ -154,7 +146,7 @@ private Q_SLOTS:
// Wait for dbus sync
QTest::qWait(500);
- QCOMPARE(m_model.status(), QDBusObject::Connected);
+ QCOMPARE(m_model.status(), DBusEnums::Connected);
QCOMPARE(m_model.rowCount(), 4);
QVariant e = m_model.data(m_model.index(0, 0), QMenuModel::Extra);
@@ -193,12 +185,12 @@ private Q_SLOTS:
// Int64
v = extra["int64"];
- QCOMPARE(v.typeName(), "long");
+ QCOMPARE(v.type(), QVariant::LongLong);
QCOMPARE(v.value<long>(), (long) -42);
// UInt64
v = extra["uint64"];
- QCOMPARE(v.typeName(), "ulong");
+ QCOMPARE(v.type(), QVariant::ULongLong);
QCOMPARE(v.value<ulong>(), (ulong) 42);
// Double
diff --git a/tests/client/servicetest.cpp b/tests/client/servicetest.cpp
index cc47334..a8b0c2a 100644
--- a/tests/client/servicetest.cpp
+++ b/tests/client/servicetest.cpp
@@ -34,7 +34,7 @@ private:
void setupModel(QDBusMenuModel *model)
{
- model->setBusType(QDBusObject::SessionBus);
+ model->setBusType(DBusEnums::SessionBus);
model->setBusName(MENU_SERVICE_NAME);
model->setObjectPath(MENU_OBJECT_PATH);
}
@@ -53,7 +53,7 @@ private Q_SLOTS:
void init()
{
m_model.stop();
- m_model.setBusType(QDBusObject::SessionBus);
+ m_model.setBusType(DBusEnums::SessionBus);
m_model.setBusName(MENU_SERVICE_NAME);
m_model.setObjectPath(MENU_OBJECT_PATH);
}
@@ -66,10 +66,10 @@ private Q_SLOTS:
void testMenuStartStopWithNoService()
{
m_model.start();
- QCOMPARE(m_model.status(), QDBusObject::Connecting);
+ QCOMPARE(m_model.status(), DBusEnums::Connecting);
m_model.stop();
- QCOMPARE(m_model.status(), QDBusObject::Disconnected);
+ QCOMPARE(m_model.status(), DBusEnums::Disconnected);
}
void testMenuStartStopWithService()
@@ -83,33 +83,33 @@ private Q_SLOTS:
// Wait for dbus sync
QTest::qWait(500);
- QCOMPARE(m_model.status(), QDBusObject::Connected);
+ QCOMPARE(m_model.status(), DBusEnums::Connected);
// Diconnect model
m_model.stop();
- QCOMPARE(m_model.status(), QDBusObject::Disconnected);
+ QCOMPARE(m_model.status(), DBusEnums::Disconnected);
}
void testMenuServiceAppearAndDissapear()
{
m_model.start();
- QCOMPARE(m_model.status(), QDBusObject::Connecting);
+ QCOMPARE(m_model.status(), DBusEnums::Connecting);
- QSignalSpy spy(&m_model, SIGNAL(statusChanged(QDBusObject::ConnectionStatus)));
+ QSignalSpy spy(&m_model, SIGNAL(statusChanged(DBusEnums::ConnectionStatus)));
// Make menu available
m_script.publishMenu();
// singal changed to connected
QCOMPARE(spy.count(), 1);
- QCOMPARE(m_model.status(), QDBusObject::Connected);
+ QCOMPARE(m_model.status(), DBusEnums::Connected);
// remove menu service
m_script.unpublishMenu();
// signal changed to connecting
QCOMPARE(spy.count(), 2);
- QCOMPARE(m_model.status(), QDBusObject::Connecting);
+ QCOMPARE(m_model.status(), DBusEnums::Connecting);
}
};
diff --git a/tests/script/menuscript.py b/tests/script/menuscript.py
index f50aacd..ba67560 100644
--- a/tests/script/menuscript.py
+++ b/tests/script/menuscript.py
@@ -127,7 +127,7 @@ class ActionList(object):
self._actions = []
self._actions_bk = []
self._objectPath = objectPath
- self._bux = None
+ self._bus = None
self._exportMenuID = None
self._exportActionID = None
self._ownNameID = None