Fix doc snippets paths and parsing errors
[profile/ivi/qtdeclarative.git] / examples / demos / twitter / twitter.qml
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtQml module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 import QtQuick 2.0
43 import QtQuick.XmlListModel 2.0
44 import "TwitterCore" 2.0 as Twitter
45
46 Item {
47     id: screen; width: 320; height: 480
48     property bool userView : false
49     property variant tmpStr
50     function setUser(str){hack.running = true; tmpStr = str}
51     function reallySetUser(){rssModel.from = tmpStr;rssModel.to = ""; rssModel.phrase = ""}
52     state:"searchquery"
53     //Workaround for bug 260266
54     Timer{ interval: 1; running: false; repeat: false; onTriggered: screen.reallySetUser(); id:hack }
55     Keys.onEscapePressed: screen.state="searchquery"
56     Keys.onBacktabPressed: screen.state="searchquery"
57     Rectangle {
58         id: background
59         anchors.fill: parent; color: "#343434";
60
61         state:"searchquery"
62         Image { source: "TwitterCore/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 }
63
64         MouseArea {
65             anchors.fill: parent
66             onClicked: screen.focus = false;
67         }
68
69         Twitter.RssModel { id: rssModel }
70         Twitter.Loading { anchors.centerIn: parent; visible: rssModel.status==XmlListModel.Loading && state!='unauthed'}
71         Text {
72             width: 180
73             text: "Could not access twitter using this screen name and password pair.";
74             color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrapMode: Text.WordWrap
75             visible: rssModel.status==XmlListModel.Error; anchors.centerIn: parent
76         }
77
78         Item {
79             id: views
80             x: 2; width: parent.width - 4
81             y:60 //Below the title bars
82             height: parent.height - 100
83
84             Text {
85                 id:title
86                 text: "Search Twitter"
87                 anchors.horizontalCenter: parent.horizontalCenter
88                 font.pixelSize: 20; font.bold: true; color: "#bbb"; style: Text.Raised; styleColor: "black"
89                 opacity:0
90             }
91
92             Twitter.SearchView{
93                 id: searchView
94                 anchors.verticalCenter: parent.verticalCenter
95                 width: parent.width; height: parent.height-60;
96                 x: -(screen.width * 1.5)
97             }
98
99             Twitter.FatDelegate { id: fatDelegate }
100             ListView {
101                 id: mainView; model: rssModel.model; delegate: fatDelegate;
102                 width: parent.width; height: parent.height; x: 0; cacheBuffer: 100;
103             }
104         }
105
106         Twitter.MultiTitleBar { id: titleBar; width: parent.width }
107         Twitter.ToolBar { id: toolBar; height: 40;
108             //anchors.bottom: parent.bottom;
109             //TODO: Use anchor changes instead of hard coding
110             y: screen.height - 40
111             width: parent.width; opacity: 0.9
112             button1Label: "New Search"
113             button2Label: "Update"
114             onButton1Clicked:
115             {
116                 screen.state="searchquery"
117             }
118             onButton2Clicked: rssModel.reload();
119         }
120     }
121     states: [
122         State {
123             name: "searchquery";
124             PropertyChanges { target: searchView; x: 0; focus:true}
125             PropertyChanges { target: mainView; x: -(parent.width * 1.5) }
126             PropertyChanges { target: titleBar; y: -80 }
127             PropertyChanges { target: toolBar; y: screen.height }
128             PropertyChanges { target: toolBar }
129             PropertyChanges { target: title; opacity:1}
130         }
131     ]
132     transitions: [
133         Transition { NumberAnimation { properties: "x,y,opacity"; duration: 500; easing.type: Easing.InOutQuad } }
134     ]
135 }