main.qml Example File
bluetoothgatt/assets/main.qml
import bb.cascades 1.0
import bb.system 1.0
NavigationPane {
id: navigationPane
onPopTransitionEnded: {
if (page.objectName == "ServicePage")
_bluetoothGatt.disconnectServices()
else if (page.objectName == "CharacteristicsPage")
_bluetoothGatt.resetCharacteristicsList()
else if (page.objectName == "CharacteristicsEditorPage")
_bluetoothGatt.resetEditor()
page.destroy()
}
attachedObjects: [
SystemToast {
body: _bluetoothGatt.errorMessage
onBodyChanged: show()
},
SystemToast {
body: _bluetoothGatt.editor.errorMessage
onBodyChanged: show()
}
]
Page {
titleBar: TitleBar {
title: qsTr("Paired GATT Devices")
}
actions: [
ActionItem {
title: qsTr("Refresh")
imageSource: "asset:///images/ic_refresh.png"
onTriggered: {
_bluetoothGatt.refreshDevices();
}
ActionBar.placement: ActionBarPlacement.OnBar
}
]
attachedObjects: [
ComponentDefinition {
id: servicesPage
source: "Services.qml"
}
]
ListView {
onTriggered: {
if (indexPath.length != 0) {
_bluetoothGatt.viewServices(indexPath[0]);
navigationPane.push(servicesPage.createObject())
}
}
dataModel: _bluetoothGatt.devicesModel
listItemComponents: [
ListItemComponent {
type: "item"
Container {
topPadding: 10
leftPadding: 10
rightPadding: 10
Container {
layout: StackLayout {
orientation: LayoutOrientation.LeftToRight
}
Container {
layoutProperties: StackLayoutProperties {
spaceQuota: 1
}
verticalAlignment: VerticalAlignment.Fill
horizontalAlignment: HorizontalAlignment.Fill
ImageView {
preferredHeight: 85
preferredWidth: 85
imageSource: ListItemData.paired ? "asset:///images/device_paired.png" : "asset:///images/device.png"
verticalAlignment: VerticalAlignment.Center
horizontalAlignment: HorizontalAlignment.Center
}
}
Container {
leftMargin: 10
layoutProperties: StackLayoutProperties {
spaceQuota: 10
}
Label {
text: ListItemData.name
textStyle.fontSize: FontSize.Medium
bottomMargin: 0.0
}
Label {
text: ListItemData.address
textStyle.fontSize: FontSize.Small
topMargin: 0.0
}
}
}
Divider {
topMargin: 1
}
}
}
]
}
}
}