@@ -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,84 @@ 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: root.scopesListFlickable.contentY >=
47+ (root.scopesListFlickable.contentHeight - root.scopesListFlickable.height) - (autoscroller.dragItem.height)
49+ readonly property real bottomBoundary: {
51+ root.scopesListFlickable.visibleArea.heightRatio *
52+ root.scopesListFlickable.contentHeight
54+ - (1.5 * dragItem.height)
55+ + root.scopesListFlickable.contentY
58+ readonly property int delayMs: 32
59+ readonly property real topBoundary: root.scopesListFlickable.contentY + (.5 * dragItem.height)
62+ readonly property real maxStep: units.dp(10)
63+ function stepSize(scrollingUp) {
66+ delta = dragItem.y - topBoundary;
67+ delta /= (1.5 * dragItem.height);
69+ delta = dragItem.y - bottomBoundary;
70+ delta /= (1.5 * dragItem.height);
73+ step = Math.abs(delta) * autoscroller.maxStep
74+ return Math.ceil(step);
40− property var scopeStyle: ScopeStyle {
78+ Timer {
79+ interval: autoscroller.delayMs
80+ running: autoscroller.dragging &&
81+ autoscroller.dragItem.y < autoscroller.topBoundary &&
82+ !root.scopesListFlickable.atYBeginning
85+ root.scopesListFlickable.contentY -= autoscroller.stepSize(true);
86+ autoscroller.dragItem.y -= autoscroller.stepSize(true);
92+ interval: autoscroller.delayMs
93+ running: autoscroller.dragging &&
94+ autoscroller.dragItem.y >= autoscroller.bottomBoundary &&
95+ !autoscroller.fuzzyAtYEnd
98+ root.scopesListFlickable.contentY += autoscroller.stepSize(false);
99+ autoscroller.dragItem.y += autoscroller.stepSize(false);
104+ function autoscroll(dragging, dragItem) {
106+ autoscroller.dragItem = dragItem
107+ autoscroller.dragging = true;
109+ autoscroller.dragItem = null;
110+ autoscroller.dragging = false
116+ property var scopeStyle: ScopeStyle {}
43 onStateChanged: {
118 onStateChanged: {
44 if (state == "edit") {
119 if (state == "edit") {
45 // As per design entering edit mode clears the possible existing search
120 // As per design entering edit mode clears the possible existing search
@@ -73,7 +148,8 @@ Item {
76− Flickable {
151+ ListView {
152+ id: scopesListFlickable
77 objectName: "scopesListFlickable"
153 objectName: "scopesListFlickable"
78 anchors {
154 anchors {
79 top: header.bottom
155 top: header.bottom
@@ -82,43 +158,34 @@ Item {
82 right: parent.right
158 right: parent.right
84 clip: true
160 clip: true
85− contentWidth: root.width
86− contentHeight: column.height
87− onContentHeightChanged: returnToBounds();
91− model: scope ? scope.categories : null
161+ model: scope ? scope.categories : null
93− delegate: Loader {
162+ delegate: Loader {
94− asynchronous: true
163+ asynchronous: true
95− width: root.width
164+ width: root.width
96− active: results.count > 0
165+ active: results.count > 0
97− visible: active
166+ visible: active
98− sourceComponent: ScopesListCategory {
167+ sourceComponent: ScopesListCategory {
99− objectName: "scopesListCategory" + categoryId
168+ objectName: "scopesListCategory" + categoryId
101− model: results
170+ model: results
103− title: {
172+ title: {
104− if (isFavoritesFeed) return i18n.tr("Home");
173+ if (isFavoritesFeed) return i18n.tr("Home");
105− else if (isAlsoInstalled) return i18n.tr("Also installed");
174+ else if (isAlsoInstalled) return i18n.tr("Also installed");
106− else return name;
175+ 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);
178+ editMode: root.state == "edit"
179+ scopeStyle: root.scopeStyle
180+ isFavoritesFeed: categoryId == "favorites"
181+ isAlsoInstalled: categoryId == "other"
183+ onItemDragging: autoscroll(dragging, dragItem);
184+ onRequestFavorite: root.requestFavorite(scopeId, favorite);
185+ onRequestEditMode: root.state = "edit";
186+ onRequestScopeMoveTo: root.requestFavoriteMoveTo(scopeId, index);
187+ onRequestActivate: root.scope.activate(result, categoryId);
188+ onRequestRestore: root.requestRestore(scopeId);