From a84bdce356c9eb576660336f189d14ac5d88ef05 Mon Sep 17 00:00:00 2001 From: selsta Date: Fri, 18 Jan 2019 00:15:24 +0100 Subject: [PATCH] tabs: cleanup from repo --- LeftPanel.qml | 14 ---- RightPanel.qml | 1 - qml.qrc | 3 - tabs/TweetsModel.qml | 113 ---------------------------- tabs/Twitter.qml | 171 ------------------------------------------- tabs/tweetSearch.js | 83 --------------------- 6 files changed, 385 deletions(-) delete mode 100644 tabs/TweetsModel.qml delete mode 100644 tabs/Twitter.qml delete mode 100644 tabs/tweetSearch.js diff --git a/LeftPanel.qml b/LeftPanel.qml index 16b1a8f9..3636b868 100644 --- a/LeftPanel.qml +++ b/LeftPanel.qml @@ -293,20 +293,6 @@ Rectangle { anchors.right: parent.right height: 1 } - /* Disable twitter/news panel - Image { - anchors.left: parent.left - anchors.verticalCenter: logo.verticalCenter - anchors.leftMargin: 19 - source: appWindow.rightPanelExpanded ? "images/expandRightPanel.png" : - "images/collapseRightPanel.png" - } - - MouseArea { - anchors.fill: parent - onClicked: appWindow.rightPanelExpanded = !appWindow.rightPanelExpanded - } - */ } } } diff --git a/RightPanel.qml b/RightPanel.qml index 7810f973..03635409 100644 --- a/RightPanel.qml +++ b/RightPanel.qml @@ -31,7 +31,6 @@ import QtQuick.Controls 1.2 import QtQuick.Controls.Styles 1.2 import QtGraphicalEffects 1.0 -import "tabs" import "components" Rectangle { diff --git a/qml.qrc b/qml.qrc index f2c1cf4f..ba078075 100644 --- a/qml.qrc +++ b/qml.qrc @@ -49,9 +49,6 @@ images/dropdownSend.png components/TipItem.qml images/tip.png - tabs/Twitter.qml - tabs/tweetSearch.js - tabs/TweetsModel.qml components/Scroll.qml components/AddressBookTable.qml images/deleteIcon.png diff --git a/tabs/TweetsModel.qml b/tabs/TweetsModel.qml deleted file mode 100644 index aceaa58b..00000000 --- a/tabs/TweetsModel.qml +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (c) 2014-2018, The Monero Project -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without modification, are -// permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this list of -// conditions and the following disclaimer. -// -// 2. 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. -// -// 3. Neither the name of the copyright holder 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 HOLDER 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. - -import QtQuick 2.2 -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 tweetsMaxCount: "20" - 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=" + tweetsMaxCount + "&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] - } - - Component.onCompleted: { - if (consumerKey === "" || consumerSecret == "") { - console.log("setting demo token") - bearerToken = encodeURIComponent(Helper.demoToken()) - tweetsModel.phrase = "" - tweetsModel.from = "@monerocurrency" - // reload() - 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/tabs/Twitter.qml b/tabs/Twitter.qml deleted file mode 100644 index f2cb3b1a..00000000 --- a/tabs/Twitter.qml +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright (c) 2014-2018, The Monero Project -// -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without modification, are -// permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this list of -// conditions and the following disclaimer. -// -// 2. 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. -// -// 3. Neither the name of the copyright holder 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 HOLDER 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. - -import QtQuick 2.2 -import QtQuick.Controls 1.2 -import "tweetSearch.js" as Helper -import "../components" - -Item { - id: tab - - - - ListModel { - id: testModel - ListElement { head: "Monero || #xmr"; foot: "@btcplanet Duis turpis arcu, varius nec rutrum in, adipiscing at enim. Donec quis consequat ipsum," } - ListElement { head: "Monero || #xmr"; foot: "@btcplanet Duis turpis arcu, varius nec rutrum in, adipiscing at enim. Donec quis consequat ipsum," } - ListElement { head: "Monero || #xmr"; foot: "@btcplanet Duis turpis arcu, varius nec rutrum in, adipiscing at enim. Donec quis consequat ipsum," } - ListElement { head: "Monero || #xmr"; foot: "@btcplanet Duis turpis arcu, varius nec rutrum in, adipiscing at enim. Donec quis consequat ipsum," } - ListElement { head: "Monero || #xmr"; foot: "@btcplanet Duis turpis arcu, varius nec rutrum in, adipiscing at enim. Donec quis consequat ipsum," } - ListElement { head: "Monero || #xmr"; foot: "@btcplanet Duis turpis arcu, varius nec rutrum in, adipiscing at enim. Donec quis consequat ipsum," } - ListElement { head: "Monero || #xmr"; foot: "@btcplanet Duis turpis arcu, varius nec rutrum in, adipiscing at enim. Donec quis consequat ipsum," } - ListElement { head: "Monero || #xmr"; foot: "@btcplanet Duis turpis arcu, varius nec rutrum in, adipiscing at enim. Donec quis consequat ipsum," } - ListElement { head: "Monero || #xmr"; foot: "@btcplanet Duis turpis arcu, varius nec rutrum in, adipiscing at enim. Donec quis consequat ipsum," } - ListElement { head: "Monero || #xmr"; foot: "@btcplanet Duis turpis arcu, varius nec rutrum in, adipiscing at enim. Donec quis consequat ipsum," } - ListElement { head: "Monero || #xmr"; foot: "@btcplanet Duis turpis arcu, varius nec rutrum in, adipiscing at enim. Donec quis consequat ipsum," } - ListElement { head: "Monero || #xmr"; foot: "@btcplanet Duis turpis arcu, varius nec rutrum in, adipiscing at enim. Donec quis consequat ipsum," } - } - - property int inAnimDur: 250 - property int counter: 0 - property alias isLoading: tweetsModel.isLoading - property var idx - property var ids - - function updateTweets() { - tweetsModel.reload() - } - - - 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") - tab.counter = idx.length - } - } - - Timer { - id: timer - interval: 1; running: tab.counter; repeat: true - onTriggered: { - tab.counter--; - var id = tweetsModel.model.get(idx[tab.counter]).id - var item = tweetsModel.model.get(tab.counter) - listView.add({ "statusText": item.text, - "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) - } - } - - Scroll { - id: flickableScroll - anchors.right: listView.right - anchors.rightMargin: -14 - anchors.top: listView.top - anchors.bottom: listView.bottom - flickable: listView - } - - ListView { - id: listView - model: ListModel { id: finalModel } - anchors.fill: parent - clip: true - boundsBehavior: ListView.StopAtBounds - onContentYChanged: flickableScroll.flickableContentYChanged() - - function add(obj) { model.insert(0, obj) } - delegate: Rectangle { - height: 88 - width: listView.width - - Text { - id: headerText - anchors.left: parent.left - anchors.right: parent.right - anchors.top: parent.top - anchors.topMargin: 11 - elide: Text.ElideRight - font.family: "Arial" - font.pixelSize: 18 - color: "#000000" - text: model.name - } - - Text { - anchors.left: parent.left - anchors.right: parent.right - anchors.top: headerText.bottom - anchors.bottom: parent.bottom - anchors.topMargin: 10 - anchors.bottomMargin: 10 - wrapMode: Text.Wrap - elide: Text.ElideRight - font.family: "Arial" - font.pixelSize: 12 - color: "#535353" - text: model.statusText - } - - Rectangle { - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.bottom - height: 1 - color: "#DBDBDB" - } - } - } -} diff --git a/tabs/tweetSearch.js b/tabs/tweetSearch.js deleted file mode 100644 index 2d1c083f..00000000 --- a/tabs/tweetSearch.js +++ /dev/null @@ -1,83 +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) + - '' + - textForEntity(links[i]) + '' + - text.substring(links[i].indices[1]) - } - return text.replace(/\n/g, '
'); -} - -function boldLinks(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) + - '' + textForEntity(links[i]) + '' + - text.substring(links[i].indices[1]) - } - return text.replace(/\n/g, '
'); -}