on xenial help sign in
Adapt to new api
e671b82Albert Astals
qml/Components/PageHeader.qml+1−1
@@ -25,7 +25,7 @@ Item {
25 property bool searchEntryEnabled: false
25 property bool searchEntryEnabled: false
26 property alias searchQuery: searchField.text
26 property alias searchQuery: searchField.text
27 property ListModel searchHistory
27 property ListModel searchHistory
28− property Scope scope
28+ property var scope: null
29 property alias childItem: itemContainer.children
29 property alias childItem: itemContainer.children
30 property alias showBackButton: backButton.visible
30 property alias showBackButton: backButton.visible
31
31
qml/Dash/CardCarousel.qml+2−2
@@ -43,8 +43,8 @@ DashRenderer {
43 cacheBuffer: 1404 // 18px * 13gu * 6
43 cacheBuffer: 1404 // 18px * 13gu * 6
44 model: cardCarousel.model
44 model: cardCarousel.model
45
45
46− onClicked: cardCarousel.clicked(index, itemY)
46+ onClicked: cardCarousel.clicked(index, null)
47− onPressAndHold: cardCarousel.pressAndHold(index, itemY)
47+ onPressAndHold: cardCarousel.pressAndHold(index)
48
48
49 property real fontScale: 1 / selectedItemScaleFactor
49 property real fontScale: 1 / selectedItemScaleFactor
50 property real headerHeight: cardTool.headerHeight / selectedItemScaleFactor
50 property real headerHeight: cardTool.headerHeight / selectedItemScaleFactor
qml/Dash/CardFilterGrid.qml+2−2
@@ -62,8 +62,8 @@ DashRenderer {
62
62
63 headerAlignment: cardTool.headerAlignment
63 headerAlignment: cardTool.headerAlignment
64
64
65− onClicked: genericFilterGrid.clicked(index, card.y)
65+ onClicked: genericFilterGrid.clicked(index, result)
66− onPressAndHold: genericFilterGrid.pressAndHold(index, card.y)
66+ onPressAndHold: genericFilterGrid.pressAndHold(index)
67 }
67 }
68 }
68 }
69 }
69 }
qml/Dash/DashContent.qml+1−1
@@ -138,7 +138,7 @@ Item {
138
138
139 readonly property bool moving: item ? item.moving : false
139 readonly property bool moving: item ? item.moving : false
140 readonly property var categoryView: item ? item.categoryView : null
140 readonly property var categoryView: item ? item.categoryView : null
141− readonly property Scope theScope: scope
141+ readonly property var theScope: scope
142
142
143 // these are needed for autopilot tests
143 // these are needed for autopilot tests
144 readonly property string scopeId: scope.id
144 readonly property string scopeId: scope.id
qml/Dash/DashRenderer.qml+3−4
@@ -50,13 +50,12 @@ Item {
50
50
51 /// Emitted when the user clicked on an item
51 /// Emitted when the user clicked on an item
52 /// @param index is the index of the clicked item
52 /// @param index is the index of the clicked item
53− /// @param itemY is y of the clicked delegate
53+ /// @param result result model of the cliked item, used for activation
54− signal clicked(int index, real itemY)
54+ signal clicked(int index, var result)
55
55
56 /// Emitted when the user pressed and held on an item
56 /// Emitted when the user pressed and held on an item
57 /// @param index is the index of the held item
57 /// @param index is the index of the held item
58− /// @param itemY is y of the held delegate
59− signal pressAndHold(int index, real itemY)
58+ signal pressAndHold(int index)
60
59
61 function setFilter(filter, animate) {
60 function setFilter(filter, animate) {
62 }
61 }
qml/Dash/GenericScopeView.qml+2−3
@@ -25,7 +25,7 @@ import "../Components/ListItems" as ListItems
25FocusScope {
25FocusScope {
26 id: scopeView
26 id: scopeView
27
27
28− property Scope scope: null
28+ property var scope: null
29 property SortFilterProxyModel categories: categoryFilter
29 property SortFilterProxyModel categories: categoryFilter
30 property bool isCurrent: false
30 property bool isCurrent: false
31 property alias moving: categoryView.moving
31 property alias moving: categoryView.moving
@@ -187,8 +187,7 @@ FocusScope {
187 // TODO Technically it is possible that calling activate() will make the scope emit
187 // TODO Technically it is possible that calling activate() will make the scope emit
188 // previewRequested so that we show a preview but there's no scope that does that yet
188 // previewRequested so that we show a preview but there's no scope that does that yet
189 // so it's not implemented
189 // so it's not implemented
190− var item = target.model.get(index);
191− scopeView.scope.activate(item.result)
190+ scopeView.scope.activate(result)
192 } else {
191 } else {
193 previewListView.model = target.model;
192 previewListView.model = target.model;
194 previewListView.currentIndex = -1
193 previewListView.currentIndex = -1
qml/Dash/PreviewListView.qml+2−2
@@ -23,7 +23,7 @@ import "Previews" as Previews
23Item {
23Item {
24 id: root
24 id: root
25
25
26− property Scope scope: null
26+ property var scope: null
27 property var pageHeader: null
27 property var pageHeader: null
28
28
29 property alias open: previewListView.open
29 property alias open: previewListView.open
@@ -116,7 +116,7 @@ Item {
116
116
117 previewModel: {
117 previewModel: {
118 var previewStack = root.scope.preview(result);
118 var previewStack = root.scope.preview(result);
119− return previewStack.get(0);
119+ return previewStack.getPreviewModel(0);
120 }
120 }
121 }
121 }
122
122
qml/ScopeTool.qml+1−1
@@ -74,7 +74,7 @@ Rectangle {
74
74
75 model: filteredScopes
75 model: filteredScopes
76 searchHistory: SearchHistoryModel { }
76 searchHistory: SearchHistoryModel { }
77− property Scope scope: scopes.get(currentIndex)
77+ property var scope: scopes.getScope(currentIndex)
78
78
79 anchors {
79 anchors {
80 top: parent.top
80 top: parent.top
tests/mocks/Unity/fake_previewstack.cpp+1−1
@@ -48,7 +48,7 @@ int PreviewStack::rowCount(const QModelIndex&) const
48 return m_previews.size();
48 return m_previews.size();
49}
49}
50
50
51−unity::shell::scopes::PreviewModelInterface* PreviewStack::get(int index) const
51+unity::shell::scopes::PreviewModelInterface* PreviewStack::getPreviewModel(int index) const
52{
52{
53 if (index >= m_previews.size()) {
53 if (index >= m_previews.size()) {
54 return nullptr;
54 return nullptr;
tests/mocks/Unity/fake_previewstack.h+1−1
@@ -36,7 +36,7 @@ public:
36 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
36 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
37 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
37 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
38
38
39− Q_INVOKABLE unity::shell::scopes::PreviewModelInterface* get(int index) const override;
39+ Q_INVOKABLE unity::shell::scopes::PreviewModelInterface* getPreviewModel(int index) const override;
40
40
41 void setWidgetColumnCount(int columnCount) override;
41 void setWidgetColumnCount(int columnCount) override;
42 int widgetColumnCount() const override;
42 int widgetColumnCount() const override;
tests/mocks/Unity/fake_resultsmodel.cpp−17
@@ -51,23 +51,6 @@ int ResultsModel::count() const
51 return rowCount();
51 return rowCount();
52}
52}
53
53
54−QVariant ResultsModel::get(int row) const
55−{
56− if (row >= m_result_count || row < 0) return QVariantMap();
57−
58− QVariantMap result;
59− QModelIndex modelIndex(index(row));
60− QHashIterator<int, QByteArray> it(roleNames());
61− while (it.hasNext()) {
62− it.next();
63− QVariant val(data(modelIndex, it.key()));
64− if (val.isNull()) continue;
65− result[it.value()] = val;
66− }
67−
68− return result;
69−}
70−
71QVariant
54QVariant
72ResultsModel::data(const QModelIndex& index, int role) const
55ResultsModel::data(const QModelIndex& index, int role) const
73{
56{
tests/mocks/Unity/fake_resultsmodel.h−2
@@ -33,8 +33,6 @@ public:
33 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
33 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
34 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
34 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
35
35
36− Q_INVOKABLE QVariant get(int row) const override;
37−
38 /* getters */
36 /* getters */
39 QString categoryId() const override;
37 QString categoryId() const override;
40 int count() const override;
38 int count() const override;
tests/mocks/Unity/fake_scopes.cpp+8−4
@@ -104,14 +104,18 @@ QVariant Scopes::data(const QModelIndex& index, int role) const
104 }
104 }
105}
105}
106
106
107−QVariant Scopes::get(int row) const
107+unity::shell::scopes::ScopeInterface* Scopes::getScope(int row) const
108{
108{
109− return data(QAbstractListModel::index(row), 0);
109+ if (row < 0 || row >= m_scopes.size()) {
110+ return nullptr;
111+ }
112+
113+ return m_scopes[row];
110}
114}
111
115
112−QVariant Scopes::get(QString const&) const
116+unity::shell::scopes::ScopeInterface* Scopes::getScope(QString const&) const
113{
117{
114− return QVariant();
118+ return nullptr;
115}
119}
116
120
117QModelIndex Scopes::parent(const QModelIndex&) const
121QModelIndex Scopes::parent(const QModelIndex&) const
tests/mocks/Unity/fake_scopes.h+2−2
@@ -38,8 +38,8 @@ public:
38
38
39 Q_INVOKABLE int rowCount(const QModelIndex& parent = QModelIndex()) const override;
39 Q_INVOKABLE int rowCount(const QModelIndex& parent = QModelIndex()) const override;
40
40
41− Q_INVOKABLE QVariant get(int row) const override;
41+ Q_INVOKABLE unity::shell::scopes::ScopeInterface* getScope(int row) const override;
42− Q_INVOKABLE QVariant get(const QString& scope_id) const override;
42+ Q_INVOKABLE unity::shell::scopes::ScopeInterface* getScope(const QString& scope_id) const override;
43
43
44 Q_INVOKABLE void addScope(Scope* scope);
44 Q_INVOKABLE void addScope(Scope* scope);
45
45
tests/mocks/Unity/fake_unity_plugin.cpp+1−1
@@ -40,7 +40,7 @@ void FakeUnityPlugin::registerTypes(const char *uri)
40 Q_ASSERT(uri == QLatin1String("Unity"));
40 Q_ASSERT(uri == QLatin1String("Unity"));
41
41
42 qmlRegisterType<Scopes>(uri, 0, 2, "Scopes");
42 qmlRegisterType<Scopes>(uri, 0, 2, "Scopes");
43− qmlRegisterType<Scope>(uri, 0, 2, "Scope");
43+ qmlRegisterUncreatableType<unity::shell::scopes::ScopeInterface>(uri, 0, 2, "Scope", "Can't create Scope object in QML.");
44 qmlRegisterUncreatableType<unity::shell::scopes::CategoriesInterface>(uri, 0, 2, "Categories", "Can't create Categories object in QML.");
44 qmlRegisterUncreatableType<unity::shell::scopes::CategoriesInterface>(uri, 0, 2, "Categories", "Can't create Categories object in QML.");
45 qmlRegisterUncreatableType<ResultsModel>(uri, 0, 2, "ResultsModel", "Can't create ResultsModel object in QML.");
45 qmlRegisterUncreatableType<ResultsModel>(uri, 0, 2, "ResultsModel", "Can't create ResultsModel object in QML.");
46 qmlRegisterType<PreviewModel>(uri, 0, 2, "FakePreviewModel");
46 qmlRegisterType<PreviewModel>(uri, 0, 2, "FakePreviewModel");
tests/qmltests/Dash/tst_DashContent.qml+4−4
@@ -195,7 +195,7 @@ Item {
195 dashContent.setCurrentScopeAtIndex(data.index, true, false);
195 dashContent.setCurrentScopeAtIndex(data.index, true, false);
196 tryCompareFunction(get_current_item_object_name, data.objectName)
196 tryCompareFunction(get_current_item_object_name, data.objectName)
197 var pageHeader = findChild(dashContent, "pageHeader");
197 var pageHeader = findChild(dashContent, "pageHeader");
198− compare(pageHeader.scope, scopesModel.get(data.index));
198+ compare(pageHeader.scope, scopesModel.getScope(data.index));
199 }
199 }
200
200
201 function test_is_active_data() {
201 function test_is_active_data() {
@@ -212,9 +212,9 @@ Item {
212 dashContent.setCurrentScopeAtIndex(data.select, true, false);
212 dashContent.setCurrentScopeAtIndex(data.select, true, false);
213 dashContent.visible = data.visible;
213 dashContent.visible = data.visible;
214
214
215− tryCompare(scopesModel.get(0), "isActive", data.active0);
215+ tryCompare(scopesModel.getScope(0), "isActive", data.active0);
216− tryCompare(scopesModel.get(1), "isActive", data.active1);
216+ tryCompare(scopesModel.getScope(1), "isActive", data.active1);
217− tryCompare(scopesModel.get(2), "isActive", data.active2);
217+ tryCompare(scopesModel.getScope(2), "isActive", data.active2);
218 }
218 }
219
219
220 function doFindMusicButton(parent) {
220 function doFindMusicButton(parent) {
tests/qmltests/Dash/tst_GenericScopeView.qml+10−10
@@ -39,7 +39,7 @@ Item {
39 id: scopes
39 id: scopes
40
40
41 onLoadedChanged: {
41 onLoadedChanged: {
42− genericScopeView.scope = scopes.get(2)
42+ genericScopeView.scope = scopes.getScope(2)
43 }
43 }
44 }
44 }
45
45
@@ -67,7 +67,7 @@ Item {
67 when: scopes.loaded && windowShown
67 when: scopes.loaded && windowShown
68
68
69 function init() {
69 function init() {
70− genericScopeView.scope = scopes.get(2)
70+ genericScopeView.scope = scopes.getScope(2)
71 shell.width = units.gu(120)
71 shell.width = units.gu(120)
72 genericScopeView.categoryView.positionAtBeginning();
72 genericScopeView.categoryView.positionAtBeginning();
73 tryCompare(genericScopeView.categoryView, "contentY", 0)
73 tryCompare(genericScopeView.categoryView, "contentY", 0)
@@ -96,31 +96,31 @@ Item {
96
96
97 function test_showDash() {
97 function test_showDash() {
98 previewListView.open = true;
98 previewListView.open = true;
99− scopes.get(2).showDash();
99+ scopes.getScope(2).showDash();
100 tryCompare(previewListView, "open", false);
100 tryCompare(previewListView, "open", false);
101 }
101 }
102
102
103 function test_hideDash() {
103 function test_hideDash() {
104 previewListView.open = true;
104 previewListView.open = true;
105− scopes.get(2).hideDash();
105+ scopes.getScope(2).hideDash();
106 tryCompare(previewListView, "open", false);
106 tryCompare(previewListView, "open", false);
107 }
107 }
108
108
109 function test_searchQuery() {
109 function test_searchQuery() {
110− genericScopeView.scope = scopes.get(0);
110+ genericScopeView.scope = scopes.getScope(0);
111 genericScopeView.scope.searchQuery = "test";
111 genericScopeView.scope.searchQuery = "test";
112− genericScopeView.scope = scopes.get(1);
112+ genericScopeView.scope = scopes.getScope(1);
113 genericScopeView.scope.searchQuery = "test2";
113 genericScopeView.scope.searchQuery = "test2";
114− genericScopeView.scope = scopes.get(0);
114+ genericScopeView.scope = scopes.getScope(0);
115 tryCompare(genericScopeView.scope, "searchQuery", "test");
115 tryCompare(genericScopeView.scope, "searchQuery", "test");
116− genericScopeView.scope = scopes.get(1);
116+ genericScopeView.scope = scopes.getScope(1);
117 tryCompare(genericScopeView.scope, "searchQuery", "test2");
117 tryCompare(genericScopeView.scope, "searchQuery", "test2");
118 }
118 }
119
119
120 function test_changeScope() {
120 function test_changeScope() {
121 genericScopeView.scope.searchQuery = "test"
121 genericScopeView.scope.searchQuery = "test"
122− genericScopeView.scope = scopes.get(1)
122+ genericScopeView.scope = scopes.getScope(1)
123− genericScopeView.scope = scopes.get(2)
123+ genericScopeView.scope = scopes.getScope(2)
124 tryCompare(genericScopeView.scope, "searchQuery", "test")
124 tryCompare(genericScopeView.scope, "searchQuery", "test")
125 }
125 }
126
126