@@ -22,6 +22,8 @@ import "../Components"
25+ property alias scopesListFlickable: scopesListFlickable
25 // Properties set by parent
27 // Properties set by parent
26 property var scope: null
28 property var scope: null
@@ -35,11 +37,98 @@ Item {
35 signal requestFavoriteMoveTo(string scopeId, int index)
37 signal requestFavoriteMoveTo(string scopeId, int index)
36 signal requestRestore(string scopeId)
38 signal requestRestore(string scopeId)
38− state: "browse"
40+ Item {
43+ property bool dragging: false
44+ property var dragItem: new Object();
46+ readonly property bool fuzzyAtYEnd: {
47+ var contentHeight = root.scopesListFlickable.contentHeight
48+ var contentY = root.scopesListFlickable.contentY
49+ var dragItemHeight = dragItem ? autoscroller.dragItem.height : 0
50+ var flickableHeight = root.scopesListFlickable.height
55+ return contentY >= (contentHeight - flickableHeight) - dragItemHeight
59+ readonly property real bottomBoundary: {
60+ var contentHeight = root.scopesListFlickable.contentHeight
61+ var contentY = root.scopesListFlickable.contentY
62+ var dragItemHeight = dragItem ? autoscroller.dragItem.height : 0
63+ var heightRatio = root.scopesListFlickable.visibleArea.heightRatio
68+ return (heightRatio * contentHeight) -
69+ (1.5 * dragItemHeight) + contentY
73+ readonly property int delayMs: 32
74+ readonly property real topBoundary: dragItem ? root.scopesListFlickable.contentY + (.5 * dragItem.height) : 0
77+ readonly property real maxStep: units.dp(10)
78+ function stepSize(scrollingUp) {
81+ delta = dragItem.y - topBoundary;
82+ delta /= (1.5 * dragItem.height);
84+ delta = dragItem.y - bottomBoundary;
85+ delta /= (1.5 * dragItem.height);
88+ step = Math.abs(delta) * autoscroller.maxStep
89+ return Math.ceil(step);
94+ interval: autoscroller.delayMs
95+ running: autoscroller.dragItem ? (autoscroller.dragging &&
96+ autoscroller.dragItem.y < autoscroller.topBoundary &&
97+ !root.scopesListFlickable.atYBeginning) : false
100+ root.scopesListFlickable.contentY -= autoscroller.stepSize(true);
101+ autoscroller.dragItem.y -= autoscroller.stepSize(true);
106+ interval: autoscroller.delayMs
107+ running: autoscroller.dragItem ? (autoscroller.dragging &&
108+ autoscroller.dragItem.y >= autoscroller.bottomBoundary &&
109+ !autoscroller.fuzzyAtYEnd) : false
112+ root.scopesListFlickable.contentY += autoscroller.stepSize(false);
113+ autoscroller.dragItem.y += autoscroller.stepSize(false);
40− property var scopeStyle: ScopeStyle {
118+ function autoscroll(dragging, dragItem) {
120+ autoscroller.dragItem = dragItem
121+ autoscroller.dragging = true;
123+ autoscroller.dragItem = null;
124+ autoscroller.dragging = false
130+ property var scopeStyle: ScopeStyle {}
43 onStateChanged: {
132 onStateChanged: {
44 if (state == "edit") {
133 if (state == "edit") {
45 // As per design entering edit mode clears the possible existing search
134 // As per design entering edit mode clears the possible existing search
@@ -73,7 +162,8 @@ Item {
76− Flickable {
165+ ListView {
166+ id: scopesListFlickable
77 objectName: "scopesListFlickable"
167 objectName: "scopesListFlickable"
78 anchors {
168 anchors {
79 top: header.bottom
169 top: header.bottom
@@ -82,43 +172,34 @@ Item {
82 right: parent.right
172 right: parent.right
84 clip: true
174 clip: true
85− contentWidth: root.width
86− contentHeight: column.height
87− onContentHeightChanged: returnToBounds();
91− model: scope ? scope.categories : null
175+ model: scope ? scope.categories : null
93− delegate: Loader {
176+ delegate: Loader {
94− asynchronous: true
177+ asynchronous: true
95− width: root.width
178+ width: root.width
96− active: results.count > 0
179+ active: results.count > 0
97− visible: active
180+ visible: active
98− sourceComponent: ScopesListCategory {
181+ sourceComponent: ScopesListCategory {
99− objectName: "scopesListCategory" + categoryId
182+ objectName: "scopesListCategory" + categoryId
101− model: results
184+ model: results
103− title: {
186+ title: {
104− if (isFavoritesFeed) return i18n.tr("Home");
187+ if (isFavoritesFeed) return i18n.tr("Home");
105− else if (isAlsoInstalled) return i18n.tr("Also installed");
188+ else if (isAlsoInstalled) return i18n.tr("Also installed");
106− else return name;
189+ else return name;
109− editMode: root.state == "edit"
111− scopeStyle: root.scopeStyle
112− isFavoritesFeed: categoryId == "favorites"
113− isAlsoInstalled: categoryId == "other"
115− onRequestFavorite: root.requestFavorite(scopeId, favorite);
116− onRequestEditMode: root.state = "edit";
117− onRequestScopeMoveTo: root.requestFavoriteMoveTo(scopeId, index);
118− onRequestActivate: root.scope.activate(result, categoryId);
119− onRequestRestore: root.requestRestore(scopeId);
192+ editMode: root.state == "edit"
193+ scopeStyle: root.scopeStyle
194+ isFavoritesFeed: categoryId == "favorites"
195+ isAlsoInstalled: categoryId == "other"
197+ onItemDragging: autoscroll(dragging, dragItem);
198+ onRequestFavorite: root.requestFavorite(scopeId, favorite);
199+ onRequestEditMode: root.state = "edit";
200+ onRequestScopeMoveTo: root.requestFavoriteMoveTo(scopeId, index);
201+ onRequestActivate: root.scope.activate(result, categoryId);
202+ onRequestRestore: root.requestRestore(scopeId);