on xenial help sign in
Don't create the whole current scope delegates, just height * 3
9601a8fAlbert Astals
plugins/Dash/CardCreator.js+2−5
@@ -85,8 +85,7 @@ var kArtShapeHolderCode = 'Item { \n\
85 CroppedImageMinimumSourceSize { \n\
85 CroppedImageMinimumSourceSize { \n\
86 id: artImage; \n\
86 id: artImage; \n\
87 objectName: "artImage"; \n\
87 objectName: "artImage"; \n\
88− property bool doLoadSource: !NetworkingStatus.limitedBandwith; \n\
89− source: { if (root.visible) doLoadSource = true; return doLoadSource && cardData && cardData["art"] || ""; } \n\
88+ source: cardData && cardData["art"] || ""; \n\
90 asynchronous: root.asynchronous; \n\
89 asynchronous: root.asynchronous; \n\
91 visible: false; \n\
90 visible: false; \n\
92 width: %2; \n\
91 width: %2; \n\
@@ -196,8 +195,7 @@ var kMascotImageCode = 'CroppedImageMinimumSourceSize { \n\
196 id: mascotImage; \n\
195 id: mascotImage; \n\
197 objectName: "mascotImage"; \n\
196 objectName: "mascotImage"; \n\
198 anchors { %1 } \n\
197 anchors { %1 } \n\
199− property bool doLoadSource: !NetworkingStatus.limitedBandwith; \n\
200− source: { if (root.visible) doLoadSource = true; return doLoadSource && cardData && cardData["mascot"] || ""; } \n\
198+ source: cardData && cardData["mascot"] || ""; \n\
201 width: units.gu(6); \n\
199 width: units.gu(6); \n\
202 height: units.gu(5.625); \n\
200 height: units.gu(5.625); \n\
203 horizontalAlignment: Image.AlignHCenter; \n\
201 horizontalAlignment: Image.AlignHCenter; \n\
@@ -654,7 +652,6 @@ function createCardComponent(parent, template, components) {
654 var imports = 'import QtQuick 2.2; \n\
652 var imports = 'import QtQuick 2.2; \n\
655 import Ubuntu.Components 1.1; \n\
653 import Ubuntu.Components 1.1; \n\
656 import Ubuntu.Settings.Components 0.1; \n\
654 import Ubuntu.Settings.Components 0.1; \n\
657− import Ubuntu.Connectivity 1.0; \n\
658 import Dash 0.1;\n\
655 import Dash 0.1;\n\
659 import Utils 0.1;\n';
656 import Utils 0.1;\n';
660 var card = cardString(template, components);
657 var card = cardString(template, components);
plugins/Dash/croppedimagesizer.cpp+6
@@ -24,6 +24,9 @@
24#include <QQuickView>
24#include <QQuickView>
25
25
26CroppedImageSizer::CroppedImageSizer()
26CroppedImageSizer::CroppedImageSizer()
27+ : m_width(0),
28+ m_height(0),
29+ m_sourceSize(QSize(-1, -1))
27{
30{
28 connect(this, &CroppedImageSizer::inputParamsChanged, this, &CroppedImageSizer::calculateSourceSize);
31 connect(this, &CroppedImageSizer::inputParamsChanged, this, &CroppedImageSizer::calculateSourceSize);
29}
32}
@@ -89,6 +92,9 @@ void CroppedImageSizer::calculateSourceSize()
89 QNetworkRequest request(m_source);
92 QNetworkRequest request(m_source);
90 m_reply = qmlEngine(this)->networkAccessManager()->get(request);
93 m_reply = qmlEngine(this)->networkAccessManager()->get(request);
91 connect(m_reply, &QNetworkReply::finished, this, &CroppedImageSizer::requestFinished);
94 connect(m_reply, &QNetworkReply::finished, this, &CroppedImageSizer::requestFinished);
95+ } else if (m_sourceSize != QSize(-1, -1)) {
96+ m_sourceSize = QSize(-1, -1);
97+ sourceSizeChanged();
92 }
98 }
93}
99}
94
100
plugins/Dash/croppedimagesizer.h+3−3
@@ -58,9 +58,9 @@ private Q_SLOT:
58
58
59private:
59private:
60 QUrl m_source;
60 QUrl m_source;
61− qreal m_width = 0;
61+ qreal m_width;
62− qreal m_height = 0;
62+ qreal m_height;
63− QSize m_sourceSize = QSize(-1, -1);
63+ QSize m_sourceSize;
64 QNetworkReply *m_reply = nullptr;
64 QNetworkReply *m_reply = nullptr;
65};
65};
66
66
qml/Dash/CardGrid.qml+1−1
@@ -52,10 +52,10 @@ DashRenderer {
52 displayMarginEnd: root.displayMarginEnd
52 displayMarginEnd: root.displayMarginEnd
53 cacheBuffer: 0
53 cacheBuffer: 0
54 interactive: false
54 interactive: false
55+
55 delegate: Item {
56 delegate: Item {
56 width: grid.cellWidth
57 width: grid.cellWidth
57 height: grid.cellHeight
58 height: grid.cellHeight
58− visible: y + height >= root.visibleRangeBegin && y <= root.visibleRangeEnd
59 Loader {
59 Loader {
60 id: loader
60 id: loader
61 sourceComponent: cardTool.cardComponent
61 sourceComponent: cardTool.cardComponent
qml/Dash/CardVerticalJournal.qml−1
@@ -49,7 +49,6 @@ DashRenderer {
49 id: loader
49 id: loader
50 sourceComponent: cardTool.cardComponent
50 sourceComponent: cardTool.cardComponent
51 width: cardTool.cardWidth
51 width: cardTool.cardWidth
52− visible: y + height >= root.visibleRangeBegin && y <= root.visibleRangeEnd
53 onLoaded: {
52 onLoaded: {
54 item.objectName = "delegate" + index;
53 item.objectName = "delegate" + index;
55 item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
54 item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
qml/Dash/DashRenderer.qml−4
@@ -27,10 +27,6 @@ Item {
27
27
28 property int displayMarginEnd: 0
28 property int displayMarginEnd: 0
29
29
30− property int visibleRangeBegin: 0
31−
32− property int visibleRangeEnd: 0
33−
34 property real originY: 0
30 property real originY: 0
35
31
36 // The model to renderer
32 // The model to renderer
qml/Dash/GenericScopeView.qml+5−11
@@ -379,20 +379,10 @@ FocusScope {
379 }
379 }
380 }
380 }
381
381
382− if (item && item.hasOwnProperty("visibleRangeBegin")) {
383− item.visibleRangeBegin = Math.max(-baseItem.y, 0)
384− item.visibleRangeEnd = item.visibleRangeBegin + Math.min(categoryView.height, rendererLoader.height)
385− }
386−
387 if (item && item.hasOwnProperty("displayMarginBeginning")) {
382 if (item && item.hasOwnProperty("displayMarginBeginning")) {
388 // TODO do we need item.originY here, test 1300302 once we have a silo
383 // TODO do we need item.originY here, test 1300302 once we have a silo
389 // and we can run it on the phone
384 // and we can run it on the phone
390− if (scopeView.isCurrent) {
391− // 1073741823 is s^30 -1. A quite big number so that you have "infinite" display margin, but not so
392− // big so that if you add if with itself you're outside the 2^31 int range
393− item.displayMarginBeginning = 1073741823;
394− item.displayMarginEnd = 1073741823;
395− } else if (baseItem.y + baseItem.height <= 0) {
385+ if (baseItem.y + baseItem.height <= 0) {
396 // Not visible (item at top of the list viewport)
386 // Not visible (item at top of the list viewport)
397 item.displayMarginBeginning = -baseItem.height;
387 item.displayMarginBeginning = -baseItem.height;
398 item.displayMarginEnd = 0;
388 item.displayMarginEnd = 0;
@@ -404,6 +394,10 @@ FocusScope {
404 item.displayMarginBeginning = Math.round(-Math.max(-baseItem.y, 0));
394 item.displayMarginBeginning = Math.round(-Math.max(-baseItem.y, 0));
405 item.displayMarginEnd = -Math.round(Math.max(baseItem.height - seeAll.height -
395 item.displayMarginEnd = -Math.round(Math.max(baseItem.height - seeAll.height -
406 categoryView.height + baseItem.y, 0));
396 categoryView.height + baseItem.y, 0));
397+ if (scopeView.isCurrent) {
398+ item.displayMarginBeginning += categoryView.height * 1.5;
399+ item.displayMarginEnd += categoryView.height * 1.5;
400+ }
407 }
401 }
408 }
402 }
409 }
403 }
qml/Dash/ScopesOverviewAll.qml−2
@@ -44,8 +44,6 @@ Flickables.Flickable {
44 id: cardGrid
44 id: cardGrid
45 width: root.width
45 width: root.width
46 height: parent.height
46 height: parent.height
47− visibleRangeBegin: root.contentY
48− visibleRangeEnd: root.contentY + root.height
49
47
50 onClicked: {
48 onClicked: {
51 root.clicked(index, result, item, itemModel);
49 root.clicked(index, result, item, itemModel);