This file is indexed.

/usr/lib/x86_64-linux-gnu/qt5/qml/Ubuntu/Components/Themes/Ambiance/1.3/ListItemStyle.qml is in ubuntu-ui-toolkit-theme 1.3.1918+16.04.20160404-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
/*
 * Copyright 2015 Canonical Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; version 3.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import QtQuick 2.4
import Ubuntu.Components.Styles 1.3 as Styles
import Ubuntu.Components 1.3

Styles.ListItemStyle {

    id: listItemStyle

    /*
     * Coloring properties
     */
    property color leadingPanelColor: theme.palette.normal.foreground
    property color trailingPanelColor: theme.palette.normal.foreground
    property color leadingForegroundColor: theme.palette.normal.negative
    property color trailingForegroundColor: theme.palette.normal.foregroundText
    property color leadingDisabledForegroundColor: theme.palette.disabled.negative
    property color trailingDisabledForegroundColor: theme.palette.disabled.foregroundText
    // anchoring
    anchors {
        // do not anchor fill
        fill: undefined
        top: parent ? parent.top : undefined
        bottom: parent ? parent.bottom : undefined
        bottomMargin: styledItem.divider.visible ? styledItem.divider.height : 0
        left: styledItem.contentItem.left
        leftMargin: -styledItem.contentItem.anchors.leftMargin
        right: styledItem.contentItem.right
        rightMargin: -styledItem.contentItem.anchors.rightMargin
    }
    LayoutMirroring.childrenInherit: true

    // leading/trailing panels
    Component {
        id: panelComponent
        Rectangle {
            id: panel
            objectName: "ListItemPanel" + (leading ? "Leading" : "Trailing")
            // add 0.5 GUs to the panel size so we get 2GU default margin on the first action
            readonly property real panelWidth: actionsRow.width + units.gu(0.5)

            color: leading ? leadingPanelColor : trailingPanelColor
            anchors.fill: parent

            readonly property ListItemActions itemActions: leading ? styledItem.leadingActions : styledItem.trailingActions

            Row {
                id: actionsRow
                anchors {
                    left: leading ? undefined : parent.left
                    right: leading ? parent.right : undefined
                    leftMargin: leading ? 0 : units.gu(0.5)
                    rightMargin: leading ? units.gu(0.5) : 0
                    top: parent.top
                    bottom: parent.bottom
                }

                readonly property real maxItemWidth: parent.width / itemActions.actions.length
                readonly property real minItemWidth: units.gu(6) // 2GU icon + 2* 2GU margin

                Repeater {
                    model: itemActions.actions
                    AbstractButton {
                        id: actionButton
                        action: modelData
                        enabled: action.enabled
                        activeFocusOnTab: false
                        width: MathUtils.clamp(delegateLoader.item ? delegateLoader.item.width : 0, actionsRow.minItemWidth, actionsRow.maxItemWidth)
                        anchors {
                            top: parent ? parent.top : undefined
                            bottom: parent ? parent.bottom : undefined
                        }
                        function trigger() {
                            internals.selectedAction = modelData;
                            listItemStyle.rebound();
                        }

                        Rectangle {
                            anchors.fill: parent
                            color: theme.palette.highlighted.background
                            visible: pressed
                        }

                        Loader {
                            id: delegateLoader
                            height: parent.height
                            sourceComponent: itemActions.delegate ? itemActions.delegate : defaultDelegate
                            property Action action: modelData
                            property int index: listItemIndex
                            property bool pressed: actionButton.pressed
                            onItemChanged: {
                                // use action's objectName to identify the visualized action
                                if (item && item.objectName === "") {
                                    item.objectName = modelData.objectName;
                                    actionButton.objectName = "actionbutton_" + modelData.objectName
                                }
                            }
                        }
                    }
                }
            }

            Component {
                id: defaultDelegate
                Item {
                    width: actionsRow.minItemWidth
                    Icon {
                        width: units.gu(2)
                        height: width
                        name: action.iconName
                        color: leading
                               ? (action.enabled ? leadingForegroundColor : leadingDisabledForegroundColor)
                               : (action.enabled ? trailingForegroundColor : trailingDisabledForegroundColor)
                        anchors.centerIn: parent
                    }
                }
            }
        }
    }
    // the selection/multiselection panel
    Component {
        id: selectionDelegate
        Item {
            id: selectPanel
            objectName: "selection_panel" + listItemIndex
            anchors.fill: parent ? parent : undefined

            CheckBox {
                id: checkbox
                opacity: 0
                // for unit and autopilot tests
                objectName: "listitem_select"
                anchors.centerIn: parent
                // for the initial value
                checked: styledItem.selected
                onCheckedChanged: styledItem.selected = checked;
                Binding {
                    target: checkbox
                    property: "checked"
                    value: styledItem.selected
                }
            }

            states: State {
                name: "enabled"
                when: loaded && styledItem.selectMode
                PropertyChanges {
                    target: checkbox
                    opacity: 1.0
                }
            }
            transitions: Transition {
                from: ""
                to: "*"
                reversible: true
                enabled: listItemStyle.animatePanels
                OpacityAnimator {
                    easing: UbuntuAnimation.StandardEasing
                    duration: UbuntuAnimation.FastDuration
                }
            }
        }
    }
    // drag panel
    Component {
        id: dragDelegate
        Item {
            id: dragPanel
            objectName: "drag_panel" + listItemIndex
            anchors.fill: parent ? parent : undefined
            Icon {
                objectName: "icon"
                id: dragIcon
                anchors.centerIn: parent
                width: units.gu(3)
                height: width
                name: "view-grid-symbolic"
                opacity: 0.0
                scale: 0.5
                color: theme.palette.normal.base
            }
            Binding {
                target: listItemStyle
                property: "dragPanel"
                value: dragPanel
            }

            states: State {
                name: "enabled"
                when: loaded && styledItem.dragMode
                PropertyChanges {
                    target: dragIcon
                    opacity: 1.0
                    scale: 1.0
                }
            }
            transitions: Transition {
                from: ""
                to: "*"
                reversible: true
                enabled: listItemStyle.animatePanels
                ParallelAnimation {
                    OpacityAnimator {
                        easing: UbuntuAnimation.StandardEasing
                        duration: UbuntuAnimation.FastDuration
                    }
                    ScaleAnimator {
                        easing: UbuntuAnimation.StandardEasing
                        duration: UbuntuAnimation.FastDuration
                    }
                }
            }
        }
    }

    // leading panel loader
    Loader {
        id: leadingLoader
        objectName: "leading_loader"
        anchors {
            top: parent.top
            bottom: parent.bottom
            right: parent.left
        }
        width: styledItem.width
        sourceComponent: styledItem.swiped && styledItem.leadingActions && styledItem.leadingActions.actions.length > 0 ?
                             panelComponent : null
        // context properties used in delegates
        readonly property bool leading: true
        readonly property bool loaded: status == Loader.Ready

        // panel states
        states: [
            State {
                name: "selectable"
                when: styledItem.selectMode
                PropertyChanges {
                    target: leadingLoader
                    sourceComponent: selectionDelegate
                    width: units.gu(5)
                }
                PropertyChanges {
                    target: listItemStyle
                    anchors.leftMargin: 0
                }
                PropertyChanges {
                    target: styledItem.contentItem
                    anchors.leftMargin: units.gu(5)
                }
            }
        ]
        transitions: Transition {
            from: ""
            to: "selectable"
            reversible: true
            enabled: listItemStyle.animatePanels
            PropertyAnimation {
                target: styledItem.contentItem
                properties: "anchors.leftMargin"
                easing: UbuntuAnimation.StandardEasing
                duration: UbuntuAnimation.FastDuration
            }
        }
    }
    // trailing panel loader
    Loader {
        id: trailingLoader
        objectName: "trailing_loader"
        anchors {
            top: parent.top
            bottom: parent.bottom
            left: parent.right
        }
        width: styledItem.width
        sourceComponent: styledItem.swiped && styledItem.trailingActions && styledItem.trailingActions.actions.length > 0 ?
                             panelComponent : null
        // context properties used in delegates
        readonly property bool leading: false
        readonly property bool loaded: status == Loader.Ready

        // panel states
        states: State {
            name: "draggable"
            when: styledItem.dragMode
            PropertyChanges {
                target: trailingLoader
                sourceComponent: dragDelegate
                width: units.gu(5)
            }
            PropertyChanges {
                target: listItemStyle
                anchors.rightMargin: 0
            }
            PropertyChanges {
                target: styledItem.contentItem
                anchors.rightMargin: units.gu(5)
            }
        }
        transitions: Transition {
            from: ""
            to: "*"
            reversible: true
            enabled: listItemStyle.animatePanels
            PropertyAnimation {
                target: styledItem.contentItem
                properties: "anchors.rightMargin"
                easing: UbuntuAnimation.StandardEasing
                duration: UbuntuAnimation.FastDuration
            }
        }
    }

    // internals
    QtObject {
        id: internals
        // action triggered
        property Action selectedAction
        // swipe handling
        readonly property Item swipedPanel: leadingPanel ? leadingLoader.item : trailingLoader.item
        readonly property bool leadingPanel: listItemStyle.LayoutMirroring.enabled ? (listItemStyle.x < 0) : (listItemStyle.x > 0)
        readonly property real swipedOffset: (leadingPanel ? listItemStyle.x : -listItemStyle.x) *
                                             (listItemStyle.LayoutMirroring.enabled ? -1 : 1)
        readonly property real panelWidth: swipedPanel && swipedPanel.hasOwnProperty("panelWidth") ? swipedPanel.panelWidth : 0
        property real prevX: 0.0
        property real snapChangerLimit: 0.0
        readonly property real threshold: units.gu(1.5)
        property bool snapIn: false
        property bool completed: false

        // update snap direction
        function updateSnapDirection() {
            if (prevX < listItemStyle.x && (snapChangerLimit <= listItemStyle.x)) {
                snapIn = (listItemStyle.LayoutMirroring.enabled !== leadingPanel);
                snapChangerLimit = listItemStyle.x - threshold;
            } else if (prevX > listItemStyle.x && (listItemStyle.x < snapChangerLimit)) {
                snapIn = (listItemStyle.LayoutMirroring.enabled === leadingPanel);
                snapChangerLimit = listItemStyle.x + threshold;
            }
            prevX = listItemStyle.x;
        }
        // perform snapIn/Out
        function snap() {
            var snapPos = (swipedOffset > units.gu(2) && snapIn) ? panelWidth : 0.0;
            snapPos *= leadingPanel ? 1 : -1;
            // invert snapPos on RTL
            snapPos *= listItemStyle.LayoutMirroring.enabled ? -1 : 1;
            snapAnimation.snapTo(snapPos);
        }
        // handle elasticity on overshoot
        function overshoot(event) {
            var offset = event.content.x - styledItem.contentItem.anchors.leftMargin;
            offset *= leadingPanel ? 1 : -1;
            // invert offset on RTL
            offset *= listItemStyle.LayoutMirroring.enabled ? -1 : 1;
            if (offset > panelWidth) {
                // do elastic move
                event.content.x = styledItem.contentItem.x + (event.to.x - event.from.x) / 2;
            }
        }
    }
    snapAnimation: SmoothedAnimation {
        objectName: "snap_animation"
        target: styledItem.contentItem
        property: "x"
        // use 50GU/second velocity
        velocity: units.gu(60)
        onStopped: {
            // trigger action
            if (to == styledItem.contentItem.anchors.leftMargin && internals.selectedAction) {
                internals.selectedAction.trigger(listItemIndex);
                internals.selectedAction = null;
            }
        }
        // animated snapping
        function snapTo(pos) {
            if (pos == to && styledItem.contentItem.x == to) {
                return;
            }

            stop();
            from = styledItem.contentItem.x;
            // add leading margin as the snapped out item's X coordinate is the leftMargin
            pos += styledItem.contentItem.anchors.leftMargin;
            to = pos;
            start();
        }
    }

    // simple drop animation
    dropAnimation: SmoothedAnimation {
        properties: "y"
        velocity: units.gu(60)
    }

    onXChanged: internals.updateSnapDirection()
    // overriding default functions
    function swipeEvent(event) {
        if (event.status == SwipeEvent.Started) {
            internals.prevX = x;
            snapAnimation.stop();
        } else if (event.status == SwipeEvent.Finished) {
            internals.snap();
        } else if (event.status == SwipeEvent.Updated) {
            // handle elasticity when overshooting
            internals.overshoot(event)
        }
    }
    function rebound() {
        snapAnimation.snapTo(0);
    }

    // expansion
    Component.onCompleted: internals.completed = true
    state: (internals.completed && styledItem.expansion.expanded) ? (listItemStyle.flickable ? "expandedWithFlickable" : "expandedNoFlickable") : ""
    states: [
        State {
            name: "expandedNoFlickable"
            PropertyChanges {
                target: styledItem
                height: styledItem.expansion.height
            }
        },
        State {
            name: "expandedWithFlickable"
            PropertyChanges {
                target: styledItem
                height: styledItem.expansion.height
            }
            PropertyChanges {
                target: listItemStyle.flickable
                // we do not need to restore the original values
                restoreEntryValues: false
                // and we should not get any binding updates even
                explicit: true
                contentY: {
                    var bottom = styledItem.y + styledItem.expansion.height - listItemStyle.flickable.contentY + listItemStyle.flickable.originY;
                    var dy = bottom - listItemStyle.flickable.height;
                    if (dy > 0) {
                        return listItemStyle.flickable.contentY + dy - listItemStyle.flickable.originY;
                    } else {
                        return listItemStyle.flickable.contentY;
                    }
                }
            }
        }
    ]
    transitions: [
        Transition {
            from: ""
            to: "expandedWithFlickable"
            reversible: true
            enabled: listItemStyle.animatePanels
            ParallelAnimation {
                UbuntuNumberAnimation {
                    target: listItemStyle.flickable
                    property: "contentY"
                }
                UbuntuNumberAnimation {
                    target: styledItem
                    property: "height"
                }
            }
        },
        Transition {
            from: ""
            to: "expandedNoFlickable"
            reversible: true
            enabled: listItemStyle.animatePanels
            UbuntuNumberAnimation {
                target: styledItem
                property: "height"
            }
        }
    ]
}