1
1
/****************************************************************************
3
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
3
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4
4
** Contact: http://www.qt-project.org/legal
6
** This file is part of the QtQml module of the Qt Toolkit.
8
** $QT_BEGIN_LICENSE:LGPL$
9
** Commercial License Usage
10
** Licensees holding valid commercial Qt licenses may use this file in
11
** accordance with the commercial license agreement provided with the
12
** Software or, alternatively, in accordance with the terms contained in
13
** a written agreement between you and Digia. For licensing terms and
14
** conditions see http://qt.digia.com/licensing. For further information
15
** use the contact form at http://qt.digia.com/contact-us.
17
** GNU Lesser General Public License Usage
18
** Alternatively, this file may be used under the terms of the GNU Lesser
19
** General Public License version 2.1 as published by the Free Software
20
** Foundation and appearing in the file LICENSE.LGPL included in the
21
** packaging of this file. Please review the following information to
22
** ensure the GNU Lesser General Public License version 2.1 requirements
23
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25
** In addition, as a special exception, Digia gives you certain additional
26
** rights. These rights are described in the Digia Qt LGPL Exception
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29
** GNU General Public License Usage
30
** Alternatively, this file may be used under the terms of the GNU
31
** General Public License version 3.0 as published by the Free Software
32
** Foundation and appearing in the file LICENSE.GPL included in the
33
** packaging of this file. Please review the following information to
34
** ensure the GNU General Public License version 3.0 requirements will be
35
** met: http://www.gnu.org/copyleft/gpl.html.
6
** This file is part of the examples of the Qt Toolkit.
8
** $QT_BEGIN_LICENSE:BSD$
9
** You may use this file under the terms of the BSD license as follows:
11
** "Redistribution and use in source and binary forms, with or without
12
** modification, are permitted provided that the following conditions are
14
** * Redistributions of source code must retain the above copyright
15
** notice, this list of conditions and the following disclaimer.
16
** * Redistributions in binary form must reproduce the above copyright
17
** notice, this list of conditions and the following disclaimer in
18
** the documentation and/or other materials provided with the
20
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
21
** of its contributors may be used to endorse or promote products derived
22
** from this software without specific prior written permission.
25
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
38
37
** $QT_END_LICENSE$
40
39
****************************************************************************/
46
height: column.height + 40
47
45
width: delegate.ListView.view.width
52
width: parent.width - 40
48
// Returns a string representing how long ago an event occurred
49
function timeSinceEvent(pubDate) {
52
// We need to modify the pubDate read from the RSS feed
53
// so the JavaScript Date object can interpret it
54
var d = pubDate.replace(',','').split(' ');
58
var date = new Date([d[0], d[2], d[1], d[3], d[4], 'GMT' + d[5]].join(' '));
60
if (!isNaN(date.getDate())) {
61
var age = new Date() - date;
62
var minutes = Math.floor(Number(age) / 60000);
65
result = qsTr("Just now");
66
else if (minutes < 60)
67
result = '' + minutes + ' ' + qsTr("minutes ago")
68
else if (minutes < 120)
69
result = qsTr("1 hour ago");
71
result = '' + Math.floor(minutes/60) + ' ' + qsTr("hours ago");
74
result = date.toDateString();
80
Item { height: 8; width: delegate.width }
89
height: titleText.font.pixelSize / 4
56
text: title; width: parent.width; wrapMode: Text.WordWrap
57
font { bold: true; family: "Helvetica"; pointSize: 16 }
62
width: parent.width; text: description
63
wrapMode: Text.WordWrap; font.family: "Helvetica"
68
width: parent.width; height: 1; color: "#cccccc"
69
anchors.bottom: parent.bottom
102
width: delegate.width - titleImage.width
103
wrapMode: Text.WordWrap
110
width: delegate.width
112
textFormat: Text.RichText
114
text: timeSinceEvent(pubDate) + " (<a href=\"" + link + "\">Link</a>)"
116
Qt.openUrlExternally(link)
125
wrapMode: Text.WordWrap
127
textFormat: Text.StyledText
128
horizontalAlignment: Qt.AlignLeft