diff options
Diffstat (limited to 'examples/quick/demos/tweetsearch')
22 files changed, 0 insertions, 1397 deletions
diff --git a/examples/quick/demos/tweetsearch/content/FlipBar.qml b/examples/quick/demos/tweetsearch/content/FlipBar.qml deleted file mode 100644 index 608f5cc08b..0000000000 --- a/examples/quick/demos/tweetsearch/content/FlipBar.qml +++ /dev/null @@ -1,183 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 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 - - onFrontShownChanged: { - back.visible = !frontShown - front.visible = frontShown - } - - 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; - } - - 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; - } - - ShaderEffect { - id: effect - width: cur.width - height: cur.height - property real factor: container.factor * width - property real delta: 1.0 - - mesh: GridMesh { resolution: Qt.size(8,2) } - - SequentialAnimation on delta { - id: dAnim - running: false - NumberAnimation { - id: deltaAnim - duration: animDuration//expose anim - } - } - - 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() { - 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); - } 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 - pos.y = delta * h; - gl_Position = qt_Matrix * pos; - qt_TexCoord0 = qt_MultiTexCoord0; - }" - - } -} diff --git a/examples/quick/demos/tweetsearch/content/LineInput.qml b/examples/quick/demos/tweetsearch/content/LineInput.qml deleted file mode 100644 index 1ef8fd9f5c..0000000000 --- a/examples/quick/demos/tweetsearch/content/LineInput.qml +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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.displayText.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/quick/demos/tweetsearch/content/ListFooter.qml b/examples/quick/demos/tweetsearch/content/ListFooter.qml deleted file mode 100644 index b84496d4c1..0000000000 --- a/examples/quick/demos/tweetsearch/content/ListFooter.qml +++ /dev/null @@ -1,164 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 - Connections { - target: mainListView - onAutoSearch: { - if (type == 'tag') { - tagSearch.open() - tagSearch.searchText = str - } else if (type == 'user'){ - userSearch.open() - userSearch.searchText = str - } else { - wordSearch.open() - wordSearch.searchText = str - } - } - } - - 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 - } - } - - SpriteSequence { - id: sprite - anchors.horizontalCenter: parent.horizontalCenter - width: 320 - height: 300 - running: true - interpolate: false - Sprite { - name: "bird" - source: "resources/bird-anim-sprites.png" - frameCount: 1 - frameRate: 1 - frameWidth: 320 - frameHeight: 300 - to: { "bird":10, "trill":1, "blink":1 } - } - Sprite { - name: "trill" - source: "resources/bird-anim-sprites.png" - frameCount: 5 - frameRate: 3 - frameWidth: 320 - frameHeight: 300 - to: {"bird":1} - } - Sprite { - name: "blink" - source: "resources/bird-anim-sprites.png" - frameCount: 1 - frameRate: 3 - frameWidth: 320 - frameHeight: 300 - frameX: 1600 - to: {"bird":1} - } - } - } -} diff --git a/examples/quick/demos/tweetsearch/content/ListHeader.qml b/examples/quick/demos/tweetsearch/content/ListHeader.qml deleted file mode 100644 index 8c4facf34b..0000000000 --- a/examples/quick/demos/tweetsearch/content/ListHeader.qml +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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: 18 - color: "#999999" - } - } - - 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/quick/demos/tweetsearch/content/SearchDelegate.qml b/examples/quick/demos/tweetsearch/content/SearchDelegate.qml deleted file mode 100644 index 082653657a..0000000000 --- a/examples/quick/demos/tweetsearch/content/SearchDelegate.qml +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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: { - if (Qt.inputMethod.visible) - Qt.inputMethod.hide() - flipBar.ok() - } - } - } - } - -} diff --git a/examples/quick/demos/tweetsearch/content/TweetDelegate.qml b/examples/quick/demos/tweetsearch/content/TweetDelegate.qml deleted file mode 100644 index b8953314f1..0000000000 --- a/examples/quick/demos/tweetsearch/content/TweetDelegate.qml +++ /dev/null @@ -1,199 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 - - 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 - MouseArea { - id: mouseArea - anchors.fill: parent - onClicked: { - flipBar.flipUp() - flipBar.flipped = true - } - } - } - - Text { - id: name - text: 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" - onLinkActivated: { - var tag = link.split("https://twitter.com/search?q=%23") - var user = link.split("https://twitter.com/") - if (tag[1] != undefined) { - mainListView.positionViewAtBeginning() - mainListView.clear() - mainListView.autoSearch('tag', tag[1]) - tweetsModel.from = "" - tweetsModel.phrase = "#" + tag[1] - } else if (user[1] != undefined) { - mainListView.positionViewAtBeginning() - mainListView.clear() - mainListView.autoSearch('user', user[1]) - tweetsModel.phrase = "" - tweetsModel.from = user[1] - } else - Qt.openUrlExternally(link) - } - } - } - - 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 - MouseArea { - anchors.fill: parent - onClicked: { - flipBar.flipDown() - flipBar.flipped = false - } - } - } - - Text { - id: username - text: model.twitterName - 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/quick/demos/tweetsearch/content/TweetsModel.qml b/examples/quick/demos/tweetsearch/content/TweetsModel.qml deleted file mode 100644 index 492f85be76..0000000000 --- a/examples/quick/demos/tweetsearch/content/TweetsModel.qml +++ /dev/null @@ -1,135 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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: wrapper - - // Insert valid consumer key and secret tokens below - // See https://dev.twitter.com/apps -//! [auth tokens] - property string consumerKey : "" - property string consumerSecret : "" -//! [auth tokens] - property string bearerToken : "" - - property variant model: tweets - property string from : "" - property string phrase : "" - - property int status: XMLHttpRequest.UNSENT - property bool isLoading: status === XMLHttpRequest.LOADING - property bool wasLoading: false - signal isLoaded - - ListModel { id: tweets } - - function encodePhrase(x) { return encodeURIComponent(x); } - - function reload() { - tweets.clear() - - if (from == "" && phrase == "") - return; - -//! [requesting] - var req = new XMLHttpRequest; - req.open("GET", "https://api.twitter.com/1.1/search/tweets.json?from=" + from + - "&count=10&q=" + encodePhrase(phrase)); - req.setRequestHeader("Authorization", "Bearer " + bearerToken); - req.onreadystatechange = function() { - status = req.readyState; - if (status === XMLHttpRequest.DONE) { - var objectArray = JSON.parse(req.responseText); - if (objectArray.errors !== undefined) - console.log("Error fetching tweets: " + objectArray.errors[0].message) - else { - for (var key in objectArray.statuses) { - var jsonObject = objectArray.statuses[key]; - tweets.append(jsonObject); - } - } - if (wasLoading == true) - wrapper.isLoaded() - } - wasLoading = (status === XMLHttpRequest.LOADING); - } - req.send(); -//! [requesting] - } - - onPhraseChanged: reload(); - onFromChanged: reload(); - - Component.onCompleted: { - if (consumerKey === "" || consumerSecret == "") { - bearerToken = encodeURIComponent(Helper.demoToken()) - return; - } - - var authReq = new XMLHttpRequest; - authReq.open("POST", "https://api.twitter.com/oauth2/token"); - authReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8"); - authReq.setRequestHeader("Authorization", "Basic " + Qt.btoa(consumerKey + ":" + consumerSecret)); - authReq.onreadystatechange = function() { - if (authReq.readyState === XMLHttpRequest.DONE) { - var jsonResponse = JSON.parse(authReq.responseText); - if (jsonResponse.errors !== undefined) - console.log("Authentication error: " + jsonResponse.errors[0].message) - else - bearerToken = jsonResponse.access_token; - } - } - authReq.send("grant_type=client_credentials"); - } - -} diff --git a/examples/quick/demos/tweetsearch/content/resources/anonymous.png b/examples/quick/demos/tweetsearch/content/resources/anonymous.png Binary files differdeleted file mode 100644 index 88fba26e90..0000000000 --- a/examples/quick/demos/tweetsearch/content/resources/anonymous.png +++ /dev/null diff --git a/examples/quick/demos/tweetsearch/content/resources/bird-anim-sprites.png b/examples/quick/demos/tweetsearch/content/resources/bird-anim-sprites.png Binary files differdeleted file mode 100644 index 4e8d7e6116..0000000000 --- a/examples/quick/demos/tweetsearch/content/resources/bird-anim-sprites.png +++ /dev/null diff --git a/examples/quick/demos/tweetsearch/content/resources/icon-clear.png b/examples/quick/demos/tweetsearch/content/resources/icon-clear.png Binary files differdeleted file mode 100644 index 75672f64c7..0000000000 --- a/examples/quick/demos/tweetsearch/content/resources/icon-clear.png +++ /dev/null diff --git a/examples/quick/demos/tweetsearch/content/resources/icon-loading.png b/examples/quick/demos/tweetsearch/content/resources/icon-loading.png Binary files differdeleted file mode 100644 index 8dbff8b70f..0000000000 --- a/examples/quick/demos/tweetsearch/content/resources/icon-loading.png +++ /dev/null diff --git a/examples/quick/demos/tweetsearch/content/resources/icon-refresh.png b/examples/quick/demos/tweetsearch/content/resources/icon-refresh.png Binary files differdeleted file mode 100644 index b639a638fe..0000000000 --- a/examples/quick/demos/tweetsearch/content/resources/icon-refresh.png +++ /dev/null diff --git a/examples/quick/demos/tweetsearch/content/resources/icon-search.png b/examples/quick/demos/tweetsearch/content/resources/icon-search.png Binary files differdeleted file mode 100644 index e41935a6c1..0000000000 --- a/examples/quick/demos/tweetsearch/content/resources/icon-search.png +++ /dev/null diff --git a/examples/quick/demos/tweetsearch/content/tweetsearch.js b/examples/quick/demos/tweetsearch/content/tweetsearch.js deleted file mode 100644 index 42a76c99fc..0000000000 --- a/examples/quick/demos/tweetsearch/content/tweetsearch.js +++ /dev/null @@ -1,62 +0,0 @@ -.pragma library - -function formatDate(date) -{ - var da = new Date(date) - return da.toDateString() -} - -function demoToken() -{ - var a = new Array(22).join('A') - return a + String.fromCharCode(0x44, 0x69, 0x4a, 0x52, 0x51, 0x41, 0x41, 0x41, 0x41, - 0x41, 0x41, 0x74, 0x2b, 0x72, 0x6a, 0x6c, 0x2b, 0x71, - 0x6d, 0x7a, 0x30, 0x72, 0x63, 0x79, 0x2b, 0x42, 0x62, - 0x75, 0x58, 0x42, 0x42, 0x73, 0x72, 0x55, 0x48, 0x47, - 0x45, 0x67, 0x3d, 0x71, 0x30, 0x45, 0x4b, 0x32, 0x61, - 0x57, 0x71, 0x51, 0x4d, 0x62, 0x31, 0x35, 0x67, 0x43, - 0x5a, 0x4e, 0x77, 0x5a, 0x6f, 0x39, 0x79, 0x71, 0x61, - 0x65, 0x30, 0x68, 0x70, 0x65, 0x32, 0x46, 0x44, 0x73, - 0x53, 0x39, 0x32, 0x57, 0x41, 0x75, 0x30, 0x67) -} - -function linkForEntity(entity) -{ - return (entity.url ? entity.url : - (entity.screen_name ? 'https://twitter.com/' + entity.screen_name : - 'https://twitter.com/search?q=%23' + entity.text)) -} - -function textForEntity(entity) -{ - return (entity.display_url ? entity.display_url : - (entity.screen_name ? entity.screen_name : entity.text)) -} - -function insertLinks(text, entities) -{ - if (typeof text !== 'string') - return ""; - - if (!entities) - return text; - - // Add all links (urls, usernames and hashtags) to an array and sort them in - // descending order of appearance in text - var links = [] - if (entities.urls) - links = entities.urls.concat(entities.hashtags, entities.user_mentions) - else if (entities.url) - links = entities.url.urls - - links.sort(function(a, b) { return b.indices[0] - a.indices[0] }) - - for (var i = 0; i < links.length; i++) { - var offset = links[i].url ? 0 : 1 - text = text.substring(0, links[i].indices[0] + offset) + - '<a href=\"' + linkForEntity(links[i]) + '\">' + - textForEntity(links[i]) + '</a>' + - text.substring(links[i].indices[1]) - } - return text.replace(/\n/g, '<br>'); -} diff --git a/examples/quick/demos/tweetsearch/doc/images/qtquick-demo-tweetsearch-med-1.png b/examples/quick/demos/tweetsearch/doc/images/qtquick-demo-tweetsearch-med-1.png Binary files differdeleted file mode 100644 index 930ee39929..0000000000 --- a/examples/quick/demos/tweetsearch/doc/images/qtquick-demo-tweetsearch-med-1.png +++ /dev/null diff --git a/examples/quick/demos/tweetsearch/doc/images/qtquick-demo-tweetsearch-med-2.png b/examples/quick/demos/tweetsearch/doc/images/qtquick-demo-tweetsearch-med-2.png Binary files differdeleted file mode 100644 index 9eff191a47..0000000000 --- a/examples/quick/demos/tweetsearch/doc/images/qtquick-demo-tweetsearch-med-2.png +++ /dev/null diff --git a/examples/quick/demos/tweetsearch/doc/src/tweetsearch.qdoc b/examples/quick/demos/tweetsearch/doc/src/tweetsearch.qdoc deleted file mode 100644 index 4145ccfc14..0000000000 --- a/examples/quick/demos/tweetsearch/doc/src/tweetsearch.qdoc +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \title Qt Quick Demo - Tweet Search - \ingroup qtquickdemos - \example demos/tweetsearch - \brief A Twitter search client with 3D effects. - \image qtquick-demo-tweetsearch-med-1.png - \image qtquick-demo-tweetsearch-med-2.png - - \e{Tweet Search} is a QML application that searches items posted to Twitter - service using a number of query parameters. Search can be done for tweets - from a specified user, a hashtag, or a search phrase. - - The search result is a list of items showing the contents of the - tweet as well as the name and image of the user who posted it. - Hashtags, names and links in the content are clickable. Clicking - on the image will flip the item to reveal more information. - - \include examples-run.qdocinc - - Tweet Search uses Twitter API v1.1 for running seaches. - - \section1 Request Authentication - - Each request must be authenticated on behalf of the application. - For demonstration purposes, the application uses a hard-coded - token for identifying itself to the Twitter service. However, this - token is subject to rate limits for the number of requests as well - as possible expiration. - - If you are having authentication or rate limit problems running the - demo, obtain a set of application-specific tokens (consumer - key and consumer secret) by registering a new application on - \l{https://dev.twitter.com/apps}. - - Type in the two token values in \e {TweetsModel.qml}: - - \snippet demos/tweetsearch/content/TweetsModel.qml auth tokens - - Rebuild and run the demo. - - \section1 JSON Parsing - - Search results are returned in JSON (JavaScript Object Notation) - format. \c TweetsModel uses an \l XMLHTTPRequest object to send - an HTTP GET request, and calls JSON.parse() on the returned text - string to convert it to a JavaScript object. Each object - representing a tweet is then added to a \l ListModel: - - \snippet demos/tweetsearch/content/TweetsModel.qml requesting - - \sa {QML Applications} -*/ diff --git a/examples/quick/demos/tweetsearch/main.cpp b/examples/quick/demos/tweetsearch/main.cpp deleted file mode 100644 index fe612eaa1e..0000000000 --- a/examples/quick/demos/tweetsearch/main.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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 "../../shared/shared.h" -DECLARATIVE_EXAMPLE_MAIN(demos/tweetsearch/tweetsearch) diff --git a/examples/quick/demos/tweetsearch/tweetsearch.pro b/examples/quick/demos/tweetsearch/tweetsearch.pro deleted file mode 100644 index 27c34bac5d..0000000000 --- a/examples/quick/demos/tweetsearch/tweetsearch.pro +++ /dev/null @@ -1,13 +0,0 @@ -TEMPLATE = app - -QT += quick qml -SOURCES += main.cpp -RESOURCES += tweetsearch.qrc - -OTHER_FILES = tweetsearch.qml \ - content/*.qml \ - content/*.js \ - content/resources/* - -target.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/tweetsearch -INSTALLS += target diff --git a/examples/quick/demos/tweetsearch/tweetsearch.qml b/examples/quick/demos/tweetsearch/tweetsearch.qml deleted file mode 100644 index 40e258d79e..0000000000 --- a/examples/quick/demos/tweetsearch/tweetsearch.qml +++ /dev/null @@ -1,142 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the examples of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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" -import "content/tweetsearch.js" as Helper - -Rectangle { - id: main - width: 320 - height: 480 - color: "#d6d6d6" - - 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 - var item = tweetsModel.model.get(main.counter) - mainListView.add( { "statusText": Helper.insertLinks(item.text, item.entities), - "twitterName": item.user.screen_name, - "name" : item.user.name, - "userImage": item.user.profile_image_url, - "source": item.source, - "id": id, - "uri": Helper.insertLinks(item.user.url, item.user.entities), - "published": item.created_at } ); - 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.reload() } - - ListHeader { - id: header - y: -mainListView.contentY - height - } - - footer: ListFooter { } - - function clear() { - ids = new Array() - model.clear() - } - - function add(obj) { - model.insert(0, obj) - } - - signal autoSearch(string type, string str) // To communicate with Footer instance - } -} diff --git a/examples/quick/demos/tweetsearch/tweetsearch.qmlproject b/examples/quick/demos/tweetsearch/tweetsearch.qmlproject deleted file mode 100644 index 5a0f31117b..0000000000 --- a/examples/quick/demos/tweetsearch/tweetsearch.qmlproject +++ /dev/null @@ -1,16 +0,0 @@ -import QmlProject 1.1 - -Project { - mainFile: "tweetsearch.qml" - - /* Include .qml, .js, and image files from current directory and subdirectories */ - QmlFiles { - directory: "." - } - JavaScriptFiles { - directory: "." - } - ImageFiles { - directory: "." - } -} diff --git a/examples/quick/demos/tweetsearch/tweetsearch.qrc b/examples/quick/demos/tweetsearch/tweetsearch.qrc deleted file mode 100644 index b23c3c5537..0000000000 --- a/examples/quick/demos/tweetsearch/tweetsearch.qrc +++ /dev/null @@ -1,19 +0,0 @@ -<RCC> - <qresource prefix="/demos/tweetsearch"> - <file>tweetsearch.qml</file> - <file>content/FlipBar.qml</file> - <file>content/LineInput.qml</file> - <file>content/ListFooter.qml</file> - <file>content/ListHeader.qml</file> - <file>content/SearchDelegate.qml</file> - <file>content/TweetDelegate.qml</file> - <file>content/tweetsearch.js</file> - <file>content/TweetsModel.qml</file> - <file>content/resources/anonymous.png</file> - <file>content/resources/bird-anim-sprites.png</file> - <file>content/resources/icon-clear.png</file> - <file>content/resources/icon-loading.png</file> - <file>content/resources/icon-refresh.png</file> - <file>content/resources/icon-search.png</file> - </qresource> -</RCC> |