/usr/share/unity-2d/shell/dash/MultiRangeView.qml is in unity-2d-shell 5.10.0-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 | /*
* This file is part of unity-2d
*
* Copyright 2010-2011 Canonical Ltd.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 1.0
FocusScope {
id: multiRangeView
property alias model: list.model
property alias count: list.count
property int cellWidth: Math.floor(width / count)
/* Keep track of active cells with array, from which determine index
of leftmost and rightmost active cells.*/
property variant activeCells: Array(count)
property int leftActiveCell: -1
property int rightActiveCell: -1
function cellActivationChanged(cellId, state) {
var tmp = activeCells
tmp[cellId] = state
activeCells = tmp
setSelectionBarPosition()
}
function setSelectionBarPosition() {
leftActiveCell = activeCells.indexOf(true)
rightActiveCell = activeCells.lastIndexOf(true);
}
Rectangle {
id: container
/* FIXME: Rectangle's borders grow half inside and half outside of the
rectangle. In order to avoid it being clipped, we adjust its size
and position depending on its border's width.
Ref.: http://lists.qt.nokia.com/pipermail/qt-qml/2010-May/000264.html
*/
x: Math.floor(border.width / 2)
y: Math.floor(border.width / 2)
width: parent.width - border.width
height: parent.height - border.width
border.color: "#21ffffff" // 80% opaque white
border.width: 1
color: "transparent"
radius: 5
}
ListView {
id: list
anchors.fill: parent
orientation: ListView.Horizontal
focus: true
boundsBehavior: Flickable.StopAtBounds
delegate: MultiRangeButton {
height: ListView.view.height
width: cellWidth
text: item.name
checked: item.active
onClicked: item.active = !item.active
onCheckedChanged: cellActivationChanged(model.index, checked)
isLast: ( model.index == count-1 )
Component.onCompleted: cellActivationChanged(model.index, item.active)
}
}
MultiRangeSelectionBar {
id: selectionBar
visible: ( leftActiveCell != -1 && rightActiveCell != -1 )
isFirst: ( leftActiveCell == 0 )
isLast: ( rightActiveCell == count-1 )
leftPos: ( leftActiveCell == 0 ) ? 0 : leftActiveCell*cellWidth-2
/* Hack: Rounding errors can mean the right of the selectionBar fails
to wholly cover the container Rectangle (and its border) */
rightPos: ( rightActiveCell == count-1 ) ? parent.width : (rightActiveCell+1)*cellWidth+3
}
}
|