Changeset View
Changeset View
Standalone View
Standalone View
applets/kickoff/package/contents/ui/KickoffListView.qml
Show First 20 Lines • Show All 90 Lines • ▼ Show 20 Line(s) | 84 | delegate: KickoffItem { | |||
---|---|---|---|---|---|
91 | onAddBreadcrumb: view.addBreadcrumb(model, title) | 91 | onAddBreadcrumb: view.addBreadcrumb(model, title) | ||
92 | } | 92 | } | ||
93 | 93 | | |||
94 | section { | 94 | section { | ||
95 | property: "group" | 95 | property: "group" | ||
96 | criteria: ViewSection.FullString | 96 | criteria: ViewSection.FullString | ||
97 | delegate: SectionDelegate {} | 97 | delegate: SectionDelegate {} | ||
98 | } | 98 | } | ||
99 | } | | |||
100 | } | | |||
101 | 99 | | |||
102 | MouseArea { | 100 | MouseArea { | ||
103 | anchors.left: parent.left | 101 | anchors.left: parent.left | ||
104 | 102 | | |||
105 | width: scrollArea.viewport.width | 103 | width: scrollArea.viewport.width | ||
106 | height: parent.height | 104 | height: parent.height | ||
107 | 105 | | |||
108 | id: mouseArea | 106 | id: mouseArea | ||
109 | 107 | | |||
110 | property Item pressed: null | 108 | property Item pressed: null | ||
111 | property int pressX: -1 | 109 | property int pressX: -1 | ||
112 | property int pressY: -1 | 110 | property int pressY: -1 | ||
111 | property bool tapandhold: false | ||||
113 | 112 | | |||
114 | hoverEnabled: true | 113 | hoverEnabled: true | ||
115 | acceptedButtons: Qt.LeftButton | Qt.RightButton | 114 | acceptedButtons: Qt.LeftButton | Qt.RightButton | ||
116 | 115 | | |||
117 | onPressed: { | 116 | onPressed: { | ||
118 | var mapped = listView.mapToItem(listView.contentItem, mouse.x, mouse.y); | 117 | var mapped = listView.mapToItem(listView.contentItem, mouse.x, mouse.y); | ||
119 | var item = listView.itemAt(mapped.x, mapped.y); | 118 | var item = listView.itemAt(mapped.x, mapped.y); | ||
120 | 119 | | |||
Show All 12 Lines | 129 | } else { | |||
133 | pressY = mouse.y; | 132 | pressY = mouse.y; | ||
134 | } | 133 | } | ||
135 | } | 134 | } | ||
136 | 135 | | |||
137 | onReleased: { | 136 | onReleased: { | ||
138 | var mapped = listView.mapToItem(listView.contentItem, mouse.x, mouse.y); | 137 | var mapped = listView.mapToItem(listView.contentItem, mouse.x, mouse.y); | ||
139 | var item = listView.itemAt(mapped.x, mapped.y); | 138 | var item = listView.itemAt(mapped.x, mapped.y); | ||
140 | 139 | | |||
141 | if (item && pressed === item) { | 140 | if (item && pressed === item && !tapandhold) { | ||
142 | if (item.appView) { | 141 | if (item.appView) { | ||
142 | if (mouse.source == Qt.MouseEventSynthesizedByQt) { | ||||
davidedmundson: why do we need this? | |||||
Probably so click-and-hold doesn't trigger these behaviors when not using a touchscreen. ngraham: Probably so click-and-hold doesn't trigger these behaviors when not using a touchscreen. | |||||
This is the Fix for Bug: 406361 steffenh: This is the Fix for Bug: 406361
In the appView the listView.currentItem will get open, but… | |||||
143 | positionChanged(mouse); | ||||
144 | } | ||||
143 | view.state = "OutgoingLeft"; | 145 | view.state = "OutgoingLeft"; | ||
144 | } else { | 146 | } else { | ||
145 | item.activate(); | 147 | item.activate(); | ||
146 | } | 148 | } | ||
147 | 149 | | |||
148 | listView.currentIndex = -1; | 150 | listView.currentIndex = -1; | ||
149 | } | 151 | } | ||
150 | 152 | | |||
153 | if (tapandhold && mouse.source == Qt.MouseEventSynthesizedByQt) { | ||||
154 | if (item.hasActionList) { | ||||
155 | mapped = listView.contentItem.mapToItem(item, mapped.x, mapped.y); | ||||
156 | listView.currentItem.openActionMenu(mapped.x, mapped.y); | ||||
157 | } | ||||
158 | } | ||||
151 | pressed = null; | 159 | pressed = null; | ||
152 | pressX = -1; | 160 | pressX = -1; | ||
153 | pressY = -1; | 161 | pressY = -1; | ||
162 | tapandhold = false; | ||||
154 | } | 163 | } | ||
155 | 164 | | |||
156 | onPositionChanged: { | 165 | onPositionChanged: { | ||
157 | var mapped = listView.mapToItem(listView.contentItem, mouse.x, mouse.y); | 166 | var mapped = listView.mapToItem(listView.contentItem, mouse.x, mouse.y); | ||
158 | var item = listView.itemAt(mapped.x, mapped.y); | 167 | var item = listView.itemAt(mapped.x, mapped.y); | ||
159 | 168 | | |||
160 | if (item) { | 169 | if (item) { | ||
161 | listView.currentIndex = item.itemIndex; | 170 | listView.currentIndex = item.itemIndex; | ||
162 | } else { | 171 | } else { | ||
163 | listView.currentIndex = -1; | 172 | listView.currentIndex = -1; | ||
164 | } | 173 | } | ||
165 | 174 | | |||
175 | if (mouse.source != Qt.MouseEventSynthesizedByQt || tapandhold) { | ||||
166 | if (pressed && pressX != -1 && pressed.url && dragHelper.isDrag(pressX, pressY, mouse.x, mouse.y)) { | 176 | if (pressed && pressX != -1 && pressed.url && dragHelper.isDrag(pressX, pressY, mouse.x, mouse.y)) { | ||
167 | kickoff.dragSource = item; | 177 | kickoff.dragSource = item; | ||
168 | dragHelper.startDrag(root, pressed.url, pressed.decoration); | 178 | dragHelper.startDrag(root, pressed.url, pressed.decoration); | ||
169 | pressed = null; | 179 | pressed = null; | ||
170 | pressX = -1; | 180 | pressX = -1; | ||
171 | pressY = -1; | 181 | pressY = -1; | ||
182 | tapandhold = false | ||||
183 | } | ||||
172 | } | 184 | } | ||
173 | } | 185 | } | ||
174 | 186 | | |||
175 | onContainsMouseChanged: { | 187 | onContainsMouseChanged: { | ||
176 | if (!containsMouse) { | 188 | if (!containsMouse) { | ||
177 | pressed = null; | 189 | pressed = null; | ||
178 | pressX = -1; | 190 | pressX = -1; | ||
179 | pressY = -1; | 191 | pressY = -1; | ||
192 | tapandhold = false | ||||
193 | } | ||||
194 | } | ||||
195 | | ||||
196 | onPressAndHold: { | ||||
197 | if (mouse.source == Qt.MouseEventSynthesizedByQt) { | ||||
198 | tapandhold = true; | ||||
davidedmundson: we tend to useCamelCaseForVariables | |||||
199 | positionChanged(mouse); | ||||
ngraham: remove extra leading space here | |||||
200 | } | ||||
201 | } | ||||
180 | } | 202 | } | ||
181 | } | 203 | } | ||
182 | } | 204 | } | ||
183 | } | 205 | } |
why do we need this?