on xenial help sign in
merge trunk
80a7d99Michał Sawicz
Dash/Apps/ApplicationsFilterGrid.qml+3−3
@@ -36,7 +36,7 @@ FilterGrid {
36 objectName: "delegate" + index
36 objectName: "delegate" + index
37 Application {
37 Application {
38 id: application
38 id: application
39− desktopFile: model.column_7 ? stripProtocol(model.column_7) : model.desktopFile // FIXME: this is temporary
39+ desktopFile: model.dndUri ? stripProtocol(model.dndUri) : model.desktopFile // FIXME: this is temporary
40
40
41 function stripProtocol(uri) {
41 function stripProtocol(uri) {
42 var chunks = uri.split('file://')
42 var chunks = uri.split('file://')
@@ -44,11 +44,11 @@ FilterGrid {
44 }
44 }
45 }
45 }
46
46
47− property string icon: model.column_1 ? model.column_1 : "../../graphics/applicationIcons/" + application.icon + ".png" // FIXME: this is temporary
47+ property string icon: model.icon ? model.icon : "../../graphics/applicationIcons/" + application.icon + ".png" // FIXME: this is temporary
48
48
49 width: filterGrid.cellWidth
49 width: filterGrid.cellWidth
50 height: filterGrid.cellHeight
50 height: filterGrid.cellHeight
51− text: model.column_5 ? model.column_5 : application.name // FIXME: this is temporary
51+ text: model.title ? model.title : application.name // FIXME: this is temporary
52 imageWidth: units.gu(8)
52 imageWidth: units.gu(8)
53 imageHeight: units.gu(7.5)
53 imageHeight: units.gu(7.5)
54 source: IconUtil.from_gicon(icon)
54 source: IconUtil.from_gicon(icon)
Dash/DashApps.qml+10−8
@@ -81,17 +81,19 @@ ScopeView {
81 AppsAvailableForDownloadModel { id: appsAvailableForDownloadModel }
81 AppsAvailableForDownloadModel { id: appsAvailableForDownloadModel }
82
82
83 // FIXME this should not be needed, the backend should handle all that itself
83 // FIXME this should not be needed, the backend should handle all that itself
84− SortFilterProxyModel {
84+ property var installedModel: null
85− id: installedFilter
85+
86− dynamicSortFilter: true
86+ Repeater {
87− filterRole: 2 // this is the category id for each result
87+ model: scopeView.scope.categories
88− filterRegExp: /^3$/ // only proxy items that are category 3 - Installed
88+
89− model: dashContent.scopes.get("applications.scope").results
89+ delegate: Item {
90+ Component.onCompleted: if (index == 3) scopeView.installedModel = Qt.binding(function() { return model.results; });
91+ }
90 }
92 }
91
93
92 property var categoryModels: {
94 property var categoryModels: {
93 "FrequentlyUsedAppsModel": frequentlyUsedAppsModel,
95 "FrequentlyUsedAppsModel": frequentlyUsedAppsModel,
94− "InstalledApplicationsModel": installedFilter,
96+ "InstalledApplicationsModel": installedModel,
95 "AppsAvailableForDownloadModel": appsAvailableForDownloadModel,
97 "AppsAvailableForDownloadModel": appsAvailableForDownloadModel,
96 }
98 }
97
99
@@ -134,7 +136,7 @@ ScopeView {
134 shell.activateApplication(data);
136 shell.activateApplication(data);
135 }
137 }
136
138
137− item.model = categoryModels[modelName]
139+ item.model = Qt.binding(function() { return categoryModels[modelName]; });
138 item.clicked.connect(activateApplication);
140 item.clicked.connect(activateApplication);
139
141
140 }
142 }
Dash/DashHome.qml+20−31
@@ -52,42 +52,33 @@ ScopeView {
52 FrequentlyUsedAppsModel { id: appsModel }
52 FrequentlyUsedAppsModel { id: appsModel }
53
53
54 // FIXME this should be handled by the backends by populating the global search model
54 // FIXME this should be handled by the backends by populating the global search model
55− SortFilterProxyModel {
55+ property var musicModel: null
56− id: favouritesFilter
56+ property var videosModel: null
57− dynamicSortFilter: true
58− filterRole: 2
59− filterRegExp: /^0$/
60− }
61
57
62− SortFilterProxyModel {
58+ Repeater {
63− id: recentFilter
59+ id: musicRepeater
64− dynamicSortFilter: true
65− filterRole: 2
66− filterRegExp: /^2$/
67− }
68
60
69− SortFilterProxyModel {
61+ delegate: Item {
70− id: musicFilter
62+ Component.onCompleted: if (index == 1) musicModel = Qt.binding(function() { return model.results; });
71− dynamicSortFilter: true
63+ }
72− filterRole: 2
73− filterRegExp: /^1$/
74 }
64 }
75
65
76− SortFilterProxyModel {
66+ Repeater {
77− id: videosFilter
67+ id: videosRepeater
78− dynamicSortFilter: true
68+
79− filterRole: 2
69+ delegate: Item {
80− filterRegExp: /^3$/
70+ Component.onCompleted: if (index == 3) videosModel = Qt.binding(function() { return model.results; });
71+ }
81 }
72 }
82
73
83 Component.onCompleted: {
74 Component.onCompleted: {
84 var scope = dashContent.scopes.get("mockmusicmaster.scope")
75 var scope = dashContent.scopes.get("mockmusicmaster.scope")
85 if (scope) {
76 if (scope) {
86− musicFilter.model = dashContent.scopes.get("mockmusicmaster.scope").results
77+ musicRepeater.model = dashContent.scopes.get("mockmusicmaster.scope").categories
87 }
78 }
88 scope = dashContent.scopes.get("mockvideosmaster.scope")
79 scope = dashContent.scopes.get("mockvideosmaster.scope")
89 if (scope) {
80 if (scope) {
90− videosFilter.model = dashContent.scopes.get("mockvideosmaster.scope").results
81+ videosRepeater.model = dashContent.scopes.get("mockvideosmaster.scope").categories
91 }
82 }
92 }
83 }
93
84
@@ -95,19 +86,17 @@ ScopeView {
95 target: dashContent
86 target: dashContent
96 onScopeLoaded: switch (scopeId) {
87 onScopeLoaded: switch (scopeId) {
97 case "mockmusicmaster.scope":
88 case "mockmusicmaster.scope":
98− musicFilter.model = dashContent.scopes.get("mockmusicmaster.scope").results
89+ musicRepeater.model = dashContent.scopes.get("mockmusicmaster.scope").categories
99 break;
90 break;
100 case "mockvideosmaster.scope":
91 case "mockvideosmaster.scope":
101− videosFilter.model = dashContent.scopes.get("mockvideosmaster.scope").results
92+ videosRepeater.model = dashContent.scopes.get("mockvideosmaster.scope").categories
102 break;
93 break;
103 }
94 }
104 }
95 }
105
96
106 property var categoryModels: {"AppsModel": appsModel,
97 property var categoryModels: {"AppsModel": appsModel,
107− "FavouriteModel": favouritesFilter,
108− "RecentModel": recentFilter,
109− "MusicModel": musicFilter,
98+ "MusicModel": musicModel,
110− "VideosModel": videosFilter,
99+ "VideosModel": videosModel,
111 }
100 }
112
101
113 ScopeListView {
102 ScopeListView {
@@ -127,7 +116,7 @@ ScopeView {
127 anchors { top: parent.top; left: parent.left; right: parent.right }
116 anchors { top: parent.top; left: parent.left; right: parent.right }
128 source: component
117 source: component
129 onLoaded: {
118 onLoaded: {
130− item.model = categoryModels[modelName]
119+ item.model = Qt.binding(function() { return categoryModels[modelName]; });
131
120
132 //FIXME: workaround for lack of previews for videos in Home scope.
121 //FIXME: workaround for lack of previews for videos in Home scope.
133 //Need to connect to the clicked() signal here and act upon it here instead.
122 //Need to connect to the clicked() signal here and act upon it here instead.
Dash/DashVideos.qml+2−2
@@ -120,8 +120,8 @@ ScopeView {
120 // VideosCarousel and VideosFilterGrid have different
120 // VideosCarousel and VideosFilterGrid have different
121 // clicked signals, accomodate for that
121 // clicked signals, accomodate for that
122 if (categoryId == 1) {
122 if (categoryId == 1) {
123− var fileUri = delegateItem.model.column_0.replace(/^[^:]+:/, "")
123+ var fileUri = delegateItem.model.uri.replace(/^[^:]+:/, "")
124− dataItem = {fileUri: fileUri, nfoUri: delegateItem.model.column_6}
124+ dataItem = {fileUri: fileUri, nfoUri: delegateItem.model.comment}
125 } else {
125 } else {
126 dataItem = data;
126 dataItem = data;
127 }
127 }
Dash/Music/CarouselDelegateMusic.qml+1−1
@@ -28,7 +28,7 @@ BaseCarouselDelegate {
28 image: Image {
28 image: Image {
29 asynchronous: true
29 asynchronous: true
30 sourceSize { width: item.width; height: item.height }
30 sourceSize { width: item.width; height: item.height }
31− source: model ? model.column_1 : ""
31+ source: model ? model.icon : ""
32 }
32 }
33 }
33 }
34
34
Dash/Music/MusicFilterGrid.qml+3−3
@@ -38,9 +38,9 @@ FilterGrid {
38 height: filterGrid.cellHeight
38 height: filterGrid.cellHeight
39 iconWidth: filterGrid.iconWidth
39 iconWidth: filterGrid.iconWidth
40 iconHeight: filterGrid.iconHeight
40 iconHeight: filterGrid.iconHeight
41− artist: model.column_5
41+ artist: model.title
42− album: model.column_6
42+ album: model.comment
43− source: model.column_1
43+ source: model.icon
44 onClicked: {
44 onClicked: {
45 filterGrid.clicked(index);
45 filterGrid.clicked(index);
46 }
46 }
Dash/Video/CarouselDelegateVideo.qml+1−1
@@ -28,7 +28,7 @@ BaseCarouselDelegate {
28 image: Image {
28 image: Image {
29 asynchronous: true
29 asynchronous: true
30 sourceSize { width: item.width; height: item.height }
30 sourceSize { width: item.width; height: item.height }
31− source: model ? model.column_1 : ""
31+ source: model ? model.icon : ""
32 }
32 }
33 }
33 }
34
34
Dash/Video/VideosFilterGrid.qml+4−4
@@ -37,14 +37,14 @@ FilterGrid {
37 objectName: "delegate" + index
37 objectName: "delegate" + index
38 width: filtergrid.cellWidth
38 width: filtergrid.cellWidth
39 height: filtergrid.cellHeight
39 height: filtergrid.cellHeight
40− text: model.column_5
40+ text: model.title
41 imageWidth: filtergrid.iconWidth
41 imageWidth: filtergrid.iconWidth
42 imageHeight: filtergrid.iconHeight
42 imageHeight: filtergrid.iconHeight
43− source: model.column_1
43+ source: model.icon
44 fillMode: Image.PreserveAspectCrop
44 fillMode: Image.PreserveAspectCrop
45 onClicked: {
45 onClicked: {
46− var fileUri = model.column_0.replace(/^[^:]+:/, "")
46+ var fileUri = model.uri.replace(/^[^:]+:/, "")
47− var data = {fileUri: fileUri, nfoUri: model.column_6}
47+ var data = {fileUri: fileUri, nfoUri: model.comment}
48 filtergrid.clicked(index, data, tile.y);
48 filtergrid.clicked(index, data, tile.y);
49 }
49 }
50 }
50 }
Launcher/ShortcutsContainer.qmldeleted−39
@@ -1,39 +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−
17−import QtQuick 2.0
18−
19−Column {
20− id: shortcutsContainer
21−
22− property int foldedAngle: 0
23− property int initialFoldedOffset: 0
24− property int foldedOffset: 0
25− property int initialIndex: 0
26−
27− property bool animating: angleAnimation.running || offsetAnimation.running
28−
29− property ListModel model
30− property var delegate
31−
32− Behavior on foldedAngle { NumberAnimation { id: angleAnimation; duration: 200; } }
33− Behavior on foldedOffset { NumberAnimation { id: offsetAnimation; duration: 200; } }
34−
35− Repeater {
36− model: shortcutsContainer.model
37− delegate: shortcutsContainer.delegate
38− }
39−}
debian/changelog+13
@@ -1,3 +1,16 @@
1+unity8 (7.81.3+13.10.20130709ubuntu.unity.next-0ubuntu1) saucy; urgency=low
2+
3+ [ Michal Hruby ]
4+ * Implement CategoryResults based on DeeFilterModel.
5+
6+ [ Nick Dedekind ]
7+ * Added plugin cmake procedure for qmltypes files.
8+
9+ [ Ubuntu daily release ]
10+ * Automatic snapshot from revision 86 (ubuntu-unity/next)
11+
12+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Tue, 09 Jul 2013 02:58:58 +0000
13+
1unity8 (7.81.3+13.10.20130708ubuntu.unity.next-0ubuntu1) saucy; urgency=low
14unity8 (7.81.3+13.10.20130708ubuntu.unity.next-0ubuntu1) saucy; urgency=low
2
15
3 [ Michael Terry ]
16 [ Michael Terry ]
plugins/ListViewWithPageHeader/listviewwithpageheader.cpp+13
@@ -347,6 +347,19 @@ void ListViewWithPageHeader::showHeader()
347
347
348 auto to = qMax(-minYExtent(), contentY() - m_headerItem->height() + m_headerItemShownHeight);
348 auto to = qMax(-minYExtent(), contentY() - m_headerItem->height() + m_headerItemShownHeight);
349 if (to != contentY()) {
349 if (to != contentY()) {
350+ const bool headerShownByItsOwn = contentY() < m_headerItem->y() + m_headerItem->height();
351+ if (headerShownByItsOwn && m_headerItemShownHeight == 0) {
352+ // We are not clipping since we are just at the top of the viewport
353+ // but because of the showHeader animation we will need to, so
354+ // enable the clipping without logically moving the items
355+ m_headerItemShownHeight = m_headerItem->y() + m_headerItem->height() - contentY();
356+ if (!m_visibleItems.isEmpty()) {
357+ updateClipItem();
358+ ListItem *firstItem = m_visibleItems.first();
359+ firstItem->setY(firstItem->y() - m_headerItemShownHeight);
360+ layout();
361+ }
362+ }
350 m_headerShowAnimation->setTo(to);
363 m_headerShowAnimation->setTo(to);
351 m_headerShowAnimation->start();
364 m_headerShowAnimation->start();
352 }
365 }
plugins/Unity/CMakeLists.txt+2
@@ -31,6 +31,8 @@ set(QMLPLUGIN_SRC
31 preview.cpp
31 preview.cpp
32 previewaction.cpp
32 previewaction.cpp
33 previewinfohint.cpp
33 previewinfohint.cpp
34+ socialpreview.cpp
35+ socialpreviewcomment.cpp
34 variantutils.cpp
36 variantutils.cpp
35 )
37 )
36
38
plugins/Unity/genericpreview.cpp+5
@@ -24,3 +24,8 @@ GenericPreview::GenericPreview(QObject *parent):
24 Preview(parent)
24 Preview(parent)
25{
25{
26}
26}
27+
28+void GenericPreview::setUnityPreview(unity::dash::Preview::Ptr /* unityPreview */)
29+{
30+ Q_EMIT previewChanged();
31+}
plugins/Unity/genericpreview.h+6
@@ -33,6 +33,12 @@ class GenericPreview : public Preview
33
33
34public:
34public:
35 explicit GenericPreview(QObject *parent = 0);
35 explicit GenericPreview(QObject *parent = 0);
36+
37+Q_SIGNALS:
38+ void previewChanged();
39+
40+protected:
41+ void setUnityPreview(unity::dash::Preview::Ptr unityPreview) override;
36};
42};
37
43
38Q_DECLARE_METATYPE(GenericPreview *)
44Q_DECLARE_METATYPE(GenericPreview *)
plugins/Unity/plugin.cpp+2
@@ -27,6 +27,7 @@
27#include "preview.h"
27#include "preview.h"
28#include "previewaction.h"
28#include "previewaction.h"
29#include "previewinfohint.h"
29#include "previewinfohint.h"
30+#include "socialpreviewcomment.h"
30#include "scope.h"
31#include "scope.h"
31#include "scopes.h"
32#include "scopes.h"
32#include "categories.h"
33#include "categories.h"
@@ -46,6 +47,7 @@ void UnityPlugin::registerTypes(const char *uri)
46 qmlRegisterUncreatableType<Preview>(uri, 0, 1, "Preview", "Can't create Preview object in QML.");
47 qmlRegisterUncreatableType<Preview>(uri, 0, 1, "Preview", "Can't create Preview object in QML.");
47 qmlRegisterUncreatableType<PreviewAction>(uri, 0, 1, "PreviewAction", "Can't create PreviewAction object in QML.");
48 qmlRegisterUncreatableType<PreviewAction>(uri, 0, 1, "PreviewAction", "Can't create PreviewAction object in QML.");
48 qmlRegisterUncreatableType<PreviewInfoHint>(uri, 0, 1, "PreviewInfoHint", "Can't create PreviewInfoHint object in QML.");
49 qmlRegisterUncreatableType<PreviewInfoHint>(uri, 0, 1, "PreviewInfoHint", "Can't create PreviewInfoHint object in QML.");
50+ qmlRegisterUncreatableType<SocialPreviewComment>(uri, 0, 1, "SocialPreviewComment", "Can't create SocialPreviewComment object in QML.");
49 qmlRegisterType<Scope>(uri, 0, 1, "Scope");
51 qmlRegisterType<Scope>(uri, 0, 1, "Scope");
50 qmlRegisterType<Scopes>(uri, 0, 1, "Scopes");
52 qmlRegisterType<Scopes>(uri, 0, 1, "Scopes");
51 qmlRegisterType<Categories>(uri, 0, 1, "Categories");
53 qmlRegisterType<Categories>(uri, 0, 1, "Categories");
plugins/Unity/preview.cpp+4
@@ -25,6 +25,7 @@
25#include "applicationpreview.h"
25#include "applicationpreview.h"
26#include "moviepreview.h"
26#include "moviepreview.h"
27#include "musicpreview.h"
27#include "musicpreview.h"
28+#include "socialpreview.h"
28#include "variantutils.h"
29#include "variantutils.h"
29
30
30// Qt
31// Qt
@@ -35,6 +36,7 @@
35#include <UnityCore/ApplicationPreview.h>
36#include <UnityCore/ApplicationPreview.h>
36#include <UnityCore/MoviePreview.h>
37#include <UnityCore/MoviePreview.h>
37#include <UnityCore/MusicPreview.h>
38#include <UnityCore/MusicPreview.h>
39+#include <UnityCore/SocialPreview.h>
38
40
39Preview::Preview(QObject *parent):
41Preview::Preview(QObject *parent):
40 QObject(parent),
42 QObject(parent),
@@ -124,6 +126,8 @@ Preview* Preview::newFromUnityPreview(unity::dash::Preview::Ptr unityPreview)
124 preview = new MoviePreview();
126 preview = new MoviePreview();
125 } else if (dynamic_cast<unity::dash::ApplicationPreview *>(unityPreview.get()) != nullptr) {
127 } else if (dynamic_cast<unity::dash::ApplicationPreview *>(unityPreview.get()) != nullptr) {
126 preview = new ApplicationPreview();
128 preview = new ApplicationPreview();
129+ } else if (dynamic_cast<unity::dash::SocialPreview *>(unityPreview.get()) != nullptr) {
130+ preview = new SocialPreview();
127 } else {
131 } else {
128 qWarning() << "Unknown preview type: " << typeid(*unityPreview).name();
132 qWarning() << "Unknown preview type: " << typeid(*unityPreview).name();
129 preview = new GenericPreview();
133 preview = new GenericPreview();
plugins/Unity/previewaction.h+1−1
@@ -36,7 +36,7 @@ enum LayoutHint // keep in sync with unty::dash::LayoutHint
36 Bottom
36 Bottom
37};
37};
38
38
39−class PreviewAction : public QObject
39+class Q_DECL_EXPORT PreviewAction : public QObject
40{
40{
41 Q_OBJECT
41 Q_OBJECT
42
42
plugins/Unity/socialpreview.cppnew file+83
@@ -0,0 +1,83 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * Authors:
5+ * Pawel Stolowski <pawel.stolowski@canonical.com>
6+ *
7+ * This program is free software; you can redistribute it and/or modify
8+ * it under the terms of the GNU General Public License as published by
9+ * the Free Software Foundation; version 3.
10+ *
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU General Public License
17+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
18+ */
19+
20+#include "socialpreview.h"
21+#include "socialpreviewcomment.h"
22+
23+#include <QDebug>
24+
25+SocialPreview::SocialPreview(QObject *parent):
26+ Preview(parent),
27+ m_unitySocialPreview(nullptr)
28+{
29+}
30+
31+QString SocialPreview::sender() const
32+{
33+ if (m_unitySocialPreview) {
34+ return QString::fromStdString(m_unitySocialPreview->sender());
35+ } else {
36+ qWarning() << "Preview not set";
37+ }
38+ return QString();
39+}
40+
41+QString SocialPreview::content() const
42+{
43+ if (m_unitySocialPreview) {
44+ return QString::fromStdString(m_unitySocialPreview->content());
45+ } else {
46+ qWarning() << "Preview not set";
47+ }
48+ return QString();
49+}
50+
51+QString SocialPreview::avatar() const
52+{
53+ if (m_unitySocialPreview) {
54+ return QString::fromUtf8(g_icon_to_string(m_unitySocialPreview->avatar()));
55+ } else {
56+ qWarning() << "Preview not set";
57+ }
58+ return QString();
59+}
60+
61+QVariant SocialPreview::comments()
62+{
63+ return QVariant::fromValue(m_comments);
64+}
65+
66+void SocialPreview::setUnityPreview(unity::dash::Preview::Ptr unityPreview)
67+{
68+ m_unitySocialPreview = std::dynamic_pointer_cast<unity::dash::SocialPreview>(unityPreview);
69+ qDeleteAll(m_comments);
70+ m_comments.clear();
71+
72+ if (m_unitySocialPreview) {
73+ for (auto unityComment: m_unitySocialPreview->GetComments()) {
74+ auto comment = new SocialPreviewComment(this);
75+ comment->setUnityComment(unityComment);
76+ m_comments.append(comment);
77+
78+ Q_EMIT previewChanged();
79+ }
80+ } else {
81+ qWarning() << "Incorrect preview type";
82+ }
83+}
plugins/Unity/socialpreview.hnew file+63
@@ -0,0 +1,63 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * Authors:
5+ * Pawel Stolowski <pawel.stolowski@canonical.com>
6+ *
7+ * This program is free software; you can redistribute it and/or modify
8+ * it under the terms of the GNU General Public License as published by
9+ * the Free Software Foundation; version 3.
10+ *
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU General Public License
17+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
18+ */
19+
20+#ifndef SOCIALPREVIEW_H
21+#define SOCIALPREVIEW_H
22+
23+// local
24+#include "preview.h"
25+
26+// Qt
27+#include <QObject>
28+#include <QList>
29+#include <QMetaType>
30+
31+// libunity-core
32+#include <UnityCore/SocialPreview.h>
33+
34+class Q_DECL_EXPORT SocialPreview: public Preview
35+{
36+ Q_OBJECT
37+
38+ Q_PROPERTY(QString sender READ sender NOTIFY previewChanged)
39+ Q_PROPERTY(QString content READ content NOTIFY previewChanged)
40+ Q_PROPERTY(QString avatar READ avatar NOTIFY previewChanged)
41+
42+public:
43+ explicit SocialPreview(QObject *parent = 0);
44+
45+ QString sender() const;
46+ QString content() const;
47+ QString avatar() const;
48+ QVariant comments();
49+
50+Q_SIGNALS:
51+ void previewChanged();
52+
53+protected:
54+ void setUnityPreview(unity::dash::Preview::Ptr unityPreview) override;
55+
56+private:
57+ unity::dash::SocialPreview::Ptr m_unitySocialPreview;
58+ QList<QObject *> m_comments;
59+};
60+
61+Q_DECLARE_METATYPE(SocialPreview *)
62+
63+#endif
plugins/Unity/socialpreviewcomment.cppnew file+63
@@ -0,0 +1,63 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * Authors:
5+ * Pawel Stolowski <pawel.stolowski@canonical.com>
6+ *
7+ * This program is free software; you can redistribute it and/or modify
8+ * it under the terms of the GNU General Public License as published by
9+ * the Free Software Foundation; version 3.
10+ *
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU General Public License
17+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
18+ */
19+
20+// local
21+#include "socialpreviewcomment.h"
22+
23+SocialPreviewComment::SocialPreviewComment(QObject *parent) :
24+ QObject(parent)
25+{
26+}
27+
28+void SocialPreviewComment::setUnityComment(unity::dash::SocialPreview::CommentPtr unityComment)
29+{
30+ m_unityComment = unityComment;
31+}
32+
33+QString SocialPreviewComment::id() const
34+{
35+ if (m_unityComment) {
36+ return QString::fromStdString(m_unityComment->id);
37+ }
38+ return QString();
39+}
40+
41+QString SocialPreviewComment::displayName() const
42+{
43+ if (m_unityComment) {
44+ return QString::fromStdString(m_unityComment->display_name);
45+ }
46+ return QString();
47+}
48+
49+QString SocialPreviewComment::content() const
50+{
51+ if (m_unityComment) {
52+ return QString::fromStdString(m_unityComment->content);
53+ }
54+ return QString();
55+}
56+
57+QString SocialPreviewComment::time() const
58+{
59+ if (m_unityComment) {
60+ return QString::fromStdString(m_unityComment->time);
61+ }
62+ return QString();
63+}
plugins/Unity/socialpreviewcomment.hnew file+57
@@ -0,0 +1,57 @@
1+/*
2+ * Copyright (C) 2013 Canonical, Ltd.
3+ *
4+ * Authors:
5+ * Pawel Stolowski <pawel.stolowski@canonical.com>
6+ *
7+ * This program is free software; you can redistribute it and/or modify
8+ * it under the terms of the GNU General Public License as published by
9+ * the Free Software Foundation; version 3.
10+ *
11+ * This program is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+ * GNU General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU General Public License
17+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
18+ */
19+
20+#ifndef SOCIALPREVIEWCOMMENT_H
21+#define SOCIALPREVIEWCOMMENT_H
22+
23+// Qt
24+#include <QObject>
25+#include <QMetaType>
26+
27+// libunity-core
28+#include <UnityCore/SocialPreview.h>
29+
30+class Q_DECL_EXPORT SocialPreviewComment : public QObject
31+{
32+ Q_OBJECT
33+
34+ Q_PROPERTY(QString id READ id NOTIFY socialPreviewCommentChanged)
35+ Q_PROPERTY(QString displayName READ displayName NOTIFY socialPreviewCommentChanged)
36+ Q_PROPERTY(QString content READ content NOTIFY socialPreviewCommentChanged)
37+ Q_PROPERTY(QString time READ time NOTIFY socialPreviewCommentChanged)
38+
39+public:
40+ explicit SocialPreviewComment(QObject *parent = 0);
41+ void setUnityComment(unity::dash::SocialPreview::CommentPtr unityComment);
42+
43+ QString id() const;
44+ QString displayName() const;
45+ QString content() const;
46+ QString time() const;
47+
48+Q_SIGNALS:
49+ void socialPreviewCommentChanged();
50+
51+private:
52+ unity::dash::SocialPreview::CommentPtr m_unityComment;
53+};
54+
55+Q_DECLARE_METATYPE(SocialPreviewComment *)
56+
57+#endif
po/es.po+7−31
@@ -8,14 +8,14 @@ msgstr ""
8"Project-Id-Version: unity\n"
8"Project-Id-Version: unity\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
9"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
10"POT-Creation-Date: 2013-06-26 22:58+0200\n"
10"POT-Creation-Date: 2013-06-26 22:58+0200\n"
11−"PO-Revision-Date: 2013-06-16 23:44+0000\n"
11+"PO-Revision-Date: 2013-07-08 07:25+0000\n"
12"Last-Translator: Adolfo Jayme Barrientos <fitoschido@gmail.com>\n"
12"Last-Translator: Adolfo Jayme Barrientos <fitoschido@gmail.com>\n"
13"Language-Team: Spanish <es@li.org>\n"
13"Language-Team: Spanish <es@li.org>\n"
14"MIME-Version: 1.0\n"
14"MIME-Version: 1.0\n"
15"Content-Type: text/plain; charset=UTF-8\n"
15"Content-Type: text/plain; charset=UTF-8\n"
16"Content-Transfer-Encoding: 8bit\n"
16"Content-Transfer-Encoding: 8bit\n"
17−"X-Launchpad-Export-Date: 2013-06-27 16:16+0000\n"
17+"X-Launchpad-Export-Date: 2013-07-09 06:13+0000\n"
18−"X-Generator: Launchpad (build 16681)\n"
18+"X-Generator: Launchpad (build 16696)\n"
19
19
20#: Applications/applications.js:23
20#: Applications/applications.js:23
21msgid "Phone"
21msgid "Phone"
@@ -167,16 +167,16 @@ msgstr "Autor:"
167
167
168#: Greeter/Lockscreen.qml:133
168#: Greeter/Lockscreen.qml:133
169msgid "Emergency call"
169msgid "Emergency call"
170−msgstr ""
170+msgstr "Llamada de emergencia"
171
171
172#: Greeter/PassphraseLockscreen.qml:59
172#: Greeter/PassphraseLockscreen.qml:59
173#, qt-format
173#, qt-format
174msgid "Hello %1"
174msgid "Hello %1"
175−msgstr ""
175+msgstr "Hola %1"
176
176
177#: Greeter/PassphraseLockscreen.qml:59
177#: Greeter/PassphraseLockscreen.qml:59
178msgid "Hello"
178msgid "Hello"
179−msgstr ""
179+msgstr "Hola"
180
180
181#: Hud/HudParametrizedActionsPage.qml:132
181#: Hud/HudParametrizedActionsPage.qml:132
182msgid "Confirm"
182msgid "Confirm"
@@ -217,28 +217,4 @@ msgstr "No hay nada que coincida con su búsqueda."
217#: Shell.qml:383
217#: Shell.qml:383
218#, qt-format
218#, qt-format
219msgid "Please enter %1"
219msgid "Please enter %1"
220−msgstr ""
220+msgstr "Introduzca %1"
221−
222−#~ msgid "People"
223−#~ msgstr "Gente"
224−
225−#~ msgid "Home screen"
226−#~ msgstr "Pantalla de inicio"
227−
228−#~ msgid "Favourite People"
229−#~ msgstr "Gente favorita"
230−
231−#~ msgid "People Recently in Touch"
232−#~ msgstr "Gente contactada recientemente"
233−
234−#~ msgid "Recently in touch"
235−#~ msgstr "Contactados recientemente"
236−
237−#~ msgid "Favourites"
238−#~ msgstr "Favoritos"
239−
240−#~ msgid "A-Z"
241−#~ msgstr "A-Z"
242−
243−#~ msgid "New Contacts"
244−#~ msgstr "Contactos nuevos"
tests/plugins/ListViewWithPageHeader/listviewwithpageheadertest.cpp+55
@@ -1248,6 +1248,61 @@ private Q_SLOTS:
1248 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1248 QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1249 }
1249 }
1250
1250
1251+ void testShowHeaderHalfShown()
1252+ {
1253+#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
1254+ QSKIP("This test is extremely unstable in 5.0.x");
1255+#endif
1256+ changeContentY(20);
1257+
1258+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 4);
1259+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
1260+ verifyItem(0, 30., 150., false);
1261+ verifyItem(1, 180, 200., false);
1262+ verifyItem(2, 380, 350., false);
1263+ verifyItem(3, 730, 350., true);
1264+ QCOMPARE(lvwph->m_minYExtent, 0.);
1265+ QCOMPARE(lvwph->m_clipItem->y(), 20.);
1266+ QCOMPARE(lvwph->m_clipItem->clip(), false);
1267+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
1268+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
1269+ QCOMPARE(lvwph->contentY(), 20.);
1270+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);;
1271+
1272+ lvwph->showHeader();
1273+
1274+ QTRY_VERIFY(!lvwph->m_headerShowAnimation->isRunning());
1275+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 4);
1276+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
1277+ verifyItem(0, -20., 150., false);
1278+ verifyItem(1, 130, 200., false);
1279+ verifyItem(2, 330, 350., false);
1280+ verifyItem(3, 680, 350., true);
1281+ QCOMPARE(lvwph->m_minYExtent, 20.);
1282+ QCOMPARE(lvwph->m_clipItem->y(), 50.);
1283+ QCOMPARE(lvwph->m_clipItem->clip(), true);
1284+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
1285+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
1286+ QCOMPARE(lvwph->contentY(), 0.);
1287+ QCOMPARE(lvwph->m_headerItemShownHeight, 50.);
1288+
1289+ scrollToTop();
1290+
1291+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 4);
1292+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
1293+ verifyItem(0, 50., 150., false);
1294+ verifyItem(1, 200., 200., false);
1295+ verifyItem(2, 400., 350., false);
1296+ verifyItem(3, 750, 350., true);
1297+ QCOMPARE(lvwph->m_minYExtent, 20.);
1298+ QCOMPARE(lvwph->m_clipItem->y(), -20.);
1299+ QCOMPARE(lvwph->m_clipItem->clip(), false);
1300+ QCOMPARE(lvwph->m_headerItem->y(), -20.);
1301+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
1302+ QCOMPARE(lvwph->contentY(), -20.);
1303+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1304+ }
1305+
1251 void testShowHeaderAtBottom()
1306 void testShowHeaderAtBottom()
1252 {
1307 {
1253 scrollToBottom();
1308 scrollToBottom();
tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsection.cpp+57
@@ -1407,6 +1407,63 @@ private Q_SLOTS:
1407 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
1407 QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
1408 }
1408 }
1409
1409
1410+ void testShowHeaderHalfShown()
1411+ {
1412+#if (QT_VERSION < QT_VERSION_CHECK(5, 1, 0))
1413+ QSKIP("This test is extremely unstable in 5.0.x");
1414+#endif
1415+ changeContentY(20);
1416+
1417+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 3);
1418+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
1419+ verifyItem(0, 30., 190., false, "Agressive", false);
1420+ verifyItem(1, 220, 240., false, "Regular", false);
1421+ verifyItem(2, 460, 390., false, "Mild", false);
1422+ QCOMPARE(lvwph->m_minYExtent, 0.);
1423+ QCOMPARE(lvwph->m_clipItem->y(), 20.);
1424+ QCOMPARE(lvwph->m_clipItem->clip(), false);
1425+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
1426+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
1427+ QCOMPARE(lvwph->contentY(), 20.);
1428+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);;
1429+ QVERIFY(QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
1430+
1431+ lvwph->showHeader();
1432+
1433+ QTRY_VERIFY(!lvwph->m_headerShowAnimation->isRunning());
1434+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 3);
1435+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
1436+ verifyItem(0, -20., 190., false, "Agressive", true);
1437+ verifyItem(1, 170, 240., false, "Regular", false);
1438+ verifyItem(2, 410, 390., false, "Mild", false);
1439+ QCOMPARE(lvwph->m_minYExtent, 20.);
1440+ QCOMPARE(lvwph->m_clipItem->y(), 50.);
1441+ QCOMPARE(lvwph->m_clipItem->clip(), true);
1442+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
1443+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
1444+ QCOMPARE(lvwph->contentY(), 0.);
1445+ QCOMPARE(lvwph->m_headerItemShownHeight, 50.);
1446+ QVERIFY(!QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
1447+ QCOMPARE(section(lvwph->m_topSectionItem), QString("Agressive"));
1448+ QCOMPARE(lvwph->m_topSectionItem->y(), 0.);
1449+
1450+ scrollToTop();
1451+
1452+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 3);
1453+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
1454+ verifyItem(0, 50., 190., false, "Agressive", false);
1455+ verifyItem(1, 240., 240., false, "Regular", false);
1456+ verifyItem(2, 480., 390., false, "Mild", false);
1457+ QCOMPARE(lvwph->m_minYExtent, 20.);
1458+ QCOMPARE(lvwph->m_clipItem->y(), -20.);
1459+ QCOMPARE(lvwph->m_clipItem->clip(), false);
1460+ QCOMPARE(lvwph->m_headerItem->y(), -20.);
1461+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
1462+ QCOMPARE(lvwph->contentY(), -20.);
1463+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
1464+ QVERIFY(QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
1465+ }
1466+
1410 void testShowHeaderCloseToTheTop()
1467 void testShowHeaderCloseToTheTop()
1411 {
1468 {
1412 changeContentY(375);
1469 changeContentY(375);
tests/plugins/Unity/previewbindingstest.cpp+113−58
@@ -25,6 +25,12 @@
25#include "applicationpreview.h"
25#include "applicationpreview.h"
26#include "moviepreview.h"
26#include "moviepreview.h"
27#include "musicpreview.h"
27#include "musicpreview.h"
28+#include "socialpreview.h"
29+#include "socialpreviewcomment.h"
30+#include "previewaction.h"
31+
32+#include <glib.h>
33+#include <glib-object.h>
28
34
29void PreviewBindingsTest::initTestCase()
35void PreviewBindingsTest::initTestCase()
30{
36{
@@ -32,81 +38,130 @@ void PreviewBindingsTest::initTestCase()
32
38
33void PreviewBindingsTest::testGenericPreview()
39void PreviewBindingsTest::testGenericPreview()
34{
40{
35− auto raw_preview = (GObject *)unity_protocol_generic_preview_new();
41+ auto rawPreview = (GObject *)unity_protocol_generic_preview_new();
36− unity_protocol_preview_set_title(UNITY_PROTOCOL_PREVIEW(raw_preview), "Metallica");
42+ unity_protocol_preview_set_title(UNITY_PROTOCOL_PREVIEW(rawPreview), "Metallica");
37− unity_protocol_preview_set_subtitle(UNITY_PROTOCOL_PREVIEW(raw_preview), "Ride The Lightning");
43+ unity_protocol_preview_set_subtitle(UNITY_PROTOCOL_PREVIEW(rawPreview), "Ride The Lightning");
38− unity_protocol_preview_set_description(UNITY_PROTOCOL_PREVIEW(raw_preview), "Lorem ipsum dolor sit amet");
44+ unity_protocol_preview_set_description(UNITY_PROTOCOL_PREVIEW(rawPreview), "Lorem ipsum dolor sit amet");
45+ GFile *iconFile = g_file_new_for_path("/foo.png");
46+ GIcon *icon = g_file_icon_new(iconFile);
47+ unity_protocol_preview_add_action(UNITY_PROTOCOL_PREVIEW(rawPreview), "1", "Action1", icon,
48+ UNITY_PROTOCOL_LAYOUT_HINT_LEFT);
39− unity::glib::Object<GObject> gen_prv(raw_preview);
49+ unity::glib::Object<GObject> genPrv(rawPreview);
40−
50+
41− auto core_prv = unity::dash::Preview::PreviewForProtocolObject(gen_prv);
51+ auto corePrv = unity::dash::Preview::PreviewForProtocolObject(genPrv);
42− auto prv = Preview::newFromUnityPreview(core_prv);
52+ auto prv = Preview::newFromUnityPreview(corePrv);
43
53
44 QCOMPARE(prv != nullptr, true);
54 QCOMPARE(prv != nullptr, true);
45 QCOMPARE(prv->title(), QString("Metallica"));
55 QCOMPARE(prv->title(), QString("Metallica"));
46 QCOMPARE(prv->subtitle(), QString("Ride The Lightning"));
56 QCOMPARE(prv->subtitle(), QString("Ride The Lightning"));
47 QCOMPARE(prv->description(), QString("Lorem ipsum dolor sit amet"));
57 QCOMPARE(prv->description(), QString("Lorem ipsum dolor sit amet"));
58+
59+ auto actions = prv->actions().value<QList<QObject *>>();
60+ QCOMPARE(actions.size(), 1);
61+ auto act = dynamic_cast<PreviewAction *>(actions[0]);
62+ QVERIFY(act != nullptr);
63+ QCOMPARE(act->id(), QString("1"));
64+ QCOMPARE(act->displayName(), QString("Action1"));
65+ QCOMPARE(act->iconHint(), QString("/foo.png"));
66+
67+ g_object_unref(icon);
68+ g_object_unref(iconFile);
48}
69}
49
70
50void PreviewBindingsTest::testApplicationPreview()
71void PreviewBindingsTest::testApplicationPreview()
51{
72{
52− auto raw_preview = (GObject *)unity_protocol_application_preview_new();
73+ auto rawPreview = (GObject *)unity_protocol_application_preview_new();
53− unity_protocol_preview_set_title(UNITY_PROTOCOL_PREVIEW(raw_preview), "Firefox");
74+ unity_protocol_preview_set_title(UNITY_PROTOCOL_PREVIEW(rawPreview), "Firefox");
54− unity_protocol_preview_set_subtitle(UNITY_PROTOCOL_PREVIEW(raw_preview), "Web Browser");
75+ unity_protocol_preview_set_subtitle(UNITY_PROTOCOL_PREVIEW(rawPreview), "Web Browser");
55− unity_protocol_preview_set_description(UNITY_PROTOCOL_PREVIEW(raw_preview), "Lorem ipsum dolor sit amet");
76+ unity_protocol_preview_set_description(UNITY_PROTOCOL_PREVIEW(rawPreview), "Lorem ipsum dolor sit amet");
56− unity_protocol_application_preview_set_license(UNITY_PROTOCOL_APPLICATION_PREVIEW(raw_preview), "GPL");
77+ unity_protocol_application_preview_set_license(UNITY_PROTOCOL_APPLICATION_PREVIEW(rawPreview), "GPL");
57− unity_protocol_application_preview_set_rating(UNITY_PROTOCOL_APPLICATION_PREVIEW(raw_preview), 0.5f);
78+ unity_protocol_application_preview_set_rating(UNITY_PROTOCOL_APPLICATION_PREVIEW(rawPreview), 0.5f);
58− unity_protocol_application_preview_set_num_ratings(UNITY_PROTOCOL_APPLICATION_PREVIEW(raw_preview), 4);
79+ unity_protocol_application_preview_set_num_ratings(UNITY_PROTOCOL_APPLICATION_PREVIEW(rawPreview), 4);
59− unity::glib::Object<GObject> gen_prv(raw_preview);
80+ unity::glib::Object<GObject> genPrv(rawPreview);
60−
81+
61− auto core_prv = unity::dash::Preview::PreviewForProtocolObject(gen_prv);
82+ auto corePrv = unity::dash::Preview::PreviewForProtocolObject(genPrv);
62− auto prv = Preview::newFromUnityPreview(core_prv);
83+ auto prv = Preview::newFromUnityPreview(corePrv);
63− auto app_prv = dynamic_cast<ApplicationPreview*>(prv);
84+ auto appPrv = dynamic_cast<ApplicationPreview*>(prv);
64−
85+
65− QCOMPARE(app_prv != nullptr, true);
86+ QCOMPARE(appPrv != nullptr, true);
66− QCOMPARE(app_prv->title(), QString("Firefox"));
87+ QCOMPARE(appPrv->title(), QString("Firefox"));
67− QCOMPARE(app_prv->subtitle(), QString("Web Browser"));
88+ QCOMPARE(appPrv->subtitle(), QString("Web Browser"));
68− QCOMPARE(app_prv->description(), QString("Lorem ipsum dolor sit amet"));
89+ QCOMPARE(appPrv->description(), QString("Lorem ipsum dolor sit amet"));
69− QCOMPARE(app_prv->license(), QString("GPL"));
90+ QCOMPARE(appPrv->license(), QString("GPL"));
70− QCOMPARE(app_prv->rating(), 0.5f);
91+ QCOMPARE(appPrv->rating(), 0.5f);
71− QCOMPARE(app_prv->numRatings(), unsigned (4));
92+ QCOMPARE(appPrv->numRatings(), unsigned (4));
72}
93}
73
94
74void PreviewBindingsTest::testMoviePreview()
95void PreviewBindingsTest::testMoviePreview()
75{
96{
76− auto raw_preview = (GObject *)unity_protocol_movie_preview_new();
97+ auto rawPreview = (GObject *)unity_protocol_movie_preview_new();
77− unity_protocol_preview_set_title(UNITY_PROTOCOL_PREVIEW(raw_preview), "Blade Runner");
98+ unity_protocol_preview_set_title(UNITY_PROTOCOL_PREVIEW(rawPreview), "Blade Runner");
78− unity_protocol_preview_set_subtitle(UNITY_PROTOCOL_PREVIEW(raw_preview), "Ridley Scott");
99+ unity_protocol_preview_set_subtitle(UNITY_PROTOCOL_PREVIEW(rawPreview), "Ridley Scott");
79− unity_protocol_preview_set_description(UNITY_PROTOCOL_PREVIEW(raw_preview), "Lorem ipsum dolor sit amet");
100+ unity_protocol_preview_set_description(UNITY_PROTOCOL_PREVIEW(rawPreview), "Lorem ipsum dolor sit amet");
80− unity_protocol_movie_preview_set_year(UNITY_PROTOCOL_MOVIE_PREVIEW(raw_preview), "1982");
101+ unity_protocol_movie_preview_set_year(UNITY_PROTOCOL_MOVIE_PREVIEW(rawPreview), "1982");
81− unity::glib::Object<GObject> gen_prv(raw_preview);
102+ unity::glib::Object<GObject> genPrv(rawPreview);
82−
103+
83− auto core_prv = unity::dash::Preview::PreviewForProtocolObject(gen_prv);
104+ auto corePrv = unity::dash::Preview::PreviewForProtocolObject(genPrv);
84− auto prv = Preview::newFromUnityPreview(core_prv);
105+ auto prv = Preview::newFromUnityPreview(corePrv);
85− auto movie_prv = dynamic_cast<MoviePreview*>(prv);
106+ auto moviePrv = dynamic_cast<MoviePreview*>(prv);
86−
107+
87− QCOMPARE(movie_prv != nullptr, true);
108+ QCOMPARE(moviePrv != nullptr, true);
88− QCOMPARE(movie_prv->title(), QString("Blade Runner"));
109+ QCOMPARE(moviePrv->title(), QString("Blade Runner"));
89− QCOMPARE(movie_prv->subtitle(), QString("Ridley Scott"));
110+ QCOMPARE(moviePrv->subtitle(), QString("Ridley Scott"));
90− QCOMPARE(movie_prv->description(), QString("Lorem ipsum dolor sit amet"));
111+ QCOMPARE(moviePrv->description(), QString("Lorem ipsum dolor sit amet"));
91− QCOMPARE(movie_prv->year(), QString("1982"));
112+ QCOMPARE(moviePrv->year(), QString("1982"));
92}
113}
93
114
94void PreviewBindingsTest::testMusicPreview()
115void PreviewBindingsTest::testMusicPreview()
95{
116{
96− auto raw_preview = (GObject *)unity_protocol_music_preview_new();
117+ auto rawPreview = (GObject *)unity_protocol_music_preview_new();
97− unity_protocol_preview_set_title(UNITY_PROTOCOL_PREVIEW(raw_preview), "Metallica");
118+ unity_protocol_preview_set_title(UNITY_PROTOCOL_PREVIEW(rawPreview), "Metallica");
98− unity_protocol_preview_set_subtitle(UNITY_PROTOCOL_PREVIEW(raw_preview), "Death Magnetic");
119+ unity_protocol_preview_set_subtitle(UNITY_PROTOCOL_PREVIEW(rawPreview), "Death Magnetic");
99− unity_protocol_preview_set_description(UNITY_PROTOCOL_PREVIEW(raw_preview), "Lorem ipsum dolor sit amet");
120+ unity_protocol_preview_set_description(UNITY_PROTOCOL_PREVIEW(rawPreview), "Lorem ipsum dolor sit amet");
100− unity::glib::Object<GObject> gen_prv(raw_preview);
121+ unity::glib::Object<GObject> genPrv(rawPreview);
101−
122+
102− auto core_prv = unity::dash::Preview::PreviewForProtocolObject(gen_prv);
123+ auto corePrv = unity::dash::Preview::PreviewForProtocolObject(genPrv);
103− auto prv = Preview::newFromUnityPreview(core_prv);
124+ auto prv = Preview::newFromUnityPreview(corePrv);
104− auto music_prv = dynamic_cast<MusicPreview*>(prv);
125+ auto musicPrv = dynamic_cast<MusicPreview*>(prv);
105−
126+
106− QCOMPARE(music_prv != nullptr, true);
127+ QCOMPARE(musicPrv != nullptr, true);
107− QCOMPARE(music_prv->title(), QString("Metallica"));
128+ QCOMPARE(musicPrv->title(), QString("Metallica"));
108− QCOMPARE(music_prv->subtitle(), QString("Death Magnetic"));
129+ QCOMPARE(musicPrv->subtitle(), QString("Death Magnetic"));
109− QCOMPARE(music_prv->description(), QString("Lorem ipsum dolor sit amet"));
130+ QCOMPARE(musicPrv->description(), QString("Lorem ipsum dolor sit amet"));
131+}
132+
133+void PreviewBindingsTest::testSocialPreview()
134+{
135+ GFile *iconFile = g_file_new_for_path("/foo.png");
136+ GIcon *icon = g_file_icon_new(iconFile);
137+
138+ auto rawPreview = (GObject *)unity_protocol_social_preview_new();
139+ unity_protocol_social_preview_set_sender(UNITY_PROTOCOL_SOCIAL_PREVIEW(rawPreview), "John");
140+ unity_protocol_social_preview_set_avatar(UNITY_PROTOCOL_SOCIAL_PREVIEW(rawPreview), icon);
141+ unity_protocol_social_preview_set_content(UNITY_PROTOCOL_SOCIAL_PREVIEW(rawPreview), "Lorem ipsum dolor sit amet");
142+ unity_protocol_social_preview_add_comment(UNITY_PROTOCOL_SOCIAL_PREVIEW(rawPreview), "1", "comment1", "Ubuntu", "2013-07-04 14:10");
143+ unity::glib::Object<GObject> genPrv(rawPreview);
144+
145+ auto corePrv = unity::dash::Preview::PreviewForProtocolObject(genPrv);
146+ auto prv = Preview::newFromUnityPreview(corePrv);
147+ auto socialPrv = dynamic_cast<SocialPreview*>(prv);
148+
149+ QCOMPARE(socialPrv != nullptr, true);
150+ QCOMPARE(socialPrv->sender(), QString("John"));
151+ QCOMPARE(socialPrv->content(), QString("Lorem ipsum dolor sit amet"));
152+ QCOMPARE(socialPrv->avatar(), QString("/foo.png"));
153+
154+ auto comments = socialPrv->comments().value<QList<QObject *>>();
155+ QCOMPARE(comments.size(), 1);
156+ auto cmt = dynamic_cast<SocialPreviewComment *>(comments[0]);
157+ QVERIFY(cmt != nullptr);
158+ QCOMPARE(cmt->id(), QString("1"));
159+ QCOMPARE(cmt->displayName(), QString("comment1"));
160+ QCOMPARE(cmt->content(), QString("Ubuntu"));
161+ QCOMPARE(cmt->time(), QString("2013-07-04 14:10"));
162+
163+ g_object_unref(icon);
164+ g_object_unref(iconFile);
110}
165}
111
166
112QTEST_MAIN(PreviewBindingsTest)
167QTEST_MAIN(PreviewBindingsTest)
tests/plugins/Unity/previewbindingstest.h+1
@@ -29,6 +29,7 @@ class PreviewBindingsTest : public QObject
29 void testApplicationPreview();
29 void testApplicationPreview();
30 void testMoviePreview();
30 void testMoviePreview();
31 void testMusicPreview();
31 void testMusicPreview();
32+ void testSocialPreview();
32};
33};
33
34
34#endif
35#endif
tests/qmltests/Dash/tst_FilterGrids.qml+20−20
@@ -53,26 +53,26 @@ Rectangle {
53
53
54 ListModel {
54 ListModel {
55 id: fakeModel
55 id: fakeModel
56− ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item0"; column_5: ""; column_6: "dummy.desktop" }
56+ ListElement { icon: "../../graphics/clock.png"; title: "Item0"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
57− ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item1"; column_5: ""; column_6: "dummy.desktop" }
57+ ListElement { icon: "../../graphics/clock.png"; title: "Item1"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
58− ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item2"; column_5: ""; column_6: "dummy.desktop" }
58+ ListElement { icon: "../../graphics/clock.png"; title: "Item2"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
59− ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item3"; column_5: ""; column_6: "dummy.desktop" }
59+ ListElement { icon: "../../graphics/clock.png"; title: "Item3"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
60− ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item4"; column_5: ""; column_6: "dummy.desktop" }
60+ ListElement { icon: "../../graphics/clock.png"; title: "Item4"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
61− ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item5"; column_5: ""; column_6: "dummy.desktop" }
61+ ListElement { icon: "../../graphics/clock.png"; title: "Item5"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
62− ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item6"; column_5: ""; column_6: "dummy.desktop" }
62+ ListElement { icon: "../../graphics/clock.png"; title: "Item6"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
63− ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item7"; column_5: ""; column_6: "dummy.desktop" }
63+ ListElement { icon: "../../graphics/clock.png"; title: "Item7"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
64− ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item8"; column_5: ""; column_6: "dummy.desktop" }
64+ ListElement { icon: "../../graphics/clock.png"; title: "Item8"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
65− ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item9"; column_5: ""; column_6: "dummy.desktop" }
65+ ListElement { icon: "../../graphics/clock.png"; title: "Item9"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
66− ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item10"; column_5: ""; column_6: "dummy.desktop" }
66+ ListElement { icon: "../../graphics/clock.png"; title: "Item10"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
67− ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item11"; column_5: ""; column_6: "dummy.desktop" }
67+ ListElement { icon: "../../graphics/clock.png"; title: "Item11"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
68− ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item12"; column_5: ""; column_6: "dummy.desktop" }
68+ ListElement { icon: "../../graphics/clock.png"; title: "Item12"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
69− ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item13"; column_5: ""; column_6: "dummy.desktop" }
69+ ListElement { icon: "../../graphics/clock.png"; title: "Item13"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
70− ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item14"; column_5: ""; column_6: "dummy.desktop" }
70+ ListElement { icon: "../../graphics/clock.png"; title: "Item14"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
71− ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item15"; column_5: ""; column_6: "dummy.desktop" }
71+ ListElement { icon: "../../graphics/clock.png"; title: "Item15"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
72− ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item16"; column_5: ""; column_6: "dummy.desktop" }
72+ ListElement { icon: "../../graphics/clock.png"; title: "Item16"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
73− ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item17"; column_5: ""; column_6: "dummy.desktop" }
73+ ListElement { icon: "../../graphics/clock.png"; title: "Item17"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
74− ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item18"; column_5: ""; column_6: "dummy.desktop" }
74+ ListElement { icon: "../../graphics/clock.png"; title: "Item18"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
75− ListElement { column_0: "Column0"; column_1: "../../graphics/clock.png"; column_4: "Item19"; column_5: ""; column_6: "dummy.desktop" }
75+ ListElement { icon: "../../graphics/clock.png"; title: "Item19"; comment: ""; uri: "dummy.desktop"; dndUri: "dummy.desktop" }
76 }
76 }
77
77
78 Rectangle {
78 Rectangle {