main.qml Example File
rssnews/assets/main.qml
import bb.cascades 1.0
import bb.data 1.0
NavigationPane {
id: navPane
onPopTransitionEnded: page.destroy()
Page {
Container {
layout: DockLayout {}
ImageView {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
imageSource: "asset:///images/background.png"
}
Container {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
Container {
horizontalAlignment: HorizontalAlignment.Center
layout: DockLayout {}
ImageView {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
imageSource: "asset:///images/header_background.png"
}
Label {
horizontalAlignment: HorizontalAlignment.Center
text: qsTr ("RSS News Feeds")
textStyle.base: SystemDefaults.TextStyles.BigText
textStyle.color: Color.create("#bbffffff")
}
}
SegmentedControl {
id: newsSources
options: [
Option {
text: qsTr ("Google")
value: "googlerssfeeds.json"
},
Option {
text: qsTr ("Yahoo!")
value: "yahoorssfeeds.json"
}
]
onSelectedOptionChanged: {
if (selectedOption != 0) {
feedsDataSource.source = selectedOption.value;
feedsDataSource.load();
}
}
onCreationCompleted: {
if (selectedOption != 0) {
feedsDataSource.source = selectedOption.value;
feedsDataSource.load();
}
}
}
ListView {
dataModel: feedsDataModel
listItemComponents: [
ListItemComponent {
type: "item"
Container {
leftPadding: 30
preferredWidth: 768
preferredHeight: 100
layout: DockLayout {}
Label {
verticalAlignment: VerticalAlignment.Center
text: ListItemData.name
textStyle.base: SystemDefaults.TextStyles.TitleText
textStyle.color: Color.White
}
Divider {
verticalAlignment: VerticalAlignment.Bottom
}
}
}
]
onTriggered: {
var feedItem = feedsDataModel.data(indexPath);
articlesDataSource.source = "http://" + feedItem.feed;
articlesDataSource.load();
var page = newsListings.createObject();
page.title = newsSources.selectedOption.text + ": " + feedItem.name
navPane.push(page);
}
}
}
}
}
attachedObjects: [
GroupDataModel {
id: feedsDataModel
sortingKeys: ["order"]
grouping: ItemGrouping.None
},
DataSource {
id: feedsDataSource
source: ""
onDataLoaded: {
feedsDataModel.clear();
feedsDataModel.insertList(data);
}
onError: {
console.log("JSON Load Error: [" + errorType + "]: " + errorMessage);
}
},
GroupDataModel {
id: articlesDataModel
sortingKeys: ["pubDate"]
sortedAscending: false
grouping: ItemGrouping.None
},
DataSource {
id: articlesDataSource
source: ""
query: "/rss/channel/item"
type: DataSource.Xml
onDataLoaded: {
articlesDataModel.clear();
articlesDataModel.insertList(data);
}
onError: {
console.log("RSS Load Error[" + errorType + "]: " + errorMessage);
}
},
ComponentDefinition {
id: newsListings
Page {
property alias title : titleLabel.text
Container {
layout: DockLayout {}
ImageView {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
imageSource: "asset:///images/background.png"
}
Container {
Container {
horizontalAlignment: HorizontalAlignment.Center
layout: DockLayout {}
ImageView {
horizontalAlignment: HorizontalAlignment.Fill
verticalAlignment: VerticalAlignment.Fill
imageSource: "asset:///images/header_background.png"
}
Label {
id: titleLabel
horizontalAlignment: HorizontalAlignment.Center
textStyle.base: SystemDefaults.TextStyles.BigText
textStyle.color: Color.create("#bbffffff")
}
}
ListView {
dataModel: articlesDataModel
listItemComponents: [
ListItemComponent {
type: "item"
ArticleItem {
title: ListItemData.title
pubDate: ListItemData.pubDate
}
}
]
onTriggered: {
var feedItem = articlesDataModel.data(indexPath);
var page = detailPage.createObject();
page.htmlContent = feedItem.description;
navPane.push(page);
}
}
}
}
}
},
ComponentDefinition {
id: detailPage
Page {
property alias htmlContent: detailView.html
Container {
ScrollView {
scrollViewProperties.scrollMode: ScrollMode.Vertical
WebView {
id: detailView;
}
}
}
}
}
]
}