18 import Ubuntu.Components 0.1
21 import
"../Components"
26 property var model: null
27 property var scopes: null
28 readonly
property alias currentIndex: dashContentList.currentIndex
29 property alias previewOpen: previewListView.open
31 property ListModel searchHistory
33 signal scopeLoaded(
string scopeId)
34 signal gotoScope(
string scopeId)
35 signal openScope(var scope)
39 property var set_current_index: undefined
43 if (scopes.loaded && set_current_index != undefined) {
44 setCurrentScopeAtIndex(set_current_index[0], set_current_index[1], set_current_index[2]);
45 set_current_index = undefined;
50 function setCurrentScopeAtIndex(index, animate, reset) {
53 set_current_index = [ index, animate, reset ]
57 var storedMoveDuration = dashContentList.highlightMoveDuration
58 var storedMoveSpeed = dashContentList.highlightMoveVelocity
60 dashContentList.highlightMoveVelocity = units.gu(4167)
61 dashContentList.highlightMoveDuration = 0
64 set_current_index = undefined;
66 if (dashContentList.count > index)
68 dashContentList.currentIndex = index
71 dashContentList.currentItem.item.positionAtBeginning()
76 dashContentList.highlightMoveDuration = storedMoveDuration
77 dashContentList.highlightMoveVelocity = storedMoveSpeed
81 function closeScope(scope) {
82 dashContentList.currentItem.theScope.closeScope(scope)
85 function closePreview() {
86 previewListView.open =
false;
90 id: dashContentListHolder
92 x: previewListView.open ? -width : 0
93 Behavior on x { UbuntuNumberAnimation { } }
99 objectName:
"dashContentList"
101 interactive: dashContent.scopes.loaded && !previewListView.open && currentItem && !currentItem.moving
104 model: dashContent.model
105 orientation: ListView.Horizontal
106 boundsBehavior: Flickable.DragAndOvershootBounds
107 flickDeceleration: units.gu(625)
108 maximumFlickVelocity: width * 5
109 snapMode: ListView.SnapOneItem
110 highlightMoveDuration: 250
111 highlightRangeMode: ListView.StrictlyEnforceRange
113 cacheBuffer: 1073741823
114 onMovementStarted: currentItem.item.showHeader();
120 if (currentIndex >= count) {
121 dashContent.setCurrentScopeAtIndex(count-1,
true,
true)
122 }
else if (currentIndex < 0) {
124 dashContentList.currentIndex = 0
131 width: ListView.view.width
132 height: ListView.view.height
136 source: (scope.id ==
"clickscope") ?
"DashApps.qml" :
"GenericScopeView.qml"
137 objectName: scope.id +
" loader"
139 readonly property
bool moving: item ? item.moving :
false
140 readonly property var categoryView: item ? item.categoryView : null
141 readonly property Scope theScope: scope
144 readonly property
string scopeId: scope.id
145 readonly property
bool isCurrent: ListView.isCurrentItem
146 readonly property
bool isLoaded: status == Loader.Ready
149 item.objectName = scope.id
150 item.pageHeader = dashPageHeader;
151 item.previewListView = previewListView;
152 item.scope = Qt.binding(
function() {
return scope })
153 item.isCurrent = Qt.binding(
function() {
return visible && ListView.isCurrentItem })
154 item.tabBarHeight = dashPageHeader.implicitHeight;
155 dashContent.scopeLoaded(item.scope.id)
158 target: isCurrent ? scope : null
161 dashContent.gotoScope(scopeId);
164 dashContent.openScope(scope);
168 Component.onDestruction: active =
false
174 objectName:
"pageHeader"
176 searchEntryEnabled:
true
177 searchHistory: dashContent.searchHistory
178 scope: dashContentList.currentItem && dashContentList.currentItem.theScope
183 height: units.gu(6.5)
185 style: DashContentTabBarStyle {}
187 SortFilterProxyModel {
190 model: dashContentList.model
192 property int selectedIndex: -1
193 onSelectedIndexChanged: {
194 if (dashContentList.currentIndex == -1 && tabBar.selectedIndex != -1) {
199 selectionModeTimer.restart();
201 dashContentList.currentIndex = selectedIndex;
205 model: tabBarModel.count > 0 ? tabBarModel : null
208 target: dashContentList
209 onCurrentIndexChanged: {
210 tabBarModel.selectedIndex = dashContentList.currentIndex
215 id: selectionModeTimer
217 onTriggered: tabBar.selectionMode =
false
225 objectName:
"dashContentPreviewList"
227 scope: dashContentList.currentItem ? dashContentList.currentItem.theScope : null
228 pageHeader: dashPageHeader
230 height: parent.height
231 anchors.left: dashContentListHolder.right