chore: reformat

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
Sefa Eyeoglu
2023-08-14 18:16:53 +02:00
parent 779f70057b
commit 91ba4cf75e
603 changed files with 15840 additions and 16257 deletions

View File

@ -49,8 +49,7 @@ NewsChecker::NewsChecker(shared_qobject_ptr<QNetworkAccessManager> network, cons
void NewsChecker::reloadNews()
{
// Start a netjob to download the RSS feed and call rssDownloadFinished() when it's done.
if (isLoadingNews())
{
if (isLoadingNews()) {
qDebug() << "Ignored request to reload news. Currently reloading already.";
return;
}
@ -113,7 +112,6 @@ void NewsChecker::rssDownloadFailed(QString reason)
fail(tr("Failed to load news RSS feed:\n%1").arg(reason));
}
QList<NewsEntryPtr> NewsChecker::getNewsEntries() const
{
return m_newsEntries;
@ -144,4 +142,3 @@ void NewsChecker::fail(const QString& errorMsg)
m_newsNetJob.reset();
emit newsLoadingFailed(errorMsg);
}

View File

@ -15,18 +15,17 @@
#pragma once
#include <QList>
#include <QObject>
#include <QString>
#include <QList>
#include <net/NetJob.h>
#include "NewsEntry.h"
class NewsChecker : public QObject
{
class NewsChecker : public QObject {
Q_OBJECT
public:
public:
/*!
* Constructs a news reader to read from the given RSS feed URL.
*/
@ -57,7 +56,7 @@ public:
*/
void Q_SLOT reloadNews();
signals:
signals:
/*!
* Signal fired after the news has finished loading.
*/
@ -68,11 +67,11 @@ signals:
*/
void newsLoadingFailed(QString errorMsg);
protected slots:
protected slots:
void rssDownloadFinished();
void rssDownloadFailed(QString reason);
protected: /* data */
protected: /* data */
//! The URL for the RSS feed to fetch.
QString m_feedUrl;
@ -95,11 +94,10 @@ protected: /* data */
shared_qobject_ptr<QNetworkAccessManager> m_network;
protected slots:
protected slots:
/// Emits newsLoaded() and sets m_lastLoadError to empty string.
void succeed();
/// Emits newsLoadingFailed() and sets m_lastLoadError to the given message.
void fail(const QString& errorMsg);
};

View File

@ -18,16 +18,14 @@
#include <QDomNodeList>
#include <QVariant>
NewsEntry::NewsEntry(QObject* parent) :
QObject(parent)
NewsEntry::NewsEntry(QObject* parent) : QObject(parent)
{
this->title = tr("Untitled");
this->content = tr("No content.");
this->link = "";
}
NewsEntry::NewsEntry(const QString& title, const QString& content, const QString& link, QObject* parent) :
QObject(parent)
NewsEntry::NewsEntry(const QString& title, const QString& content, const QString& link, QObject* parent) : QObject(parent)
{
this->title = title;
this->content = content;
@ -37,16 +35,13 @@ NewsEntry::NewsEntry(const QString& title, const QString& content, const QString
/*!
* Gets the text content of the given child element as a QVariant.
*/
inline QString childValue(const QDomElement& element, const QString& childName, QString defaultVal="")
inline QString childValue(const QDomElement& element, const QString& childName, QString defaultVal = "")
{
QDomNodeList nodes = element.elementsByTagName(childName);
if (nodes.count() > 0)
{
if (nodes.count() > 0) {
QDomElement elem = nodes.at(0).toElement();
return elem.text();
}
else
{
} else {
return defaultVal;
}
}

View File

@ -15,33 +15,31 @@
#pragma once
#include <QDomElement>
#include <QObject>
#include <QString>
#include <QDomElement>
#include <memory>
class NewsEntry : public QObject
{
class NewsEntry : public QObject {
Q_OBJECT
public:
public:
/*!
* Constructs an empty news entry.
*/
explicit NewsEntry(QObject* parent=0);
explicit NewsEntry(QObject* parent = 0);
/*!
* Constructs a new news entry.
* Note that content may contain HTML.
*/
NewsEntry(const QString& title, const QString& content, const QString& link, QObject* parent=0);
NewsEntry(const QString& title, const QString& content, const QString& link, QObject* parent = 0);
/*!
* Attempts to load information from the given XML element into the given news entry pointer.
* If this fails, the function will return false and store an error message in the errorMsg pointer.
*/
static bool fromXmlElement(const QDomElement& element, NewsEntry* entry, QString* errorMsg=0);
static bool fromXmlElement(const QDomElement& element, NewsEntry* entry, QString* errorMsg = 0);
//! The post title.
QString title;
@ -54,4 +52,3 @@ public:
};
typedef std::shared_ptr<NewsEntry> NewsEntryPtr;