import QtQuick 2.2
import QtQuick.XmlListModel 2.0
import QtQuick.Window 2.1
import QtQuick.Controls 1.1
import QtQuick.Extras 1.4
//import "./content"
Rectangle {
id: window
width: 680
height: 800
visible: true
property string currentFeed: rssFeeds.get(0).feed
property bool loading: feedModel.status === XmlListModel.Loading
property bool isPortrait: Screen.primaryOrientation === false
//Qt.PortraitOrientation
onLoadingChanged: {
if (feedModel.status == XmlListModel.Ready)
list.positionViewAtBeginning()
}
RssFeeds { id: rssFeeds }
property var feeds: [
{ name: "NASA", feed: "http://www.nasa.gov/rss/dyn/solar_system.rss", icon: "awesome/rss"}
]
property var selectedFeed: feeds[0]
XmlListModel {
id: feedModel
source: selectedFeed.feed
query: "/rss/channel/item"
XmlRole { name: "title"; query: "title/string()"}
XmlRole { name: "description"; query: "description/string()"}
XmlRole { name: "image"}
XmlRole { name: "link"; query: "link/string()" }
XmlRole { name: "pubDate"; query: "pubDate/string()" }
}
ListView {
id: categories
property int itemWidth: 300
width: isPortrait ? parent.width : itemWidth
height: isPortrait ? itemWidth : parent.height
orientation: isPortrait ? ListView.Horizontal : ListView.Vertical
anchors.top: parent.top
model: rssFeeds
delegate: CategoryDelegate { itemSize: categories.itemWidth }
spacing: 5
}
ListView {
id: list
anchors.left: isPortrait ? window.left : categories.right
anchors.right: closeButton.left
anchors.top: isPortrait ? categories.bottom : window.top
anchors.bottom: window.bottom
anchors.leftMargin: 30
anchors.rightMargin: 4
clip: isPortrait
model: feedModel
footer: footerText
delegate: NewsDelegate {}
}
}