source: trunk/demos/declarative/twitter/twitter.qml@ 846

Last change on this file since 846 was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 5.3 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtDeclarative module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
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** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42import QtQuick 1.0
43import "TwitterCore" 1.0 as Twitter
44
45Item {
46 id: screen; width: 320; height: 480
47 property bool userView : false
48 property variant tmpStr
49 function setUser(str){hack.running = true; tmpStr = str}
50 function reallySetUser(){rssModel.from = tmpStr;rssModel.to = ""; rssModel.phrase = ""}
51 state:"searchquery"
52 //Workaround for bug 260266
53 Timer{ interval: 1; running: false; repeat: false; onTriggered: screen.reallySetUser(); id:hack }
54 Keys.onEscapePressed: screen.state="searchquery"
55 Keys.onBacktabPressed: screen.state="searchquery"
56 Rectangle {
57 id: background
58 anchors.fill: parent; color: "#343434";
59
60 state:"searchquery"
61 Image { source: "TwitterCore/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 }
62
63 MouseArea {
64 anchors.fill: parent
65 onClicked: screen.focus = false;
66 }
67
68 Twitter.RssModel { id: rssModel }
69 Twitter.Loading { anchors.centerIn: parent; visible: rssModel.status==XmlListModel.Loading && state!='unauthed'}
70 Text {
71 width: 180
72 text: "Could not access twitter using this screen name and password pair.";
73 color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrapMode: Text.WordWrap
74 visible: rssModel.status==XmlListModel.Error; anchors.centerIn: parent
75 }
76
77 Item {
78 id: views
79 x: 2; width: parent.width - 4
80 y:60 //Below the title bars
81 height: parent.height - 100
82
83 Text {
84 id:title
85 text: "Search Twitter"
86 anchors.horizontalCenter: parent.horizontalCenter
87 font.pixelSize: 20; font.bold: true; color: "#bbb"; style: Text.Raised; styleColor: "black"
88 opacity:0
89 }
90
91 Twitter.SearchView{
92 id: searchView
93 anchors.verticalCenter: parent.verticalCenter
94 width: parent.width; height: parent.height-60;
95 x: -(screen.width * 1.5)
96 }
97
98 Twitter.FatDelegate { id: fatDelegate }
99 ListView {
100 id: mainView; model: rssModel.model; delegate: fatDelegate;
101 width: parent.width; height: parent.height; x: 0; cacheBuffer: 100;
102 }
103 }
104
105 Twitter.MultiTitleBar { id: titleBar; width: parent.width }
106 Twitter.ToolBar { id: toolBar; height: 40;
107 //anchors.bottom: parent.bottom;
108 //TODO: Use anchor changes instead of hard coding
109 y: screen.height - 40
110 width: parent.width; opacity: 0.9
111 button1Label: "New Search"
112 button2Label: "Update"
113 onButton1Clicked:
114 {
115 screen.state="searchquery"
116 }
117 onButton2Clicked: rssModel.reload();
118 }
119 }
120 states: [
121 State {
122 name: "searchquery";
123 PropertyChanges { target: searchView; x: 0; focus:true}
124 PropertyChanges { target: mainView; x: -(parent.width * 1.5) }
125 PropertyChanges { target: titleBar; y: -80 }
126 PropertyChanges { target: toolBar; y: screen.height }
127 PropertyChanges { target: toolBar }
128 PropertyChanges { target: title; opacity:1}
129 }
130 ]
131 transitions: [
132 Transition { NumberAnimation { properties: "x,y,opacity"; duration: 500; easing.type: Easing.InOutQuad } }
133 ]
134}
Note: See TracBrowser for help on using the repository browser.