main.qml Example File
pushCollector/10.0/pushCollector/assets/main.qml
 
    
    import bb.cascades 1.0
    import bb.system 1.0
    NavigationPane {
        id: navPane
        Page {
            Container {
                
                Label {
                    horizontalAlignment: HorizontalAlignment.Center
                    text: qsTr("There are currently no pushes.")
                    textStyle {
                        base: SystemDefaults.TextStyles.BodyText
                        fontWeight: FontWeight.Bold
                    }
                    visible: _pushAPIHandler.modelIsEmpty
                }
                
                ListView {
                    dataModel: _pushAPIHandler.model
                    listItemComponents: [
                        
                        ListItemComponent {
                            type: "header"
                            CustomHeaderItem {
                                text: Qt.formatDate(ListItemData, "ddd, MMM d, yyyy")
                            }
                        },
                        
                        ListItemComponent {
                            type: "item"
                            CustomPushItem {
                                type: ListItemData.type
                                extension: ListItemData.extension
                                content: ListItem.view.convertToUtf8String(ListItemData.content);
                                unread: ListItemData.unread
                                pushTime: ListItemData.pushtime
                                selected: ListItem.selected
                                onDeleteClicked: ListItem.view.deletePush(ListItemData);
                            }
                        }
                    ]
                    function deletePush(pushItem) {
                        _pushAPIHandler.deletePush(pushItem);
                    }
                    function convertToUtf8String(pushContent){
                        return _pushAPIHandler.convertToUtf8String(pushContent);
                    }
                    onTriggered: {
                        if (dataModel.itemType(indexPath) == "item") {
                            clearSelection();
                            select(indexPath);
                            
                            _pushAPIHandler.selectPush(indexPath);
                        }
                    }
                }
            }
            attachedObjects: [
                
                ActivityDialog {
                    title: _pushAPIHandler.activityDialogTitle
                    message: _pushAPIHandler.activityDialogBody
                    onCreationCompleted: {
                        _pushAPIHandler.openActivityDialog.connect(open)
                        _pushAPIHandler.closeActivityDialog.connect(close)
                    }
                },
                
                Sheet {
                    id: configurationSheet
                    objectName: "configurationSheet"
                    SheetConfig {
                        id: config
                        onCancel: {
                            
                            configurationSheet.close();
                            
                            refresh();
                        }
                        onSave: {
                            if (_pushAPIHandler.validateConfiguration()) {
                                
                                _pushAPIHandler.saveConfiguration();
                                
                                configurationSheet.close();
                                
                                refresh();
                            }
                        }
                    }
                },
                
                SystemDialog {
                    id: notificationDialog
                    confirmButton.label: qsTr("OK")
                    
                    cancelButton.label: objectName
                    title: _pushAPIHandler.notificationTitle
                    body: _pushAPIHandler.notificationBody
                }
            ]
            function displayContent() {
                
                navPane.push(pushContentPage);
            }
            onCreationCompleted: {
                _pushAPIHandler.notificationChanged.connect(notificationDialog.exec)
                
                
                
                _pushAPIHandler.currentPushContent.pushContentChanged.connect(displayContent)
            }
            
            actions: [
                ActionItem {
                    title: qsTr("Config")
                    ActionBar.placement: ActionBarPlacement.OnBar
                    imageSource: "asset:///images/actionbar/configicon.png"
                    onTriggered: {
                        configurationSheet.open();
                    }
                },
                ActionItem {
                    title: qsTr("Register")
                    ActionBar.placement: ActionBarPlacement.OnBar
                    imageSource: "asset:///images/actionbar/registericon.png"
                    onTriggered: {
                        _pushAPIHandler.createChannel();
                    }
                },
                ActionItem {
                    title: qsTr("Unregister")
                    ActionBar.placement: ActionBarPlacement.OnBar
                    imageSource: "asset:///images/actionbar/unregistericon.png"
                    onTriggered: {
                        _pushAPIHandler.destroyChannel();
                    }
                },
                ActionItem {
                    title: qsTr("Mark All Read")
                    imageSource: "asset:///images/actionbar/markallicon.png"
                    enabled: !_pushAPIHandler.modelIsEmpty
                    onTriggered: {
                        _pushAPIHandler.markAllPushesAsRead();
                    }
                },
                ActionItem {
                    title: qsTr("Delete All")
                    ActionBar.placement: ActionBarPlacement.OnBar
                    imageSource: "asset:///images/actionbar/deleteallicon.png"
                    enabled: !_pushAPIHandler.modelIsEmpty
                    onTriggered: {
                        _pushAPIHandler.deleteAllPushes();
                    }
                }
            ]
        }
        attachedObjects: [
            
            Page {
                id: pushContentPage
                PushContent {
                }
                paneProperties: NavigationPaneProperties {
                    backButton: ActionItem {
                        title: qsTr("Back")
                        onTriggered: {
                            navPane.pop();
                        }
                    }
                }
            }
        ]
    }