aboutsummaryrefslogtreecommitdiffstats
path: root/examples/declarative/shared/FlickrRssModel.qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/declarative/shared/FlickrRssModel.qml')
-rw-r--r--examples/declarative/shared/FlickrRssModel.qml45
1 files changed, 0 insertions, 45 deletions
diff --git a/examples/declarative/shared/FlickrRssModel.qml b/examples/declarative/shared/FlickrRssModel.qml
deleted file mode 100644
index 66f53b8ef..000000000
--- a/examples/declarative/shared/FlickrRssModel.qml
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-import QtQuick 2.12
-
-ListModel {
- id: flickrImages
- property string tags : ""
- readonly property string queryUrl : "http://api.flickr.com/services/feeds/photos_public.gne?"
-
- function encodeParams(x) {
- return encodeURIComponent(x.replace(" ",","));
- }
- function fetchImages(format) {
- var requestURL = queryUrl + (tags ? "tags="+encodeParams(tags)+"&" : "") + "format=" + format + "&nojsoncallback=1";
- var xhr = new XMLHttpRequest;
- xhr.onreadystatechange = function() {
- if (xhr.readyState === XMLHttpRequest.DONE) {
-
- if (xhr.status !== 200) {
- console.log("Failed to get images from flickr. status code: " + xhr.status);
- return;
- }
-
- var jsonText = xhr.responseText;
- var objArray = JSON.parse(jsonText.replace(/\'/g,"'"))
- if (objArray.errors !== undefined)
- console.log("Error fetching tweets: " + objArray.errors[0].message)
- else {
- for (var key in objArray.items) {
- var rssItem = objArray.items[key];
- var jsonObject = "{ \"title\": \"" + rssItem.title +"\",\"media\": \"" + rssItem.media.m + "\", \"thumbnail\": \"" + rssItem.media.m.replace(/\_m\.jpg/,"_s.jpg") +"\"}"
- flickrImages.append(JSON.parse(jsonObject));
- }
- }
- }
- }
- xhr.open("GET", requestURL, true);
- xhr.send();
- }
- Component.onCompleted: {
- fetchImages("json");
- }
-}
-