on xenial help sign in
Add some spacing where the item is going to be dropped
commit1ecc5579d3c592a3e6bccfbe3e2e69de3be000c1 authorAlbert Astals <albert.astals@canonical.com> dateWed 29 Oct 2014, 11:57 (12 years ago) parent05d868e
2 files changed+80−59
qml/Dash/ScopesListCategory.qml+17−3 qml/Dash/ScopesListCategoryItem.qml+63−56
qml/Dash/ScopesListCategory.qml+17−3
@@ -61,15 +61,27 @@ Item {
6161 anchors.top: header.bottom
6262 delegate: Loader {
6363 id: loader
64+ readonly property bool addDropHint: {
65+ if (dragMarker.visible) {
66+ if (dragItem.originalIndex > index) {
67+ return dragMarker.index == index;
68+ } else {
69+ return dragMarker.index == index - 1;
70+ }
71+ } else {
72+ return false;
73+ }
74+ }
6475 asynchronous: true
6576 width: root.width
66− height: listItemHeight
67− clip: height != listItemHeight
77+ height: listItemHeight + (addDropHint ? units.gu(2) : 0)
78+ clip: height < listItemHeight
6879 Behavior on height { enabled: visible; UbuntuNumberAnimation { } }
6980 sourceComponent: ScopesListCategoryItem {
7081 objectName: "delegate" + index
7182
7283 width: root.width
84+ topMargin: height > listItemHeight ? height - listItemHeight : 0
7385
7486 icon: model.art || ""
7587 text: model.title || ""
@@ -101,6 +113,7 @@ Item {
101113 dragItem.text = text;
102114 dragItem.subtext = subtext;
103115 dragItem.originalY = mapToItem(root, 0, 0).y;
116+ dragItem.originalIndex = index;
104117 dragItem.y = dragItem.originalY;
105118 dragItem.x = units.gu(1);
106119 dragItem.visible = true;
@@ -136,13 +149,14 @@ Item {
136149 if (i >= model.count - 1) i = model.count - 1;
137150 return i;
138151 }
139− y: list.y + index * listItemHeight
152+ y: list.y + index * listItemHeight + units.gu(1)
140153 }
141154
142155 ScopesListCategoryItem {
143156 id: dragItem
144157
145158 property real originalY
159+ property int originalIndex
146160 property var loaderToShrink: null
147161
148162 objectName: "dragItem"
qml/Dash/ScopesListCategoryItem.qml+63−56
@@ -25,6 +25,7 @@ MouseArea {
2525 signal handlePressed(var handle)
2626 signal handleReleased(var handle)
2727
28+ property real topMargin: 0
2829 property alias icon: shapeImage.source
2930 property alias text: titleLabel.text
3031 property alias subtext: subtitleLabel.text
@@ -33,65 +34,71 @@ MouseArea {
3334 property bool isFavorite: false
3435 property bool hideChildren: false
3536
36− UbuntuShape {
37− id: shape
38− anchors {
39− left: parent.left
40− leftMargin: units.gu(1)
41− verticalCenter: parent.verticalCenter
42− }
43− width: units.gu(5)
44− height: units.gu(5)
45− visible: !hideChildren
46− image: Image {
47− id: shapeImage
48− cache: true
49− fillMode: Image.PreserveAspectCrop
50− }
51− }
37+ Item {
38+ id: holder
39+ anchors.fill: parent
40+ anchors.topMargin: root.topMargin
5241
53− ColumnLayout {
54− visible: !hideChildren
55− anchors {
56− left: shape.right
57− leftMargin: units.gu(1)
58− right: starArea.right
59− rightMargin: units.gu(1)
60− verticalCenter: parent.verticalCenter
61− }
62− Label {
63− id: titleLabel
64− elide: Text.ElideRight
65− wrapMode: Text.Wrap
66− maximumLineCount: 1
67− verticalAlignment: Text.AlignHCenter
68− }
69− Label {
70− id: subtitleLabel
71− elide: Text.ElideRight
72− fontSize: "xx-small"
73− wrapMode: Text.Wrap
74− maximumLineCount: 1
75− verticalAlignment: Text.AlignHCenter
76− visible: text != ""
42+ UbuntuShape {
43+ id: shape
44+ anchors {
45+ left: parent.left
46+ leftMargin: units.gu(1)
47+ verticalCenter: parent.verticalCenter
48+ }
49+ width: units.gu(5)
50+ height: units.gu(5)
51+ visible: !hideChildren
52+ image: Image {
53+ id: shapeImage
54+ cache: true
55+ fillMode: Image.PreserveAspectCrop
56+ }
7757 }
78− }
79− MouseArea {
80− id: starArea
81− height: parent.height
82− width: height
83− anchors.right: parent.right
84− onClicked: if (!editMode) root.requestFavorite(model.scopeId, !isFavorite);
85− onPressed: if (editMode) root.handlePressed(starArea);
86− onReleased: if (editMode) root.handleReleased(starArea);
87− Icon {
88− id: star
89− anchors.centerIn: parent
90− height: units.gu(2)
91− width: units.gu(2)
58+
59+ ColumnLayout {
9260 visible: !hideChildren
93− // TODO is view-grid-symbolic what we really want here? Looks good but seems semantically wrong
94− source: editMode ? "image://theme/view-grid-symbolic" : isFavorite ? "image://theme/starred" : "image://theme/non-starred"
61+ anchors {
62+ left: shape.right
63+ leftMargin: units.gu(1)
64+ right: starArea.right
65+ rightMargin: units.gu(1)
66+ verticalCenter: parent.verticalCenter
67+ }
68+ Label {
69+ id: titleLabel
70+ elide: Text.ElideRight
71+ wrapMode: Text.Wrap
72+ maximumLineCount: 1
73+ verticalAlignment: Text.AlignHCenter
74+ }
75+ Label {
76+ id: subtitleLabel
77+ elide: Text.ElideRight
78+ fontSize: "xx-small"
79+ wrapMode: Text.Wrap
80+ maximumLineCount: 1
81+ verticalAlignment: Text.AlignHCenter
82+ visible: text != ""
83+ }
84+ }
85+ MouseArea {
86+ id: starArea
87+ height: parent.height
88+ width: height
89+ anchors.right: parent.right
90+ onClicked: if (!editMode) root.requestFavorite(model.scopeId, !isFavorite);
91+ onPressed: if (editMode) root.handlePressed(starArea);
92+ onReleased: if (editMode) root.handleReleased(starArea);
93+ Icon {
94+ id: star
95+ anchors.centerIn: parent
96+ height: units.gu(2)
97+ width: units.gu(2)
98+ visible: !hideChildren
99+ // TODO is view-grid-symbolic what we really want here? Looks good but seems semantically wrong
100+ source: editMode ? "image://theme/view-grid-symbolic" : isFavorite ? "image://theme/starred" : "image://theme/non-starred"
101+ }
95102 }
96103 }
97104}