From: Yann Bodson Date: Fri, 11 May 2012 03:54:08 +0000 (+1000) Subject: Replace twitter demo with new tweetsearch demo X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=ead5eaa77158b03f209596eb201b7b0b2f3170e9;p=konrad%2Fqtdeclarative.git Replace twitter demo with new tweetsearch demo Change-Id: I1b4433e63184cb773056bb753011d6320254cd52 Reviewed-by: Alan Alpert --- diff --git a/examples/demos/demos.pro b/examples/demos/demos.pro index abe718b..e4d2243 100644 --- a/examples/demos/demos.pro +++ b/examples/demos/demos.pro @@ -1,2 +1,3 @@ TEMPLATE = subdirs -SUBDIRS = calculator +SUBDIRS = calculator \ + tweetsearch diff --git a/examples/demos/tweetsearch/content/FlipBar.qml b/examples/demos/tweetsearch/content/FlipBar.qml new file mode 100644 index 0000000..ea149ec --- /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 0000000..d81d845 --- /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 0000000..fab40bd --- /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 0000000..fbb1765 --- /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 0000000..8c6ad40 --- /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 0000000..f67685c --- /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 + "
" + Helper.formatDate(model.published) + "
" + 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 0000000..d59252b --- /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 0000000..88fba26 Binary files /dev/null and b/examples/demos/tweetsearch/content/resources/anonymous.png 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 0000000..07ed904 Binary files /dev/null and b/examples/demos/tweetsearch/content/resources/bird-anim-sprites.png 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 0000000..75672f6 Binary files /dev/null and b/examples/demos/tweetsearch/content/resources/icon-clear.png 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 0000000..8dbff8b Binary files /dev/null and b/examples/demos/tweetsearch/content/resources/icon-loading.png 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 0000000..b639a63 Binary files /dev/null and b/examples/demos/tweetsearch/content/resources/icon-refresh.png 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 0000000..e41935a Binary files /dev/null and b/examples/demos/tweetsearch/content/resources/icon-search.png differ diff --git a/examples/demos/tweetsearch/content/tweetsearch.js b/examples/demos/tweetsearch/content/tweetsearch.js new file mode 100644 index 0000000..78c58c0 --- /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() +} + diff --git a/examples/demos/tweetsearch/main.cpp b/examples/demos/tweetsearch/main.cpp new file mode 100644 index 0000000..fb34c52 --- /dev/null +++ b/examples/demos/tweetsearch/main.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#include +#include +#include +#include + +void usage() +{ + exit(0); +} + +int main(int argc, char* argv[]) +{ + QGuiApplication app(argc,argv); + QQuickView view; + QUrl launchFile = QUrl::fromLocalFile(QLatin1String("tweetsearch.qml")); + if (app.arguments().contains(QLatin1String("-help"))) + usage(); + view.connect(view.engine(), SIGNAL(quit()), &app, SLOT(quit())); + view.setSource(launchFile); + view.show(); + return app.exec(); +} + diff --git a/examples/demos/tweetsearch/tweetsearch.pro b/examples/demos/tweetsearch/tweetsearch.pro new file mode 100644 index 0000000..12a09df --- /dev/null +++ b/examples/demos/tweetsearch/tweetsearch.pro @@ -0,0 +1,9 @@ +TEMPLATE = app + +QT += quick qml +SOURCES += main.cpp + +target.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/demos/tweetsearch +qml.files = tweetsearch.qml content +qml.path = $$[QT_INSTALL_EXAMPLES]/qtdeclarative/demos/tweetsearch +INSTALLS += target qml diff --git a/examples/demos/tweetsearch/tweetsearch.qdoc b/examples/demos/tweetsearch/tweetsearch.qdoc new file mode 100644 index 0000000..1cff976 --- /dev/null +++ b/examples/demos/tweetsearch/tweetsearch.qdoc @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +/*! + \title QML Demo - Tweet Search + \example demos/tweetsearch + \brief This is simple twitter application written in QML. + + The Tweet Search demo shows how to write a simple twitter application. + It uses the twitter search API to search for tweets with specific words or hashtag + or from a specific user. The tweets are presented in a list that can be pulled to + be updated. +*/ + diff --git a/examples/demos/tweetsearch/tweetsearch.qml b/examples/demos/tweetsearch/tweetsearch.qml new file mode 100644 index 0000000..754dcac --- /dev/null +++ b/examples/demos/tweetsearch/tweetsearch.qml @@ -0,0 +1,128 @@ +/**************************************************************************** +** +** 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 "content" + +Rectangle { + id: main + width: 320 + height: 480 + + property string searchTerms: "" + property int inAnimDur: 250 + property int counter: 0 + property alias isLoading: tweetsModel.isLoading + property var idx + property var ids + + Component.onCompleted: ids = new Array() + + function idInModel(id) + { + for (var j = 0; j < ids.length; j++) + if (ids[j] === id) + return 1 + return 0 + } + + TweetsModel { + id: tweetsModel + onIsLoaded: { + console.debug("Reload") + idx = new Array() + for (var i = 0; i < tweetsModel.model.count; i++) { + var id = tweetsModel.model.get(i).id + if (!idInModel(id)) + idx.push(i) + } + console.debug(idx.length + " new tweets") + main.counter = idx.length + } + } + + Timer { + id: timer + interval: 500; running: main.counter; repeat: true + onTriggered: { + main.counter--; + var id = tweetsModel.model.get(idx[main.counter]).id + mainListView.add( { "statusText": tweetsModel.model.get(main.counter).content, + "name": tweetsModel.model.get(main.counter).name, + "userImage": tweetsModel.model.get(main.counter).image, + "source": tweetsModel.model.get(main.counter).source, + "id": id, + "uri": tweetsModel.model.get(main.counter).uri, + "published": tweetsModel.model.get(main.counter).published } ); + ids.push(id) + } + } + + ListView { + id: mainListView + anchors.fill: parent + delegate: TweetDelegate { } + model: ListModel { id: finalModel } + + add: Transition { + NumberAnimation { property: "hm"; from: 0; to: 1.0; duration: 300; easing.type: Easing.OutQuad } + PropertyAction { property: "appear"; value: 250 } + } + + onDragEnded: if (header.refresh) { tweetsModel.model.reload() } + + ListHeader { + id: header + y: -mainListView.contentY - height + } + + footer: ListFooter { } + + function clear() { + ids = new Array() + model.clear() + } + + function add(obj) { + model.insert(0, obj) + } + + } +} diff --git a/examples/demos/twitter/twitter.qmlproject b/examples/demos/tweetsearch/tweetsearch.qmlproject similarity index 89% rename from examples/demos/twitter/twitter.qmlproject rename to examples/demos/tweetsearch/tweetsearch.qmlproject index b14f71f..5a0f311 100644 --- a/examples/demos/twitter/twitter.qmlproject +++ b/examples/demos/tweetsearch/tweetsearch.qmlproject @@ -1,7 +1,7 @@ import QmlProject 1.1 Project { - mainFile: "twitter.qml" + mainFile: "tweetsearch.qml" /* Include .qml, .js, and image files from current directory and subdirectories */ QmlFiles { diff --git a/examples/demos/twitter/TwitterCore/Button.qml b/examples/demos/twitter/TwitterCore/Button.qml deleted file mode 100644 index 353b993..0000000 --- a/examples/demos/twitter/TwitterCore/Button.qml +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: container - - signal clicked - - property string text - property bool keyUsing: false - - BorderImage { - id: buttonImage - source: "images/toolbutton.sci" - width: container.width; height: container.height - } - BorderImage { - id: pressed - opacity: 0 - source: "images/toolbutton.sci" - width: container.width; height: container.height - } - MouseArea { - id: mouseRegion - anchors.fill: buttonImage - onClicked: { container.clicked(); } - } - Text { - id: btnText - color: if(container.keyUsing){"#D0D0D0";} else {"#FFFFFF";} - anchors.centerIn: buttonImage; font.bold: true - text: container.text; style: Text.Raised; styleColor: "black" - font.pixelSize: 12 - } - states: [ - State { - name: "Pressed" - when: mouseRegion.pressed == true - PropertyChanges { target: pressed; opacity: 1 } - }, - State { - name: "Focused" - when: container.activeFocus == true - PropertyChanges { target: btnText; color: "#FFFFFF" } - } - ] - transitions: Transition { - ColorAnimation { target: btnText; } - } -} diff --git a/examples/demos/twitter/TwitterCore/FatDelegate.qml b/examples/demos/twitter/TwitterCore/FatDelegate.qml deleted file mode 100644 index 4cb0dfc..0000000 --- a/examples/demos/twitter/TwitterCore/FatDelegate.qml +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Component { - id: listDelegate - Item { - id: wrapper; width: wrapper.ListView.view.width; height: if(txt.height > 60){txt.height+10}else{60} //50+5+5 - function handleLink(link){ - if(link.slice(0,3) == 'app'){ - screen.setUser(link.slice(7)); - }else if(link.slice(0,4) == 'http'){ - Qt.openUrlExternally(link); - } - } - function addTags(str){ - var ret = str.replace(/@[a-zA-Z0-9_]+/g, '$&');//click to jump to user? - var ret2 = ret.replace(/http:\/\/[^ \n\t]+/g, '$&');//surrounds http links with html link tags - return ret2; - } - - // Strip away paranthesis - function userName(str) { - var user = str.replace(/\([\S|\s]*\)/gi, ""); - return user.trim(); - } - - Item { - id: moveMe; height: parent.height - Rectangle { - id: blackRect - color: "black"; opacity: wrapper.ListView.index % 2 ? 0.2 : 0.3; height: wrapper.height-2; width: wrapper.width; y: 1 - } - Item { - id: image; x: 6; width: 48; height: 48; smooth: true - anchors.verticalCenter: parent.verticalCenter - - Loading { x: 1; y: 1; width: 48; height: 48; visible: realImage.status != Image.Ready } - Image { - id: realImage; - source: userImage; x: 1; y: 1; - width:48; height:48; opacity:0 ; - onStatusChanged: { - if(status==Image.Ready) - image.state="loaded" - } - } - states: State { - name: "loaded"; - PropertyChanges { target: realImage ; opacity:1 } - } - transitions: Transition { NumberAnimation { target: realImage; property: "opacity"; duration: 200 } } - - } - Text { id:txt; y:4; x: 56 - text: '' - + ''+userName(name) + " from " +source - + "
" + statusText + ""; - textFormat: Text.StyledText - color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrapMode: Text.WordWrap; linkColor: "#aaccaa" - anchors.left: image.right; anchors.right: blackRect.right; anchors.leftMargin: 6; anchors.rightMargin: 6 - onLinkActivated: wrapper.handleLink(link) - } - } - } -} diff --git a/examples/demos/twitter/TwitterCore/Input.qml b/examples/demos/twitter/TwitterCore/Input.qml deleted file mode 100644 index 68b1c61..0000000 --- a/examples/demos/twitter/TwitterCore/Input.qml +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -FocusScope { - id:container - width: 220 - height: 28 - BorderImage { source: "images/lineedit.sci"; anchors.fill: parent } - signal accepted - property alias text: input.text - property alias item:input - TextInput{ - id: input - width: parent.width - 12 - anchors.centerIn: parent - maximumLength:21 - font.pixelSize: 16; - font.bold: true - color: "#151515"; selectionColor: "mediumseagreen" - focus: true - onAccepted:{container.accepted()} - text: "" - selectByMouse: true - } -} diff --git a/examples/demos/twitter/TwitterCore/Loading.qml b/examples/demos/twitter/TwitterCore/Loading.qml deleted file mode 100644 index 566857b..0000000 --- a/examples/demos/twitter/TwitterCore/Loading.qml +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Image { - id: loading; source: "images/loading.png" - NumberAnimation on rotation { - from: 0; to: 360; running: loading.visible == true; loops: Animation.Infinite; duration: 900 - } -} diff --git a/examples/demos/twitter/TwitterCore/MultiTitleBar.qml b/examples/demos/twitter/TwitterCore/MultiTitleBar.qml deleted file mode 100644 index 3920520..0000000 --- a/examples/demos/twitter/TwitterCore/MultiTitleBar.qml +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - TitleBar { id: titleBar; width: parent.width; height: 60; - y: -80 - untaggedString: "Latest tweets from everyone" - taggedString: "Latest tweets from " - } - states: [ - State { - name: "search"; when: screen.state!="search" - PropertyChanges { target: titleBar; y: 0 } - } - ] - transitions: [ - Transition { NumberAnimation { properties: "x,y"; duration: 500; easing.type: Easing.InOutQuad } } - ] -} - diff --git a/examples/demos/twitter/TwitterCore/RssModel.qml b/examples/demos/twitter/TwitterCore/RssModel.qml deleted file mode 100644 index 27f7495..0000000 --- a/examples/demos/twitter/TwitterCore/RssModel.qml +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 - -Item { id: wrapper - property variant model: xmlModel - property string from : "" - property string to : "" - property string phrase : "" - - property string mode : "everyone" - property int status: xmlModel.status - function reload() { xmlModel.reload(); } - - XmlListModel { - id: xmlModel - - function encodePhrase(x) { return encodeURIComponent(x); } - - source: (from=="" && to=="" && phrase=="") ? "" : - 'http://search.twitter.com/search.atom?from='+from+"&to="+to+"&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: "statusText"; query: "content/string()" } - XmlRole { name: "timestamp"; query: "published/string()" } - XmlRole { name: "source"; query: "twitter:source/string()" } - XmlRole { name: "name"; query: "author/name/string()" } - XmlRole { name: "userImage"; query: "link[@rel = 'image']/@href/string()" } - - } - Binding { - property: "mode" - target: wrapper - value: {if(wrapper.tags==''){"everyone";}else if(wrapper.tags=='my timeline'){"self";}else{"user";}} - } -} diff --git a/examples/demos/twitter/TwitterCore/SearchView.qml b/examples/demos/twitter/TwitterCore/SearchView.qml deleted file mode 100644 index 7732e6f..0000000 --- a/examples/demos/twitter/TwitterCore/SearchView.qml +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -FocusScope { - id: wrapper - Column { - anchors.centerIn: parent - spacing: 20 - Column{ - spacing: 4 - Text { - text: "Posted by:" - font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black" - horizontalAlignment: Qt.AlignRight - } - Input{ - id: fromIn - KeyNavigation.backtab: searchbutton - KeyNavigation.tab:toIn - onAccepted:searchbutton.doSearch(); - focus: true - } - Text { - text: "In reply to:" - font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black" - horizontalAlignment: Qt.AlignRight - } - Input{ - id: toIn - KeyNavigation.backtab: fromIn - KeyNavigation.tab:phraseIn - onAccepted:searchbutton.doSearch(); - } - Text { - text: "Search phrase:" - font.pixelSize: 16; font.bold: true; color: "white"; style: Text.Raised; styleColor: "black" - horizontalAlignment: Qt.AlignRight - } - Input{ - id: phraseIn - KeyNavigation.backtab: toIn - KeyNavigation.tab:searchbutton - onAccepted:searchbutton.doSearch(); - text: "Qt Quick" - } - } - Button { - width: 100 - height: 32 - id: searchbutton - keyUsing: true; - opacity: 1 - text: "Search" - KeyNavigation.tab: fromIn - Keys.onReturnPressed: searchbutton.doSearch(); - Keys.onEnterPressed: searchbutton.doSearch(); - Keys.onSelectPressed: searchbutton.doSearch(); - Keys.onSpacePressed: searchbutton.doSearch(); - onClicked: searchbutton.doSearch(); - - function doSearch() { - // Search ! allowed - if (wrapper.state=="invalidinput") - return; - - rssModel.from=fromIn.text; - rssModel.to= toIn.text; - rssModel.phrase = phraseIn.text; - screen.focus = true; - screen.state = "" - } - } - } - states: - State { - name: "invalidinput" - when: fromIn.text=="" && toIn.text=="" && phraseIn.text=="" - PropertyChanges { target: searchbutton ; opacity: 0.6 ; } - } - transitions: - Transition { - NumberAnimation { target: searchbutton; property: "opacity"; duration: 200 } - } -} diff --git a/examples/demos/twitter/TwitterCore/TitleBar.qml b/examples/demos/twitter/TwitterCore/TitleBar.qml deleted file mode 100644 index 3e0818b..0000000 --- a/examples/demos/twitter/TwitterCore/TitleBar.qml +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: titleBar - property string untaggedString: "Uploads from everyone" - property string taggedString: "Recent uploads tagged " - - BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } - - Item { - id: container - width: (parent.width * 2) - 55 ; height: parent.height - - function accept() { - titleBar.state = "" - background.state = "" - rssModel.tags = editor.text - } - - Item { - id:imageBox - x: 6; width: 0; height: 50; smooth: true - anchors.verticalCenter: parent.verticalCenter - - UserModel { user: rssModel.from; id: userModel } - Component { - id: imgDelegate; - Item { - id:imageitem - visible:true - Loading { width:48; height:48; visible: realImage.status != Image.Ready } - Image { id: realImage; source: image; width:48; height:48; opacity:0; } - states: - State { - name: "loaded" - when: (realImage.status == Image.Ready) - PropertyChanges { target: realImage; opacity:1 } - } - transitions: Transition { - NumberAnimation { target: realImage; property: "opacity"; duration: 200 } - } - } - } - ListView { id:view; model: userModel.model; x:1; y:1; delegate: imgDelegate } - states: - State { - when: !userModel.user=="" - PropertyChanges { target: imageBox; width: 50; } - } - transitions: - Transition { - NumberAnimation { target: imageBox; property: "width"; duration: 200 } - } - } - - Image { - id: quitButton - x: 5 - anchors.verticalCenter: parent.verticalCenter - source: "images/quit.png" - MouseArea { - anchors.fill: parent - onClicked: Qt.quit() - } - } - - Text { - id: categoryText - anchors { - left: quitButton.right; right: parent.right; leftMargin: 10; rightMargin: 10 - verticalCenter: parent.verticalCenter - } - elide: Text.ElideLeft - text: (rssModel.from=="" ? untaggedString : taggedString + rssModel.from) - font.bold: true; color: "White"; style: Text.Raised; styleColor: "Black" - font.pixelSize: 12 - } - } - - states: State { - name: "Tags" - PropertyChanges { target: container; x: -tagButton.x + 5 } - PropertyChanges { target: editor; focus: true } - } - - transitions: Transition { - NumberAnimation { properties: "x"; easing.type: Easing.InOutQuad } - } -} diff --git a/examples/demos/twitter/TwitterCore/ToolBar.qml b/examples/demos/twitter/TwitterCore/ToolBar.qml deleted file mode 100644 index d4265f3..0000000 --- a/examples/demos/twitter/TwitterCore/ToolBar.qml +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -Item { - id: toolbar - - property alias button1Label: button1.text - property alias button2Label: button2.text - signal button1Clicked - signal button2Clicked - focus:true - BorderImage { source: "images/titlebar.sci"; width: parent.width; height: parent.height + 14; y: -7 } - Button { - id: button1 - anchors.left: parent.left; anchors.leftMargin: 5; y: 3; width: 140; height: 32 - onClicked: toolbar.button1Clicked() - focus:true - } - Button { - id: button2 - anchors.right: parent.right; anchors.rightMargin: 5; y: 3; width: 140; height: 32 - onClicked: toolbar.button2Clicked() - } -} diff --git a/examples/demos/twitter/TwitterCore/UserModel.qml b/examples/demos/twitter/TwitterCore/UserModel.qml deleted file mode 100644 index 428089b..0000000 --- a/examples/demos/twitter/TwitterCore/UserModel.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 - -//This "model" gets the user information about the searched user. Mainly for the icon. - -Item { id: wrapper - property variant model: xmlModel - property string user : "" - property int status: xmlModel.status - function reload() { xmlModel.reload(); } - XmlListModel { - id: xmlModel - - source: user!= "" ? "http://twitter.com/users/show.xml?screen_name="+user : "" - query: "/user" - - XmlRole { name: "name"; query: "name/string()" } - XmlRole { name: "screenName"; query: "screen_name/string()" } - XmlRole { name: "image"; query: "profile_image_url/string()" } - XmlRole { name: "location"; query: "location/string()" } - XmlRole { name: "description"; query: "description/string()" } - XmlRole { name: "followers"; query: "followers_count/string()" } - //TODO: Could also get the user's color scheme, timezone and a few other things - } -} diff --git a/examples/demos/twitter/TwitterCore/images/gloss.png b/examples/demos/twitter/TwitterCore/images/gloss.png deleted file mode 100644 index 5d370cd..0000000 Binary files a/examples/demos/twitter/TwitterCore/images/gloss.png and /dev/null differ diff --git a/examples/demos/twitter/TwitterCore/images/lineedit.png b/examples/demos/twitter/TwitterCore/images/lineedit.png deleted file mode 100644 index 2cc38dc..0000000 Binary files a/examples/demos/twitter/TwitterCore/images/lineedit.png and /dev/null differ diff --git a/examples/demos/twitter/TwitterCore/images/lineedit.sci b/examples/demos/twitter/TwitterCore/images/lineedit.sci deleted file mode 100644 index 054bff7..0000000 --- a/examples/demos/twitter/TwitterCore/images/lineedit.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 10 -border.top: 10 -border.bottom: 10 -border.right: 10 -source: lineedit.png diff --git a/examples/demos/twitter/TwitterCore/images/loading.png b/examples/demos/twitter/TwitterCore/images/loading.png deleted file mode 100644 index 47a1589..0000000 Binary files a/examples/demos/twitter/TwitterCore/images/loading.png and /dev/null differ diff --git a/examples/demos/twitter/TwitterCore/images/quit.png b/examples/demos/twitter/TwitterCore/images/quit.png deleted file mode 100644 index 5bda1b6..0000000 Binary files a/examples/demos/twitter/TwitterCore/images/quit.png and /dev/null differ diff --git a/examples/demos/twitter/TwitterCore/images/stripes.png b/examples/demos/twitter/TwitterCore/images/stripes.png deleted file mode 100644 index 9f36727e..0000000 Binary files a/examples/demos/twitter/TwitterCore/images/stripes.png and /dev/null differ diff --git a/examples/demos/twitter/TwitterCore/images/titlebar.png b/examples/demos/twitter/TwitterCore/images/titlebar.png deleted file mode 100644 index 51c9008..0000000 Binary files a/examples/demos/twitter/TwitterCore/images/titlebar.png and /dev/null differ diff --git a/examples/demos/twitter/TwitterCore/images/titlebar.sci b/examples/demos/twitter/TwitterCore/images/titlebar.sci deleted file mode 100644 index 0418d94..0000000 --- a/examples/demos/twitter/TwitterCore/images/titlebar.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 10 -border.top: 12 -border.bottom: 12 -border.right: 10 -source: titlebar.png diff --git a/examples/demos/twitter/TwitterCore/images/toolbutton.png b/examples/demos/twitter/TwitterCore/images/toolbutton.png deleted file mode 100644 index 1131001..0000000 Binary files a/examples/demos/twitter/TwitterCore/images/toolbutton.png and /dev/null differ diff --git a/examples/demos/twitter/TwitterCore/images/toolbutton.sci b/examples/demos/twitter/TwitterCore/images/toolbutton.sci deleted file mode 100644 index 9e4f965..0000000 --- a/examples/demos/twitter/TwitterCore/images/toolbutton.sci +++ /dev/null @@ -1,5 +0,0 @@ -border.left: 15 -border.top: 4 -border.bottom: 4 -border.right: 15 -source: toolbutton.png diff --git a/examples/demos/twitter/TwitterCore/qmldir b/examples/demos/twitter/TwitterCore/qmldir deleted file mode 100644 index 452a648..0000000 --- a/examples/demos/twitter/TwitterCore/qmldir +++ /dev/null @@ -1,10 +0,0 @@ -SearchView 2.0 SearchView.qml -Button 2.0 Button.qml -Input 2.0 Input.qml -FatDelegate 2.0 FatDelegate.qml -Loading 2.0 Loading.qml -MultiTitleBar 2.0 MultiTitleBar.qml -TitleBar 2.0 TitleBar.qml -RssModel 2.0 RssModel.qml -UserModel 2.0 UserModel.qml -ToolBar 2.0 ToolBar.qml diff --git a/examples/demos/twitter/twitter.qml b/examples/demos/twitter/twitter.qml deleted file mode 100644 index aca0968..0000000 --- a/examples/demos/twitter/twitter.qml +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtQuick.XmlListModel 2.0 -import "TwitterCore" 2.0 as Twitter - -Item { - id: screen; width: 320; height: 480 - property bool userView : false - property variant tmpStr - function setUser(str){hack.running = true; tmpStr = str} - function reallySetUser(){rssModel.from = tmpStr;rssModel.to = ""; rssModel.phrase = ""} - state:"searchquery" - //Workaround for bug 260266 - Timer{ interval: 1; running: false; repeat: false; onTriggered: screen.reallySetUser(); id:hack } - Keys.onEscapePressed: screen.state="searchquery" - Keys.onBacktabPressed: screen.state="searchquery" - Rectangle { - id: background - anchors.fill: parent; color: "#343434"; - - state:"searchquery" - Image { source: "TwitterCore/images/stripes.png"; fillMode: Image.Tile; anchors.fill: parent; opacity: 0.3 } - - MouseArea { - anchors.fill: parent - onClicked: screen.focus = false; - } - - Twitter.RssModel { id: rssModel } - Twitter.Loading { anchors.centerIn: parent; visible: rssModel.status==XmlListModel.Loading && state!='unauthed'} - Text { - width: 180 - text: "Could not access twitter using this screen name and password pair."; - color: "#cccccc"; style: Text.Raised; styleColor: "black"; wrapMode: Text.WordWrap - visible: rssModel.status==XmlListModel.Error; anchors.centerIn: parent - } - - Item { - id: views - x: 2; width: parent.width - 4 - y:60 //Below the title bars - height: parent.height - 100 - - Text { - id:title - text: "Search Twitter" - anchors.horizontalCenter: parent.horizontalCenter - font.pixelSize: 20; font.bold: true; color: "#bbb"; style: Text.Raised; styleColor: "black" - opacity:0 - } - - Twitter.SearchView{ - id: searchView - anchors.verticalCenter: parent.verticalCenter - width: parent.width; height: parent.height-60; - x: -(screen.width * 1.5) - } - - Twitter.FatDelegate { id: fatDelegate } - ListView { - id: mainView; model: rssModel.model; delegate: fatDelegate; - width: parent.width; height: parent.height; x: 0; cacheBuffer: 100; - } - } - - Twitter.MultiTitleBar { id: titleBar; width: parent.width } - Twitter.ToolBar { id: toolBar; height: 40; - //anchors.bottom: parent.bottom; - //TODO: Use anchor changes instead of hard coding - y: screen.height - 40 - width: parent.width; opacity: 0.9 - button1Label: "New Search" - button2Label: "Update" - onButton1Clicked: - { - screen.state="searchquery" - } - onButton2Clicked: rssModel.reload(); - } - } - states: [ - State { - name: "searchquery"; - PropertyChanges { target: searchView; x: 0; focus:true} - PropertyChanges { target: mainView; x: -(parent.width * 1.5) } - PropertyChanges { target: titleBar; y: -80 } - PropertyChanges { target: toolBar; y: screen.height } - PropertyChanges { target: toolBar } - PropertyChanges { target: title; opacity:1} - } - ] - transitions: [ - Transition { NumberAnimation { properties: "x,y,opacity"; duration: 500; easing.type: Easing.InOutQuad } } - ] -}