aboutsummaryrefslogtreecommitdiff
path: root/launcher/news
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/news')
-rw-r--r--launcher/news/NewsChecker.cpp5
-rw-r--r--launcher/news/NewsChecker.h16
-rw-r--r--launcher/news/NewsEntry.cpp15
-rw-r--r--launcher/news/NewsEntry.h15
4 files changed, 19 insertions, 32 deletions
diff --git a/launcher/news/NewsChecker.cpp b/launcher/news/NewsChecker.cpp
index 4f02bf5e..11ba5311 100644
--- a/launcher/news/NewsChecker.cpp
+++ b/launcher/news/NewsChecker.cpp
@@ -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);
}
-
diff --git a/launcher/news/NewsChecker.h b/launcher/news/NewsChecker.h
index 41babfff..cdd621a2 100644
--- a/launcher/news/NewsChecker.h
+++ b/launcher/news/NewsChecker.h
@@ -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);
};
-
diff --git a/launcher/news/NewsEntry.cpp b/launcher/news/NewsEntry.cpp
index 9726cab2..ea25f2e5 100644
--- a/launcher/news/NewsEntry.cpp
+++ b/launcher/news/NewsEntry.cpp
@@ -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;
}
}
diff --git a/launcher/news/NewsEntry.h b/launcher/news/NewsEntry.h
index 1fe95623..2d409a9f 100644
--- a/launcher/news/NewsEntry.h
+++ b/launcher/news/NewsEntry.h
@@ -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;
-