Line data Source code
1 : #include "NewsItem.h"
2 : #include "FeedItem.h"
3 : #include <QDebug>
4 :
5 1 : NewsItem::NewsItem(QObject *parent) :
6 : FangObject(parent),
7 1 : feed(nullptr),
8 1 : _id(-1),
9 1 : _feedId(-1),
10 1 : title(""),
11 1 : author(""),
12 1 : summary(""),
13 1 : content(""),
14 1 : timestamp(),
15 1 : url(),
16 1 : pinned(false),
17 2 : mediaImageURL("")
18 : {
19 1 : }
20 :
21 2648 : NewsItem::NewsItem(FeedItem* feed, qint64 id, qint64 feedId, const QString &title,
22 : const QString &author, const QString &summary, const QString &content,
23 : const QDateTime ×tamp, const QUrl &url, bool pinned,
24 2648 : const QString &mediaImageURL) :
25 : FangObject(feed),
26 2648 : feed(feed),
27 2648 : _id(id),
28 2648 : _feedId(feedId),
29 2648 : title(title),
30 2648 : author(author),
31 2648 : summary(summary),
32 2648 : content(content),
33 2648 : timestamp(timestamp),
34 2648 : url(url),
35 2648 : pinned(pinned),
36 5296 : mediaImageURL(mediaImageURL)
37 : {
38 2648 : }
39 :
40 2 : bool NewsItem::operator<(const NewsItem& right) {
41 2 : return LessThan(this, &right);
42 : }
43 :
44 12 : bool NewsItem::LessThan(const NewsItem* left, const NewsItem* right) {
45 : // Use id if dates are equal.
46 12 : if (left->timestamp == right->timestamp)
47 4 : return left->_id < right->_id;
48 :
49 : // Sort on timestamp.
50 8 : return left->timestamp < right->timestamp;
51 : }
|