2
* Copyright 2011 Canonical Ltd.
5
* Olivier Tilloy <olivier@tilloy.net>
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; version 3.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
25
property int animationDuration: 150
26
property alias model: crumbslist.model
27
property alias count: crumbslist.count
29
function addCrumb(text, view, key) {
30
crumbslist.model.append({ label: text, view: view, key: key })
33
function removeCrumb() {
34
if (crumbslist.model.count > 1) {
35
crumbslist.model.remove(crumbslist.model.count - 1)
39
signal crumbClicked(int index)
41
SystemPalette { id: activePalette }
51
orientation: ListView.Horizontal
56
property real margins: 10
57
property real fullWidth: text.paintedWidth + 2 * margins
60
height: crumbslist.height
63
border.color: activePalette.shadow
64
color: mousearea.containsMouse && !mousearea.pressed ? activePalette.light : activePalette.button
70
anchors.verticalCenter: parent.verticalCenter
72
color: activePalette.buttonText
81
while ((crumbslist.model.count - 1) > index) {
82
breadcrumbs.removeCrumb()
84
breadcrumbs.crumbClicked(index)
88
ListView.onAdd: SequentialAnimation {
89
PropertyAction { target: delegate; property: "ListView.delayRemove"; value: true }
90
PropertyAction { target: delegate; property: "width"; value: 0 }
91
NumberAnimation { target: delegate; property: "width"; to: fullWidth; duration: breadcrumbs.animationDuration }
92
PropertyAction { target: delegate; property: "ListView.delayRemove"; value: false }
94
ListView.onRemove: SequentialAnimation {
95
PropertyAction { target: delegate; property: "ListView.delayRemove"; value: true }
96
NumberAnimation { target: delegate; property: "width"; to: 0; duration: breadcrumbs.animationDuration }
97
PropertyAction { target: delegate; property: "ListView.delayRemove"; value: false }