-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
trendingnewsmodel.h
36 lines (27 loc) · 934 Bytes
/
trendingnewsmodel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// SPDX-FileCopyrightText: 2024 Joshua Goins <josh@redstrate.com>
// SPDX-License-Identifier: LGPL-2.1-or-later
#pragma once
#include "timeline/abstractlistmodel.h"
class TrendingNewsModel : public AbstractListModel
{
Q_OBJECT
QML_ELEMENT
public:
explicit TrendingNewsModel(QObject *parent = nullptr);
~TrendingNewsModel() override;
enum CustomRoles { UrlRole = Qt::UserRole, TitleRole, DescriptionRole, ImageRole };
QVariant data(const QModelIndex &index, int role) const override;
int rowCount(const QModelIndex &parent) const override;
QHash<int, QByteArray> roleNames() const override;
[[nodiscard]] QString displayName() const override;
private:
void fill();
struct Link {
QString url;
QString title;
QString description;
QString image;
};
QList<Link> m_links;
[[nodiscard]] Link fromSourceData(const QJsonObject &object) const;
};