18 import Ubuntu.Components 0.1
20 import
"../Components"
25 property var model: null
26 property var scopes: null
27 readonly
property alias currentIndex: dashContentList.currentIndex
28 property alias previewOpen: previewListView.open
30 property ListModel searchHistory
32 signal scopeLoaded(
string scopeId)
33 signal gotoScope(
string scopeId)
34 signal openScope(var scope)
38 property var set_current_index: undefined
42 if (scopes.loaded && set_current_index != undefined) {
43 setCurrentScopeAtIndex(set_current_index[0], set_current_index[1], set_current_index[2]);
44 set_current_index = undefined;
49 function setCurrentScopeAtIndex(index, animate, reset) {
52 set_current_index = [ index, animate, reset ]
56 var storedMoveDuration = dashContentList.highlightMoveDuration
57 var storedMoveSpeed = dashContentList.highlightMoveVelocity
59 dashContentList.highlightMoveVelocity = units.gu(4167)
60 dashContentList.highlightMoveDuration = 0
63 set_current_index = undefined;
65 if (dashContentList.count > index)
67 dashContentList.currentIndex = index
70 dashContentList.currentItem.item.positionAtBeginning()
75 dashContentList.highlightMoveDuration = storedMoveDuration
76 dashContentList.highlightMoveVelocity = storedMoveSpeed
80 function closeScope(scope) {
81 dashContentList.currentItem.theScope.closeScope(scope)
84 function closePreview() {
85 previewListView.open =
false;
89 id: dashContentListHolder
91 x: previewListView.open ? -width : 0
92 Behavior on x { UbuntuNumberAnimation { } }
98 objectName:
"dashContentList"
100 interactive: dashContent.scopes.loaded && !previewListView.open && currentItem && !currentItem.moving
103 model: dashContent.model
104 orientation: ListView.Horizontal
105 boundsBehavior: Flickable.DragAndOvershootBounds
106 flickDeceleration: units.gu(625)
107 maximumFlickVelocity: width * 5
108 snapMode: ListView.SnapOneItem
109 highlightMoveDuration: 250
110 highlightRangeMode: ListView.StrictlyEnforceRange
112 cacheBuffer: 1073741823
113 onMovementStarted: currentItem.item.showHeader();
119 if (currentIndex >= count) {
120 dashContent.setCurrentScopeAtIndex(count-1,
true,
true)
121 }
else if (currentIndex < 0) {
123 dashContentList.currentIndex = 0
130 width: ListView.view.width
131 height: ListView.view.height
135 source: (scope.id ==
"clickscope") ?
"DashApps.qml" :
"GenericScopeView.qml"
136 objectName: scope.id +
" loader"
138 readonly property
bool moving: item ? item.moving :
false
139 readonly property var categoryView: item ? item.categoryView : null
140 readonly property Scope theScope: scope
143 readonly property
string scopeId: scope.id
144 readonly property
bool isCurrent: ListView.isCurrentItem
145 readonly property
bool isLoaded: status == Loader.Ready
148 item.objectName = scope.id
149 item.pageHeader = dashPageHeader;
150 item.previewListView = previewListView;
151 item.scope = Qt.binding(
function() {
return scope })
152 item.isCurrent = Qt.binding(
function() {
return visible && ListView.isCurrentItem })
153 item.tabBarHeight = dashPageHeader.implicitHeight;
154 dashContent.scopeLoaded(item.scope.id)
157 target: isCurrent ? scope : null
160 dashContent.gotoScope(scopeId);
163 dashContent.openScope(scope);
167 Component.onDestruction: active =
false
173 objectName:
"pageHeader"
175 searchEntryEnabled:
true
176 searchHistory: dashContent.searchHistory
177 scope: dashContentList.currentItem && dashContentList.currentItem.theScope
182 height: units.gu(6.5)
184 style: DashContentTabBarStyle {}
186 model: dashContentList.model
188 onSelectedIndexChanged: {
189 if (dashContentList.currentIndex == -1 && tabBar.selectedIndex != -1) {
194 selectionModeTimer.restart();
196 dashContentList.currentIndex = selectedIndex;
200 target: dashContentList
201 onCurrentIndexChanged: {
202 tabBar.selectedIndex = dashContentList.currentIndex
207 id: selectionModeTimer
209 onTriggered: tabBar.selectionMode =
false
217 objectName:
"dashContentPreviewList"
219 scope: dashContentList.currentItem ? dashContentList.currentItem.theScope : null
220 pageHeader: dashPageHeader
222 height: parent.height
223 anchors.left: dashContentListHolder.right