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/>.
18import Ubuntu.Components 0.1
24 property var model: null
25 property var scopes: null
26 property real contentProgress: Math.max(0, Math.min(dashContentList.contentX / (dashContentList.contentWidth - dashContentList.width), units.dp(1)))
27 property alias currentIndex: dashContentList.currentIndex
29 property ScopeDelegateMapper scopeMapper : ScopeDelegateMapper {}
30 property ListModel searchHistory
32 signal movementStarted()
33 signal movementEnded()
34 signal contentFlickStarted()
35 signal contentEndReached()
37 signal scopeLoaded(string scopeId)
38 signal positionedAtBeginning()
40 // If we set the current scope index before the scopes have been added,
41 // then we need to wait until the loaded signals gets emitted from the scopes
42 property var set_current_index: undefined
46 if (scopes.loaded && set_current_index != undefined) {
47 setCurrentScopeAtIndex(set_current_index[0], set_current_index[1], set_current_index[2]);
48 set_current_index = undefined;
53 function setCurrentScopeAtIndex(index, animate, reset) {
54 var storedMoveDuration = dashContentList.highlightMoveDuration
55 var storedMoveSpeed = dashContentList.highlightMoveVelocity
57 dashContentList.highlightMoveVelocity = units.gu(4167)
58 dashContentList.highlightMoveDuration = 0
61 // if the scopes haven't loaded yet, then wait until they are.
63 set_current_index = [ index, animate, reset ]
66 set_current_index = undefined;
68 if (dashContentList.count > index)
70 dashContentList.currentIndex = index
73 dashContent.positionedAtBeginning()
78 dashContentList.highlightMoveDuration = storedMoveDuration
79 dashContentList.highlightMoveVelocity = storedMoveSpeed
85 objectName: "dashContentList"
87 interactive: dashContent.scopes.loaded && !currentItem.previewShown && !currentItem.moving
90 model: dashContent.model
91 orientation: ListView.Horizontal
92 boundsBehavior: Flickable.DragAndOvershootBounds
93 flickDeceleration: units.gu(625)
94 maximumFlickVelocity: width * 5
95 snapMode: ListView.SnapOneItem
96 highlightMoveDuration: 250
97 highlightRangeMode: ListView.StrictlyEnforceRange
98 /* FIXME: workaround rendering issue due to use of ShaderEffectSource in
99 UbuntuShape. While switching from the home scope to the People scope the
100 rendering would block midway.
102 cacheBuffer: 2147483647
103 onMovementStarted: dashContent.movementStarted()
104 onMovementEnded: dashContent.movementEnded()
106 // If the number of items is less than the current index, then need to reset to another item.
109 if (currentIndex >= count) {
110 dashContent.setCurrentScopeAtIndex(count-1, true, true)
111 } else if (currentIndex < 0) {
112 // setting currentIndex directly, cause we don't want to loose set_current_index
113 dashContent.currentIndex = 0
120 width: ListView.view.width
121 height: ListView.view.height
123 source: scopeMapper.map(scope.id)
124 objectName: scope.id + " loader"
126 readonly property bool previewShown: item ? item.previewShown : false
127 readonly property bool moving: item ? item.moving : false
129 // these are needed for autopilot tests
130 readonly property string scopeId: scope.id
131 readonly property bool isCurrent: ListView.isCurrentItem
132 readonly property bool isLoaded: status == Loader.Ready
135 item.scope = Qt.binding(function() { return scope })
136 item.isCurrent = Qt.binding(function() { return visible && ListView.isCurrentItem })
137 item.searchHistory = Qt.binding(function() { return dashContent.searchHistory })
138 dashContentList.movementStarted.connect(item.movementStarted)
139 dashContent.positionedAtBeginning.connect(item.positionedAtBeginning)
140 dashContent.scopeLoaded(item.scope.id)
144 ignoreUnknownSignals: true
145 onEndReached: contentEndReached()
146 onPreviewShownChanged: {
147 if (item.previewShown) {
148 dashContent.previewShown()
153 Component.onDestruction: active = false
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list