summaryrefslogtreecommitdiffstats
path: root/basicsuite/qt5-everywhere/demos/rssnews
diff options
context:
space:
mode:
Diffstat (limited to 'basicsuite/qt5-everywhere/demos/rssnews')
-rw-r--r--basicsuite/qt5-everywhere/demos/rssnews/content/BusyIndicator.qml53
-rw-r--r--basicsuite/qt5-everywhere/demos/rssnews/content/CategoryDelegate.qml84
-rw-r--r--basicsuite/qt5-everywhere/demos/rssnews/content/NewsDelegate.qml75
-rw-r--r--basicsuite/qt5-everywhere/demos/rssnews/content/RssFeeds.qml58
-rw-r--r--basicsuite/qt5-everywhere/demos/rssnews/content/ScrollBar.qml107
-rw-r--r--basicsuite/qt5-everywhere/demos/rssnews/content/images/busy.pngbin0 -> 2629 bytes
-rw-r--r--basicsuite/qt5-everywhere/demos/rssnews/content/images/scrollbar.pngbin0 -> 161 bytes
-rw-r--r--basicsuite/qt5-everywhere/demos/rssnews/rssnews.qml121
-rw-r--r--basicsuite/qt5-everywhere/demos/rssnews/rssnews.qmlproject16
9 files changed, 514 insertions, 0 deletions
diff --git a/basicsuite/qt5-everywhere/demos/rssnews/content/BusyIndicator.qml b/basicsuite/qt5-everywhere/demos/rssnews/content/BusyIndicator.qml
new file mode 100644
index 0000000..97065b2
--- /dev/null
+++ b/basicsuite/qt5-everywhere/demos/rssnews/content/BusyIndicator.qml
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Image {
+ id: container
+ property bool on: false
+
+ source: "images/busy.png"; visible: container.on
+
+ NumberAnimation on rotation {
+ running: container.on; from: 0; to: 360; loops: Animation.Infinite; duration: 1200
+ }
+}
diff --git a/basicsuite/qt5-everywhere/demos/rssnews/content/CategoryDelegate.qml b/basicsuite/qt5-everywhere/demos/rssnews/content/CategoryDelegate.qml
new file mode 100644
index 0000000..ae70e44
--- /dev/null
+++ b/basicsuite/qt5-everywhere/demos/rssnews/content/CategoryDelegate.qml
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: delegate
+ property double margin: delegate.height * 0.2;
+ width: delegate.ListView.view.width;
+ height: 60
+
+ Text {
+ text: name
+ color: delegate.ListView.isCurrentItem ? "white" : "black"
+ font { family: "Helvetica"; pixelSize: delegate.height * 0.25; bold: true }
+ anchors {
+ left: parent.left;
+ leftMargin: margin
+ verticalCenter: parent.verticalCenter
+ }
+ }
+
+ BusyIndicator {
+ scale: 0.6
+ on: delegate.ListView.isCurrentItem && window.loading
+ anchors { right: parent.right; rightMargin: margin; verticalCenter: parent.verticalCenter }
+ }
+
+ Rectangle {
+ width: delegate.width; height: 1; color: "#cccccc"
+ anchors.bottom: delegate.bottom
+ visible: delegate.ListView.isCurrentItem ? false : true
+ }
+ Rectangle {
+ width: delegate.width; height: 1; color: "white"
+ visible: delegate.ListView.isCurrentItem ? false : true
+ }
+
+ MouseArea {
+ anchors.fill: delegate
+ onClicked: {
+ delegate.ListView.view.currentIndex = index
+ window.currentFeed = feed
+ }
+ }
+}
diff --git a/basicsuite/qt5-everywhere/demos/rssnews/content/NewsDelegate.qml b/basicsuite/qt5-everywhere/demos/rssnews/content/NewsDelegate.qml
new file mode 100644
index 0000000..7080312
--- /dev/null
+++ b/basicsuite/qt5-everywhere/demos/rssnews/content/NewsDelegate.qml
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: delegate
+ height: column.height + 2*margin
+ width: delegate.ListView.view.width
+
+ property double margin: width * 0.03
+
+ Column {
+ id: column
+ x: margin; y: margin
+ width: parent.width - 2*margin
+
+ Text {
+ id: titleText
+ text: title; width: parent.width; wrapMode: Text.WordWrap
+ font { bold: true; family: "Helvetica"; pixelSize: 20}
+ }
+
+ Text {
+ id: descriptionText
+ width: parent.width; text: description
+ wrapMode: Text.WordWrap
+ font.family: "Helvetica"
+ font.pixelSize: 12
+ }
+ }
+
+ Rectangle {
+ width: parent.width; height: 1; color: "#cccccc"
+ anchors.bottom: parent.bottom
+ }
+}
diff --git a/basicsuite/qt5-everywhere/demos/rssnews/content/RssFeeds.qml b/basicsuite/qt5-everywhere/demos/rssnews/content/RssFeeds.qml
new file mode 100644
index 0000000..2f0591b
--- /dev/null
+++ b/basicsuite/qt5-everywhere/demos/rssnews/content/RssFeeds.qml
@@ -0,0 +1,58 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+ListModel {
+ id: rssFeeds
+
+ ListElement { name: "Top Stories"; feed: "feeds.bbci.co.uk/news/rss.xml" }
+ ListElement { name: "Popular Stories"; feed: "finance.yahoo.com/rss/popularstories" }
+ ListElement { name: "Qt Blog"; feed: "blog.qt.digia.com/feed/" }
+ ListElement { name: "Planet Qt"; feed: "planet.qt-project.org/rss20.xml" }
+ ListElement { name: "World"; feed: "rss.news.yahoo.com/rss/world" }
+ ListElement { name: "Oceania"; feed: "rss.news.yahoo.com/rss/oceania" }
+ ListElement { name: "U.S. National"; feed: "rss.news.yahoo.com/rss/us" }
+ ListElement { name: "Business"; feed: "rss.news.yahoo.com/rss/business" }
+ ListElement { name: "Technology"; feed: "rss.news.yahoo.com/rss/tech" }
+ ListElement { name: "Entertainment"; feed: "rss.news.yahoo.com/rss/entertainment" }
+ ListElement { name: "Sports"; feed: "sports.yahoo.com/mlb/teams/bos/rss.xml" }
+}
diff --git a/basicsuite/qt5-everywhere/demos/rssnews/content/ScrollBar.qml b/basicsuite/qt5-everywhere/demos/rssnews/content/ScrollBar.qml
new file mode 100644
index 0000000..02ad7ea
--- /dev/null
+++ b/basicsuite/qt5-everywhere/demos/rssnews/content/ScrollBar.qml
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Item {
+ id: container
+
+ property variant scrollArea
+ property variant orientation: Qt.Vertical
+
+ opacity: 0
+
+ function position()
+ {
+ var ny = 0;
+ if (container.orientation == Qt.Vertical)
+ ny = scrollArea.visibleArea.yPosition * container.height;
+ else
+ ny = scrollArea.visibleArea.xPosition * container.width;
+ if (ny > 2) return ny; else return 2;
+ }
+
+ function size()
+ {
+ var nh, ny;
+
+ if (container.orientation == Qt.Vertical)
+ nh = scrollArea.visibleArea.heightRatio * container.height;
+ else
+ nh = scrollArea.visibleArea.widthRatio * container.width;
+
+ if (container.orientation == Qt.Vertical)
+ ny = scrollArea.visibleArea.yPosition * container.height;
+ else
+ ny = scrollArea.visibleArea.xPosition * container.width;
+
+ if (ny > 3) {
+ var t;
+ if (container.orientation == Qt.Vertical)
+ t = Math.ceil(container.height - 3 - ny);
+ else
+ t = Math.ceil(container.width - 3 - ny);
+ if (nh > t) return t; else return nh;
+ } else return nh + ny;
+ }
+
+ Rectangle { anchors.fill: parent; color: "Black"; opacity: 0.3 }
+
+ BorderImage {
+ source: "images/scrollbar.png"
+ border { left: 1; right: 1; top: 1; bottom: 1 }
+ x: container.orientation == Qt.Vertical ? 2 : position()
+ width: container.orientation == Qt.Vertical ? container.width - 4 : size()
+ y: container.orientation == Qt.Vertical ? position() : 2
+ height: container.orientation == Qt.Vertical ? size() : container.height - 4
+ }
+
+ states: State {
+ name: "visible"
+ when: container.orientation == Qt.Vertical ? scrollArea.movingVertically : scrollArea.movingHorizontally
+ PropertyChanges { target: container; opacity: 1.0 }
+ }
+
+ transitions: Transition {
+ from: "visible"; to: ""
+ NumberAnimation { properties: "opacity"; duration: 600 }
+ }
+}
diff --git a/basicsuite/qt5-everywhere/demos/rssnews/content/images/busy.png b/basicsuite/qt5-everywhere/demos/rssnews/content/images/busy.png
new file mode 100644
index 0000000..664c2b1
--- /dev/null
+++ b/basicsuite/qt5-everywhere/demos/rssnews/content/images/busy.png
Binary files differ
diff --git a/basicsuite/qt5-everywhere/demos/rssnews/content/images/scrollbar.png b/basicsuite/qt5-everywhere/demos/rssnews/content/images/scrollbar.png
new file mode 100644
index 0000000..0228dcf
--- /dev/null
+++ b/basicsuite/qt5-everywhere/demos/rssnews/content/images/scrollbar.png
Binary files differ
diff --git a/basicsuite/qt5-everywhere/demos/rssnews/rssnews.qml b/basicsuite/qt5-everywhere/demos/rssnews/rssnews.qml
new file mode 100644
index 0000000..213d9e8
--- /dev/null
+++ b/basicsuite/qt5-everywhere/demos/rssnews/rssnews.qml
@@ -0,0 +1,121 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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, Digia gives you certain additional
+** rights. These rights are described in the Digia 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.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
+import "content"
+
+Rectangle {
+ id: window
+ anchors.fill: parent
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "#eeeeee" }
+ GradientStop { position: 0.1; color: "#ffffff" }
+ GradientStop { position: 0.9; color: "#ffffff" }
+ GradientStop { position: 1.0; color: "#bbbbbb" }
+ }
+
+ property int listWidth: window.width*0.35
+ property string currentFeed: "feeds.bbci.co.uk/news/rss.xml"
+ property bool loading: feedModel.status == XmlListModel.Loading
+
+ RssFeeds { id: rssFeeds }
+
+ XmlListModel {
+ id: feedModel
+ source: "http://" + window.currentFeed
+ query: "/rss/channel/item"
+
+ XmlRole { name: "title"; query: "title/string()" }
+ XmlRole { name: "link"; query: "link/string()" }
+ XmlRole { name: "description"; query: "description/string()" }
+
+ onStatusChanged: {
+ if (status == XmlListModel.Error) {
+ networkErrorBox.opacity = 1.0
+ } else if (status == XmlListModel.Ready) {
+ networkErrorBox.opacity = 0.0
+ }
+ }
+ }
+
+ Row {
+ Rectangle {
+ id: categoryContent
+ width: window.listWidth; height: window.height
+ color: "#efefef"
+
+ ListView {
+ id: categories
+ anchors.fill: parent
+ model: rssFeeds
+ delegate: CategoryDelegate {}
+ highlight: Rectangle { color: "steelblue" }
+ highlightMoveVelocity: 9999999
+ }
+ ScrollBar {
+ scrollArea: categories; height: categories.height; width: 8
+ anchors.right: categories.right
+ }
+ }
+ ListView {
+ id: list
+ width: window.width - window.listWidth; height: window.height
+ model: feedModel
+ delegate: NewsDelegate {}
+
+ Item {
+ id: networkErrorBox
+ opacity: 0
+ anchors.fill: parent
+
+ Text {
+ anchors.centerIn: parent
+ text: qsTr("Sorry! No network connection")
+ }
+ }
+ }
+ }
+
+
+ ScrollBar { scrollArea: list; height: list.height; width: 8; anchors.right: window.right }
+ Rectangle { x: window.listWidth; height: window.height; width: 1; color: "#cccccc" }
+}
diff --git a/basicsuite/qt5-everywhere/demos/rssnews/rssnews.qmlproject b/basicsuite/qt5-everywhere/demos/rssnews/rssnews.qmlproject
new file mode 100644
index 0000000..5becbda
--- /dev/null
+++ b/basicsuite/qt5-everywhere/demos/rssnews/rssnews.qmlproject
@@ -0,0 +1,16 @@
+import QmlProject 1.1
+
+Project {
+ mainFile: "rssnews.qml"
+
+ /* Include .qml, .js, and image files from current directory and subdirectories */
+ QmlFiles {
+ directory: "."
+ }
+ JavaScriptFiles {
+ directory: "."
+ }
+ ImageFiles {
+ directory: "."
+ }
+}