@@ -15,7 +15,7 @@
17import QtQuick 2.0
17import QtQuick 2.0
18−import Ubuntu.Components 1.1;
18+import Ubuntu.Components 1.1
19import Dash 0.1
19import Dash 0.1
20import "../Components/ListItems" as ListItems
20import "../Components/ListItems" as ListItems
@@ -27,8 +27,11 @@ Item {
27 property bool isFavoriteFeeds: false
27 property bool isFavoriteFeeds: false
28 property bool editMode: false
28 property bool editMode: false
30+ visible: !editMode || isFavoriteFeeds
30 signal requestFavorite(string scopeId, bool favorite)
32 signal requestFavorite(string scopeId, bool favorite)
31 signal requestEditMode()
33 signal requestEditMode()
34+ signal requestScopeMoveTo(string scopeId, int index)
33 implicitHeight: childrenRect.height
36 implicitHeight: childrenRect.height
@@ -43,10 +46,12 @@ Item {
43 property var myTemplate: JSON.parse('{"card-layout":"horizontal","card-size":"small","category-layout":"grid","collapsed-rows":2}')
46 property var myTemplate: JSON.parse('{"card-layout":"horizontal","card-size":"small","category-layout":"grid","collapsed-rows":2}')
44 property var myComponents: JSON.parse('{"art":{"aspect-ratio":1,"field":"art"},"title":{"field":"title"},"attributes":{}}')
47 property var myComponents: JSON.parse('{"art":{"aspect-ratio":1,"field":"art"},"title":{"field":"title"},"attributes":{}}')
49+ readonly property double listItemHeight: units.gu(6)
46 ListView {
51 ListView {
49− readonly property double targetHeight: model.count * units.gu(6)
54+ readonly property double targetHeight: model.count * listItemHeight
50 clip: height != targetHeight
55 clip: height != targetHeight
51 height: targetHeight
56 height: targetHeight
52 Behavior on height { enabled: visible; UbuntuNumberAnimation { } }
57 Behavior on height { enabled: visible; UbuntuNumberAnimation { } }
@@ -59,59 +64,63 @@ Item {
59 delegate: Loader {
64 delegate: Loader {
60 asynchronous: true
65 asynchronous: true
61 width: root.width
66 width: root.width
62− height: units.gu(6)
67+ height: listItemHeight
63− sourceComponent: MouseArea {
68+ sourceComponent: ScopesListCategoryItem {
64 width: root.width
69 width: root.width
66− id: shape
71+ icon: model.art || ""
67− anchors {
72+ text: model.title || ""
68− left: parent.left
73+ showStar: model.scopeId != "clickscope"
69− leftMargin: units.gu(1)
74+
70− verticalCenter: parent.verticalCenter
75+ onRequestFavorite: root.requestFavorite(model.scopeId, favorite);
71− }
76+ onPressAndHold: {
72− width: units.gu(5)
77+ if (!editMode) {
73− height: units.gu(5)
78+ root.requestEditMode();
74− image: Image {
79+ } else {
75− source: model["art"] || ""
80+ dragItem.icon = icon;
76− cache: true
81+ dragItem.text = text;
77− fillMode: Image.PreserveAspectCrop
82+ dragItem.x = units.gu(1)
78− }
83+ dragItem.y = mapToItem(root, 0, 0).y + units.gu(1)
79− }
84+ drag.target = dragItem;
80− Label {
85+ dragItem.visible = true;
84− leftMargin: units.gu(1)
86− rightMargin: units.gu(1)
87− verticalCenter: parent.verticalCenter
89− text: model["title"] || ""
90− elide: Text.ElideRight
93− verticalAlignment: Text.AlignHCenter
95− Icon {
88+ onReleased: {
96− id: star
89+ if (dragItem.visible) {
97− anchors {
90+ dragItem.visible = false;
98− right: parent.right
91+ if (dragMarker.index != index && dragMarker.index != index + 1) {
99− rightMargin: units.gu(1)
92+ var targetIndex = dragMarker.index > index ? dragMarker.index - 1 : dragMarker.index;
100− verticalCenter: parent.verticalCenter
93+ root.requestScopeMoveTo(model.scopeId, targetIndex);
104− visible: model.scopeId != "clickscope" && (isFavoriteFeeds || !editMode)
105− // TODO is view-grid-symbolic what we really want here? Looks good but seems semantically wrong
106− source: editMode ? "image://theme/view-grid-symbolic" : isFavoriteFeeds ? "image://theme/starred" : "image://theme/non-starred"
108− anchors.fill: parent
109− onClicked: root.requestFavorite(model.scopeId, !isFavoriteFeeds);
113− onPressAndHold: root.requestEditMode();
107+ visible: dragItem.visible
108+ property int index: {
109+ var i = Math.round((dragItem.y - list.y) / listItemHeight);
111+ if (i >= model.count) i = model.count;
114+ y: list.y + index * listItemHeight
117+ ScopesListCategoryItem {
119+ objectName: "dragItem"
123+ height: listItemHeight