Merge lp:~ken-vandine/content-hub/lp1236932 into lp:~content-hub-team/content-hub/trunk

Proposed by Ken VanDine
Status: Merged
Approved by: Ken VanDine
Approved revision: 70
Merged at revision: 62
Proposed branch: lp:~ken-vandine/content-hub/lp1236932
Merge into: lp:~content-hub-team/content-hub/trunk
Diff against target: 264 lines (+96/-54)
5 files modified
examples/import-qml/import.qml (+78/-34)
import/Ubuntu/Content/contenthub.cpp (+3/-4)
import/Ubuntu/Content/contenthub.h (+1/-1)
import/Ubuntu/Content/contentpeer.cpp (+10/-11)
import/Ubuntu/Content/contentpeer.h (+4/-4)
To merge this branch: bzr merge lp:~ken-vandine/content-hub/lp1236932
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Günter Schwann (community) Approve
Review via email: mp+192207@code.launchpad.net

Commit message

return a QVariantList from knownSourcesForType so the QML bindings can
expose a list of peers, fixes (LP: #1236932)

Description of the change

* return a QVariantList from knownSourcesForType so the QML bindings can
  expose a list of peers, fixes (LP: #1236932)

* Added id() and return name for name() instead of id

* Removed type property from ContentPeer, it isn't used and the cpp API doesn't provide it.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
66. By Ken VanDine

removed FIXME

67. By Ken VanDine

emit idChanged on setPeer

68. By Ken VanDine

removed the "type" property from ContentPeer, it isn't used and
com::ubuntu::content::Peer doesn't provide a type either.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Günter Schwann (schwann) wrote :

218 + Q_PROPERTY(QString id READ id NOTIFY idChanged)

Having a property called "id" is not the best idea, as it collides with QML "id"

review: Needs Fixing
69. By Ken VanDine

Renamed id to appId to avoid colliding with QML's id property

70. By Ken VanDine

revert changelog entry

Revision history for this message
Günter Schwann (schwann) wrote :

looks good to me

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'examples/import-qml/import.qml'
--- examples/import-qml/import.qml 2013-10-01 16:55:39 +0000
+++ examples/import-qml/import.qml 2013-10-23 12:08:41 +0000
@@ -1,6 +1,6 @@
1import QtQuick 2.01import QtQuick 2.0
2import Ubuntu.Components 0.12import Ubuntu.Components 0.1
3import Ubuntu.Components.ListItems 0.13import Ubuntu.Components.ListItems 0.1 as ListItem
44
5import Ubuntu.Content 0.15import Ubuntu.Content 0.1
66
@@ -12,41 +12,85 @@
1212
13 property list<ContentItem> importItems13 property list<ContentItem> importItems
14 property var activeTransfer14 property var activeTransfer
1515 property var peers
16 Button {16
17 id: importButton17
18 text: "Import from default"18 function _importFromPeer(peer) {
19 onClicked: {19 /* if peer is null, choose default */
20 var peer = ContentHub.defaultSourceForType(ContentType.Pictures);20 if (peer === null)
21 var transfer = ContentHub.importContent(ContentType.Pictures, peer);21 peer = ContentHub.defaultSourceForType(ContentType.Pictures);
22 var store = ContentHub.defaultStoreForType(ContentType.Pictures);22 var transfer = ContentHub.importContent(ContentType.Pictures, peer);
23 console.log("Store is: " + store.uri);23 var store = ContentHub.defaultStoreForType(ContentType.Pictures);
24 if (transfer !== null) {24 console.log("Store is: " + store.uri);
25 transfer.selectionType = ContentTransfer.Multiple;25 if (transfer !== null) {
26 transfer.setStore(store);26 transfer.selectionType = ContentTransfer.Multiple;
27 activeTransfer = transfer;27 transfer.setStore(store);
28 activeTransfer.start();28 activeTransfer = transfer;
29 }29 activeTransfer.start();
30 }30 }
31 }31 }
3232
33 Button {33 Component.onCompleted: {
34 anchors.left: importButton.right34 peers = ContentHub.knownSourcesForType(ContentType.Pictures);
35 text: "Finalize import"35 }
36 enabled: activeTransfer.state === ContentTransfer.Collected36
37 onClicked: activeTransfer.finalize()37 ListView {
38 }38 id: peerList
3939 anchors {
40 ListView {40 left: parent.left
41 anchors {41 right: parent.right
42 left: parent.left42 top: importButtons.bottom
43 right: parent.right43 }
44 bottom: parent.bottom44 height: childrenRect.height
45 top: importButton.bottom45 model: peers
46 }46
47 delegate: ListItem.Standard {
48 text: modelData.name
49 control: Button {
50 text: "Import"
51 onClicked: {
52 _importFromPeer(modelData);
53 }
54 }
55 }
56 }
57
58 ListItem.Empty {
59 id: importButtons
60 Button {
61 anchors {
62 left: parent.left
63 margins: units.gu(2)
64 }
65 text: "Import from default"
66 onClicked: {
67 _importFromPeer(null);
68 }
69 }
70
71 Button {
72 anchors {
73 right: parent.right
74 margins: units.gu(2)
75 }
76 text: "Finalize import"
77 enabled: activeTransfer.state === ContentTransfer.Collected
78 onClicked: activeTransfer.finalize()
79 }
80 }
81
82
83 ListView {
84 id: resultList
85 anchors {
86 left: parent.left
87 right: parent.right
88 top: peerList.bottom
89 }
90 height: childrenRect.height
4791
48 model: importItems92 model: importItems
49 delegate: Empty {93 delegate: ListItem.Empty {
50 id: result94 id: result
51 height: 12895 height: 128
52 UbuntuShape {96 UbuntuShape {
5397
=== modified file 'import/Ubuntu/Content/contenthub.cpp'
--- import/Ubuntu/Content/contenthub.cpp 2013-10-01 16:55:39 +0000
+++ import/Ubuntu/Content/contenthub.cpp 2013-10-23 12:08:41 +0000
@@ -148,20 +148,19 @@
148 *148 *
149 * Returns all possible peers for the given content \a type149 * Returns all possible peers for the given content \a type
150 */150 */
151QList<ContentPeer *> ContentHub::knownSourcesForType(int type)151QVariantList ContentHub::knownSourcesForType(int type)
152{152{
153 qDebug() << Q_FUNC_INFO;153 qDebug() << Q_FUNC_INFO;
154154
155 const cuc::Type &hubType = ContentType::contentType2HubType(type);155 const cuc::Type &hubType = ContentType::contentType2HubType(type);
156 QVector<cuc::Peer> hubPeers = m_hub->known_peers_for_type(hubType);156 QVector<cuc::Peer> hubPeers = m_hub->known_peers_for_type(hubType);
157157
158 QList<ContentPeer *> qmlPeers;158 QVariantList qmlPeers;
159 foreach (const cuc::Peer &hubPeer, hubPeers) {159 foreach (const cuc::Peer &hubPeer, hubPeers) {
160 ContentPeer *qmlPeer = new ContentPeer(this);160 ContentPeer *qmlPeer = new ContentPeer(this);
161 qmlPeer->setPeer(hubPeer);161 qmlPeer->setPeer(hubPeer);
162 qmlPeers.append(qmlPeer);162 qmlPeers.append(QVariant::fromValue(qmlPeer));
163 }163 }
164
165 return qmlPeers;164 return qmlPeers;
166}165}
167166
168167
=== modified file 'import/Ubuntu/Content/contenthub.h'
--- import/Ubuntu/Content/contenthub.h 2013-10-01 16:55:39 +0000
+++ import/Ubuntu/Content/contenthub.h 2013-10-23 12:08:41 +0000
@@ -48,7 +48,7 @@
48 ContentHub(QObject *parent = nullptr);48 ContentHub(QObject *parent = nullptr);
4949
50 Q_INVOKABLE ContentPeer *defaultSourceForType(int type);50 Q_INVOKABLE ContentPeer *defaultSourceForType(int type);
51 Q_INVOKABLE QList<ContentPeer *> knownSourcesForType(int type);51 Q_INVOKABLE QVariantList knownSourcesForType(int type);
5252
53 Q_INVOKABLE ContentStore *defaultStoreForType(int type);53 Q_INVOKABLE ContentStore *defaultStoreForType(int type);
5454
5555
=== modified file 'import/Ubuntu/Content/contentpeer.cpp'
--- import/Ubuntu/Content/contentpeer.cpp 2013-08-23 10:05:50 +0000
+++ import/Ubuntu/Content/contentpeer.cpp 2013-10-23 12:08:41 +0000
@@ -28,7 +28,7 @@
28 *28 *
29 * FIXME add documentation29 * FIXME add documentation
30 *30 *
31 * See documentation for \ContentHub31 * See documentation for ContentHub
32 */32 */
3333
34namespace cuc = com::ubuntu::content;34namespace cuc = com::ubuntu::content;
@@ -43,29 +43,28 @@
43/*!43/*!
44 * \qmlproperty string ContentPeer::name44 * \qmlproperty string ContentPeer::name
45 *45 *
46 * FIXME add documentation46 * Returns user friendly name of the peer
47 */47 */
48const QString &ContentPeer::name() const48QString ContentPeer::name()
49{49{
50 qDebug() << Q_FUNC_INFO;50 qDebug() << Q_FUNC_INFO;
51 return m_peer.id();51 return m_peer.name();
52}52}
5353
54/*!54/*!
55 * \qmlproperty string ContentPeer::type55 * \qmlproperty string ContentPeer::appId
56 *56 *
57 * FIXME add documentation57 * Returns the Application id
58 */58 */
59const QString &ContentPeer::type() const59const QString &ContentPeer::appId() const
60{60{
61 qDebug() << Q_FUNC_INFO;61 qDebug() << Q_FUNC_INFO;
62 // FIXME return the type
63 return m_peer.id();62 return m_peer.id();
64}63}
6564
66/*!65/*!
67 * \brief ContentPeer::peer66 * \brief ContentPeer::peer
68 * \return67 * \internal
69 */68 */
70const com::ubuntu::content::Peer &ContentPeer::peer() const69const com::ubuntu::content::Peer &ContentPeer::peer() const
71{70{
@@ -74,11 +73,11 @@
7473
75/*!74/*!
76 * \brief ContentPeer::setPeer75 * \brief ContentPeer::setPeer
77 * \param peer76 * \internal
78 */77 */
79void ContentPeer::setPeer(const cuc::Peer &peer)78void ContentPeer::setPeer(const cuc::Peer &peer)
80{79{
81 m_peer = peer;80 m_peer = peer;
82 Q_EMIT nameChanged();81 Q_EMIT nameChanged();
83 Q_EMIT typeChanged();82 Q_EMIT appIdChanged();
84}83}
8584
=== modified file 'import/Ubuntu/Content/contentpeer.h'
--- import/Ubuntu/Content/contentpeer.h 2013-08-23 07:48:15 +0000
+++ import/Ubuntu/Content/contentpeer.h 2013-10-23 12:08:41 +0000
@@ -26,20 +26,20 @@
26{26{
27 Q_OBJECT27 Q_OBJECT
28 Q_PROPERTY(QString name READ name NOTIFY nameChanged)28 Q_PROPERTY(QString name READ name NOTIFY nameChanged)
29 Q_PROPERTY(QString type READ type NOTIFY typeChanged)29 Q_PROPERTY(QString appId READ appId NOTIFY appIdChanged)
3030
31public:31public:
32 ContentPeer(QObject *parent = nullptr);32 ContentPeer(QObject *parent = nullptr);
3333
34 const QString &name() const;34 QString name();
35 const QString &type() const;35 const QString &appId() const;
3636
37 const com::ubuntu::content::Peer &peer() const;37 const com::ubuntu::content::Peer &peer() const;
38 void setPeer(const com::ubuntu::content::Peer &peer);38 void setPeer(const com::ubuntu::content::Peer &peer);
3939
40Q_SIGNALS:40Q_SIGNALS:
41 void nameChanged();41 void nameChanged();
42 void typeChanged();42 void appIdChanged();
4343
44private:44private:
45 com::ubuntu::content::Peer m_peer;45 com::ubuntu::content::Peer m_peer;

Subscribers

People subscribed via source and target branches