Merge lp:~super-friends/qml-friends/raring into lp:qml-friends

Proposed by Ken VanDine
Status: Merged
Approved by: Ken VanDine
Approved revision: 38
Merged at revision: 34
Proposed branch: lp:~super-friends/qml-friends/raring
Merge into: lp:qml-friends
Diff against target: 1000 lines (+538/-149)
19 files modified
debian/changelog (+15/-0)
debian/control (+7/-0)
examples/README (+95/-0)
examples/streamview.qml (+0/-121)
friends.pro (+3/-0)
modules/Friends/plugin/friendsdispatcher.cpp (+8/-0)
modules/Friends/plugin/friendsdispatcher.h (+2/-0)
modules/Friends/plugin/friendsutils.cpp (+0/-2)
modules/Friends/plugin/friendsutils.h (+1/-6)
modules/Friends/plugin/plugin.cpp (+9/-11)
modules/Friends/plugin/plugin.h (+2/-3)
modules/Friends/plugin/plugin.pro (+8/-6)
modules/Friends/plugin/streammodel.cpp (+176/-0)
modules/Friends/plugin/streammodel.h (+46/-0)
tests/tests.pro (+4/-0)
tests/unit/main.cpp (+2/-0)
tests/unit/run.sh (+7/-0)
tests/unit/tst_test.qml (+140/-0)
tests/unit/unit.pro (+13/-0)
To merge this branch: bzr merge lp:~super-friends/qml-friends/raring
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Ken VanDine Approve
Review via email: mp+154367@code.launchpad.net

Commit message

  * Added StreamModel
    - Filters available for stream, service, and account (LP: #1156941)
  * Added Refresh
  * Added tests
  * Updated for the schema changes in friends
  * debian/control
    - build depend on libdee-qt5-dev
    - Added build depends for running tests: dbus-test-runner, xvfb,
      qtdeclarative5-qtquick2-plugin, and qtdeclarative5-test-plugin
    - build depend on friends-dispatcher (>= 0.1.2daily13.03.14)

Description of the change

Merged queued changes for raring now that the FFe is approved

To post a comment you must log in.
Revision history for this message
Ken VanDine (ken-vandine) wrote :

These changes have been reviewed before merging into the raring branch

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2013-03-07 16:38:08 +0000
+++ debian/changelog 2013-03-20 13:31:31 +0000
@@ -1,3 +1,18 @@
1qml-friends (0.1.1-0ubuntu1) UNRELEASED; urgency=low
2
3 * Added StreamModel
4 - Filters available for stream, service, and account (LP: #1156941)
5 * Added Refresh
6 * Added tests
7 * Updated for the schema changes in friends
8 * debian/control
9 - build depend on libdee-qt5-dev
10 - Added build depends for running tests: dbus-test-runner, xvfb,
11 qtdeclarative5-qtquick2-plugin, and qtdeclarative5-test-plugin
12 - build depend on friends-dispatcher (>= 0.1.2daily13.03.14)
13
14 -- Ken VanDine <ken.vandine@canonical.com> Mon, 18 Mar 2013 22:49:02 -0400
15
1qml-friends (0.1.0bzr13.03.07-0ubuntu1) raring; urgency=low16qml-friends (0.1.0bzr13.03.07-0ubuntu1) raring; urgency=low
217
3 * Use the correct callback for likeAsync18 * Use the correct callback for likeAsync
419
=== modified file 'debian/control'
--- debian/control 2013-03-05 18:52:53 +0000
+++ debian/control 2013-03-20 13:31:31 +0000
@@ -11,7 +11,14 @@
11 qt5-qmake,11 qt5-qmake,
12 qtbase5-dev,12 qtbase5-dev,
13 qtdeclarative5-dev,13 qtdeclarative5-dev,
14 qtdeclarative5-test-plugin,
15 libdee-qt5-dev,
16 friends-dispatcher (>= 0.1.2daily13.03.14),
14 libfriends-dev (>= 0.1.1bzr13.02.07-0ubuntu1),17 libfriends-dev (>= 0.1.1bzr13.02.07-0ubuntu1),
18 dbus-test-runner,
19 xvfb,
20 qtdeclarative5-qtquick2-plugin,
21 qtdeclarative5-test-plugin,
15Standards-Version: 3.9.322Standards-Version: 3.9.3
16Section: libs23Section: libs
17Homepage: https://launchpad.net/qml-friends24Homepage: https://launchpad.net/qml-friends
1825
=== added file 'examples/README'
--- examples/README 1970-01-01 00:00:00 +0000
+++ examples/README 2013-03-20 13:31:31 +0000
@@ -0,0 +1,95 @@
1Code examples for qml-friends
2
3All the dependencies can be installed from ppa:super-friends/ppa
4
5Installing the qtdeclarative5-friends-plugin package should bring in the necessary dependencies
6
7/* Sending
8 http://bazaar.launchpad.net/~super-friends/qml-friends/raring/view/head:/examples/poster.qml */
9
10import Friends 0.1
11
12FriendsDispatcher {
13 id: friends
14 // use this to check if the send was successfull
15 onSendComplete: {
16 if (success) {
17 console.log ("Send completed successfully");
18 } else {
19 console.log ("Send failed: " + errorMessage);
20 }
21 }
22}
23
24Button {
25 id: sendButton
26 text: i18n.tr("Send")
27 onClicked: {
28 /* async method to send, connect to onSendComplete for success/failure */
29 friends.sendAsync(entry.text);
30 }
31}
32
33Getting a model of the data from Friends
34http://bazaar.launchpad.net/~super-friends/qml-friends/raring/view/head:/examples/streamview.qml
35
36/* To get a model of all posts, suitable for use in a ListView,
37 Repeater, etc */
38StreamModel {
39 id: streamModel
40}
41
42/* The roleNames provided from streamModel isn't all that intuitive right now.
43 service: column_0
44 account_id: column_1
45 message_id: column_2
46 stream: column_3
47 sender: column_4
48 sender_id: column_5
49 sender_nick: column_6
50 from_me: column_7
51 timestamp: column_8
52 message: column_9
53 icon_uri: column_10
54 url: column_11
55 likes: column_12
56 liked: column_13
57 link_picture: column_14
58 link_name: column_15
59 link_url: column_16
60 link_desc: column_17
61 link_caption: column_18
62 link_icon: column_19
63 location: column_20
64 latitude: column_21
65 longitude: column_22
66*/
67
68/* To get a model of all images */
69StreamModel {
70 stream: "images"
71}
72
73/* To get a model of content from twitter */
74StreamModel {
75 service: "twitter"
76}
77
78/* To get a model of content from accountId 2 */
79StreamModel {
80 account: 2
81}
82
83/* To get a model of threads on a post */
84StreamModel {
85 stream: "reply_to/"+messageId
86}
87
88/* convenience function for converting timestamps into time delta
89 strings, like "2 hours ago" */
90FriendsUtils {
91 id: friendsUtils
92}
93
94friendsUtils.createTimeString(column_8)
95
096
=== added file 'examples/streamview.qml'
--- examples/streamview.qml 1970-01-01 00:00:00 +0000
+++ examples/streamview.qml 2013-03-20 13:31:31 +0000
@@ -0,0 +1,128 @@
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import Ubuntu.Components 0.1
19import Ubuntu.Components.ListItems 0.1
20import Friends 0.1
21
22MainView {
23 width: units.gu(50)
24 height: units.gu(100)
25
26 FriendsUtils {
27 id: friendsUtils
28 }
29
30 ListView {
31 id: listView
32 anchors {
33 fill: parent
34 }
35 snapMode: ListView.SnapToItem
36 /* Reverse ListView order */
37 verticalLayoutDirection: ListView.BottomToTop
38 cacheBuffer: parent.height
39 model: StreamModel {
40 //stream: "messages"
41 //service: "facebook"
42 /* account Id from libaccounts */
43 //account: 1
44 }
45 populate: Transition {
46 ScriptAction { script: listView.positionViewAtEnd() }
47 }
48
49 delegate: Item {
50 id: tile
51 height: status_update_content.height
52 width: parent.width
53 anchors {
54 margins: units.gu(1)
55 }
56
57 UbuntuShape {
58 id: avatarImage
59 radius: "medium"
60 height: units.dp(48)
61 width: units.dp(48)
62 anchors {
63 left: parent.left
64 top: parent.top
65 leftMargin: units.gu(1)
66 topMargin: units.gu(1)
67 }
68 image: Image {
69 anchors.fill: parent
70 source: Qt.resolvedUrl(column_10)
71 asynchronous: true
72 fillMode: Image.PreserveAspectFit
73 }
74 }
75
76 Item {
77 id: status_update_content
78 anchors {
79 left: avatarImage.right
80 right: parent.right
81 top: parent.top
82 topMargin: units.gu(1)
83 leftMargin: units.gu(1)
84 bottomMargin: units.gu(1)
85 rightMargin: units.gu(1)
86 }
87 height: childrenRect.height + units.gu(2)
88 Column {
89 spacing: units.gu(1)
90 anchors {
91 left: parent.left;
92 right: parent.right
93 bottomMargin: units.gu(2)
94 }
95 Label {
96 id: sender
97 text: column_4
98 fontSize: "medium"
99 font.bold: true
100 font.family: "Ubuntu"
101 width: parent.width
102 }
103 Label {
104 id: message
105 text: column_9
106 wrapMode: Text.WrapAtWordBoundaryOrAnywhere
107 width: parent.width - units.gu(3)
108 font.family: "Ubuntu"
109 }
110 }
111 Row {
112 anchors.right: parent.right
113 anchors.rightMargin: units.gu(1)
114 anchors.top: parent.top
115 spacing: units.gu(1)
116
117 Label {
118 id: time
119 text: friendsUtils.createTimeString(column_8)
120 fontSize: "small"
121 font.family: "Ubuntu"
122 }
123 }
124 }
125 ThinDivider {}
126 }
127 }
128}
0129
=== removed file 'examples/streamview.qml'
--- examples/streamview.qml 2013-03-08 15:19:38 +0000
+++ examples/streamview.qml 1970-01-01 00:00:00 +0000
@@ -1,121 +0,0 @@
1/*
2 * Copyright (C) 2013 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import Ubuntu.Components 0.1
19import Ubuntu.Components.ListItems 0.1
20import Dee 3.0
21import Friends 0.1
22
23MainView {
24 width: units.gu(50)
25 height: units.gu(100)
26
27 FriendsUtils {
28 id: friendsUtils
29 }
30
31 ListView {
32 id: listView
33 anchors {
34 fill: parent
35 }
36 snapMode: ListView.SnapToItem
37 verticalLayoutDirection: ListView.BottomToTop
38 cacheBuffer: parent.height
39
40 model: DeeListModel { name: "com.canonical.Friends.Streams" }
41
42 delegate: Item {
43 id: tile
44 height: status_update_content.height
45 width: parent.width
46 anchors {
47 margins: units.gu(1)
48 }
49
50 UbuntuShape {
51 id: avatarImage
52 radius: "medium"
53 height: units.dp(48)
54 width: units.dp(48)
55 anchors {
56 left: parent.left
57 top: parent.top
58 leftMargin: units.gu(1)
59 topMargin: units.gu(1)
60 }
61 image: Image {
62 anchors.fill: parent
63 source: Qt.resolvedUrl(column_8)
64 asynchronous: true
65 fillMode: Image.PreserveAspectFit
66 }
67 }
68
69 Item {
70 id: status_update_content
71 anchors {
72 left: avatarImage.right
73 right: parent.right
74 top: parent.top
75 topMargin: units.gu(1)
76 leftMargin: units.gu(1)
77 bottomMargin: units.gu(1)
78 rightMargin: units.gu(1)
79 }
80 height: childrenRect.height + units.gu(2)
81 Column {
82 spacing: units.gu(1)
83 anchors {
84 left: parent.left;
85 right: parent.right
86 bottomMargin: units.gu(2)
87 }
88 Label {
89 id: sender
90 text: column_2
91 fontSize: "medium"
92 font.bold: true
93 font.family: "Ubuntu"
94 width: parent.width
95 }
96 Label {
97 id: message
98 text: column_7
99 wrapMode: Text.WrapAtWordBoundaryOrAnywhere
100 width: parent.width - units.gu(3)
101 font.family: "Ubuntu"
102 }
103 }
104 Row {
105 anchors.right: parent.right
106 anchors.rightMargin: units.gu(1)
107 anchors.top: parent.top
108 spacing: units.gu(1)
109
110 Label {
111 id: time
112 text: friendsUtils.createTimeString(column_6)
113 fontSize: "small"
114 font.family: "Ubuntu"
115 }
116 }
117 }
118 ThinDivider {}
119 }
120 }
121}
1220
=== modified file 'friends.pro'
--- friends.pro 2013-01-15 19:49:40 +0000
+++ friends.pro 2013-03-20 13:31:31 +0000
@@ -15,3 +15,6 @@
15dist.depends = distclean15dist.depends = distclean
1616
17QMAKE_EXTRA_TARGETS += dist17QMAKE_EXTRA_TARGETS += dist
18
19SUBDIRS += \
20 tests
1821
=== modified file 'modules/Friends/plugin/friendsdispatcher.cpp'
--- modules/Friends/plugin/friendsdispatcher.cpp 2013-03-06 17:51:39 +0000
+++ modules/Friends/plugin/friendsdispatcher.cpp 2013-03-20 13:31:31 +0000
@@ -299,3 +299,11 @@
299 &sendReplyCompleteCallback, (gpointer) this);299 &sendReplyCompleteCallback, (gpointer) this);
300}300}
301301
302void FriendsDispatcherQml::refresh() const
303{
304 GError* error = NULL;
305 friends_dispatcher_refresh(m_dispatcher, &error);
306
307 if (error != NULL)
308 g_error_free (error);
309}
302310
=== modified file 'modules/Friends/plugin/friendsdispatcher.h'
--- modules/Friends/plugin/friendsdispatcher.h 2013-02-14 15:26:37 +0000
+++ modules/Friends/plugin/friendsdispatcher.h 2013-03-20 13:31:31 +0000
@@ -46,6 +46,8 @@
46 void likeAsync(const int& account_id, const QString& message_id) const;46 void likeAsync(const int& account_id, const QString& message_id) const;
47 void unlike(const int& account_id, const QString& message_id) const;47 void unlike(const int& account_id, const QString& message_id) const;
48 void unlikeAsync(const int& account_id, const QString& message_id) const;48 void unlikeAsync(const int& account_id, const QString& message_id) const;
49 void refresh() const;
50
4951
50Q_SIGNALS:52Q_SIGNALS:
51 void uploadComplete(QString resultUrl, bool success, QString errorMessage);53 void uploadComplete(QString resultUrl, bool success, QString errorMessage);
5254
=== modified file 'modules/Friends/plugin/friendsutils.cpp'
--- modules/Friends/plugin/friendsutils.cpp 2012-11-28 18:22:36 +0000
+++ modules/Friends/plugin/friendsutils.cpp 2013-03-20 13:31:31 +0000
@@ -17,9 +17,7 @@
1717
18#include "friendsutils.h"18#include "friendsutils.h"
1919
20#include <QGuiApplication>
21#include <QtQuick/QQuickView>20#include <QtQuick/QQuickView>
22#include <QtQuick/QQuickItem>
2321
24#include <glib-object.h>22#include <glib-object.h>
2523
2624
=== modified file 'modules/Friends/plugin/friendsutils.h'
--- modules/Friends/plugin/friendsutils.h 2012-11-28 18:22:36 +0000
+++ modules/Friends/plugin/friendsutils.h 2013-03-20 13:31:31 +0000
@@ -18,14 +18,9 @@
18#ifndef FRIENDSUTILS_H18#ifndef FRIENDSUTILS_H
19#define FRIENDSUTILS_H19#define FRIENDSUTILS_H
2020
21#include <QtCore/QObject>21#include <QObject>
22#include <QtQuick/QQuickView>
23#include <friends.h>22#include <friends.h>
2423
25class QQuickItem;
26class QQmlEngine;
27class QJSEngine;
28
29class FriendsUtilsQml : public QObject24class FriendsUtilsQml : public QObject
30{25{
31 Q_OBJECT26 Q_OBJECT
3227
=== modified file 'modules/Friends/plugin/plugin.cpp'
--- modules/Friends/plugin/plugin.cpp 2013-02-09 15:33:54 +0000
+++ modules/Friends/plugin/plugin.cpp 2013-03-20 13:31:31 +0000
@@ -14,25 +14,23 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */15 */
1616
17#include <QtQml>
18#include <QtQml/QQmlContext>
19
20#include "plugin.h"
21#include "friendsutils.h"17#include "friendsutils.h"
22#include "friendsdispatcher.h"18#include "friendsdispatcher.h"
2319#include "streammodel.h"
24#include <glib-object.h>20#include "plugin.h"
25#include <friends.h>21
22#include <QDebug>
23#include <QQmlComponent>
24
2625
27void FriendsPlugin::registerTypes(const char *uri)26void FriendsPlugin::registerTypes(const char *uri)
28{27{
29 Q_ASSERT(uri == QLatin1String("Friends"));28 Q_ASSERT(uri == QLatin1String("Friends"));
3029
30 qDebug() << Q_FUNC_INFO << uri;
31
31 qmlRegisterType<FriendsUtilsQml>(uri, 0, 1, "FriendsUtils");32 qmlRegisterType<FriendsUtilsQml>(uri, 0, 1, "FriendsUtils");
32 qmlRegisterType<FriendsDispatcherQml>(uri, 0, 1, "FriendsDispatcher");33 qmlRegisterType<FriendsDispatcherQml>(uri, 0, 1, "FriendsDispatcher");
34 qmlRegisterType<StreamModel>(uri, 0, 1, "StreamModel");
33}35}
3436
35void FriendsPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
36{
37 QQmlExtensionPlugin::initializeEngine(engine, uri);
38}
3937
=== modified file 'modules/Friends/plugin/plugin.h'
--- modules/Friends/plugin/plugin.h 2012-11-28 18:22:36 +0000
+++ modules/Friends/plugin/plugin.h 2013-03-20 13:31:31 +0000
@@ -17,8 +17,7 @@
17#ifndef FRIENDS_PLUGIN_H17#ifndef FRIENDS_PLUGIN_H
18#define FRIENDS_PLUGIN_H18#define FRIENDS_PLUGIN_H
1919
20#include <QtQml/QQmlEngine>20#include <QQmlExtensionPlugin>
21#include <QtQml/QQmlExtensionPlugin>
2221
23class FriendsPlugin : public QQmlExtensionPlugin22class FriendsPlugin : public QQmlExtensionPlugin
24{23{
@@ -27,7 +26,7 @@
2726
28public:27public:
29 void registerTypes(const char *uri);28 void registerTypes(const char *uri);
30 void initializeEngine(QQmlEngine *engine, const char *uri);
31};29};
30
32#endif // FRIENDS_PLUGIN_H31#endif // FRIENDS_PLUGIN_H
3332
3433
=== modified file 'modules/Friends/plugin/plugin.pro'
--- modules/Friends/plugin/plugin.pro 2013-02-09 15:33:54 +0000
+++ modules/Friends/plugin/plugin.pro 2013-03-20 13:31:31 +0000
@@ -2,26 +2,28 @@
22
3TEMPLATE = lib3TEMPLATE = lib
4TARGET = ../Friends4TARGET = ../Friends
5QT += qml quick5QT += qml
6CONFIG += qt plugin no_keywords link_pkgconfig6CONFIG += qt plugin no_keywords link_pkgconfig
7PKGCONFIG += friends-0.1 gobject-2.07PKGCONFIG += friends-0.1 gobject-2.0 libdee-qt5
8
9#comment in the following line to disable traces8#comment in the following line to disable traces
10#DEFINES += QT_NO_DEBUG_OUTPUT9#DEFINES += QT_NO_DEBUG_OUTPUT
1110
11QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF
12
12TARGET = $$qtLibraryTarget($$TARGET)13TARGET = $$qtLibraryTarget($$TARGET)
13uri = Friends14uri = Friends
1415
15HEADERS += plugin.h \16HEADERS += plugin.h \
16 friendsutils.h \17 friendsutils.h \
17 friendsdispatcher.h18 friendsdispatcher.h \
19 streammodel.h
1820
19SOURCES += plugin.cpp \21SOURCES += plugin.cpp \
20 friendsutils.cpp \22 friendsutils.cpp \
21 friendsdispatcher.cpp23 friendsdispatcher.cpp \
24 streammodel.cpp
2225
23# deployment rules for the plugin26# deployment rules for the plugin
24installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /)27installPath = $$[QT_INSTALL_QML]/$$replace(uri, \\., /)
25target.path = $$installPath28target.path = $$installPath
26INSTALLS += target29INSTALLS += target
27
2830
=== added file 'modules/Friends/plugin/streammodel.cpp'
--- modules/Friends/plugin/streammodel.cpp 1970-01-01 00:00:00 +0000
+++ modules/Friends/plugin/streammodel.cpp 2013-03-20 13:31:31 +0000
@@ -0,0 +1,176 @@
1#include <glib-object.h>
2#include "streammodel.h"
3#include <QDebug>
4#include <QProcessEnvironment>
5
6class StreamModelPrivate: public DeeListModel
7{
8 Q_DECLARE_PUBLIC(StreamModel)
9
10public:
11 StreamModelPrivate(StreamModel *model);
12 ~StreamModelPrivate();
13 static void onModelReady(GObject* parent, GParamSpec *pspec, StreamModelPrivate *q);
14 void updateResults(StreamModelPrivate *d);
15
16private:
17 mutable StreamModel *q_ptr;
18 QString streamId = NULL;
19 QString serviceId = NULL;
20 uint accountId = 0;
21 DeeModel* m_resultsModel;
22 DeeModel* m_sharedModel;
23 DeeModel* m_sortedModel;
24};
25
26StreamModelPrivate::StreamModelPrivate(StreamModel *model):
27 DeeListModel(model),
28 q_ptr(model)
29{
30 qDebug() << Q_FUNC_INFO;
31 QString modelName = "com.canonical.Friends.Streams";
32 /* read environment variables */
33 QProcessEnvironment environment = QProcessEnvironment::systemEnvironment();
34 if (environment.contains(QLatin1String("FRIENDS_STREAMS_MODEL")))
35 {
36 modelName = environment.value(QLatin1String("FRIENDS_STREAMS_MODEL"));
37 }
38
39 qDebug() << "MODEL: " << modelName;
40
41 m_sharedModel = dee_shared_model_new (modelName.toUtf8());
42 m_resultsModel = m_sharedModel;
43 m_sortedModel = dee_sequence_model_new ();
44 g_signal_connect(m_sharedModel, "notify::synchronized", G_CALLBACK(onModelReady), this);
45}
46
47void
48StreamModelPrivate::onModelReady(GObject* parent __attribute__ ((unused)), GParamSpec *pspec, StreamModelPrivate *d)
49{
50 qDebug() << Q_FUNC_INFO;
51 DeeModel *model = (DeeModel*)parent;
52 DeeFilter _sort_filter;
53 dee_filter_new_collator (8, &_sort_filter);
54 d->m_sortedModel = dee_filter_model_new (model, &_sort_filter);
55 qDebug() << Q_FUNC_INFO << " " << dee_model_get_n_rows (d->m_sortedModel);
56 d->updateResults(d);
57}
58
59void StreamModelPrivate::updateResults(StreamModelPrivate *d)
60{
61 /* Only updateResults if the model is populated */
62 if (dee_model_get_n_rows (d->m_sortedModel) < 1) return;
63
64 if (d->streamId != NULL)
65 {
66 DeeFilter _key_filter;
67 dee_filter_new_for_key_column (3, d->streamId.toUtf8().data(), &_key_filter);
68 d->m_resultsModel = dee_filter_model_new (d->m_sortedModel, &_key_filter);
69 } else
70 {
71 GRegex *regex;
72 regex = g_regex_new ("^((?!reply_to).)*$", G_REGEX_FIRSTLINE, G_REGEX_MATCH_PARTIAL, NULL);
73 DeeFilter _regex_filter;
74 dee_filter_new_regex (3, regex, &_regex_filter);
75 g_regex_unref (regex);
76 d->m_resultsModel = dee_filter_model_new (d->m_sortedModel, &_regex_filter);
77 }
78 qDebug () << "STREAM: " << d->streamId << " ROWS: " << dee_model_get_n_rows (d->m_resultsModel);
79
80 if (d->serviceId != NULL)
81 {
82 DeeFilter _service_filter;
83 dee_filter_new_for_key_column (0, d->serviceId.toUtf8().data(), &_service_filter);
84 d->m_resultsModel = dee_filter_model_new (d->m_resultsModel, &_service_filter);
85 }
86 qDebug () << "SERVICE: " << d->serviceId << " ROWS: " << dee_model_get_n_rows (d->m_resultsModel);
87
88 if (d->accountId != 0)
89 {
90 DeeFilter _account_filter;
91 dee_filter_new_for_any_column (1, g_variant_new_uint64(d->accountId), &_account_filter);
92 d->m_resultsModel = dee_filter_model_new (d->m_resultsModel, &_account_filter);
93 qDebug () << "ACCOUNT: " << d->accountId << " ROWS: " << dee_model_get_n_rows (d->m_resultsModel);
94 }
95
96 q_ptr->setModel(m_resultsModel);
97 Q_EMIT q_ptr->streamChanged();
98}
99
100StreamModelPrivate::~StreamModelPrivate()
101{
102}
103
104StreamModel::StreamModel(DeeListModel *parent) :
105 DeeListModel(parent),
106 d_ptr(new StreamModelPrivate(this))
107{
108}
109
110StreamModel::~StreamModel()
111{
112}
113
114
115void StreamModel::classBegin()
116{
117}
118
119void StreamModel::componentComplete()
120{
121}
122
123void StreamModel::setStream(const QString& streamId)
124{
125 Q_D(StreamModel);
126 if (streamId == d->streamId) return;
127 d->streamId = streamId;
128 d->updateResults(d);
129}
130
131/*!
132 * \qmlproperty string StreamModel::stream
133 * If set, the model will include only this stream
134 */
135QString StreamModel::stream() const
136{
137 Q_D(const StreamModel);
138 return d->streamId;
139}
140
141void StreamModel::setService(const QString& serviceId)
142{
143 Q_D(StreamModel);
144 if (serviceId == d->serviceId) return;
145 d->serviceId = serviceId;
146 d->updateResults(d);
147}
148
149/*!
150 * \qmlproperty string StreamModel::service
151 * If set, the model will include only this service
152 */
153QString StreamModel::service() const
154{
155 Q_D(const StreamModel);
156 return d->serviceId;
157}
158
159void StreamModel::setAccount(uint account)
160{
161 Q_D(StreamModel);
162 if (account == d->accountId) return;
163 d->accountId = account;
164 d->updateResults(d);
165 qDebug() << "Account: " << account;
166}
167
168/*!
169 * \qmlproperty string StreamModel::account
170 * If set, the model will include only this account
171 */
172uint StreamModel::account() const
173{
174 Q_D(const StreamModel);
175 return d->accountId;
176}
0177
=== added file 'modules/Friends/plugin/streammodel.h'
--- modules/Friends/plugin/streammodel.h 1970-01-01 00:00:00 +0000
+++ modules/Friends/plugin/streammodel.h 2013-03-20 13:31:31 +0000
@@ -0,0 +1,46 @@
1#ifndef StreamModel_H
2#define StreamModel_H
3
4
5#include <QObject>
6#include <QString>
7#include <QQmlParserStatus>
8#include <QQmlListProperty>
9#include "deelistmodel.h"
10#include <dee-1.0/dee.h>
11
12class StreamModelPrivate;
13class StreamModel : public DeeListModel, public QQmlParserStatus
14{
15 Q_OBJECT
16 Q_INTERFACES(QQmlParserStatus)
17 Q_PROPERTY(QString stream READ stream WRITE setStream NOTIFY streamChanged)
18 Q_PROPERTY(QString service READ service WRITE setService NOTIFY serviceChanged)
19 Q_PROPERTY(uint account READ account WRITE setAccount NOTIFY accountChanged)
20
21public:
22 explicit StreamModel(DeeListModel *parent = 0);
23 ~StreamModel();
24
25 void setStream(const QString& streamId);
26 QString stream() const;
27 void setService(const QString& serviceId);
28 QString service() const;
29 void setAccount(uint account);
30 uint account() const;
31 void classBegin();
32 void componentComplete();
33
34
35Q_SIGNALS:
36 void streamChanged();
37 void serviceChanged();
38 void accountChanged();
39
40private:
41 StreamModelPrivate* const d_ptr;
42 Q_DECLARE_PRIVATE(StreamModel)
43
44};
45
46#endif // StreamModel_H
047
=== added directory 'tests'
=== added file 'tests/tests.pro'
--- tests/tests.pro 1970-01-01 00:00:00 +0000
+++ tests/tests.pro 2013-03-20 13:31:31 +0000
@@ -0,0 +1,4 @@
1TEMPLATE = subdirs
2
3SUBDIRS += \
4 unit
05
=== added directory 'tests/unit'
=== added file 'tests/unit/main.cpp'
--- tests/unit/main.cpp 1970-01-01 00:00:00 +0000
+++ tests/unit/main.cpp 2013-03-20 13:31:31 +0000
@@ -0,0 +1,2 @@
1#include <QtQuickTest/quicktest.h>
2QUICK_TEST_MAIN(unit)
03
=== added file 'tests/unit/run.sh'
--- tests/unit/run.sh 1970-01-01 00:00:00 +0000
+++ tests/unit/run.sh 2013-03-20 13:31:31 +0000
@@ -0,0 +1,7 @@
1#!/bin/sh
2
3export FRIENDS_STREAMS_MODEL=com.canonical.Friends.TestSharedModel
4export QML2_IMPORT_PATH=../../modules
5
6xvfb-run -a dbus-test-runner -t friends-dispatcher -p --test \
7 --task-name FriendsService --ignore-return -t ./unit -m 120
08
=== added file 'tests/unit/tst_test.qml'
--- tests/unit/tst_test.qml 1970-01-01 00:00:00 +0000
+++ tests/unit/tst_test.qml 2013-03-20 13:31:31 +0000
@@ -0,0 +1,140 @@
1import QtQuick 2.0
2import QtTest 1.0
3import Friends 0.1
4
5// See more details @ http://qt-project.org/doc/qt-5.0/qtquick/qml-testcase.html
6
7Item {
8 // The objects
9
10 FriendsDispatcher {
11 id: friends
12 }
13
14 SignalSpy {
15 id: signalSpy
16 target: friends
17 }
18 TestCase {
19 name: "testFriendsDispatcher"
20
21 function test_features () {
22 var input = ["facebook"]
23 var res = friends.featuresForProtocol (input[0]);
24 compare (res, input);
25 }
26
27 function test_uploadForAccountAsync () {
28 var acct = 1;
29 var uri = "file:///tmp/foo.png";
30 var desc = "Something interesting to say";
31 signalSpy.clear ();
32 signalSpy.signalName = "onUploadComplete"
33 friends.uploadForAccountAsync (acct, uri, desc)
34 signalSpy.wait ();
35 compare(1, signalSpy.count, "onUploadComplete emitted");
36 }
37
38 function test_sendforAccountAsync () {
39 var acct = 1;
40 var msg = "Something interesting to say";
41 signalSpy.clear ();
42 signalSpy.signalName = "onSendComplete"
43 friends.sendForAccountAsync (acct, msg)
44 signalSpy.wait ();
45 compare(1, signalSpy.count, "onSendComplete emitted");
46 }
47
48 function test_sendAsync () {
49 var msg = "Something interesting to say";
50 signalSpy.clear ();
51 signalSpy.signalName = "onSendComplete"
52 friends.sendAsync (msg)
53 signalSpy.wait ();
54 compare(1, signalSpy.count, "onSendComplete emitted");
55 }
56
57 function test_sendReplyAsync () {
58 var acct = 1;
59 var msgId = "10";
60 var msg = "Something interesting to say";
61 signalSpy.clear ();
62 signalSpy.signalName = "onSendComplete"
63 friends.sendReplyAsync (acct, msgId, msg)
64 signalSpy.wait ();
65 compare(1, signalSpy.count, "onSendComplete emitted");
66 }
67
68 function test_retweetAsync () {
69 var acct = 1;
70 var msgId = "10";
71 signalSpy.clear ();
72 signalSpy.signalName = "onRetweetComplete"
73 friends.retweetAsync (acct, msgId)
74 signalSpy.wait ();
75 compare(1, signalSpy.count, "onRetweetComplete emitted");
76 }
77
78 function test_likeAsync () {
79 var acct = 1;
80 var msgId = "10";
81 signalSpy.clear ();
82 signalSpy.signalName = "onLikeComplete"
83 friends.likeAsync (acct, msgId)
84 signalSpy.wait ();
85 compare(1, signalSpy.count, "onLikeComplete emitted");
86 }
87
88 function test_unlikeAsync () {
89 var acct = 1;
90 var msgId = "10";
91 signalSpy.clear ();
92 signalSpy.signalName = "onUnlikeComplete"
93 friends.unlikeAsync (acct, msgId)
94 signalSpy.wait ();
95 compare(1, signalSpy.count, "onUnlikeComplete emitted");
96 }
97 }
98
99 StreamModel {
100 id: streamModel
101 }
102
103 TestCase {
104 name: "testStreamModel"
105
106 function init() {
107 console.debug(">> init");
108 console.debug("<< init");
109 }
110
111 function cleanup() {
112 console.debug(">> cleanup");
113 console.debug("<< cleanup");
114 }
115
116 function initTestCase() {
117 console.debug(">> initTestCase");
118 console.debug("<< initTestCase");
119 }
120
121 function cleanupTestCase() {
122 console.debug(">> cleanupTestCase");
123 console.debug("<< cleanupTestCase");
124 }
125
126 function test_streamModelStream() {
127 streamModel.stream = "messages";
128 compare(0, streamModel.count, "Test StreamModel row count filtered by stream");
129 }
130
131 function test_streamModelService() {
132 streamModel.service = "twitter";
133 compare(0, streamModel.count, "Test StreamModel row count filtered by service");
134 }
135 function test_streamModelAccount() {
136 streamModel.account = 1;
137 compare(0, streamModel.count, "Test StreamModel row count filtered by account");
138 }
139 }
140}
0141
=== added file 'tests/unit/unit.pro'
--- tests/unit/unit.pro 1970-01-01 00:00:00 +0000
+++ tests/unit/unit.pro 2013-03-20 13:31:31 +0000
@@ -0,0 +1,13 @@
1TEMPLATE = app
2QT += qml quick qmltest
3CONFIG += no_keywords
4
5TARGET = unit
6SOURCES += main.cpp
7
8OTHER_FILES += $$system(ls *.qml)
9check.commands = "sh run.sh"
10check.depends = $${TARGET}
11QMAKE_EXTRA_TARGETS += check
12
13#system(cp $$PWD/*.qml $$OUT_PWD)

Subscribers

People subscribed via source and target branches

to all changes: