on xenial help sign in
Don't create the whole current scope delegates, just height * 3
commit9601a8fb4d4ce0cca5f70ae0f8a3022993497bc6 authorAlbert Astals <albert.astals@canonical.com> dateTue 28 Oct 2014, 10:32 (12 years ago) parent2467aa9
8 files changed+17−27
plugins/Dash/CardCreator.js+2−5 plugins/Dash/croppedimagesizer.cpp+6 plugins/Dash/croppedimagesizer.h+3−3 qml/Dash/CardGrid.qml+1−1 qml/Dash/CardVerticalJournal.qml−1 qml/Dash/DashRenderer.qml−4 qml/Dash/GenericScopeView.qml+5−11 qml/Dash/ScopesOverviewAll.qml−2
plugins/Dash/CardCreator.js+2−5
@@ -85,8 +85,7 @@ var kArtShapeHolderCode = 'Item { \n\
8585 CroppedImageMinimumSourceSize { \n\
8686 id: artImage; \n\
8787 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\
9089 asynchronous: root.asynchronous; \n\
9190 visible: false; \n\
9291 width: %2; \n\
@@ -196,8 +195,7 @@ var kMascotImageCode = 'CroppedImageMinimumSourceSize { \n\
196195 id: mascotImage; \n\
197196 objectName: "mascotImage"; \n\
198197 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\
201199 width: units.gu(6); \n\
202200 height: units.gu(5.625); \n\
203201 horizontalAlignment: Image.AlignHCenter; \n\
@@ -654,7 +652,6 @@ function createCardComponent(parent, template, components) {
654652 var imports = 'import QtQuick 2.2; \n\
655653 import Ubuntu.Components 1.1; \n\
656654 import Ubuntu.Settings.Components 0.1; \n\
657− import Ubuntu.Connectivity 1.0; \n\
658655 import Dash 0.1;\n\
659656 import Utils 0.1;\n';
660657 var card = cardString(template, components);
plugins/Dash/croppedimagesizer.cpp+6
@@ -24,6 +24,9 @@
2424#include <QQuickView>
2525
2626CroppedImageSizer::CroppedImageSizer()
27+ : m_width(0),
28+ m_height(0),
29+ m_sourceSize(QSize(-1, -1))
2730{
2831 connect(this, &CroppedImageSizer::inputParamsChanged, this, &CroppedImageSizer::calculateSourceSize);
2932}
@@ -89,6 +92,9 @@ void CroppedImageSizer::calculateSourceSize()
8992 QNetworkRequest request(m_source);
9093 m_reply = qmlEngine(this)->networkAccessManager()->get(request);
9194 connect(m_reply, &QNetworkReply::finished, this, &CroppedImageSizer::requestFinished);
95+ } else if (m_sourceSize != QSize(-1, -1)) {
96+ m_sourceSize = QSize(-1, -1);
97+ sourceSizeChanged();
9298 }
9399}
94100
plugins/Dash/croppedimagesizer.h+3−3
@@ -58,9 +58,9 @@ private Q_SLOT:
5858
5959private:
6060 QUrl m_source;
61− qreal m_width = 0;
62− qreal m_height = 0;
63− QSize m_sourceSize = QSize(-1, -1);
61+ qreal m_width;
62+ qreal m_height;
63+ QSize m_sourceSize;
6464 QNetworkReply *m_reply = nullptr;
6565};
6666
qml/Dash/CardGrid.qml+1−1
@@ -52,10 +52,10 @@ DashRenderer {
5252 displayMarginEnd: root.displayMarginEnd
5353 cacheBuffer: 0
5454 interactive: false
55+
5556 delegate: Item {
5657 width: grid.cellWidth
5758 height: grid.cellHeight
58− visible: y + height >= root.visibleRangeBegin && y <= root.visibleRangeEnd
5959 Loader {
6060 id: loader
6161 sourceComponent: cardTool.cardComponent
qml/Dash/CardVerticalJournal.qml−1
@@ -49,7 +49,6 @@ DashRenderer {
4949 id: loader
5050 sourceComponent: cardTool.cardComponent
5151 width: cardTool.cardWidth
52− visible: y + height >= root.visibleRangeBegin && y <= root.visibleRangeEnd
5352 onLoaded: {
5453 item.objectName = "delegate" + index;
5554 item.fixedArtShapeSize = Qt.binding(function() { return cardTool.artShapeSize; });
qml/Dash/DashRenderer.qml−4
@@ -27,10 +27,6 @@ Item {
2727
2828 property int displayMarginEnd: 0
2929
30− property int visibleRangeBegin: 0
31−
32− property int visibleRangeEnd: 0
33−
3430 property real originY: 0
3531
3632 // The model to renderer
qml/Dash/GenericScopeView.qml+5−11
@@ -379,20 +379,10 @@ FocusScope {
379379 }
380380 }
381381
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−
387382 if (item && item.hasOwnProperty("displayMarginBeginning")) {
388383 // TODO do we need item.originY here, test 1300302 once we have a silo
389384 // 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) {
396386 // Not visible (item at top of the list viewport)
397387 item.displayMarginBeginning = -baseItem.height;
398388 item.displayMarginEnd = 0;
@@ -404,6 +394,10 @@ FocusScope {
404394 item.displayMarginBeginning = Math.round(-Math.max(-baseItem.y, 0));
405395 item.displayMarginEnd = -Math.round(Math.max(baseItem.height - seeAll.height -
406396 categoryView.height + baseItem.y, 0));
397+ if (scopeView.isCurrent) {
398+ item.displayMarginBeginning += categoryView.height * 1.5;
399+ item.displayMarginEnd += categoryView.height * 1.5;
400+ }
407401 }
408402 }
409403 }
qml/Dash/ScopesOverviewAll.qml−2
@@ -44,8 +44,6 @@ Flickables.Flickable {
4444 id: cardGrid
4545 width: root.width
4646 height: parent.height
47− visibleRangeBegin: root.contentY
48− visibleRangeEnd: root.contentY + root.height
4947
5048 onClicked: {
5149 root.clicked(index, result, item, itemModel);