aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/demos/rssnews
diff options
context:
space:
mode:
authorTopi Reinio <topi.reinio@digia.com>2014-06-12 15:05:05 +0200
committerNiels Weber <niels.weber@digia.com>2014-06-20 09:01:38 +0200
commit68c78625d888cdd6650851290d140ccf8fbf4d6b (patch)
tree675d85eacd6fb05504324558e3dd948cbecf3a5b /examples/quick/demos/rssnews
parent28851c675cff5484be6abcbfd045537615e7a288 (diff)
Improve RSS News Qt Quick Demo
- Add main.cpp for launching, use Qt resource system - Update feed URLs - New layout and images - Make the example scalable, react to orientation changes - Use graphical effects and animations - Display time and link for each news item - Fix license headers to use the correct license Task-number: QTBUG-37203 Change-Id: I6f8941cbdaed78a3dee30305496b3ea7777ba3e3 Reviewed-by: Jerome Pasion <jerome.pasion@digia.com> Reviewed-by: Leena Miettinen <riitta-leena.miettinen@digia.com>
Diffstat (limited to 'examples/quick/demos/rssnews')
-rw-r--r--examples/quick/demos/rssnews/content/BusyIndicator.qml69
-rw-r--r--examples/quick/demos/rssnews/content/CategoryDelegate.qml143
-rw-r--r--examples/quick/demos/rssnews/content/NewsDelegate.qml142
-rw-r--r--examples/quick/demos/rssnews/content/RssFeeds.qml87
-rw-r--r--examples/quick/demos/rssnews/content/ScrollBar.qml75
-rw-r--r--examples/quick/demos/rssnews/content/images/Asia.jpgbin0 -> 10578 bytes
-rw-r--r--examples/quick/demos/rssnews/content/images/Business.jpgbin0 -> 17276 bytes
-rw-r--r--examples/quick/demos/rssnews/content/images/Entertainment.jpgbin0 -> 15433 bytes
-rw-r--r--examples/quick/demos/rssnews/content/images/Europe.jpgbin0 -> 15872 bytes
-rw-r--r--examples/quick/demos/rssnews/content/images/Health.jpgbin0 -> 16015 bytes
-rw-r--r--examples/quick/demos/rssnews/content/images/Politics.jpgbin0 -> 16401 bytes
-rw-r--r--examples/quick/demos/rssnews/content/images/Science.jpgbin0 -> 9496 bytes
-rw-r--r--examples/quick/demos/rssnews/content/images/Sports.jpgbin0 -> 9281 bytes
-rw-r--r--examples/quick/demos/rssnews/content/images/Technology.jpgbin0 -> 22290 bytes
-rw-r--r--examples/quick/demos/rssnews/content/images/TopStories.jpgbin0 -> 8067 bytes
-rw-r--r--examples/quick/demos/rssnews/content/images/USNational.jpgbin0 -> 9635 bytes
-rw-r--r--examples/quick/demos/rssnews/content/images/World.jpgbin0 -> 15128 bytes
-rw-r--r--examples/quick/demos/rssnews/content/images/btn_close.pngbin0 -> 1267 bytes
-rw-r--r--examples/quick/demos/rssnews/doc/images/qtquick-demo-rssnews-small.pngbin43372 -> 56864 bytes
-rw-r--r--examples/quick/demos/rssnews/main.cpp41
-rw-r--r--examples/quick/demos/rssnews/rssnews.pro13
-rw-r--r--examples/quick/demos/rssnews/rssnews.qml197
-rw-r--r--examples/quick/demos/rssnews/rssnews.qrc25
23 files changed, 513 insertions, 279 deletions
diff --git a/examples/quick/demos/rssnews/content/BusyIndicator.qml b/examples/quick/demos/rssnews/content/BusyIndicator.qml
index d9c3646ae3..e6cd15847a 100644
--- a/examples/quick/demos/rssnews/content/BusyIndicator.qml
+++ b/examples/quick/demos/rssnews/content/BusyIndicator.qml
@@ -3,37 +3,36 @@
** 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.
-**
+** 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 Digia Plc 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$
**
@@ -43,11 +42,13 @@ import QtQuick 2.2
Image {
id: container
- property bool on: false
- source: "images/busy.png"; visible: container.on
+ source: "images/busy.png";
NumberAnimation on rotation {
- running: container.on; from: 0; to: 360; loops: Animation.Infinite; duration: 1200
+ running: container.visible
+ from: 0; to: 360;
+ loops: Animation.Infinite;
+ duration: 1200
}
}
diff --git a/examples/quick/demos/rssnews/content/CategoryDelegate.qml b/examples/quick/demos/rssnews/content/CategoryDelegate.qml
index bb2b3581df..cb48715609 100644
--- a/examples/quick/demos/rssnews/content/CategoryDelegate.qml
+++ b/examples/quick/demos/rssnews/content/CategoryDelegate.qml
@@ -3,80 +3,123 @@
** 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.
+** This file is part of the examples 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.
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
**
-** 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.
+** "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 Digia Plc 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.
**
-** 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.
**
+** 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.2
+import QtGraphicalEffects 1.0
-Item {
+Rectangle {
id: delegate
- width: delegate.ListView.view.width; height: 60
+ property bool selected: ListView.isCurrentItem
+ property real itemSize
+ width: itemSize
+ height: itemSize
- Text {
- text: name
- color: delegate.ListView.isCurrentItem ? "white" : "black"
- font { family: "Helvetica"; pixelSize: 16; bold: true }
- anchors {
- left: parent.left; leftMargin: 15
- verticalCenter: parent.verticalCenter
- }
+ Image {
+ anchors.centerIn: parent
+ source: image
}
- BusyIndicator {
- scale: 0.6
- on: delegate.ListView.isCurrentItem && window.loading
- anchors { right: parent.right; rightMargin: 10; verticalCenter: parent.verticalCenter }
- }
+ Item {
+ id: title
+ anchors.fill: parent
+
+ Text {
+ id: titleText
+
+ anchors {
+ left: parent.left; leftMargin: 20
+ right: parent.right; rightMargin: 20
+ top: parent.top; topMargin: 20
+ }
+ font { pixelSize: 18; bold: true }
+ text: name
+ color: selected ? "#ffffff" : "#ebebdd"
+ Behavior on color { ColorAnimation { duration: 150 } }
+ }
- Rectangle {
- width: delegate.width; height: 1; color: "#cccccc"
- anchors.bottom: delegate.bottom
- visible: delegate.ListView.isCurrentItem ? false : true
+ DropShadow {
+ source: titleText
+ anchors.fill: titleText
+ horizontalOffset: selected ? 3 : 1
+ verticalOffset: selected ? 3 : 1
+ radius: 4
+ color: "#2f1000"
+ samples: 8
+
+ Behavior on horizontalOffset { NumberAnimation { duration: 300 } }
+ Behavior on verticalOffset { NumberAnimation { duration: 300 } }
+ }
+
+ states: [
+ State {
+ name: "selected"
+ when: selected
+ PropertyChanges { target: title; scale: "1.1" }
+ }]
+
+ transitions: [
+ Transition {
+ to: "selected"
+ SequentialAnimation {
+ id: titleAnimation
+ PropertyAnimation { target: title; property: "scale"; duration: 300 }
+ }
+ },
+ Transition {
+ to: ""
+ animations: titleAnimation
+ }]
}
- Rectangle {
- width: delegate.width; height: 1; color: "white"
- visible: delegate.ListView.isCurrentItem ? false : true
+
+ BusyIndicator {
+ scale: 0.8
+ visible: delegate.ListView.isCurrentItem && window.loading
+ anchors.centerIn: parent
}
MouseArea {
anchors.fill: delegate
onClicked: {
delegate.ListView.view.currentIndex = index
- window.currentFeed = feed
+ if (window.currentFeed == feed)
+ feedModel.reload()
+ else
+ window.currentFeed = feed
}
}
}
diff --git a/examples/quick/demos/rssnews/content/NewsDelegate.qml b/examples/quick/demos/rssnews/content/NewsDelegate.qml
index feb0516653..fee1119b08 100644
--- a/examples/quick/demos/rssnews/content/NewsDelegate.qml
+++ b/examples/quick/demos/rssnews/content/NewsDelegate.qml
@@ -3,69 +3,127 @@
** 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.
+** This file is part of the examples 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.
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
**
-** 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.
+** "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 Digia Plc 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.
**
-** 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.
**
+** 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.2
+import QtQuick.Layouts 1.1
-Item {
+ColumnLayout {
id: delegate
- height: column.height + 40
width: delegate.ListView.view.width
- Column {
- id: column
- x: 20; y: 20
- width: parent.width - 40
+ // Returns a string representing how long ago an event occurred
+ function timeSinceEvent(pubDate) {
+ var result = pubDate;
+
+ // We need to modify the pubDate read from the RSS feed
+ // so the JavaScript Date object can interpret it
+ var d = pubDate.replace(',','').split(' ');
+ if (d.length != 6)
+ return result;
+
+ var date = new Date([d[0], d[2], d[1], d[3], d[4], 'GMT' + d[5]].join(' '));
+
+ if (!isNaN(date.getDate())) {
+ var age = new Date() - date;
+ var minutes = Math.floor(Number(age) / 60000);
+ if (minutes < 1440) {
+ if (minutes < 2)
+ result = qsTr("Just now");
+ else if (minutes < 60)
+ result = '' + minutes + ' ' + qsTr("minutes ago")
+ else if (minutes < 120)
+ result = qsTr("1 hour ago");
+ else
+ result = '' + Math.floor(minutes/60) + ' ' + qsTr("hours ago");
+ }
+ else {
+ result = date.toDateString();
+ }
+ }
+ return result;
+ }
+
+ RowLayout {
+ Layout.maximumWidth: parent.width
+
+ ColumnLayout {
+ Layout.alignment: Qt.AlignTop
+
+ Item {
+ height: titleText.font.pixelSize / 4
+ }
+
+ Image {
+ id: titleImage
+ source: image
+ }
+ }
Text {
id: titleText
- text: title; width: parent.width; wrapMode: Text.WordWrap
- font { bold: true; family: "Helvetica"; pointSize: 16 }
+
+ text: title
+ Layout.maximumWidth: delegate.width - titleImage.width
+ wrapMode: Text.WordWrap
+ font.pixelSize: 26
+ font.bold: true
}
+ }
- Text {
- id: descriptionText
- width: parent.width; text: description
- wrapMode: Text.WordWrap; font.family: "Helvetica"
+ Text {
+ Layout.maximumWidth: delegate.width
+ font.pixelSize: 12
+ textFormat: Text.RichText
+ font.italic: true
+ Layout.alignment: Qt.AlignLeft
+ text: timeSinceEvent(pubDate) + " (<a href=\"" + link + "\">Link</a>)"
+ onLinkActivated: {
+ Qt.openUrlExternally(link)
}
}
- Rectangle {
- width: parent.width; height: 1; color: "#cccccc"
- anchors.bottom: parent.bottom
+ Text {
+ id: descriptionText
+
+ text: description
+ Layout.maximumWidth: parent.width
+ wrapMode: Text.WordWrap
+ font.pixelSize: 14
+ textFormat: Text.StyledText
+ horizontalAlignment: Qt.AlignLeft
}
}
diff --git a/examples/quick/demos/rssnews/content/RssFeeds.qml b/examples/quick/demos/rssnews/content/RssFeeds.qml
index 425b011a78..3ae3b23921 100644
--- a/examples/quick/demos/rssnews/content/RssFeeds.qml
+++ b/examples/quick/demos/rssnews/content/RssFeeds.qml
@@ -3,37 +3,36 @@
** 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.
-**
+** 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 Digia Plc 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$
**
@@ -42,18 +41,16 @@
import QtQuick 2.2
ListModel {
- id: rssFeeds
-
- ListElement { name: "Top Stories"; feed: "rss.news.yahoo.com/rss/topstories" }
- ListElement { name: "World"; feed: "rss.news.yahoo.com/rss/world" }
- ListElement { name: "Europe"; feed: "rss.news.yahoo.com/rss/europe" }
- ListElement { name: "Oceania"; feed: "rss.news.yahoo.com/rss/oceania" }
- ListElement { name: "U.S. National"; feed: "rss.news.yahoo.com/rss/us" }
- ListElement { name: "Politics"; feed: "rss.news.yahoo.com/rss/politics" }
- 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: "Health"; feed: "rss.news.yahoo.com/rss/health" }
- ListElement { name: "Science"; feed: "rss.news.yahoo.com/rss/science" }
- ListElement { name: "Sports"; feed: "rss.news.yahoo.com/rss/sports" }
+ ListElement { name: "Top Stories"; feed: "news.yahoo.com/rss/topstories"; image: "images/TopStories.jpg" }
+ ListElement { name: "World"; feed: "news.yahoo.com/rss/world"; image: "images/World.jpg" }
+ ListElement { name: "Europe"; feed: "news.yahoo.com/rss/europe"; image: "images/Europe.jpg" }
+ ListElement { name: "Asia"; feed: "news.yahoo.com/rss/asia"; image: "images/Asia.jpg" }
+ ListElement { name: "U.S. National"; feed: "news.yahoo.com/rss/us"; image: "images/USNational.jpg" }
+ ListElement { name: "Politics"; feed: "news.yahoo.com/rss/politics"; image: "images/Politics.jpg" }
+ ListElement { name: "Business"; feed: "news.yahoo.com/rss/business"; image: "images/Business.jpg" }
+ ListElement { name: "Technology"; feed: "news.yahoo.com/rss/tech"; image: "images/Technology.jpg" }
+ ListElement { name: "Entertainment"; feed: "news.yahoo.com/rss/entertainment"; image: "images/Entertainment.jpg" }
+ ListElement { name: "Health"; feed: "news.yahoo.com/rss/health"; image: "images/Health.jpg" }
+ ListElement { name: "Science"; feed: "news.yahoo.com/rss/science"; image: "images/Science.jpg" }
+ ListElement { name: "Sports"; feed: "news.yahoo.com/rss/sports"; image: "images/Sports.jpg" }
}
diff --git a/examples/quick/demos/rssnews/content/ScrollBar.qml b/examples/quick/demos/rssnews/content/ScrollBar.qml
index b8f1b730e0..606f2e4259 100644
--- a/examples/quick/demos/rssnews/content/ScrollBar.qml
+++ b/examples/quick/demos/rssnews/content/ScrollBar.qml
@@ -3,37 +3,36 @@
** 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.
+** This file is part of the examples 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.
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
**
-** 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.
+** "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 Digia Plc 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.
**
-** 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.
**
+** 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$
**
@@ -45,7 +44,7 @@ Item {
id: container
property variant scrollArea
- property variant orientation: Qt.Vertical
+ property int orientation: Qt.Vertical
opacity: 0
@@ -56,7 +55,11 @@ Item {
ny = scrollArea.visibleArea.yPosition * container.height;
else
ny = scrollArea.visibleArea.xPosition * container.width;
- if (ny > 2) return ny; else return 2;
+
+ if (ny > 2)
+ return ny;
+ else
+ return 2;
}
function size()
@@ -79,8 +82,12 @@ Item {
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;
+ if (nh > t)
+ return t;
+ else
+ return nh;
+ } else
+ return nh + ny;
}
Rectangle { anchors.fill: parent; color: "Black"; opacity: 0.3 }
@@ -89,14 +96,16 @@ Item {
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
+ width: container.orientation == Qt.Vertical ? container.width - 4 : size()
height: container.orientation == Qt.Vertical ? size() : container.height - 4
}
states: State {
name: "visible"
- when: container.orientation == Qt.Vertical ? scrollArea.movingVertically : scrollArea.movingHorizontally
+ when: container.orientation == Qt.Vertical ?
+ scrollArea.movingVertically :
+ scrollArea.movingHorizontally
PropertyChanges { target: container; opacity: 1.0 }
}
diff --git a/examples/quick/demos/rssnews/content/images/Asia.jpg b/examples/quick/demos/rssnews/content/images/Asia.jpg
new file mode 100644
index 0000000000..a609557a08
--- /dev/null
+++ b/examples/quick/demos/rssnews/content/images/Asia.jpg
Binary files differ
diff --git a/examples/quick/demos/rssnews/content/images/Business.jpg b/examples/quick/demos/rssnews/content/images/Business.jpg
new file mode 100644
index 0000000000..b2c1d92138
--- /dev/null
+++ b/examples/quick/demos/rssnews/content/images/Business.jpg
Binary files differ
diff --git a/examples/quick/demos/rssnews/content/images/Entertainment.jpg b/examples/quick/demos/rssnews/content/images/Entertainment.jpg
new file mode 100644
index 0000000000..2c69fc04d7
--- /dev/null
+++ b/examples/quick/demos/rssnews/content/images/Entertainment.jpg
Binary files differ
diff --git a/examples/quick/demos/rssnews/content/images/Europe.jpg b/examples/quick/demos/rssnews/content/images/Europe.jpg
new file mode 100644
index 0000000000..bf524e13d0
--- /dev/null
+++ b/examples/quick/demos/rssnews/content/images/Europe.jpg
Binary files differ
diff --git a/examples/quick/demos/rssnews/content/images/Health.jpg b/examples/quick/demos/rssnews/content/images/Health.jpg
new file mode 100644
index 0000000000..0e8c71f0c9
--- /dev/null
+++ b/examples/quick/demos/rssnews/content/images/Health.jpg
Binary files differ
diff --git a/examples/quick/demos/rssnews/content/images/Politics.jpg b/examples/quick/demos/rssnews/content/images/Politics.jpg
new file mode 100644
index 0000000000..0b1800c97e
--- /dev/null
+++ b/examples/quick/demos/rssnews/content/images/Politics.jpg
Binary files differ
diff --git a/examples/quick/demos/rssnews/content/images/Science.jpg b/examples/quick/demos/rssnews/content/images/Science.jpg
new file mode 100644
index 0000000000..7faccbbb97
--- /dev/null
+++ b/examples/quick/demos/rssnews/content/images/Science.jpg
Binary files differ
diff --git a/examples/quick/demos/rssnews/content/images/Sports.jpg b/examples/quick/demos/rssnews/content/images/Sports.jpg
new file mode 100644
index 0000000000..0ab3bd3ce7
--- /dev/null
+++ b/examples/quick/demos/rssnews/content/images/Sports.jpg
Binary files differ
diff --git a/examples/quick/demos/rssnews/content/images/Technology.jpg b/examples/quick/demos/rssnews/content/images/Technology.jpg
new file mode 100644
index 0000000000..db553028fb
--- /dev/null
+++ b/examples/quick/demos/rssnews/content/images/Technology.jpg
Binary files differ
diff --git a/examples/quick/demos/rssnews/content/images/TopStories.jpg b/examples/quick/demos/rssnews/content/images/TopStories.jpg
new file mode 100644
index 0000000000..e35bd67f20
--- /dev/null
+++ b/examples/quick/demos/rssnews/content/images/TopStories.jpg
Binary files differ
diff --git a/examples/quick/demos/rssnews/content/images/USNational.jpg b/examples/quick/demos/rssnews/content/images/USNational.jpg
new file mode 100644
index 0000000000..82c78228c1
--- /dev/null
+++ b/examples/quick/demos/rssnews/content/images/USNational.jpg
Binary files differ
diff --git a/examples/quick/demos/rssnews/content/images/World.jpg b/examples/quick/demos/rssnews/content/images/World.jpg
new file mode 100644
index 0000000000..7a0a806fd4
--- /dev/null
+++ b/examples/quick/demos/rssnews/content/images/World.jpg
Binary files differ
diff --git a/examples/quick/demos/rssnews/content/images/btn_close.png b/examples/quick/demos/rssnews/content/images/btn_close.png
new file mode 100644
index 0000000000..6d635375eb
--- /dev/null
+++ b/examples/quick/demos/rssnews/content/images/btn_close.png
Binary files differ
diff --git a/examples/quick/demos/rssnews/doc/images/qtquick-demo-rssnews-small.png b/examples/quick/demos/rssnews/doc/images/qtquick-demo-rssnews-small.png
index 0ad6c02251..ffef99ee5c 100644
--- a/examples/quick/demos/rssnews/doc/images/qtquick-demo-rssnews-small.png
+++ b/examples/quick/demos/rssnews/doc/images/qtquick-demo-rssnews-small.png
Binary files differ
diff --git a/examples/quick/demos/rssnews/main.cpp b/examples/quick/demos/rssnews/main.cpp
new file mode 100644
index 0000000000..0064412f39
--- /dev/null
+++ b/examples/quick/demos/rssnews/main.cpp
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** 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 Digia Plc 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 "../../shared/shared.h"
+DECLARATIVE_EXAMPLE_MAIN(demos/rssnews/rssnews)
diff --git a/examples/quick/demos/rssnews/rssnews.pro b/examples/quick/demos/rssnews/rssnews.pro
new file mode 100644
index 0000000000..c67c5a6558
--- /dev/null
+++ b/examples/quick/demos/rssnews/rssnews.pro
@@ -0,0 +1,13 @@
+TEMPLATE = app
+
+QT += quick qml xml xmlpatterns
+SOURCES += main.cpp
+RESOURCES += rssnews.qrc
+
+OTHER_FILES = rssnews.qml \
+ content/*.qml \
+ content/*.js \
+ content/images/*
+
+target.path = $$[QT_INSTALL_EXAMPLES]/quick/demos/rssnews
+INSTALLS += target
diff --git a/examples/quick/demos/rssnews/rssnews.qml b/examples/quick/demos/rssnews/rssnews.qml
index a367490ef7..cb9734208d 100644
--- a/examples/quick/demos/rssnews/rssnews.qml
+++ b/examples/quick/demos/rssnews/rssnews.qml
@@ -1,112 +1,159 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** 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.
+** This file is part of the examples 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.
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
**
-** 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.
+** "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 Digia Plc 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.
**
-** 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.
**
+** 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 2.2
import QtQuick.XmlListModel 2.0
-import "content"
+import QtQuick.Window 2.1
+import "./content"
Rectangle {
id: window
- width: 800; height: 480
- property string currentFeed: "rss.news.yahoo.com/rss/topstories"
- property bool loading: feedModel.status == XmlListModel.Loading
+ width: 800
+ height: 480
+
+ property string currentFeed: rssFeeds.get(0).feed
+ property bool loading: feedModel.status === XmlListModel.Loading
+ property bool isPortrait: Screen.primaryOrientation === Qt.PortraitOrientation
+
+ onLoadingChanged: {
+ if (feedModel.status == XmlListModel.Ready)
+ list.positionViewAtBeginning()
+ }
RssFeeds { id: rssFeeds }
XmlListModel {
id: feedModel
+
source: "http://" + window.currentFeed
- query: "/rss/channel/item"
+ query: "/rss/channel/item[child::media:content]"
+ namespaceDeclarations: "declare namespace media = 'http://search.yahoo.com/mrss/';"
XmlRole { name: "title"; query: "title/string()" }
+ // Remove any links from the description
+ XmlRole { name: "description"; query: "fn:replace(description/string(), '\&lt;a href=.*\/a\&gt;', '')" }
+ XmlRole { name: "image"; query: "media:content/@url/string()" }
XmlRole { name: "link"; query: "link/string()" }
- XmlRole { name: "description"; query: "description/string()" }
+ XmlRole { name: "pubDate"; query: "pubDate/string()" }
}
- Row {
- Rectangle {
- width: 220; height: window.height
- color: "#efefef"
-
- ListView {
- focus: true
- id: categories
- anchors.fill: parent
- model: rssFeeds
- footer: quitButtonDelegate
- 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 - 220; height: window.height
- model: feedModel
- delegate: NewsDelegate {}
- }
+ ListView {
+ id: categories
+ property int itemWidth: 190
+
+ width: isPortrait ? parent.width : itemWidth
+ height: isPortrait ? itemWidth : parent.height
+ orientation: isPortrait ? ListView.Horizontal : ListView.Vertical
+ anchors.top: parent.top
+ model: rssFeeds
+ delegate: CategoryDelegate { itemSize: categories.itemWidth }
+ spacing: 3
+ }
+
+ ScrollBar {
+ id: listScrollBar
+
+ orientation: isPortrait ? Qt.Horizontal : Qt.Vertical
+ height: isPortrait ? 8 : categories.height;
+ width: isPortrait ? categories.width : 8
+ scrollArea: categories;
+ anchors.right: categories.right
}
+
+ ListView {
+ id: list
+
+ anchors.left: isPortrait ? window.left : categories.right
+ anchors.right: closeButton.left
+ anchors.top: isPortrait ? categories.bottom : window.top
+ anchors.bottom: window.bottom
+ anchors.leftMargin: 30
+ anchors.rightMargin: 4
+ clip: isPortrait
+ model: feedModel
+ footer: footerText
+ delegate: NewsDelegate {}
+ }
+
+ ScrollBar {
+ scrollArea: list
+ width: 8
+ anchors.right: window.right
+ anchors.top: isPortrait ? categories.bottom : window.top
+ anchors.bottom: window.bottom
+ }
+
Component {
- id: quitButtonDelegate
- Item {
- width: categories.width; height: 60
+ id: footerText
+
+ Rectangle {
+ width: parent.width
+ height: closeButton.height
+ color: "lightgray"
+
Text {
- text: "Quit"
- font { family: "Helvetica"; pixelSize: 16; bold: true }
- anchors {
- left: parent.left; leftMargin: 15
- verticalCenter: parent.verticalCenter
- }
+ text: "RSS Feed from Yahoo News"
+ anchors.centerIn: parent
+ font.pixelSize: 14
}
- MouseArea {
- anchors.fill: parent
- onClicked: Qt.quit()
+ }
+ }
+
+ Image {
+ id: closeButton
+ source: "content/images/btn_close.png"
+ scale: 0.8
+ anchors.top: parent.top
+ anchors.right: parent.right
+ anchors.margins: 4
+ opacity: (isPortrait && categories.moving) ? 0.2 : 1.0
+ Behavior on opacity {
+ NumberAnimation { duration: 300; easing.type: Easing.OutSine }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ Qt.quit()
}
}
}
- ScrollBar { scrollArea: list; height: list.height; width: 8; anchors.right: window.right }
- Rectangle { x: 220; height: window.height; width: 1; color: "#cccccc" }
}
diff --git a/examples/quick/demos/rssnews/rssnews.qrc b/examples/quick/demos/rssnews/rssnews.qrc
new file mode 100644
index 0000000000..1208d44fd7
--- /dev/null
+++ b/examples/quick/demos/rssnews/rssnews.qrc
@@ -0,0 +1,25 @@
+<RCC>
+ <qresource prefix="/demos/rssnews">
+ <file>rssnews.qml</file>
+ <file>content/BusyIndicator.qml</file>
+ <file>content/CategoryDelegate.qml</file>
+ <file>content/NewsDelegate.qml</file>
+ <file>content/RssFeeds.qml</file>
+ <file>content/ScrollBar.qml</file>
+ <file>content/images/btn_close.png</file>
+ <file>content/images/Business.jpg</file>
+ <file>content/images/busy.png</file>
+ <file>content/images/Entertainment.jpg</file>
+ <file>content/images/Europe.jpg</file>
+ <file>content/images/Health.jpg</file>
+ <file>content/images/Asia.jpg</file>
+ <file>content/images/Politics.jpg</file>
+ <file>content/images/Science.jpg</file>
+ <file>content/images/scrollbar.png</file>
+ <file>content/images/Sports.jpg</file>
+ <file>content/images/Technology.jpg</file>
+ <file>content/images/TopStories.jpg</file>
+ <file>content/images/USNational.jpg</file>
+ <file>content/images/World.jpg</file>
+ </qresource>
+</RCC>