aboutsummaryrefslogtreecommitdiffstats
path: root/examples/demos/tweetsearch/content
diff options
context:
space:
mode:
Diffstat (limited to 'examples/demos/tweetsearch/content')
-rw-r--r--examples/demos/tweetsearch/content/FlipBar.qml215
-rw-r--r--examples/demos/tweetsearch/content/LineInput.qml98
-rw-r--r--examples/demos/tweetsearch/content/ListFooter.qml115
-rw-r--r--examples/demos/tweetsearch/content/ListHeader.qml81
-rw-r--r--examples/demos/tweetsearch/content/SearchDelegate.qml122
-rw-r--r--examples/demos/tweetsearch/content/TweetDelegate.qml172
-rw-r--r--examples/demos/tweetsearch/content/TweetsModel.qml91
-rw-r--r--examples/demos/tweetsearch/content/resources/anonymous.pngbin0 -> 1788 bytes
-rw-r--r--examples/demos/tweetsearch/content/resources/bird-anim-sprites.pngbin0 -> 11086 bytes
-rw-r--r--examples/demos/tweetsearch/content/resources/icon-clear.pngbin0 -> 1166 bytes
-rw-r--r--examples/demos/tweetsearch/content/resources/icon-loading.pngbin0 -> 1542 bytes
-rw-r--r--examples/demos/tweetsearch/content/resources/icon-refresh.pngbin0 -> 1202 bytes
-rw-r--r--examples/demos/tweetsearch/content/resources/icon-search.pngbin0 -> 1284 bytes
-rw-r--r--examples/demos/tweetsearch/content/tweetsearch.js20
14 files changed, 914 insertions, 0 deletions
diff --git a/examples/demos/tweetsearch/content/FlipBar.qml b/examples/demos/tweetsearch/content/FlipBar.qml
new file mode 100644
index 0000000000..ea149ec277
--- /dev/null
+++ b/examples/demos/tweetsearch/content/FlipBar.qml
@@ -0,0 +1,215 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+ property int animDuration: 300
+ property int wiggleDuration: 0 // 2x time spent each side to wiggle away before shrinking in
+ property real wiggleRoom: 0 // Size on each side it moves away before shrinking during the transition
+ property real squeezeFactor: 0.1 // More give a greater squeeze during transition (0.0 for none)
+ property Item above: Item {}
+ property Item front: Item {}
+ property Item back: Item {}
+ property real factor: 0.1 // amount the edges fold in for the 3D effect
+ property alias delta: effect.delta
+
+ property Item cur: frontShown ? front : back
+ property Item noncur:frontShown ? back : front
+ function swap() {
+ var tmp = front;
+ front = back;
+ back = tmp;
+ resync();
+ }
+
+ width: cur.width
+ height: cur.height
+ onFrontChanged: resync();
+ onBackChanged: resync();
+ function resync() {//TODO: Are the items ever actually visible?
+ back.parent = container;
+ front.parent = container;
+ frontShown ? back.visible = false : front.visible = false;
+ }
+ property bool frontShown: true
+ Rectangle {
+ anchors.fill: parent
+ color: "white"
+ }
+ function flipUp(start) {
+ effect.visible = true;
+ effect.sourceA = effect.source1
+ effect.sourceB = effect.source2
+ if (start == undefined)
+ start = 1.0;
+ deltaAnim.from = start;
+ deltaAnim.to = 0.0
+ dAnim.start();
+ frontShown = false;
+ sizeAnim.start();
+ }
+ function flipDown(start) {
+ effect.visible = true;
+ effect.sourceA = effect.source1
+ effect.sourceB = effect.source2
+ if (start == undefined)
+ start = 0.0;
+ deltaAnim.from = start;
+ deltaAnim.to = 1.0
+ dAnim.start();
+ frontShown = true;
+ sizeAnim.start();
+ }
+ SequentialAnimation on height {
+ id: sizeAnim
+ running: false
+ //Note: front has already swapped around when we start
+ NumberAnimation {
+ duration: wiggleDuration
+ to: noncur.height + wiggleRoom
+ }
+ NumberAnimation {
+ duration: animDuration/2
+ to: noncur.height - wiggleRoom * 2
+ }
+ NumberAnimation {
+ duration: animDuration/2
+ to: cur.height + wiggleRoom
+ }
+ NumberAnimation {
+ duration: wiggleDuration
+ to: cur.height
+ }
+ }
+ Binding {
+ target: above
+ property: "y"
+ value: -(container.height - effect.height) / 2
+ }
+ ShaderEffect {
+ id: effect
+ //Magic is a quadratic coefficient so that we get a down pointed parabola based on delta with value +1.0 for delta 0 and 1
+ //property real magic_x: delta - 0.5
+ //property real magic: (magic_x * magic_x) * 2 + 0.5
+ width: cur.width
+ height: cur.height// * magic*squeezeFactor
+ property real factor: container.factor * width
+ property real delta: 1.0
+ mesh: GridMesh { resolution: Qt.size(8,2) }//1x2 is all that's needed for the rect, but proper contents interpolation wants more
+ SequentialAnimation on delta {
+ id: dAnim
+ running: false
+ PauseAnimation { duration: wiggleDuration }
+ NumberAnimation {
+ id: deltaAnim
+ duration: animDuration//expose anim
+ //easing.type: Easing.OutQuart
+ }
+ }
+ property variant sourceA: source1
+ property variant sourceB: source1
+ property variant source1: ShaderEffectSource {
+ sourceItem: front
+ hideSource: effect.visible
+ }
+ property variant source2: ShaderEffectSource {
+ sourceItem: back
+ hideSource: effect.visible
+ }
+
+ fragmentShader: "
+ uniform lowp float qt_Opacity;
+ uniform sampler2D sourceA;
+ uniform sampler2D sourceB;
+ uniform highp float delta;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ /* Pre-Vertex
+ highp vec4 tex = vec4(qt_TexCoord0.x, qt_TexCoord0.y / delta, qt_TexCoord0.x, (qt_TexCoord0.y-delta)/(1.0-delta));
+ //highp float shade = (1.0 - qt_TexCoord0.y) * delta;
+ //highp float shade = (1.0 - tex.w) * delta;
+ highp float shade = vec4(delta,delta,delta,0.0) ;
+ highp vec4 col;
+ if (delta > qt_TexCoord0.y)
+ col = texture2D(sourceA, tex.xy);
+ else
+ col = texture2D(sourceB, tex.zw) * (vec4(1.0,1.0,1.0,1.0) - shade);
+ gl_FragColor = vec4(col.x, col.y, col.z, 1.0) * qt_Opacity;
+ //gl_FragColor = vec4(0.0,1.0,delta,1.0) * qt_Opacity;
+ */
+ highp vec4 tex = vec4(qt_TexCoord0.x, qt_TexCoord0.y * 2.0, qt_TexCoord0.x, (qt_TexCoord0.y-0.5) * 2.0);
+ highp float shade = clamp(delta*2.0, 0.5, 1.0);
+ highp vec4 col;
+ if (qt_TexCoord0.y < 0.5) {
+ col = texture2D(sourceA, tex.xy) * (shade);
+ //w governed by shade
+ } else {
+ col = texture2D(sourceB, tex.zw) * (1.5 - shade);
+ col.w = 1.0;
+ }
+ gl_FragColor = col * qt_Opacity;
+ }
+ "
+ property real h: height
+ vertexShader: "
+ uniform highp float delta;
+ uniform highp float factor;
+ uniform highp float h;
+ uniform highp mat4 qt_Matrix;
+ attribute highp vec4 qt_Vertex;
+ attribute highp vec2 qt_MultiTexCoord0;
+ varying highp vec2 qt_TexCoord0;
+ void main() {
+ highp vec4 pos = qt_Vertex;
+ if (qt_MultiTexCoord0.y == 0.0)
+ pos.x += factor * (1. - delta) * (qt_MultiTexCoord0.x * -2.0 + 1.0);
+ else if (qt_MultiTexCoord0.y == 1.0)
+ pos.x += factor * (delta) * (qt_MultiTexCoord0.x * -2.0 + 1.0);
+ else // (qt_MultiTexCoord0.y == 0.5 )
+ pos.y = delta * h;
+ gl_Position = qt_Matrix * pos;
+ //highp vec2 tex = qt_MultiTexCoord0;
+ qt_TexCoord0 = qt_MultiTexCoord0;
+ }"
+
+ }
+}
diff --git a/examples/demos/tweetsearch/content/LineInput.qml b/examples/demos/tweetsearch/content/LineInput.qml
new file mode 100644
index 0000000000..d81d8455d7
--- /dev/null
+++ b/examples/demos/tweetsearch/content/LineInput.qml
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+FocusScope {
+ id: wrapper
+
+ property alias text: input.text
+ property alias hint: hint.text
+ property alias prefix: prefix.text
+
+ signal accepted
+
+ Rectangle {
+ anchors.fill: parent
+ border.color: "#707070"
+ color: "#c1c1c1"
+ radius: 4
+
+ Text {
+ id: hint
+ anchors { fill: parent; leftMargin: 14 }
+ verticalAlignment: Text.AlignVCenter
+ text: "Enter word"
+ font.pixelSize: 18
+ color: "#707070"
+ opacity: input.length ? 0 : 1
+ }
+
+ Text {
+ id: prefix
+ anchors { left: parent.left; leftMargin: 14; verticalCenter: parent.verticalCenter }
+ verticalAlignment: Text.AlignVCenter
+ font.pixelSize: 18
+ color: "#707070"
+ opacity: !hint.opacity
+ }
+
+ TextInput {
+ id: input
+ focus: true
+ anchors { left: prefix.right; right: parent.right; top: parent.top; bottom: parent.bottom }
+ verticalAlignment: Text.AlignVCenter
+ font.pixelSize: 18
+ color: "#707070"
+ onAccepted: wrapper.accepted()
+ }
+
+ Image {
+ source: "resources/icon-search.png"
+ anchors.right: parent.right
+ anchors.rightMargin: 12
+ anchors.verticalCenter: parent.verticalCenter
+ MouseArea {
+ anchors { fill: parent; margins: -10 }
+ onClicked: wrapper.accepted()
+ }
+ }
+ }
+}
diff --git a/examples/demos/tweetsearch/content/ListFooter.qml b/examples/demos/tweetsearch/content/ListFooter.qml
new file mode 100644
index 0000000000..fab40bd885
--- /dev/null
+++ b/examples/demos/tweetsearch/content/ListFooter.qml
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ color: "#d6d6d6"
+ width: parent.width
+ height: childrenRect.height
+ z: 2
+
+ Column {
+ width: parent.width
+
+ SearchDelegate {
+ id: wordSearch
+ label: "Search word..."
+ placeHolder: "Enter word"
+ onHasOpened: {
+ tagSearch.close()
+ userSearch.close()
+ }
+ onOk: {
+ mainListView.positionViewAtBeginning()
+ mainListView.clear()
+ tweetsModel.from = ""
+ tweetsModel.phrase = searchText
+ }
+ }
+
+ SearchDelegate {
+ id: userSearch
+ label: "From user..."
+ placeHolder: "@username"
+ prefix: "@"
+ onHasOpened:{
+ tagSearch.close()
+ wordSearch.close()
+ }
+ onOk: {
+ mainListView.positionViewAtBeginning()
+ mainListView.clear()
+ tweetsModel.phrase = ""
+ tweetsModel.from = searchText
+ }
+ }
+
+ SearchDelegate {
+ id: tagSearch
+ label: "Search hashtag..."
+ placeHolder: "#hashtag"
+ prefix: "#"
+ onHasOpened:{
+ userSearch.close()
+ wordSearch.close()
+ }
+ onOk: {
+ mainListView.positionViewAtBeginning()
+ mainListView.clear()
+ tweetsModel.from = ""
+ tweetsModel.phrase = "#" + searchText
+ }
+ }
+
+ AnimatedSprite {
+ id: sprite
+ anchors.horizontalCenter: parent.horizontalCenter
+ width: 320
+ height: 300
+ source: "resources/bird-anim-sprites.png"
+ frameCount: 6
+ frameRate: 3
+ frameWidth: 320
+ frameHeight: 360
+ running: true
+ }
+ }
+}
diff --git a/examples/demos/tweetsearch/content/ListHeader.qml b/examples/demos/tweetsearch/content/ListHeader.qml
new file mode 100644
index 0000000000..fbb1765f59
--- /dev/null
+++ b/examples/demos/tweetsearch/content/ListHeader.qml
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ height: 60
+ width: parent.width
+
+ property bool refresh: state == "pulled" ? true : false
+
+ Row {
+ spacing: 6
+ height: childrenRect.height
+ anchors.centerIn: parent
+
+ Image {
+ id: arrow
+ source: "resources/icon-refresh.png"
+ transformOrigin: Item.Center
+ Behavior on rotation { NumberAnimation { duration: 200 } }
+ }
+
+ Text {
+ id: label
+ anchors.verticalCenter: arrow.verticalCenter
+ text: "Pull to refresh"
+ font.pixelSize: 20
+ color: "#c1c1c1"
+ }
+ }
+
+ states: [
+ State {
+ name: "base"; when: mainListView.contentY >= -120
+ PropertyChanges { target: arrow; rotation: 180 }
+ },
+ State {
+ name: "pulled"; when: mainListView.contentY < -120
+ PropertyChanges { target: label; text: "Release to refresh" }
+ PropertyChanges { target: arrow; rotation: 0 }
+ }
+ ]
+}
diff --git a/examples/demos/tweetsearch/content/SearchDelegate.qml b/examples/demos/tweetsearch/content/SearchDelegate.qml
new file mode 100644
index 0000000000..8c6ad40eac
--- /dev/null
+++ b/examples/demos/tweetsearch/content/SearchDelegate.qml
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+FlipBar {
+ id: flipBar
+ animDuration: 250
+ property string label: ""
+ property string placeHolder: ""
+ property alias searchText: lineInput.text
+ property alias prefix: lineInput.prefix
+ property bool opened: false
+ signal ok
+ signal hasOpened
+
+ height: 60
+ width: parent.width
+
+ function open() {
+ flipBar.flipUp()
+ flipBar.opened = true
+ lineInput.forceActiveFocus()
+ flipBar.hasOpened()
+ }
+
+ function close() {
+ if (opened) {
+ flipBar.flipDown()
+ flipBar.opened = false
+ }
+ }
+
+ front: Rectangle {
+ height: 60
+ width: parent.width
+ color: "#999999"
+
+ Rectangle { color: "#c1c1c1"; width: parent.width; height: 1 }
+ Rectangle { color: "#707070"; width: parent.width; height: 1; anchors.bottom: parent.bottom }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: {
+ if (!flipBar.opened)
+ open()
+ else if (!lineInput.activeFocus)
+ lineInput.forceActiveFocus()
+ else
+ close()
+ }
+ }
+
+ Text {
+ text: flipBar.label
+ anchors { left: parent.left; leftMargin: 20 }
+ anchors.verticalCenter: parent.verticalCenter
+ font.pixelSize: 18
+ color: "#ffffff"
+ }
+
+ }
+
+ back: FocusScope {
+ height: 60
+ width: parent.width
+ Rectangle {
+ anchors.fill: parent
+ color: "#999999"
+
+ Rectangle { color: "#c1c1c1"; width: parent.width; height: 1 }
+ Rectangle { color: "#707070"; width: parent.width; height: 1; anchors.bottom: parent.bottom }
+
+ LineInput {
+ id: lineInput
+ hint: flipBar.placeHolder
+ focus: flipBar.opened
+ anchors { fill: parent; margins: 6 }
+ onAccepted: flipBar.ok()
+ }
+ }
+ }
+
+}
diff --git a/examples/demos/tweetsearch/content/TweetDelegate.qml b/examples/demos/tweetsearch/content/TweetDelegate.qml
new file mode 100644
index 0000000000..f67685c172
--- /dev/null
+++ b/examples/demos/tweetsearch/content/TweetDelegate.qml
@@ -0,0 +1,172 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import "tweetsearch.js" as Helper
+
+Item {
+ id: container
+ property real hm: 1.0
+ property int appear: -1
+ property real startRotation: 1
+
+ onAppearChanged: {
+ container.startRotation = 0.5
+ flipBar.animDuration = appear;
+ delayedAnim.start();
+ }
+
+ SequentialAnimation {
+ id: delayedAnim
+ PauseAnimation { duration: 50 }
+ ScriptAction { script: flipBar.flipDown(startRotation); }
+ }
+
+ width: 320
+ height: flipBar.height * hm
+
+ FlipBar {
+ id: flipBar
+
+ property bool flipped: false
+ delta: startRotation
+// wiggleDuration: 120
+// wiggleRoom: 2
+
+ anchors.bottom: parent.bottom
+ width: container.ListView.view ? container.ListView.view.width : 0
+ height: Math.max(72, tweet.y + tweet.height + 10)
+
+ front: Rectangle {
+ width: container.ListView.view ? container.ListView.view.width : 0
+ height: Math.max(72, tweet.y + tweet.height + 10)
+ color: "#2699bf"
+
+ Rectangle { color: "#33ccff"; width: parent.width; height: 1 }
+ Rectangle { color: "#1a6680"; width: parent.width; height: 1; anchors.bottom: parent.bottom }
+
+ Image {
+ id: placeHolder
+ source: "resources/anonymous.png"
+ x: 10; y: 9
+ visible: avatar.status != Image.Ready
+ }
+ Image {
+ id: avatar
+ source: model.userImage
+ anchors.fill: placeHolder
+ }
+
+ Text {
+ id: name
+ text: Helper.realName(model.name)
+ anchors { left: avatar.right; leftMargin: 10; top: avatar.top; topMargin: -3 }
+ font.pixelSize: 12
+ font.bold: true
+ color: "white"
+ linkColor: "white"
+ }
+
+ Text {
+ id: tweet
+ text: model.statusText
+ anchors { left: avatar.right; leftMargin: 10; top: name.bottom; topMargin: 0; right: parent.right; rightMargin: 10 }
+ wrapMode: Text.WordWrap
+ font.pixelSize: 12
+ font.bold: false
+ color: "#adebff"
+ linkColor: "white"
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: {
+ if (!flipBar.flipped) {
+ flipBar.flipUp()
+ flipBar.flipped = true
+ } else {
+ flipBar.flipDown()
+ flipBar.flipped = false
+ }
+ }
+ }
+ }
+
+ back: Rectangle {
+ width: container.ListView.view ? container.ListView.view.width : 0
+ height: Math.max(72, tweet.y + tweet.height + 10)
+ color: "#be4a25"
+
+ Rectangle { color: "#ff6633"; width: parent.width; height: 1 }
+ Rectangle { color: "#80341a"; width: parent.width; height: 1; anchors.bottom: parent.bottom }
+
+ Image {
+ id: avatar2
+ source: model.userImage
+ anchors.right: parent.right
+ anchors.rightMargin: 10
+ y: 9
+ }
+
+ Text {
+ id: username
+ text: Helper.twitterName(model.name)
+ x: 10; anchors { top: avatar2.top; topMargin: -3 }
+ font.pixelSize: 12
+ font.bold: true
+ color: "white"
+ linkColor: "white"
+ }
+
+ Text {
+ text: model.source + "<br>" + Helper.formatDate(model.published) + "<br>" + model.uri
+ x: 10; anchors { top: username.bottom; topMargin: 0 }
+ wrapMode: Text.WordWrap
+ font.pixelSize: 12
+ font.bold: false
+ color: "#ffc2ad"
+ linkColor: "white"
+ onLinkActivated: Qt.openUrlExternally(link);
+
+ }
+ }
+ }
+}
diff --git a/examples/demos/tweetsearch/content/TweetsModel.qml b/examples/demos/tweetsearch/content/TweetsModel.qml
new file mode 100644
index 0000000000..d59252bbcf
--- /dev/null
+++ b/examples/demos/tweetsearch/content/TweetsModel.qml
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
+
+Item {
+ id: wrapper
+
+ property variant model: xmlModel
+ property string from : ""
+ property string phrase : ""
+
+ property string mode : "everyone"
+ property int status: xmlModel.status
+
+ function reload() { xmlModel.reload(); }
+
+ property bool isLoading: status == XmlListModel.Loading
+ property bool wasLoading: false
+ signal isLoaded
+
+ XmlListModel {
+ id: xmlModel
+
+ onStatusChanged: {
+ if (status == XmlListModel.Ready && wasLoading == true)
+ wrapper.isLoaded()
+ if (status == XmlListModel.Loading)
+ wasLoading = true;
+ else
+ wasLoading = false;
+ }
+
+ function encodePhrase(x) { return encodeURIComponent(x); }
+
+ source: (from == "" && phrase == "") ? "" :
+ 'http://search.twitter.com/search.atom?from='+from+"&rpp=10&phrase="+encodePhrase(phrase)
+
+ namespaceDeclarations: "declare default element namespace 'http://www.w3.org/2005/Atom'; " +
+ "declare namespace twitter=\"http://api.twitter.com/\";";
+
+ query: "/feed/entry"
+
+ XmlRole { name: "id"; query: "id/string()" }
+ XmlRole { name: "content"; query: "content/string()" }
+ XmlRole { name: "published"; query: "published/string()" }
+ XmlRole { name: "source"; query: "twitter:source/string()" }
+ XmlRole { name: "name"; query: "author/name/string()" }
+ XmlRole { name: "uri"; query: "author/uri/string()" }
+ XmlRole { name: "image"; query: "link[@rel = 'image']/@href/string()" }
+
+ }
+}
diff --git a/examples/demos/tweetsearch/content/resources/anonymous.png b/examples/demos/tweetsearch/content/resources/anonymous.png
new file mode 100644
index 0000000000..88fba26e90
--- /dev/null
+++ b/examples/demos/tweetsearch/content/resources/anonymous.png
Binary files differ
diff --git a/examples/demos/tweetsearch/content/resources/bird-anim-sprites.png b/examples/demos/tweetsearch/content/resources/bird-anim-sprites.png
new file mode 100644
index 0000000000..07ed9044f0
--- /dev/null
+++ b/examples/demos/tweetsearch/content/resources/bird-anim-sprites.png
Binary files differ
diff --git a/examples/demos/tweetsearch/content/resources/icon-clear.png b/examples/demos/tweetsearch/content/resources/icon-clear.png
new file mode 100644
index 0000000000..75672f64c7
--- /dev/null
+++ b/examples/demos/tweetsearch/content/resources/icon-clear.png
Binary files differ
diff --git a/examples/demos/tweetsearch/content/resources/icon-loading.png b/examples/demos/tweetsearch/content/resources/icon-loading.png
new file mode 100644
index 0000000000..8dbff8b70f
--- /dev/null
+++ b/examples/demos/tweetsearch/content/resources/icon-loading.png
Binary files differ
diff --git a/examples/demos/tweetsearch/content/resources/icon-refresh.png b/examples/demos/tweetsearch/content/resources/icon-refresh.png
new file mode 100644
index 0000000000..b639a638fe
--- /dev/null
+++ b/examples/demos/tweetsearch/content/resources/icon-refresh.png
Binary files differ
diff --git a/examples/demos/tweetsearch/content/resources/icon-search.png b/examples/demos/tweetsearch/content/resources/icon-search.png
new file mode 100644
index 0000000000..e41935a6c1
--- /dev/null
+++ b/examples/demos/tweetsearch/content/resources/icon-search.png
Binary files differ
diff --git a/examples/demos/tweetsearch/content/tweetsearch.js b/examples/demos/tweetsearch/content/tweetsearch.js
new file mode 100644
index 0000000000..78c58c0625
--- /dev/null
+++ b/examples/demos/tweetsearch/content/tweetsearch.js
@@ -0,0 +1,20 @@
+.pragma library
+
+function twitterName(str)
+{
+ var s = str.split("(")
+ return s[0]
+}
+
+function realName(str)
+{
+ var s = str.split("(")
+ return s[1].substring(0, s[1].length-1)
+}
+
+function formatDate(date)
+{
+ var da = new Date(date)
+ return da.toDateString()
+}
+