main.qml Example File
listdecorators/assets/main.qml
import bb.cascades 1.0
import bb.cascades.datamanager 1.2
import bb.cascades.decorators 1.2
Page {
titleBar: TitleBar {
kind: TitleBarKind.FreeForm
kindProperties: FreeFormTitleBarKindProperties {
Container {
layout: StackLayout {
orientation: LayoutOrientation.LeftToRight
}
leftPadding: 10
rightPadding: 10
verticalAlignment: VerticalAlignment.Center
Label {
text: "List Decorators"
layoutProperties: StackLayoutProperties {
spaceQuota: 7
}
textStyle {
base: SystemDefaults.TextStyles.TitleText
color: Color.White
}
verticalAlignment: VerticalAlignment.Center
}
ImageView {
layoutProperties: StackLayoutProperties {
spaceQuota: 1
}
imageSource: "asset:///images/ic_view_list.png"
}
}
}
}
actions: [
GroupArtistDecorator {
title: qsTr("GroupArtistModelDecorator")
imageSource: "asset:///images/list_group.png"
},
DataQualityDecorator {
title: qsTr("DataQualityDataQueryDecorator")
imageSource: "asset:///images/list_quality.png"
},
ExpandableDecorator {
title: qsTr("ExpandableDecorator")
imageSource: "asset:///images/list_expandable.png"
},
SelectableDecorator {
title: qsTr("SelectableDecorator")
imageSource: "asset:///images/list_selection.png"
},
DataLoggerDecorator {
title: qsTr("DataLoggerDecorator")
imageSource: "asset:///images/logging.png"
},
ActionItem {
title: qsTr("Reset")
imageSource: "asset:///images/list_reset.png"
ActionBar.placement: ActionBarPlacement.InOverflow
onTriggered: {
listView.dataModel = defaultModel
}
}
]
Container {
ListView {
id: listView
layout: StackListLayout {
headerMode: ListHeaderMode.Sticky
}
layoutProperties: StackLayoutProperties {
spaceQuota: 1.0
}
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
dataModel: defaultModel
function imageurl(image) {
if ("" == image || !_app.fileExists(image)) {
return _sqlImagesDir + "../../../native/assets/images/no_image.png"
}
return _sqlImagesDir + image;
}
onTriggered: {
clearSelection()
select(indexPath)
}
listItemComponents: [
ListItemComponent {
type: "header"
Container {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Center
background: Color.create("#0098F0")
Label {
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Center
preferredHeight: 200
text: ListItemData.header
}
Container {
background: Color.White
Divider {
}
}
}
},
ListItemComponent {
type: ""
Container {
id: item
layout: StackLayout {
orientation: LayoutOrientation.LeftToRight
}
CoverArt {
}
Label {
verticalAlignment: VerticalAlignment.Center
text: ListItemData.name
textStyle {
base: SystemDefaults.TextStyles.PrimaryText
}
}
}
},
GroupArtistListComponent {
},
DataQualityListComponent {
},
SelectableListComponent {
}
]
onSelectionChanged: {
console.log("onSelectionChanged, selected: " + selected)
}
onActivationChanged: {
console.log("onActivationChanged, active: " + active)
}
}
onCreationCompleted: {
defaultModel.load()
}
attachedObjects: [
AsyncDataModel {
id: defaultModel
query: SqlDataQuery {
source: _sqlImagesDir + "/../discogs_small.db"
query: "select name, primary_image, is_group from artist order by name"
countQuery: "select count(*) from artist"
onDataChanged: console.log("data changed: revision=" + revision)
onError: console.log("SQL query error: " + code + ", " + message)
}
onLoaded: console.log("initial model data is loaded")
}
]
}
}