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 : {
18 1 : }
19 :
20 86 : NewsItem::NewsItem(FeedItem* feed, qint64 id, qint64 feedId, const QString &title,
21 : const QString &author, const QString &summary, const QString &content,
22 86 : const QDateTime ×tamp, const QUrl &url, bool pinned) :
23 : FangObject(feed),
24 86 : feed(feed),
25 86 : _id(id),
26 86 : _feedId(feedId),
27 86 : title(title),
28 86 : author(author),
29 86 : summary(summary),
30 86 : content(content),
31 86 : timestamp(timestamp),
32 86 : url(url),
33 86 : pinned(pinned)
34 : {
35 86 : }
36 :
37 2 : bool NewsItem::operator<(const NewsItem& right) {
38 2 : return LessThan(this, &right);
39 : }
40 :
41 12 : bool NewsItem::LessThan(const NewsItem* left, const NewsItem* right) {
42 : // Use id if dates are equal.
43 12 : if (left->timestamp == right->timestamp)
44 4 : return left->_id < right->_id;
45 :
46 : // Sort on timestamp.
47 8 : return left->timestamp < right->timestamp;
48 : }
|