Files
pay/modules/social-feed/FeedDataProvider.h
T

76 lines
2.0 KiB
C++
Raw Permalink Normal View History

2025-02-01 11:33:18 +01:00
/*
* This file is part of the Flowee project
* Copyright (C) 2025 Tom Zander <tom@flowee.org>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef FEEDDATAPROVIDER_H
#define FEEDDATAPROVIDER_H
#include <QDateTime>
#include <QObject>
#include <QList>
2025-11-17 11:57:50 +01:00
#include <apputils/SimpleHttpClient.h>
2025-02-01 11:33:18 +01:00
class ListItem : public QObject
{
Q_OBJECT
Q_PROPERTY(QDate date READ date CONSTANT FINAL)
Q_PROPERTY(QString videoLength READ videoLength CONSTANT FINAL)
Q_PROPERTY(QString text READ text CONSTANT FINAL)
Q_PROPERTY(QString title READ title CONSTANT FINAL)
Q_PROPERTY(QString url READ url CONSTANT FINAL)
public:
ListItem(QObject *parent = nullptr);
QDate date() const;
QString videoLength() const;
QString text() const;
QString title() const;
QString url() const;
QDate m_date;
QString m_videoLength;
QString m_text;
QString m_title;
QString m_url;
};
class FeedDataProvider : public QObject
{
Q_OBJECT
Q_PROPERTY(QList<ListItem*> items READ listItems NOTIFY listItemsChanged FINAL)
public:
explicit FeedDataProvider(QObject *parent = nullptr);
QList<ListItem*> listItems() const;
signals:
void listItemsChanged();
private slots:
void start();
void downloadFinished();
2025-11-17 11:57:50 +01:00
void errored(SimpleHttpClient::ErrorType e);
2025-02-01 11:33:18 +01:00
private:
void readFeed();
QDateTime m_lastCheck;
QList<ListItem*> m_listItems;
2025-11-17 11:57:50 +01:00
std::shared_ptr<SimpleHttpClient> m_httpClient;
2025-02-01 11:33:18 +01:00
};
#endif