on xenial help sign in
Merge from trunk
commitd8b2c6316c77f9c782da82f21dacb5f669a386d5 authorMichael Terry <michael.terry@canonical.com> dateTue 24 Sep 2013, 14:50 (13 years ago) parent46bb91fa4c2f97
19 files changed+538−71
Dash/GenericScopeView.qml+6 Dash/Music/MusicFilterGrid.qml+12−2 Panel/MenuContent.qml+12−2 debian/changelog+68 plugins/AccountsService/AccountsService.cpp+4−4 plugins/AccountsService/AccountsService.h+7−7 plugins/AccountsService/AccountsServiceDBusAdaptor.cpp+15−15 plugins/AccountsService/AccountsServiceDBusAdaptor.h+2−2 plugins/ListViewWithPageHeader/listviewwithpageheader.cpp+13 plugins/ListViewWithPageHeader/listviewwithpageheader.h+1 plugins/Unity/categories.cpp+12−1 plugins/Unity/scope.cpp+13−1 po/sl.po+29−24 tests/mocks/AccountsService/AccountsService.cpp+4−4 tests/mocks/AccountsService/AccountsService.h+7−7 tests/plugins/AccountsService/client.cpp+2−2 tests/plugins/ListViewWithPageHeader/CMakeLists.txt+6 tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsectionexternalmodel.cpp+251 tests/plugins/ListViewWithPageHeader/test_sectionexternalmodel.qml+74
Dash/GenericScopeView.qml+6
@@ -36,6 +36,12 @@ ScopeView {
3636 value: pageHeader.searchQuery
3737 }
3838
39+ Binding {
40+ target: pageHeader
41+ property: "searchQuery"
42+ value: scopeView.scope.searchQuery
43+ }
44+
3945 Connections {
4046 target: panel
4147 onSearchClicked: if (isCurrent) {
Dash/Music/MusicFilterGrid.qml+12−2
@@ -29,19 +29,29 @@ FilterGrid {
2929 readonly property int iconWidth: (width / columns) * 0.8
3030 readonly property int iconHeight: iconWidth
3131
32− signal clicked(int index)
32+ signal clicked(int index, var delegateItem, real itemY)
33+ signal pressAndHold(int index, var delegateItem, real itemY)
3334
3435 delegate: AlbumTile {
36+ id: tile
3537 objectName: "delegate" + index
3638 width: filterGrid.cellWidth
3739 height: filterGrid.cellHeight
3840 iconWidth: filterGrid.iconWidth
3941 iconHeight: filterGrid.iconHeight
42+
4043 artist: model.title
4144 album: model.comment
4245 source: model.icon
46+
4347 onClicked: {
44− filterGrid.clicked(index);
48+ var data = { model: model }
49+ filterGrid.clicked(index, data, tile.y)
50+ }
51+
52+ onPressAndHold: {
53+ var data = { model: model }
54+ filterGrid.pressAndHold(index, data, tile.y)
4555 }
4656 }
4757}
Panel/MenuContent.qml+12−2
@@ -109,7 +109,7 @@ MainView {
109109 source: pageSource
110110 asynchronous: true
111111
112− property bool contentActive: content.__contentActive
112+ property bool contentActive: content.__contentActive && menuActivator.content[index].active
113113
114114 onContentActiveChanged: {
115115 if (contentActive && item) {
@@ -146,6 +146,16 @@ MainView {
146146 id: contentReleaseTimer
147147
148148 interval: contentReleaseInterval
149− onTriggered: content.__contentActive = false
149+ onTriggered: {
150+ content.__contentActive = false;
151+ menuActivator.clear();
152+ }
153+ }
154+
155+ Indicators.MenuContentActivator {
156+ id: menuActivator
157+ running: content.__contentActive
158+ baseIndex: content.currentMenuIndex
159+ count: indicatorsModel.count
150160 }
151161}
debian/changelog+68
@@ -1,3 +1,71 @@
1+unity8 (7.81.3+13.10.20130924.2-0ubuntu1) saucy; urgency=low
2+
3+ [ Michal Hruby ]
4+ * Fix the signal prototypes on music grid renderer. (LP: #1228390)
5+
6+ [ Michael Zanetti ]
7+ * use less auto variables, align coding style, constify and Qt'ify API
8+ in AccountsService plugin.
9+
10+ [ Nick Dedekind ]
11+ * Re-enable MenuContentActivator in Indicators.
12+
13+ [ Albert Astals ]
14+ * LVWPH: Update the section header on list change events.
15+
16+ [ Pawel Stolowski ]
17+ * Check results model ptr returned by GetResultsFromCategory method
18+ from UnityCore. (LP: #1228097, #1211595)
19+
20+ [ Ubuntu daily release ]
21+ * Automatic snapshot from revision 340
22+
23+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Tue, 24 Sep 2013 14:40:01 +0000
24+
25+unity8 (7.81.3+13.10.20130919.3-0ubuntu1) saucy; urgency=low
26+
27+ [ Michal Hruby ]
28+ * Add support for music grid renderer to GenericScopeView.
29+
30+ [ Nick Dedekind ]
31+ * Fixed the removal of messaging widget due to incompatible action
32+ state. (LP: #1225017)
33+
34+ [ Christopher Lee ]
35+ * Addition of initial autopilot tests for the application lifecycle.
36+
37+ [ Lars Uebernickel ]
38+ * VolumeControl: use action of the new indicator indicator-sound
39+ recently gained an action to increase and decrease the volume. This
40+ patch makes use of that to get rid of a bus round trip (to get the
41+ current volume) and a race (when the volume gets set between
42+ fetching the current volume and setting the new volume). (LP:
43+ #1219057)
44+
45+ [ Michael Terry ]
46+ * When AccountsService.backgroundFile is unset/invalid, have the
47+ greeter fall back to whatever the shell background is.
48+ * Add a tiny SessionBroadcast plugin that listens to unity-greeter-
49+ session-broadcast for the ShowHome signal.
50+
51+ [ Daniel d'Andrada ]
52+ * Remove obsolete, unused graphics.
53+ * Make MouseTouchAdaptor work with multiple QWindows.
54+
55+ [ Michael Zanetti ]
56+ * change how icons are searched a) try to find it the Icon as is b)
57+ prepend with Path if a Path variable is given c) fall back to the
58+ image://theme/ with just the icon name . (LP: #1225186)
59+ * fix an issue with removing a running app from the launcher and
60+ always store pinning to the config.
61+ * collapse any open preview when programmatically switching current
62+ dash index. (LP: #1221137)
63+
64+ [ Ubuntu daily release ]
65+ * Automatic snapshot from revision 333
66+
67+ -- Ubuntu daily release <ps-jenkins@lists.canonical.com> Thu, 19 Sep 2013 15:15:07 +0000
68+
169unity8 (7.81.3+13.10.20130916-0ubuntu1) saucy; urgency=low
270
371 [ Michael Zanetti ]
plugins/AccountsService/AccountsService.cpp+4−4
@@ -32,7 +32,7 @@ AccountsService::AccountsService(QObject* parent)
3232 this, SLOT(maybeChanged(const QString &)));
3333}
3434
35−QString AccountsService::getUser()
35+QString AccountsService::user() const
3636{
3737 return m_user;
3838}
@@ -47,7 +47,7 @@ void AccountsService::setUser(const QString &user)
4747 updateStatsWelcomeScreen();
4848}
4949
50−bool AccountsService::getDemoEdges()
50+bool AccountsService::demoEdges() const
5151{
5252 return m_demoEdges;
5353}
@@ -58,12 +58,12 @@ void AccountsService::setDemoEdges(bool demoEdges)
5858 m_service->setUserProperty(m_user, "com.canonical.unity.AccountsService", "demo-edges", demoEdges);
5959}
6060
61−QString AccountsService::getBackgroundFile()
61+QString AccountsService::backgroundFile() const
6262{
6363 return m_backgroundFile;
6464}
6565
66−bool AccountsService::statsWelcomeScreen()
66+bool AccountsService::statsWelcomeScreen() const
6767{
6868 return m_statsWelcomeScreen;
6969}
plugins/AccountsService/AccountsService.h+7−7
@@ -28,15 +28,15 @@ class AccountsService: public QObject
2828{
2929 Q_OBJECT
3030 Q_PROPERTY (QString user
31− READ getUser
31+ READ user
3232 WRITE setUser
3333 NOTIFY userChanged)
3434 Q_PROPERTY (bool demoEdges
35− READ getDemoEdges
35+ READ demoEdges
3636 WRITE setDemoEdges
3737 NOTIFY demoEdgesChanged)
3838 Q_PROPERTY (QString backgroundFile
39− READ getBackgroundFile
39+ READ backgroundFile
4040 NOTIFY backgroundFileChanged)
4141 Q_PROPERTY (bool statsWelcomeScreen
4242 READ statsWelcomeScreen
@@ -45,12 +45,12 @@ class AccountsService: public QObject
4545public:
4646 explicit AccountsService(QObject *parent = 0);
4747
48− QString getUser();
48+ QString user() const;
4949 void setUser(const QString &user);
50− bool getDemoEdges();
50+ bool demoEdges() const;
5151 void setDemoEdges(bool demoEdges);
52− QString getBackgroundFile();
53− bool statsWelcomeScreen();
52+ QString backgroundFile() const;
53+ bool statsWelcomeScreen() const;
5454
5555Q_SIGNALS:
5656 void userChanged();
plugins/AccountsService/AccountsServiceDBusAdaptor.cpp+15−15
@@ -24,13 +24,13 @@
2424
2525AccountsServiceDBusAdaptor::AccountsServiceDBusAdaptor(QObject* parent)
2626 : QObject(parent),
27− accounts_manager(NULL),
28− users()
27+ m_accountsManager(NULL),
28+ m_users()
2929{
30− auto connection = QDBusConnection::SM_BUSNAME();
31− auto interface = connection.interface();
30+ QDBusConnection connection = QDBusConnection::SM_BUSNAME();
31+ QDBusConnectionInterface *interface = connection.interface();
3232 interface->startService("org.freedesktop.Accounts");
33− accounts_manager = new QDBusInterface("org.freedesktop.Accounts",
33+ m_accountsManager = new QDBusInterface("org.freedesktop.Accounts",
3434 "/org/freedesktop/Accounts",
3535 "org.freedesktop.Accounts",
3636 connection, this);
@@ -38,9 +38,9 @@ AccountsServiceDBusAdaptor::AccountsServiceDBusAdaptor(QObject* parent)
3838
3939QVariant AccountsServiceDBusAdaptor::getUserProperty(const QString &user, const QString &interface, const QString &property)
4040{
41− auto iface = getUserInterface(user);
41+ QDBusInterface *iface = getUserInterface(user);
4242 if (iface != nullptr && iface->isValid()) {
43− auto answer = iface->call("Get", interface, property);
43+ QDBusMessage answer = iface->call("Get", interface, property);
4444 if (answer.type() == QDBusMessage::ReplyMessage) {
4545 return answer.arguments()[0].value<QDBusVariant>().variant();
4646 }
@@ -50,7 +50,7 @@ QVariant AccountsServiceDBusAdaptor::getUserProperty(const QString &user, const
5050
5151void AccountsServiceDBusAdaptor::setUserProperty(const QString &user, const QString &interface, const QString &property, const QVariant &value)
5252{
53− auto iface = getUserInterface(user);
53+ QDBusInterface *iface = getUserInterface(user);
5454 if (iface != nullptr && iface->isValid()) {
5555 // The value needs to be carefully wrapped
5656 iface->call("Set", interface, property, QVariant::fromValue(QDBusVariant(value)));
@@ -76,7 +76,7 @@ void AccountsServiceDBusAdaptor::maybeChangedSlot()
7676QString AccountsServiceDBusAdaptor::getUserForPath(const QString &path)
7777{
7878 QMap<QString, QDBusInterface *>::const_iterator i;
79− for (i = users.constBegin(); i != users.constEnd(); ++i) {
79+ for (i = m_users.constBegin(); i != m_users.constEnd(); ++i) {
8080 if (i.value()->path() == path) {
8181 return i.key();
8282 }
@@ -86,16 +86,16 @@ QString AccountsServiceDBusAdaptor::getUserForPath(const QString &path)
8686
8787QDBusInterface *AccountsServiceDBusAdaptor::getUserInterface(const QString &user)
8888{
89− auto iface = users.value(user);
90− if (iface == nullptr && accounts_manager->isValid()) {
91− auto answer = accounts_manager->call("FindUserByName", user);
89+ QDBusInterface *iface = m_users.value(user);
90+ if (iface == nullptr && m_accountsManager->isValid()) {
91+ QDBusMessage answer = m_accountsManager->call("FindUserByName", user);
9292 if (answer.type() == QDBusMessage::ReplyMessage) {
93− auto path = answer.arguments()[0].value<QDBusObjectPath>().path();
93+ QString path = answer.arguments()[0].value<QDBusObjectPath>().path();
9494
9595 iface = new QDBusInterface("org.freedesktop.Accounts",
9696 path,
9797 "org.freedesktop.DBus.Properties",
98− accounts_manager->connection(), this);
98+ m_accountsManager->connection(), this);
9999
100100 // With its own pre-defined properties, AccountsService is oddly
101101 // close-lipped. It won't send out proper DBus.Properties notices,
@@ -119,7 +119,7 @@ QDBusInterface *AccountsServiceDBusAdaptor::getUserInterface(const QString &user
119119 this,
120120 SLOT(propertiesChangedSlot(QString, QVariantMap, QStringList)));
121121
122− users.insert(user, iface);
122+ m_users.insert(user, iface);
123123 }
124124 }
125125 return iface;
plugins/AccountsService/AccountsServiceDBusAdaptor.h+2−2
@@ -47,8 +47,8 @@ private:
4747 QDBusInterface *getUserInterface(const QString &user);
4848 QString getUserForPath(const QString &path);
4949
50− QDBusInterface *accounts_manager;
51− QMap<QString, QDBusInterface *> users;
50+ QDBusInterface *m_accountsManager;
51+ QMap<QString, QDBusInterface *> m_users;
5252};
5353
5454#endif
plugins/ListViewWithPageHeader/listviewwithpageheader.cpp+13
@@ -199,6 +199,7 @@ void ListViewWithPageHeader::setModel(QAbstractItemModel *model)
199199 connect(m_delegateModel, SIGNAL(modelUpdated(QQmlChangeSet,bool)), this, SLOT(onModelUpdated(QQmlChangeSet,bool)));
200200#endif
201201 Q_EMIT modelChanged();
202+ polish();
202203 // TODO?
203204// Q_EMIT contentHeightChanged();
204205// Q_EMIT contentYChanged();
@@ -1006,6 +1007,18 @@ void ListViewWithPageHeader::onModelUpdated(const QQmlChangeSet &changeSet, bool
10061007 }
10071008 }
10081009
1010+ Q_FOREACH(const QQuickChangeSet::Change &change, changeSet.changes()) {
1011+// qDebug() << "ListViewWithPageHeader::onModelUpdated Change" << change.index << change.count;
1012+ for (int i = change.index; i < change.count; ++i) {
1013+ ListItem *item = itemAtIndex(i);
1014+ if (item && item->m_sectionItem) {
1015+ QQmlContext *context = QQmlEngine::contextForObject(item->m_sectionItem)->parentContext();
1016+ const QString sectionText = m_delegateModel->stringValue(i, m_sectionProperty);
1017+ context->setContextProperty(QLatin1String("section"), sectionText);
1018+ }
1019+ }
1020+ }
1021+
10091022 if (m_firstVisibleIndex != oldFirstVisibleIndex) {
10101023 adjustMinYExtent();
10111024 }
plugins/ListViewWithPageHeader/listviewwithpageheader.h+1
@@ -63,6 +63,7 @@ class ListViewWithPageHeader : public QQuickFlickable, public QQuickItemChangeLi
6363
6464 friend class ListViewWithPageHeaderTest;
6565 friend class ListViewWithPageHeaderTestSection;
66+ friend class ListViewWithPageHeaderTestExternalModel;
6667
6768public:
6869 ListViewWithPageHeader();
plugins/Unity/categories.cpp+12−1
@@ -21,6 +21,7 @@
2121// self
2222#include "categories.h"
2323#include "categoryresults.h"
24+#include <QDebug>
2425
2526// TODO: use something from libunity once it's public
2627enum CategoryColumn {
@@ -62,7 +63,17 @@ Categories::getResults(int index) const
6263
6364 unsigned categoryIndex = static_cast<unsigned>(index);
6465 auto unity_results = m_unityScope->GetResultsForCategory(categoryIndex);
65− results->setModel(unity_results->model());
66+ if (unity_results) {
67+ results->setModel(unity_results->model());
68+ } else {
69+ // No results model returned by unity core; this can be the case when the global
70+ // results model of this scope is still not set in unity core. Don't set backend
71+ // model in DeeListModel - it will still beahve properly as an empty model. Since
72+ // we're connected to the category model change signal, and it is set by unity core
73+ // at the same time as results model (on channel opening), we'll reset category
74+ // results models with proper models when we're notifed again.
75+ qWarning() << "No results model for category" << categoryIndex;
76+ }
6677
6778 m_results.insert(index, results);
6879 }
plugins/Unity/scope.cpp+13−1
@@ -175,7 +175,12 @@ void Scope::preview(const QVariant &uri, const QVariant &icon_hint, const QVaria
175175 const QVariant &comment, const QVariant &dnd_uri, const QVariant &metadata)
176176{
177177 auto res = createLocalResult(uri, icon_hint, category, result_type, mimetype, title, comment, dnd_uri, metadata);
178− m_unityScope->Preview(res);
178+ // canned queries don't have previews, must be activated
179+ if (uri.toString().startsWith("x-unity-no-preview-scopes-query://")) {
180+ m_unityScope->Activate(res);
181+ } else {
182+ m_unityScope->Preview(res);
183+ }
179184}
180185
181186void Scope::onActivated(unity::dash::LocalResult const& result, unity::dash::ScopeHandledType type, unity::glib::HintsMap const& hints)
@@ -199,6 +204,13 @@ void Scope::onActivated(unity::dash::LocalResult const& result, unity::dash::Sco
199204 qWarning() << "Missing goto-uri hint for GOTO_DASH_URI activation reply";
200205 }
201206 break;
207+ case unity::dash::PERFORM_SEARCH:
208+ if (hints.find("query") != hints.end()) {
209+ // note: this will emit searchQueryChanged, and shell will call setSearchQuery back with a new query,
210+ // but it will get ignored.
211+ setSearchQuery(QString::fromStdString(g_variant_get_string(hints.at("query"), nullptr)));
212+ }
213+ break;
202214 default:
203215 qWarning() << "Unhandled activation response:" << type;
204216 }
po/sl.po+29−24
@@ -8,7 +8,7 @@ msgstr ""
88"Project-Id-Version: unity\n"
99"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
1010"POT-Creation-Date: 2013-08-27 13:36-0400\n"
11−"PO-Revision-Date: 2013-07-02 12:59+0000\n"
11+"PO-Revision-Date: 2013-09-19 19:48+0000\n"
1212"Last-Translator: Damir Jerovšek <Unknown>\n"
1313"Language-Team: Slovenian <sl@li.org>\n"
1414"MIME-Version: 1.0\n"
@@ -16,8 +16,8 @@ msgstr ""
1616"Content-Transfer-Encoding: 8bit\n"
1717"Plural-Forms: nplurals=4; plural=(n%100==1 ? 1 : n%100==2 ? 2 : n%100==3 || "
1818"n%100==4 ? 3 : 0);\n"
19−"X-Launchpad-Export-Date: 2013-08-30 05:37+0000\n"
20−"X-Generator: Launchpad (build 16750)\n"
19+"X-Launchpad-Export-Date: 2013-09-20 06:21+0000\n"
20+"X-Generator: Launchpad (build 16765)\n"
2121
2222#: Applications/applications.js:23
2323msgid "Phone"
@@ -25,7 +25,7 @@ msgstr "Telefon"
2525
2626#: Applications/applications.js:29
2727msgid "Camera"
28−msgstr ""
28+msgstr "Fotoaparat"
2929
3030#: Applications/applications.js:35
3131msgid "Gallery"
@@ -89,47 +89,50 @@ msgstr "YouTube"
8989
9090#: Components/EdgeDemoOverlay.qml:145
9191msgid "Skip intro"
92−msgstr ""
92+msgstr "Preskoči uvod"
9393
9494#: Components/EdgeDemo.qml:98
9595msgid "Right edge"
96−msgstr ""
96+msgstr "Desni rob"
9797
9898#: Components/EdgeDemo.qml:99
9999msgid "Try swiping from the right edge to unlock the phone"
100−msgstr ""
100+msgstr "Poskusite povleči od desnega roba za odklep telefona"
101101
102102#: Components/EdgeDemo.qml:135
103103msgid "Top edge"
104−msgstr ""
104+msgstr "Zgornji rob"
105105
106106#: Components/EdgeDemo.qml:136
107107msgid "Try swiping from the top edge to access the indicators"
108−msgstr ""
108+msgstr "Poskusite povleči od zgornjega roba za dostop do kazalnikov"
109109
110110#: Components/EdgeDemo.qml:161
111111msgid "Close"
112−msgstr ""
112+msgstr "Zapri"
113113
114114#: Components/EdgeDemo.qml:162
115115msgid "Swipe up again to close the settings screen"
116−msgstr ""
116+msgstr "Povlecite ponovno navzgor za zaprtje zaslona z nastavitvami"
117117
118118#: Components/EdgeDemo.qml:189
119119msgid "Left edge"
120−msgstr ""
120+msgstr "Levi rob"
121121
122122#: Components/EdgeDemo.qml:190
123123msgid "Swipe from the left to reveal the launcher for quick access to apps"
124124msgstr ""
125+"Poskusite povleči od leve za razkritje zaganjalnika za hiter dostop do "
126+"programov"
125127
126128#: Components/EdgeDemo.qml:217
127129msgid "Well done"
128−msgstr ""
130+msgstr "Odlično"
129131
130132#: Components/EdgeDemo.qml:218
131133msgid "You have now mastered the edge gestures and can start using the phone"
132134msgstr ""
135+"Zdaj, ko ste osvojili kretnje z robovi, lahko začnete uporabljati telefon"
133136
134137#: Components/PageHeader.qml:298
135138msgid "Recent searches"
@@ -139,35 +142,37 @@ msgstr "Nedavna iskanja"
139142#: Dash/Apps/AppInfo.qml:73
140143#, qt-format
141144msgid "(%1)"
142−msgstr ""
145+msgstr "(%1)"
143146
144147#. TRANSLATORS: Number of persons who wrote reviews for this app
145148#: Dash/Apps/AppInfo.qml:85
146149#, qt-format
147150msgid "%1 review"
148151msgid_plural "%1 reviews"
149−msgstr[0] ""
150−msgstr[1] ""
152+msgstr[0] "%1 ocen"
153+msgstr[1] "%1 ocena"
154+msgstr[2] "%1 oceni"
155+msgstr[3] "%1 ocene"
151156
152157#: Dash/Apps/AppPreview.qml:175
153158msgid "Rate this"
154−msgstr ""
159+msgstr "Ocenite"
155160
156161#: Dash/Apps/AppReviews.qml:72
157162msgid "Add a review"
158−msgstr ""
163+msgstr "Dodaj oceno"
159164
160165#: Dash/Apps/AppReviews.qml:84
161166msgid "Review"
162−msgstr ""
167+msgstr "Ocena"
163168
164169#: Dash/Apps/AppReviews.qml:118
165170msgid "Send"
166−msgstr ""
171+msgstr "Pošlji"
167172
168173#: Dash/Apps/AppReviews.qml:136
169174msgid "Comments:"
170−msgstr ""
175+msgstr "Opombe:"
171176
172177#: Dash/DashMusic.qml:27 Dash/DashVideos.qml:28
173178msgid "Featured"
@@ -211,7 +216,7 @@ msgstr ""
211216
212217#: Greeter/Lockscreen.qml:134
213218msgid "Emergency Call"
214−msgstr ""
219+msgstr "Klic v sili"
215220
216221#: Greeter/PassphraseLockscreen.qml:59
217222#, qt-format
@@ -220,7 +225,7 @@ msgstr "Pozdravljeni, %1"
220225
221226#: Greeter/PassphraseLockscreen.qml:59
222227msgid "Hello"
223−msgstr ""
228+msgstr "Pozdravljeni"
224229
225230#: Hud/HudParametrizedActionsPage.qml:132
226231msgid "Confirm"
@@ -253,4 +258,4 @@ msgstr "Nič se ne ujema z vašim iskalnim nizom."
253258#: Shell.qml:429
254259#, qt-format
255260msgid "Please enter %1"
256−msgstr ""
261+msgstr "Vnesite %1"
tests/mocks/AccountsService/AccountsService.cpp+4−4
@@ -25,7 +25,7 @@ AccountsService::AccountsService(QObject* parent)
2525{
2626}
2727
28−QString AccountsService::getUser()
28+QString AccountsService::user() const
2929{
3030 return "testuser";
3131}
@@ -35,7 +35,7 @@ void AccountsService::setUser(const QString &user)
3535 Q_UNUSED(user)
3636}
3737
38−bool AccountsService::getDemoEdges()
38+bool AccountsService::demoEdges() const
3939{
4040 return false;
4141}
@@ -45,7 +45,7 @@ void AccountsService::setDemoEdges(bool demoEdges)
4545 Q_UNUSED(demoEdges)
4646}
4747
48−QString AccountsService::getBackgroundFile()
48+QString AccountsService::backgroundFile() const
4949{
5050 return m_backgroundFile;
5151}
@@ -56,7 +56,7 @@ void AccountsService::setBackgroundFile(const QString &backgroundFile)
5656 backgroundFileChanged();
5757}
5858
59−bool AccountsService::statsWelcomeScreen()
59+bool AccountsService::statsWelcomeScreen() const
6060{
6161 return m_statsWelcomeScreen;
6262}
tests/mocks/AccountsService/AccountsService.h+7−7
@@ -28,15 +28,15 @@ class AccountsService: public QObject
2828{
2929 Q_OBJECT
3030 Q_PROPERTY (QString user
31− READ getUser
31+ READ user
3232 WRITE setUser
3333 NOTIFY userChanged)
3434 Q_PROPERTY (bool demoEdges
35− READ getDemoEdges
35+ READ demoEdges
3636 WRITE setDemoEdges
3737 NOTIFY demoEdgesChanged)
3838 Q_PROPERTY (QString backgroundFile
39− READ getBackgroundFile
39+ READ backgroundFile
4040 WRITE setBackgroundFile // only available in mock
4141 NOTIFY backgroundFileChanged)
4242 Q_PROPERTY (bool statsWelcomeScreen
@@ -47,13 +47,13 @@ class AccountsService: public QObject
4747public:
4848 explicit AccountsService(QObject *parent = 0);
4949
50− QString getUser();
50+ QString user() const;
5151 void setUser(const QString &user);
52− bool getDemoEdges();
52+ bool demoEdges() const;
5353 void setDemoEdges(bool demoEdges);
54− QString getBackgroundFile();
54+ QString backgroundFile() const;
5555 void setBackgroundFile(const QString &backgroundFile);
56− bool statsWelcomeScreen();
56+ bool statsWelcomeScreen() const;
5757 void setStatsWelcomeScreen(bool statsWelcomeScreen);
5858
5959Q_SIGNALS:
tests/plugins/AccountsService/client.cpp+2−2
@@ -50,9 +50,9 @@ private Q_SLOTS:
5050 AccountsService session;
5151 session.setUser("testuser");
5252 session.setDemoEdges(true);
53− QCOMPARE(session.getDemoEdges(), true);
53+ QCOMPARE(session.demoEdges(), true);
5454 session.setDemoEdges(false);
55− QCOMPARE(session.getDemoEdges(), false);
55+ QCOMPARE(session.demoEdges(), false);
5656 }
5757};
5858
tests/plugins/ListViewWithPageHeader/CMakeLists.txt+6
@@ -32,5 +32,11 @@ qt5_use_modules(listviewwithpageheadertestsectionExec Test Core Qml)
3232target_link_libraries(listviewwithpageheadertestsectionExec ${Qt5Gui_LIBRARIES} ${Qt5Quick_LIBRARIES})
3333add_custom_target(testlistviewwithpageheadersection ${CMAKE_CURRENT_BINARY_DIR}/listviewwithpageheadertestsectionExec -o ${CMAKE_BINARY_DIR}/testlistviewwithpageheadersection.xml,xunitxml -o -,txt)
3434
35+add_executable(listviewwithpageheadertestsectionexternalmodelExec listviewwithpageheadertestsectionexternalmodel.cpp ${CMAKE_CURRENT_SOURCE_DIR}/../../../plugins/ListViewWithPageHeader/listviewwithpageheader.cpp)
36+qt5_use_modules(listviewwithpageheadertestsectionexternalmodelExec Test Core Qml)
37+target_link_libraries(listviewwithpageheadertestsectionexternalmodelExec ${Qt5Gui_LIBRARIES} ${Qt5Quick_LIBRARIES})
38+add_custom_target(testlistviewwithpageheadersectionexternalmodel ${CMAKE_CURRENT_BINARY_DIR}/listviewwithpageheadertestsectionexternalmodelExec -o ${CMAKE_BINARY_DIR}/testlistviewwithpageheadersectionexternalmodel.xml,xunitxml -o -,txt)
39+
3540add_dependencies(qmluitests testlistviewwithpageheader)
3641add_dependencies(qmluitests testlistviewwithpageheadersection)
42+add_dependencies(qmluitests testlistviewwithpageheadersectionexternalmodel)
tests/plugins/ListViewWithPageHeader/listviewwithpageheadertestsectionexternalmodel.cppnew file+251
@@ -0,0 +1,251 @@
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+#include "listviewwithpageheader.h"
18+
19+#include <QAbstractItemModel>
20+#include <QQmlEngine>
21+#include <QQuickView>
22+#include <QSignalSpy>
23+#include <QSortFilterProxyModel>
24+#include <QtTestGui>
25+#pragma GCC diagnostic push
26+#pragma GCC diagnostic ignored "-pedantic"
27+#if QT_VERSION < QT_VERSION_CHECK(5, 1, 0)
28+#include <private/qquicklistmodel_p.h>
29+#else
30+#include <private/qqmllistmodel_p.h>
31+#endif
32+#include <private/qquickanimation_p.h>
33+#include <private/qquickitem_p.h>
34+#pragma GCC diagnostic pop
35+
36+class StringListModel : public QAbstractListModel
37+{
38+public:
39+ StringListModel()
40+ {
41+ list << "A" << "B" << "C" << "D" << "E" << "F" << "G" << "H";
42+ }
43+
44+ int rowCount(const QModelIndex &parent) const
45+ {
46+ if (parent.isValid())
47+ return 0;
48+ else
49+ return list.count();
50+ }
51+
52+ QVariant data(const QModelIndex &index, int role) const
53+ {
54+ if (role == Qt::SizeHintRole) return 50;
55+ else if (role == Qt::DisplayRole) return list[index.row()];
56+ return QVariant();
57+ }
58+
59+ QHash<int, QByteArray> roleNames() const
60+ {
61+ QHash<int, QByteArray> hash;
62+ hash.insert(Qt::DisplayRole, "type");
63+ hash.insert(Qt::SizeHintRole, "size");
64+ return hash;
65+ }
66+
67+ void moveLastToFirst()
68+ {
69+ const int last = list.count() - 1;
70+ beginMoveRows(QModelIndex(), last, last, QModelIndex(), 0);
71+ list.move(last, 0);
72+ endMoveRows();
73+ }
74+
75+ QStringList list;
76+};
77+
78+class ListViewWithPageHeaderTestSection : public QObject
79+{
80+ Q_OBJECT
81+
82+private:
83+ void verifyItem(int visibleIndex, qreal pos, qreal height, bool culled, const QString &sectionHeader, bool sectionHeaderCulled)
84+ {
85+ QTRY_VERIFY(visibleIndex < lvwph->m_visibleItems.count());
86+ QTRY_COMPARE(lvwph->m_visibleItems[visibleIndex]->y(), pos);
87+ QTRY_COMPARE(lvwph->m_visibleItems[visibleIndex]->height(), height);
88+ QCOMPARE(QQuickItemPrivate::get(lvwph->m_visibleItems[visibleIndex]->m_item)->culled, culled);
89+ QCOMPARE(section(lvwph->m_visibleItems[visibleIndex]->m_sectionItem), sectionHeader);
90+ if (!sectionHeader.isNull()) {
91+ QCOMPARE(QQuickItemPrivate::get(lvwph->m_visibleItems[visibleIndex]->m_sectionItem)->culled, sectionHeaderCulled);
92+ QCOMPARE(sectionDelegateIndex(lvwph->m_visibleItems[visibleIndex]->m_sectionItem), lvwph->m_firstVisibleIndex + visibleIndex);
93+ }
94+ }
95+
96+ void changeContentY(qreal change)
97+ {
98+ const qreal dest = lvwph->contentY() + change;
99+ if (dest > lvwph->contentY()) {
100+ const qreal jump = 25;
101+ while (lvwph->contentY() + jump < dest) {
102+ lvwph->setContentY(lvwph->contentY() + jump);
103+ QTest::qWait(1);
104+ }
105+ } else {
106+ const qreal jump = -25;
107+ while (lvwph->contentY() + jump > dest) {
108+ lvwph->setContentY(lvwph->contentY() + jump);
109+ QTest::qWait(1);
110+ }
111+ }
112+ lvwph->setContentY(dest);
113+ QTest::qWait(1);
114+ }
115+
116+ void scrollToTop()
117+ {
118+ const qreal jump = -25;
119+ while (!lvwph->isAtYBeginning()) {
120+ if (lvwph->contentY() + jump > -lvwph->minYExtent()) {
121+ lvwph->setContentY(lvwph->contentY() + jump);
122+ } else {
123+ lvwph->setContentY(lvwph->contentY() - 1);
124+ }
125+ QTest::qWait(1);
126+ }
127+ }
128+
129+ void scrollToBottom()
130+ {
131+ const qreal jump = 25;
132+ while (!lvwph->isAtYEnd()) {
133+ if (lvwph->contentY() + lvwph->height() + jump < lvwph->contentHeight()) {
134+ lvwph->setContentY(lvwph->contentY() + jump);
135+ } else {
136+ lvwph->setContentY(lvwph->contentY() + 1);
137+ }
138+ QTest::qWait(1);
139+ }
140+ }
141+
142+ void verifyInitialTopPosition()
143+ {
144+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 0);
145+ QCOMPARE(lvwph->m_firstVisibleIndex, -1);
146+ QCOMPARE(lvwph->m_minYExtent, 0.);
147+ QCOMPARE(lvwph->m_clipItem->y(), 0.);
148+ QCOMPARE(lvwph->m_clipItem->clip(), false);
149+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
150+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
151+ QCOMPARE(lvwph->contentY(), 0.);
152+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
153+ QVERIFY(QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
154+ }
155+
156+ QString section(QQuickItem *item)
157+ {
158+ return item ? QQmlEngine::contextForObject(item)->parentContext()->contextProperty(QLatin1String("section")).toString() : QString();
159+ }
160+
161+ int sectionDelegateIndex(QQuickItem *item)
162+ {
163+ return item ? QQmlEngine::contextForObject(item)->parentContext()->contextProperty(QLatin1String("delegateIndex")).toInt() : -1;
164+ }
165+
166+private Q_SLOTS:
167+
168+ void initTestCase()
169+ {
170+ }
171+
172+ void init()
173+ {
174+ view = new QQuickView();
175+ view->engine()->addImportPath(BUILT_PLUGINS_DIR);
176+ view->setSource(QUrl::fromLocalFile(LISTVIEWWITHPAGEHEADER_FOLDER "/test_sectionexternalmodel.qml"));
177+ lvwph = dynamic_cast<ListViewWithPageHeader*>(view->rootObject()->findChild<QQuickFlickable*>());
178+ QVERIFY(lvwph);
179+ view->show();
180+ QTest::qWaitForWindowExposed(view);
181+
182+ verifyInitialTopPosition();
183+ }
184+
185+ void cleanup()
186+ {
187+ delete view;
188+ }
189+
190+ void testCreationDeletion()
191+ {
192+ // Nothing, init/cleanup already tests this
193+ }
194+
195+ void testMoveWithProxy()
196+ {
197+ StringListModel m;
198+ QSortFilterProxyModel proxy;
199+ proxy.setSourceModel(&m);
200+
201+ lvwph->setModel(&proxy);
202+
203+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 8);
204+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
205+ verifyItem(0, 50., 90., false, "A", false);
206+ verifyItem(1, 140., 90., false, "B", false);
207+ verifyItem(2, 230., 90., false, "C", false);
208+ verifyItem(3, 320., 90., false, "D", false);
209+ verifyItem(4, 410., 90., false, "E", false);
210+ verifyItem(5, 500., 90., false, "F", false);
211+ verifyItem(6, 590., 90., true, "G", true);
212+ verifyItem(7, 680., 90., true, "H", true);
213+ QCOMPARE(lvwph->m_minYExtent, 0.);
214+ QCOMPARE(lvwph->m_clipItem->y(), 0.);
215+ QCOMPARE(lvwph->m_clipItem->clip(), false);
216+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
217+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
218+ QCOMPARE(lvwph->contentY(), 0.);
219+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
220+ QVERIFY(QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
221+
222+ m.moveLastToFirst();
223+
224+ QTRY_COMPARE(lvwph->m_visibleItems.count(), 8);
225+ QCOMPARE(lvwph->m_firstVisibleIndex, 0);
226+ verifyItem(0, 50., 90., false, "H", false);
227+ verifyItem(1, 140., 90., false, "A", false);
228+ verifyItem(2, 230., 90., false, "B", false);
229+ verifyItem(3, 320., 90., false, "C", false);
230+ verifyItem(4, 410., 90., false, "D", false);
231+ verifyItem(5, 500., 90., false, "E", false);
232+ verifyItem(6, 590., 90., true, "F", true);
233+ verifyItem(7, 680., 90., true, "G", true);
234+ QCOMPARE(lvwph->m_minYExtent, 0.);
235+ QCOMPARE(lvwph->m_clipItem->y(), 0.);
236+ QCOMPARE(lvwph->m_clipItem->clip(), false);
237+ QCOMPARE(lvwph->m_headerItem->y(), 0.);
238+ QCOMPARE(lvwph->m_headerItem->height(), 50.);
239+ QCOMPARE(lvwph->contentY(), 0.);
240+ QCOMPARE(lvwph->m_headerItemShownHeight, 0.);
241+ QVERIFY(QQuickItemPrivate::get(lvwph->m_topSectionItem)->culled);
242+ }
243+
244+private:
245+ QQuickView *view;
246+ ListViewWithPageHeader *lvwph;
247+};
248+
249+QTEST_MAIN(ListViewWithPageHeaderTestSection)
250+
251+#include "listviewwithpageheadertestsectionexternalmodel.moc"
tests/plugins/ListViewWithPageHeader/test_sectionexternalmodel.qmlnew file+74
@@ -0,0 +1,74 @@
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+import ListViewWithPageHeader 0.1
19+
20+Rectangle {
21+ width: 300
22+ height: 542
23+ color: "lightblue"
24+
25+ ListViewWithPageHeader {
26+ id: listView
27+ width: parent.width
28+ anchors.top: parent.top
29+ anchors.bottom: parent.bottom
30+ model: model
31+ delegate: Rectangle {
32+ property bool timerDone: false
33+ width: parent.width - 20
34+ x: 10
35+ color: index % 2 == 0 ? "red" : "blue"
36+ height: timerDone ? size : 350
37+ Text {
38+ text: index
39+ }
40+ Timer {
41+ id: sizeTimer
42+ interval: 10;
43+ onTriggered: {
44+ timerDone = true
45+ }
46+ }
47+ Component.onCompleted: {
48+ sizeTimer.start()
49+ }
50+ }
51+
52+ pageHeader: Rectangle {
53+ color: "transparent"
54+ width: parent.width
55+ height: 50
56+ implicitHeight: 50
57+ Text {
58+ anchors.fill: parent
59+ text: "APPS"
60+ font.pixelSize: 40
61+ }
62+ }
63+
64+ sectionProperty: "type"
65+ sectionDelegate: Component {
66+ Rectangle {
67+ color: "green"
68+ height: 40
69+ Text { text: section; font.pixelSize: 34 }
70+ anchors { left: parent.left; right: parent.right }
71+ }
72+ }
73+ }
74+}