2
* Copyright (C) 2013 Canonical, Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; version 3.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
import Ubuntu.Components 0.1
19
import Unity.Indicators 0.1 as Indicators
20
import "../Components"
21
import "../Components/Flickables" as Flickables
26
readonly property alias currentItem : itemView.currentItem
27
readonly property alias currentItemIndex: itemView.currentIndex
28
readonly property alias row: itemView
29
property QtObject indicatorsModel: null
30
property int overFlowWidth: width
31
property bool showAll: false
32
property real currentItemOffset: 0.0
33
property real unitProgress: 0.0
38
function setDefaultItem() {
39
// The leftmost indicator
40
setCurrentItemIndex(0);
43
function setCurrentItemIndex(index) {
44
itemView.currentIndex = index;
47
function setCurrentItem(item) {
48
if (item && item.hasOwnProperty("ownIndex")) {
49
itemView.currentIndex = item.ownIndex;
51
itemView.currentIndex = -1;
66
objectName: "indicatorRowItems"
68
model: indicatorsModel ? indicatorsModel : null
70
width: childrenRect.width
71
height: indicatorRow.height
72
anchors.right: parent.right
73
orientation: ListView.Horizontal
75
property int lastCount: 0
77
if (lastCount < count) {
86
objectName: "item" + index
87
height: indicatorRow.height
88
width: indicatorItem.width
89
opacity: 1 - indicatorRow.unitProgress
93
property int ownIndex: index
94
property bool highlighted: indicatorRow.unitProgress > 0 ? ListView.isCurrentItem : false
95
property bool dimmed: indicatorRow.unitProgress > 0 ? !ListView.isCurrentItem : false
97
property bool hidden: !showAll && !highlighted && (indicatorRow.state == "locked" || indicatorRow.state == "commit")
98
property bool overflow: row.width - itemWrapper.x > overFlowWidth
102
identifier: model.identifier
103
height: parent.height
105
dimmed: itemWrapper.dimmed
107
widgetSource: model.widgetSource
108
indicatorProperties : model.indicatorProperties
114
when: !hidden && !overflow && !highlighted
119
PropertyChanges { target: itemWrapper; opacity: 1.0 }
123
when: hidden || overflow
124
PropertyChanges { target: itemWrapper; opacity: 0.0 }
128
Behavior on opacity { UbuntuNumberAnimation { duration: UbuntuAnimation.BriskDuration } }
135
color: Theme.palette.selected.foreground
136
objectName: "highlight"
138
anchors.top: row.bottom
139
visible: indicatorRow.currentItem != null
141
property real intendedX: row.x + (indicatorRow.currentItem != null ? (indicatorRow.currentItem.x - row.originX) + centerOffset : 0)
142
x: intendedX >= row.x ? (intendedX + width <= row.x + row.width ? intendedX : row.x + row.width - width) : row.x // listview boundaries
143
width: indicatorRow.currentItem != null ? indicatorRow.currentItem.width : 0
145
property real centerOffset: {
146
if (indicatorRow.currentItemOffset > 0.1) {
147
return (indicatorRow.currentItemOffset - 0.1) * units.gu(0.4);
148
} else if (indicatorRow.currentItemOffset < -0.1) {
149
return (indicatorRow.currentItemOffset + 0.1) * units.gu(0.4);
155
enabled: unitProgress > 0;
156
UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }
159
enabled: unitProgress > 0;
160
UbuntuNumberAnimation { duration: UbuntuAnimation.FastDuration }