Class QfNewsParser
A class fetching RSS feeds and generating news items published within the last MAXIMUM_AGE_DAYS days, minus those already dismissed.
#include <qfnewsparser.h>
Inherits the following classes: QObject
Public Static Attributes
| Type | Name |
|---|---|
| const QString | DISMISSED_UUIDS_SETTINGS_KEY = QStringLiteral( "/QField/News/DismissedUuids" ) |
| const QString | ENABLED_SETTINGS_KEY = QStringLiteral( "/QField/News/Enabled" ) |
| constexpr int | MAXIMUM_AGE_DAYS = 45News items older than this number of days are no longer shown. |
Public Properties
| Type | Name |
|---|---|
| property bool | enabled |
| property QUrl | feedUrl |
| property bool | isFetching |
| property QList< QfNewsItem > | items |
Public Signals
| Type | Name |
|---|---|
| signal void | enabledChanged Emitted when news have been enabled or disabled. |
| signal void | feedUrlChanged Emitted when the RSS feed URL has changed. |
| signal void | isFetchingChanged Emitted when a fetching operation has begun or ended. |
| signal void | itemsChanged Emitted when the list of news items has changed. |
Public Functions
| Type | Name |
|---|---|
| QfNewsParser (QObject * parent=nullptr) The news parser constructor. |
|
| Q_INVOKABLE void | dismiss (const QString & uuid) |
| bool | enabled () const |
| QUrl | feedUrl () const Returns the RSS feed URL. |
| Q_INVOKABLE void | fetch () |
| bool | isFetching () const Returns TRUE while the RSS feed is being fetched. |
| QList< QfNewsItem > | items () const Returns the undismissed news items published within the last MAXIMUM_AGE_DAYS days, most recent first. |
| void | setEnabled (bool enabled) |
| void | setFeedUrl (const QUrl & url) |
Public Static Functions
| Type | Name |
|---|---|
| QList< QfNewsItem > | parseFeed (const QByteArray & data) |
Public Static Attributes Documentation
variable DISMISSED_UUIDS_SETTINGS_KEY
const QString QfNewsParser::DISMISSED_UUIDS_SETTINGS_KEY;
variable ENABLED_SETTINGS_KEY
const QString QfNewsParser::ENABLED_SETTINGS_KEY;
variable MAXIMUM_AGE_DAYS
News items older than this number of days are no longer shown.
constexpr int QfNewsParser::MAXIMUM_AGE_DAYS;
Public Properties Documentation
property enabled [1/2]
bool QfNewsParser::enabled;
property feedUrl [1/2]
QUrl QfNewsParser::feedUrl;
property isFetching [1/2]
bool QfNewsParser::isFetching;
property items [1/2]
QList<QfNewsItem> QfNewsParser::items;
Public Signals Documentation
signal enabledChanged
Emitted when news have been enabled or disabled.
void QfNewsParser::enabledChanged;
signal feedUrlChanged
Emitted when the RSS feed URL has changed.
void QfNewsParser::feedUrlChanged;
signal isFetchingChanged
Emitted when a fetching operation has begun or ended.
void QfNewsParser::isFetchingChanged;
signal itemsChanged
Emitted when the list of news items has changed.
void QfNewsParser::itemsChanged;
Public Functions Documentation
function QfNewsParser
The news parser constructor.
explicit QfNewsParser::QfNewsParser (
QObject * parent=nullptr
)
function dismiss
Q_INVOKABLE void QfNewsParser::dismiss (
const QString & uuid
)
Dismisses the news item matching a given uuid, it will no longer be part of the news items.
function enabled [2/2]
bool QfNewsParser::enabled () const
Returns TRUE if the user has opted into receiving news.
function feedUrl [2/2]
Returns the RSS feed URL.
inline QUrl QfNewsParser::feedUrl () const
function fetch
Q_INVOKABLE void QfNewsParser::fetch ()
Fetches the RSS feed and refreshes the news items.
Note:
Nothing will be fetched when news are disabled.
function isFetching [2/2]
Returns TRUE while the RSS feed is being fetched.
inline bool QfNewsParser::isFetching () const
function items [2/2]
Returns the undismissed news items published within the last MAXIMUM_AGE_DAYS days, most recent first.
inline QList< QfNewsItem > QfNewsParser::items () const
function setEnabled
void QfNewsParser::setEnabled (
bool enabled
)
Sets whether the user has opted into receiving news.
function setFeedUrl
void QfNewsParser::setFeedUrl (
const QUrl & url
)
Sets the RSS feed URL. News items are cleared and, if available, restored from the last successful fetch of that feed until the next fetch() call.
Public Static Functions Documentation
function parseFeed
static QList< QfNewsItem > QfNewsParser::parseFeed (
const QByteArray & data
)
Parses an RSS feed data content and returns its news items.
The documentation for this class was generated from the following file src/core/qfnewsparser.h