Initial import from the monolithic Qt.
[profile/ivi/qtdeclarative.git] / demos / declarative / rssnews / rssnews.qml
1 /****************************************************************************
2 **
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of the QtDeclarative module of the Qt Toolkit.
8 **
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
15 **
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file.  Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23 **
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 import QtQuick 1.0
43 import "content"
44
45 Rectangle {
46     id: window
47     width: 800; height: 480
48
49     property string currentFeed: "rss.news.yahoo.com/rss/topstories"
50     property bool loading: feedModel.status == XmlListModel.Loading
51
52     RssFeeds { id: rssFeeds }
53
54     XmlListModel {
55         id: feedModel
56         source: "http://" + window.currentFeed
57         query: "/rss/channel/item"
58
59         XmlRole { name: "title"; query: "title/string()" }
60         XmlRole { name: "link"; query: "link/string()" }
61         XmlRole { name: "description"; query: "description/string()" }
62     }
63
64     Row {
65         Rectangle {
66             width: 220; height: window.height
67             color: "#efefef"
68
69             ListView {
70                 focus: true
71                 id: categories
72                 anchors.fill: parent
73                 model: rssFeeds
74                 footer: quitButtonDelegate
75                 delegate: CategoryDelegate {}
76                 highlight: Rectangle { color: "steelblue" }
77                 highlightMoveSpeed: 9999999
78             }
79             ScrollBar {
80                 scrollArea: categories; height: categories.height; width: 8
81                 anchors.right: categories.right
82             }
83         }
84         ListView {
85             id: list
86             width: window.width - 220; height: window.height
87             model: feedModel
88             delegate: NewsDelegate {}
89         }
90     }
91     Component {
92         id: quitButtonDelegate
93         Item {
94             width: categories.width; height: 60
95             Text {
96                 text: "Quit"
97                 font { family: "Helvetica"; pixelSize: 16; bold: true }
98                 anchors {
99                     left: parent.left; leftMargin: 15
100                     verticalCenter: parent.verticalCenter
101                 }
102             }
103             MouseArea {
104                 anchors.fill: parent
105                 onClicked: Qt.quit()
106             }
107         }
108     }
109     ScrollBar { scrollArea: list; height: list.height; width: 8; anchors.right: window.right }
110     Rectangle { x: 220; height: window.height; width: 1; color: "#cccccc" }
111 }