Refactoring, fix some code errors.
This commit is contained in:
parent
f21f366850
commit
7f8c687e95
73 changed files with 268 additions and 285 deletions
|
@ -30,7 +30,7 @@
|
|||
<url type="donation">https://martinrotter.github.io/donate/</url>
|
||||
<content_rating type="oars-1.1" />
|
||||
<releases>
|
||||
<release version="3.5.7" date="2019-04-12"/>
|
||||
<release version="3.5.7" date="2019-05-28"/>
|
||||
</releases>
|
||||
<content_rating type="oars-1.0">
|
||||
<content_attribute id="violence-cartoon">none</content_attribute>
|
||||
|
|
|
@ -161,7 +161,7 @@ void MessagePreviewer::markMessageAsReadUnread(RootItem::ReadStatus read) {
|
|||
if (m_root->getParentServiceRoot()->onBeforeSetMessagesRead(m_root.data(),
|
||||
QList<Message>() << m_message,
|
||||
read)) {
|
||||
DatabaseQueries::markMessagesReadUnread(qApp->database()->connection(objectName(), DatabaseFactory::FromSettings),
|
||||
DatabaseQueries::markMessagesReadUnread(qApp->database()->connection(objectName(), DatabaseFactory::DesiredType::FromSettings),
|
||||
QStringList() << QString::number(m_message.m_id),
|
||||
read);
|
||||
m_root->getParentServiceRoot()->onAfterSetMessagesRead(m_root.data(),
|
||||
|
@ -185,7 +185,7 @@ void MessagePreviewer::switchMessageImportance(bool checked) {
|
|||
:
|
||||
RootItem::Important)))
|
||||
{
|
||||
DatabaseQueries::switchMessagesImportance(qApp->database()->connection(objectName(), DatabaseFactory::FromSettings),
|
||||
DatabaseQueries::switchMessagesImportance(qApp->database()->connection(objectName(), DatabaseFactory::DesiredType::FromSettings),
|
||||
QStringList() << QString::number(m_message.m_id));
|
||||
m_root->getParentServiceRoot()->onAfterSwitchMessageImportance(m_root.data(),
|
||||
QList<ImportanceChange>() << ImportanceChange(m_message,
|
||||
|
|
|
@ -35,6 +35,7 @@ extern void disableWindowTabbing();
|
|||
|
||||
int main(int argc, char* argv[]) {
|
||||
for (int i = 0; i < argc; i++) {
|
||||
// TODO: use process arg parser
|
||||
const QString str = QString::fromLocal8Bit(argv[i]);
|
||||
|
||||
if (str == "-h") {
|
||||
|
@ -62,7 +63,7 @@ int main(int argc, char* argv[]) {
|
|||
// Instantiate base application object.
|
||||
Application application(APP_LOW_NAME, argc, argv);
|
||||
|
||||
if (application.arguments().contains(QL1S("-log"))) {
|
||||
if (Application::arguments().contains(QL1S("-log"))) {
|
||||
Debugging::instance()->setTargetFile(IOFactory::getSystemFolder(QStandardPaths::TempLocation) +
|
||||
QDir::separator() + QL1S("rssguard.log"));
|
||||
}
|
||||
|
@ -71,7 +72,7 @@ int main(int argc, char* argv[]) {
|
|||
qDebug("Instantiated Application class.");
|
||||
|
||||
// Check if another instance is running.
|
||||
if (application.sendMessage((QStringList() << APP_IS_RUNNING << application.arguments().mid(1)).join(ARGUMENTS_LIST_SEPARATOR))) {
|
||||
if (application.sendMessage((QStringList() << APP_IS_RUNNING << Application::arguments().mid(1)).join(ARGUMENTS_LIST_SEPARATOR))) {
|
||||
qWarning("Another instance of the application is already running. Notifying it.");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
@ -137,7 +138,7 @@ int main(int argc, char* argv[]) {
|
|||
if (qApp->isFirstRun() || qApp->isFirstRun(APP_VERSION)) {
|
||||
qApp->showGuiMessage(QSL(APP_NAME), QObject::tr("Welcome to %1.\n\nPlease, check NEW stuff included in this\n"
|
||||
"version by clicking this popup notification.").arg(APP_LONG_NAME),
|
||||
QSystemTrayIcon::NoIcon, 0, false, [] {
|
||||
QSystemTrayIcon::NoIcon, nullptr, false, [] {
|
||||
FormAbout(qApp->mainForm()).exec();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ Skin SkinFactory::skinInfo(const QString& skin_name, bool* ok) const {
|
|||
QDomDocument dokument;
|
||||
|
||||
if (!skin_file.open(QIODevice::Text | QIODevice::ReadOnly) || !dokument.setContent(&skin_file, true)) {
|
||||
if (ok) {
|
||||
if (ok != nullptr) {
|
||||
*ok = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ bool SystemFactory::removeTrolltechJunkRegistryKeys() {
|
|||
if (qApp->settings()->value(GROUP(General), SETTING(General::RemoveTrolltechJunk)).toBool()) {
|
||||
QSettings registry_key(QSL("HKEY_CURRENT_USER\\Software\\TrollTech"), QSettings::NativeFormat);
|
||||
|
||||
registry_key.remove(QSL(""));
|
||||
registry_key.remove(QString());
|
||||
registry_key.sync();
|
||||
return registry_key.status() == QSettings::NoError;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include <QTimer>
|
||||
|
||||
AdBlockDialog::AdBlockDialog(QWidget* parent)
|
||||
: QDialog(parent), m_manager(AdBlockManager::instance()), m_currentTreeWidget(0), m_currentSubscription(0),
|
||||
: QDialog(parent), m_manager(AdBlockManager::instance()), m_currentTreeWidget(nullptr), m_currentSubscription(nullptr),
|
||||
m_loaded(false), m_ui(new Ui::AdBlockDialog) {
|
||||
m_ui->setupUi(this);
|
||||
m_ui->m_cbEnable->setChecked(m_manager->isEnabled());
|
||||
|
@ -45,7 +45,7 @@ AdBlockDialog::AdBlockDialog(QWidget* parent)
|
|||
QPushButton* btn_options = m_ui->m_buttonBox->addButton(QDialogButtonBox::FirstButton);
|
||||
|
||||
btn_options->setText(tr("Options"));
|
||||
QMenu* menu = new QMenu(btn_options);
|
||||
auto* menu = new QMenu(btn_options);
|
||||
|
||||
m_actionAddRule = menu->addAction(tr("Add rule"), this, &AdBlockDialog::addRule);
|
||||
m_actionRemoveRule = menu->addAction(tr("Remove rule"), this, &AdBlockDialog::removeRule);
|
||||
|
@ -67,9 +67,9 @@ AdBlockDialog::AdBlockDialog(QWidget* parent)
|
|||
void AdBlockDialog::showRule(const AdBlockRule* rule) const {
|
||||
AdBlockSubscription* subscription = rule->subscription();
|
||||
|
||||
if (subscription) {
|
||||
if (subscription != nullptr) {
|
||||
for (int i = 0; i < m_ui->m_tabSubscriptions->count(); ++i) {
|
||||
AdBlockTreeWidget* treeWidget = qobject_cast<AdBlockTreeWidget*>(m_ui->m_tabSubscriptions->widget(i));
|
||||
auto* treeWidget = qobject_cast<AdBlockTreeWidget*>(m_ui->m_tabSubscriptions->widget(i));
|
||||
|
||||
if (subscription == treeWidget->subscription()) {
|
||||
treeWidget->showRule(rule);
|
||||
|
@ -99,7 +99,7 @@ void AdBlockDialog::addSubscription() {
|
|||
QString url = dialog.url();
|
||||
|
||||
if (AdBlockSubscription* subscription = m_manager->addSubscription(title, url)) {
|
||||
AdBlockTreeWidget* tree = new AdBlockTreeWidget(subscription, m_ui->m_tabSubscriptions);
|
||||
auto* tree = new AdBlockTreeWidget(subscription, m_ui->m_tabSubscriptions);
|
||||
int index = m_ui->m_tabSubscriptions->insertTab(m_ui->m_tabSubscriptions->count() - 1, tree, subscription->title());
|
||||
|
||||
m_ui->m_tabSubscriptions->setCurrentIndex(index);
|
||||
|
@ -128,8 +128,8 @@ void AdBlockDialog::enableAdBlock(bool state) {
|
|||
}
|
||||
|
||||
void AdBlockDialog::aboutToShowMenu() {
|
||||
bool subscriptionEditable = m_currentSubscription && m_currentSubscription->canEditRules();
|
||||
bool subscriptionRemovable = m_currentSubscription && m_currentSubscription->canBeRemoved();
|
||||
bool subscriptionEditable = (m_currentSubscription != nullptr) && m_currentSubscription->canEditRules();
|
||||
bool subscriptionRemovable = (m_currentSubscription != nullptr) && m_currentSubscription->canBeRemoved();
|
||||
|
||||
m_actionAddRule->setEnabled(subscriptionEditable);
|
||||
m_actionRemoveRule->setEnabled(subscriptionEditable);
|
||||
|
@ -142,7 +142,7 @@ void AdBlockDialog::learnAboutRules() {
|
|||
|
||||
void AdBlockDialog::loadSubscriptions() {
|
||||
for (int i = 0; i < m_ui->m_tabSubscriptions->count(); ++i) {
|
||||
AdBlockTreeWidget* treeWidget = qobject_cast<AdBlockTreeWidget*>(m_ui->m_tabSubscriptions->widget(i));
|
||||
auto* treeWidget = qobject_cast<AdBlockTreeWidget*>(m_ui->m_tabSubscriptions->widget(i));
|
||||
|
||||
treeWidget->refresh();
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ void AdBlockDialog::load() {
|
|||
}
|
||||
|
||||
foreach (AdBlockSubscription* subscription, m_manager->subscriptions()) {
|
||||
AdBlockTreeWidget* tree = new AdBlockTreeWidget(subscription, m_ui->m_tabSubscriptions);
|
||||
auto* tree = new AdBlockTreeWidget(subscription, m_ui->m_tabSubscriptions);
|
||||
|
||||
m_ui->m_tabSubscriptions->addTab(tree, subscription->title());
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
#include <QTimer>
|
||||
|
||||
AdBlockIcon::AdBlockIcon(AdBlockManager* parent)
|
||||
: QAction(parent), m_manager(parent), m_flashTimer(0), m_timerTicks(0), m_enabled(m_manager->isEnabled()) {
|
||||
: QAction(parent), m_manager(parent), m_flashTimer(nullptr), m_timerTicks(0), m_enabled(m_manager->isEnabled()) {
|
||||
setToolTip(tr("AdBlock lets you block unwanted content on web pages"));
|
||||
setText(QSL("AdBlock"));
|
||||
setMenu(new QMenu());
|
||||
|
@ -59,7 +59,7 @@ void AdBlockIcon::popupBlocked(const QString& ruleString, const QUrl& url) {
|
|||
const QString filter = ruleString.mid(index + 2, ruleString.size() - index - 3);
|
||||
AdBlockSubscription* subscription = m_manager->subscriptionByName(subscriptionName);
|
||||
|
||||
if (filter.isEmpty() || !subscription) {
|
||||
if (filter.isEmpty() || (subscription == nullptr)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ void AdBlockIcon::popupBlocked(const QString& ruleString, const QUrl& url) {
|
|||
m_blockedPopups.append(pair);
|
||||
qApp->showGuiMessage(tr("Blocked popup window"), tr("AdBlock blocked unwanted popup window."), QSystemTrayIcon::Information);
|
||||
|
||||
if (!m_flashTimer) {
|
||||
if (m_flashTimer == nullptr) {
|
||||
m_flashTimer = new QTimer(this);
|
||||
}
|
||||
|
||||
|
@ -83,10 +83,10 @@ void AdBlockIcon::popupBlocked(const QString& ruleString, const QUrl& url) {
|
|||
}
|
||||
|
||||
void AdBlockIcon::createMenu(QMenu* menu) {
|
||||
if (!menu) {
|
||||
if (menu == nullptr) {
|
||||
menu = qobject_cast<QMenu*>(sender());
|
||||
|
||||
if (!menu) {
|
||||
if (menu == nullptr) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -126,9 +126,9 @@ void AdBlockIcon::showMenu(const QPoint& pos) {
|
|||
}
|
||||
|
||||
void AdBlockIcon::toggleCustomFilter() {
|
||||
QAction* action = qobject_cast<QAction*>(sender());
|
||||
auto* action = qobject_cast<QAction*>(sender());
|
||||
|
||||
if (!action) {
|
||||
if (action == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ void AdBlockIcon::toggleCustomFilter() {
|
|||
customList->removeFilter(filter);
|
||||
}
|
||||
else {
|
||||
AdBlockRule* rule = new AdBlockRule(filter, customList);
|
||||
auto* rule = new AdBlockRule(filter, customList);
|
||||
|
||||
customList->addRule(rule);
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ bool AdBlockManager::block(QWebEngineUrlRequestInfo& request) {
|
|||
bool res = false;
|
||||
const AdBlockRule* blockedRule = m_matcher->match(request, urlDomain, urlString);
|
||||
|
||||
if (blockedRule) {
|
||||
if (blockedRule != nullptr) {
|
||||
if (request.resourceType() == QWebEngineUrlRequestInfo::ResourceTypeMainFrame) {
|
||||
QUrlQuery query;
|
||||
QUrl url(QSL("rssguard:adblockedpage"));
|
||||
|
@ -165,7 +165,7 @@ bool AdBlockManager::addSubscriptionFromUrl(const QUrl& url) {
|
|||
|
||||
AdBlockSubscription* AdBlockManager::addSubscription(const QString& title, const QString& url) {
|
||||
if (title.isEmpty() || url.isEmpty()) {
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QString fileName = title + QSL(".txt");
|
||||
|
@ -175,12 +175,12 @@ AdBlockSubscription* AdBlockManager::addSubscription(const QString& title, const
|
|||
|
||||
if (!file.open(QFile::WriteOnly)) {
|
||||
qWarning("Cannot save AdBlock subscription to file '%s'.", qPrintable(filePath));
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
file.write(data);
|
||||
file.commit();
|
||||
AdBlockSubscription* subscription = new AdBlockSubscription(title, this);
|
||||
auto* subscription = new AdBlockSubscription(title, this);
|
||||
|
||||
subscription->setUrl(QUrl(url));
|
||||
subscription->setFilePath(filePath);
|
||||
|
@ -207,14 +207,14 @@ bool AdBlockManager::removeSubscription(AdBlockSubscription* subscription) {
|
|||
|
||||
AdBlockCustomList* AdBlockManager::customList() const {
|
||||
foreach (AdBlockSubscription* subscription, m_subscriptions) {
|
||||
AdBlockCustomList* list = qobject_cast<AdBlockCustomList*>(subscription);
|
||||
auto* list = qobject_cast<AdBlockCustomList*>(subscription);
|
||||
|
||||
if (list) {
|
||||
if (list != nullptr) {
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QString AdBlockManager::storedListsPath() {
|
||||
|
@ -266,7 +266,7 @@ void AdBlockManager::load() {
|
|||
continue;
|
||||
}
|
||||
|
||||
AdBlockSubscription* subscription = new AdBlockSubscription(title, this);
|
||||
auto* subscription = new AdBlockSubscription(title, this);
|
||||
|
||||
subscription->setUrl(url);
|
||||
subscription->setFilePath(absolutePath);
|
||||
|
@ -274,7 +274,7 @@ void AdBlockManager::load() {
|
|||
}
|
||||
|
||||
// Append CustomList.
|
||||
AdBlockCustomList* customList = new AdBlockCustomList(this);
|
||||
auto* customList = new AdBlockCustomList(this);
|
||||
|
||||
m_subscriptions.append(customList);
|
||||
|
||||
|
@ -357,11 +357,11 @@ AdBlockSubscription* AdBlockManager::subscriptionByName(const QString& name) con
|
|||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void AdBlockManager::showDialog() {
|
||||
if (!m_adBlockDialog) {
|
||||
if (m_adBlockDialog == nullptr) {
|
||||
m_adBlockDialog = new AdBlockDialog();
|
||||
}
|
||||
|
||||
|
|
|
@ -34,8 +34,8 @@ AdBlockMatcher::~AdBlockMatcher() {
|
|||
const AdBlockRule* AdBlockMatcher::match(const QWebEngineUrlRequestInfo& request, const QString& urlDomain,
|
||||
const QString& urlString) const {
|
||||
// Exception rules.
|
||||
if (m_networkExceptionTree.find(request, urlDomain, urlString)) {
|
||||
return 0;
|
||||
if (m_networkExceptionTree.find(request, urlDomain, urlString) != nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int count = m_networkExceptionRules.count();
|
||||
|
@ -44,7 +44,7 @@ const AdBlockRule* AdBlockMatcher::match(const QWebEngineUrlRequestInfo& request
|
|||
const AdBlockRule* rule = m_networkExceptionRules.at(i);
|
||||
|
||||
if (rule->networkMatch(request, urlDomain, urlString)) {
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ const AdBlockRule* AdBlockMatcher::match(const QWebEngineUrlRequestInfo& request
|
|||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool AdBlockMatcher::adBlockDisabledForUrl(const QUrl& url) const {
|
||||
|
@ -178,7 +178,7 @@ void AdBlockMatcher::update() {
|
|||
const AdBlockRule* originalRule = cssRulesHash.value(rule->cssSelector());
|
||||
|
||||
// If we don't have this selector, the exception does nothing.
|
||||
if (!originalRule) {
|
||||
if (originalRule == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ static QString toSecondLevelDomain(const QUrl& url) {
|
|||
|
||||
AdBlockRule::AdBlockRule(const QString& filter, AdBlockSubscription* subscription)
|
||||
: m_subscription(subscription), m_type(StringContainsMatchRule), m_caseSensitivity(Qt::CaseInsensitive),
|
||||
m_isEnabled(true), m_isException(false), m_isInternalDisabled(false), matchers(QList<QStringMatcher>()) {
|
||||
m_isEnabled(true), m_isException(false), m_isInternalDisabled(false) {
|
||||
setFilter(filter);
|
||||
}
|
||||
|
||||
|
@ -522,8 +522,8 @@ bool AdBlockRule::filterIsOnlyDomain(const QString& filter) const {
|
|||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < filter.size(); ++i) {
|
||||
switch (filter.at(i).toLatin1()) {
|
||||
for (auto i : filter) {
|
||||
switch (i.toLatin1()) {
|
||||
case '/':
|
||||
case ':':
|
||||
case '?':
|
||||
|
@ -727,11 +727,11 @@ QStringList AdBlockRule::parseRegExpFilter(const QString& filter) const {
|
|||
}
|
||||
|
||||
bool AdBlockRule::hasOption(const AdBlockRule::RuleOption& opt) const {
|
||||
return (m_options & opt);
|
||||
return (m_options & opt) != 0;
|
||||
}
|
||||
|
||||
bool AdBlockRule::hasException(const AdBlockRule::RuleOption& opt) const {
|
||||
return (m_exceptions & opt);
|
||||
return (m_exceptions & opt) != 0;
|
||||
}
|
||||
|
||||
void AdBlockRule::setOption(const AdBlockRule::RuleOption& opt) {
|
||||
|
|
|
@ -52,7 +52,7 @@ bool AdBlockSearchTree::add(const AdBlockRule* rule) {
|
|||
const QChar c = filter.at(i);
|
||||
Node* next = node->children.value(c);
|
||||
|
||||
if (!next) {
|
||||
if (next == nullptr) {
|
||||
next = new Node;
|
||||
next->c = c;
|
||||
node->children[c] = next;
|
||||
|
@ -69,50 +69,48 @@ const AdBlockRule* AdBlockSearchTree::find(const QWebEngineUrlRequestInfo& reque
|
|||
int len = urlString.size();
|
||||
|
||||
if (len <= 0) {
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const QChar* string = urlString.constData();
|
||||
|
||||
for (int i = 0; i < len; ++i) {
|
||||
const AdBlockRule* rule = prefixSearch(request, domain, urlString, string++, len - i);
|
||||
const AdBlockRule* rule = prefixSearch(request, domain, urlString, urlString.mid(i), len - i);
|
||||
|
||||
if (rule) {
|
||||
if (rule != nullptr) {
|
||||
return rule;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const AdBlockRule* AdBlockSearchTree::prefixSearch(const QWebEngineUrlRequestInfo& request, const QString& domain, const QString& urlString,
|
||||
const QChar* string, int len) const {
|
||||
const AdBlockRule* AdBlockSearchTree::prefixSearch(const QWebEngineUrlRequestInfo& request, const QString& domain,
|
||||
const QString& urlString, const QString& choppedUrlString, int len) const {
|
||||
if (len <= 0) {
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QChar c = string[0];
|
||||
QChar c = choppedUrlString.at(0);
|
||||
Node* node = m_root->children.value(c);
|
||||
|
||||
if (!node) {
|
||||
if (node == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
for (int i = 1; i < len; ++i) {
|
||||
const QChar c = (++string)[0];
|
||||
const QChar c = choppedUrlString.at(i);
|
||||
|
||||
if (node->rule && node->rule->networkMatch(request, domain, urlString)) {
|
||||
if ((node->rule != nullptr) && node->rule->networkMatch(request, domain, urlString)) {
|
||||
return node->rule;
|
||||
}
|
||||
|
||||
node = node->children.value(c);
|
||||
|
||||
if (!node) {
|
||||
if (node == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (node->rule && node->rule->networkMatch(request, domain, urlString)) {
|
||||
if ((node->rule != nullptr) && node->rule->networkMatch(request, domain, urlString)) {
|
||||
return node->rule;
|
||||
}
|
||||
|
||||
|
@ -120,7 +118,7 @@ const AdBlockRule* AdBlockSearchTree::prefixSearch(const QWebEngineUrlRequestInf
|
|||
}
|
||||
|
||||
void AdBlockSearchTree::deleteNode(AdBlockSearchTree::Node* node) {
|
||||
if (!node) {
|
||||
if (node == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ class AdBlockSearchTree {
|
|||
|
||||
};
|
||||
const AdBlockRule* prefixSearch(const QWebEngineUrlRequestInfo& request, const QString& domain,
|
||||
const QString& urlString, const QChar* string, int len) const;
|
||||
const QString& urlString, const QString& choppedUrlString, int len) const;
|
||||
|
||||
void deleteNode(Node* node);
|
||||
|
||||
|
|
|
@ -60,9 +60,10 @@
|
|||
#include <QNetworkReply>
|
||||
#include <QSaveFile>
|
||||
#include <QTimer>
|
||||
#include <utility>
|
||||
|
||||
AdBlockSubscription::AdBlockSubscription(const QString& title, QObject* parent)
|
||||
: QObject(parent), m_reply(0), m_title(title), m_updated(false) {}
|
||||
AdBlockSubscription::AdBlockSubscription(QString title, QObject* parent)
|
||||
: QObject(parent), m_reply(nullptr), m_title(std::move(title)), m_updated(false) {}
|
||||
|
||||
QString AdBlockSubscription::title() const {
|
||||
return m_title;
|
||||
|
@ -134,11 +135,11 @@ void AdBlockSubscription::loadSubscription(const QStringList& disabledRules) {
|
|||
void AdBlockSubscription::saveSubscription() {}
|
||||
|
||||
void AdBlockSubscription::updateSubscription() {
|
||||
if (m_reply || !m_url.isValid()) {
|
||||
if ((m_reply != nullptr) || !m_url.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
SilentNetworkAccessManager* mgs = new SilentNetworkAccessManager(this);
|
||||
auto* mgs = new SilentNetworkAccessManager(this);
|
||||
|
||||
m_reply = mgs->get(QNetworkRequest(m_url));
|
||||
connect(m_reply, &QNetworkReply::finished, this, &AdBlockSubscription::subscriptionDownloaded);
|
||||
|
@ -158,7 +159,7 @@ void AdBlockSubscription::subscriptionDownloaded() {
|
|||
|
||||
m_reply->manager()->deleteLater();
|
||||
m_reply->deleteLater();
|
||||
m_reply = 0;
|
||||
m_reply = nullptr;
|
||||
|
||||
if (error) {
|
||||
emit subscriptionError(tr("Cannot load subscription!"));
|
||||
|
@ -192,7 +193,7 @@ const AdBlockRule* AdBlockSubscription::rule(int offset) const {
|
|||
return m_rules[offset];
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -211,13 +212,13 @@ const AdBlockRule* AdBlockSubscription::enableRule(int offset) {
|
|||
return rule;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
const AdBlockRule* AdBlockSubscription::disableRule(int offset) {
|
||||
if (!IS_IN_ARRAY(offset, m_rules)) {
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AdBlockRule* rule = m_rules[offset];
|
||||
|
@ -250,7 +251,7 @@ bool AdBlockSubscription::removeRule(int offset) {
|
|||
const AdBlockRule* AdBlockSubscription::replaceRule(AdBlockRule* rule, int offset) {
|
||||
Q_UNUSED(rule)
|
||||
Q_UNUSED(offset)
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AdBlockSubscription::~AdBlockSubscription() {
|
||||
|
@ -378,7 +379,7 @@ bool AdBlockCustomList::removeRule(int offset) {
|
|||
|
||||
const AdBlockRule* AdBlockCustomList::replaceRule(AdBlockRule* rule, int offset) {
|
||||
if (!IS_IN_ARRAY(offset, m_rules)) {
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
AdBlockRule* oldRule = m_rules.at(offset);
|
||||
|
|
|
@ -61,7 +61,7 @@ class AdBlockSubscription : public QObject {
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AdBlockSubscription(const QString& title, QObject* parent = 0);
|
||||
explicit AdBlockSubscription(QString title, QObject* parent = 0);
|
||||
virtual ~AdBlockSubscription();
|
||||
|
||||
QString title() const;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include <QMenu>
|
||||
|
||||
AdBlockTreeWidget::AdBlockTreeWidget(AdBlockSubscription* subscription, QWidget* parent)
|
||||
: TreeWidget(parent), m_subscription(subscription), m_topItem(0), m_itemChangingBlock(false) {
|
||||
: TreeWidget(parent), m_subscription(subscription), m_topItem(nullptr), m_itemChangingBlock(false) {
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
setDefaultItemShowMode(TreeWidget::ItemsExpanded);
|
||||
setHeaderHidden(true);
|
||||
|
@ -46,7 +46,7 @@ AdBlockSubscription* AdBlockTreeWidget::subscription() const {
|
|||
}
|
||||
|
||||
void AdBlockTreeWidget::showRule(const AdBlockRule* rule) {
|
||||
if (!m_topItem && rule) {
|
||||
if ((m_topItem == nullptr) && (rule != nullptr)) {
|
||||
m_ruleToBeSelected = rule->filter();
|
||||
}
|
||||
else if (!m_ruleToBeSelected.isEmpty()) {
|
||||
|
@ -70,7 +70,7 @@ void AdBlockTreeWidget::contextMenuRequested(const QPoint& pos) {
|
|||
|
||||
QTreeWidgetItem* item = itemAt(pos);
|
||||
|
||||
if (!item) {
|
||||
if (item == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ void AdBlockTreeWidget::contextMenuRequested(const QPoint& pos) {
|
|||
menu.addSeparator();
|
||||
QAction* deleteAction = menu.addAction(tr("Remove rule"), this, SLOT(removeRule()));
|
||||
|
||||
if (!item->parent()) {
|
||||
if (item->parent() == nullptr) {
|
||||
deleteAction->setDisabled(true);
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ void AdBlockTreeWidget::contextMenuRequested(const QPoint& pos) {
|
|||
}
|
||||
|
||||
void AdBlockTreeWidget::itemChanged(QTreeWidgetItem* item) {
|
||||
if (!item || m_itemChangingBlock) {
|
||||
if ((item == nullptr) || m_itemChangingBlock) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ void AdBlockTreeWidget::itemChanged(QTreeWidgetItem* item) {
|
|||
void AdBlockTreeWidget::copyFilter() {
|
||||
QTreeWidgetItem* item = currentItem();
|
||||
|
||||
if (!item) {
|
||||
if (item == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -140,9 +140,9 @@ void AdBlockTreeWidget::addRule() {
|
|||
return;
|
||||
}
|
||||
|
||||
AdBlockRule* rule = new AdBlockRule(newRule, m_subscription);
|
||||
auto* rule = new AdBlockRule(newRule, m_subscription);
|
||||
int offset = m_subscription->addRule(rule);
|
||||
QTreeWidgetItem* item = new QTreeWidgetItem();
|
||||
auto* item = new QTreeWidgetItem();
|
||||
|
||||
item->setText(0, newRule);
|
||||
item->setData(0, Qt::UserRole + 10, offset);
|
||||
|
@ -156,7 +156,7 @@ void AdBlockTreeWidget::addRule() {
|
|||
void AdBlockTreeWidget::removeRule() {
|
||||
QTreeWidgetItem* item = currentItem();
|
||||
|
||||
if (!item || !m_subscription->canEditRules() || item == m_topItem) {
|
||||
if ((item == nullptr) || !m_subscription->canEditRules() || item == m_topItem) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -210,7 +210,7 @@ void AdBlockTreeWidget::adjustItemFeatures(QTreeWidgetItem* item, const AdBlockR
|
|||
}
|
||||
|
||||
void AdBlockTreeWidget::keyPressEvent(QKeyEvent* event) {
|
||||
if (event->key() == Qt::Key_C && event->modifiers() & Qt::ControlModifier) {
|
||||
if (event->key() == Qt::Key_C && (event->modifiers() & Qt::ControlModifier) != 0) {
|
||||
copyFilter();
|
||||
}
|
||||
|
||||
|
@ -236,7 +236,7 @@ void AdBlockTreeWidget::refresh() {
|
|||
int index = 0;
|
||||
|
||||
foreach (const AdBlockRule* rule, allRules) {
|
||||
QTreeWidgetItem* item = new QTreeWidgetItem(m_topItem);
|
||||
auto* item = new QTreeWidgetItem(m_topItem);
|
||||
|
||||
item->setText(0, rule->filter());
|
||||
item->setData(0, Qt::UserRole + 10, index);
|
||||
|
@ -249,6 +249,6 @@ void AdBlockTreeWidget::refresh() {
|
|||
++index;
|
||||
}
|
||||
|
||||
showRule(0);
|
||||
showRule(nullptr);
|
||||
m_itemChangingBlock = false;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ BaseNetworkAccessManager::BaseNetworkAccessManager(QObject* parent)
|
|||
loadSettings();
|
||||
}
|
||||
|
||||
BaseNetworkAccessManager::~BaseNetworkAccessManager() {}
|
||||
BaseNetworkAccessManager::~BaseNetworkAccessManager() = default;
|
||||
|
||||
void BaseNetworkAccessManager::loadSettings() {
|
||||
QNetworkProxy new_proxy;
|
||||
|
|
|
@ -11,16 +11,15 @@
|
|||
|
||||
Downloader::Downloader(QObject* parent)
|
||||
: QObject(parent), m_activeReply(nullptr), m_downloadManager(new SilentNetworkAccessManager(this)),
|
||||
m_timer(new QTimer(this)), m_customHeaders(QHash<QByteArray, QByteArray>()), m_inputData(QByteArray()),
|
||||
m_timer(new QTimer(this)), m_inputData(QByteArray()),
|
||||
m_inputMultipartData(nullptr), m_targetProtected(false), m_targetUsername(QString()), m_targetPassword(QString()),
|
||||
m_lastOutputData(QByteArray()), m_lastOutputMultipartData(QList<HttpResponse>()), m_lastOutputError(QNetworkReply::NoError),
|
||||
m_lastContentType(QVariant()) {
|
||||
m_lastOutputData(QByteArray()), m_lastOutputError(QNetworkReply::NoError) {
|
||||
m_timer->setInterval(DOWNLOAD_TIMEOUT);
|
||||
m_timer->setSingleShot(true);
|
||||
connect(m_timer, &QTimer::timeout, this, &Downloader::cancel);
|
||||
}
|
||||
|
||||
Downloader::~Downloader() {}
|
||||
Downloader::~Downloader() = default;
|
||||
|
||||
void Downloader::downloadFile(const QString& url, int timeout, bool protected_contents, const QString& username,
|
||||
const QString& password) {
|
||||
|
@ -100,7 +99,7 @@ void Downloader::manipulateData(const QString& url,
|
|||
}
|
||||
|
||||
void Downloader::finished() {
|
||||
QNetworkReply* reply = qobject_cast<QNetworkReply*>(sender());
|
||||
auto* reply = qobject_cast<QNetworkReply*>(sender());
|
||||
|
||||
QNetworkAccessManager::Operation reply_operation = reply->operation();
|
||||
m_timer->stop();
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "miscellaneous/settings.h"
|
||||
#include "network-web/silentnetworkaccessmanager.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <cmath>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QDesktopServices>
|
||||
|
@ -216,7 +216,7 @@ void DownloadItem::tryAgain() {
|
|||
m_ui->m_progressDownload->setVisible(true);
|
||||
QNetworkReply* new_download = qApp->downloadManager()->networkManager()->get(QNetworkRequest(m_url));
|
||||
|
||||
if (m_reply) {
|
||||
if (m_reply != nullptr) {
|
||||
m_reply->deleteLater();
|
||||
}
|
||||
|
||||
|
@ -406,7 +406,7 @@ void DownloadItem::finished() {
|
|||
tr("File '%1' is downloaded.\nClick here to open parent directory.").arg(QDir::toNativeSeparators(
|
||||
m_output.fileName())),
|
||||
QSystemTrayIcon::Information,
|
||||
0,
|
||||
nullptr,
|
||||
false,
|
||||
[this] {
|
||||
openFolder();
|
||||
|
@ -467,7 +467,7 @@ int DownloadManager::downloadProgress() const {
|
|||
return -1;
|
||||
}
|
||||
else {
|
||||
return (bytes_received * 100.0) / bytes_total;
|
||||
return int((bytes_received * 100.0) / bytes_total);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -494,7 +494,7 @@ void DownloadManager::handleUnsupportedContent(QNetworkReply* reply) {
|
|||
return;
|
||||
}
|
||||
|
||||
DownloadItem* item = new DownloadItem(reply, this);
|
||||
auto* item = new DownloadItem(reply, this);
|
||||
|
||||
addItem(item);
|
||||
|
||||
|
@ -537,7 +537,7 @@ void DownloadManager::itemFinished() {
|
|||
}
|
||||
|
||||
void DownloadManager::updateRow() {
|
||||
if (DownloadItem* item = qobject_cast<DownloadItem*>(sender())) {
|
||||
if (auto* item = qobject_cast<DownloadItem*>(sender())) {
|
||||
updateRow(item);
|
||||
}
|
||||
}
|
||||
|
@ -644,7 +644,7 @@ void DownloadManager::load() {
|
|||
bool done = settings->value(GROUP(Downloads), QString(Downloads::ItemDone).arg(i), true).toBool();
|
||||
|
||||
if (!url.isEmpty() && !file_name.isEmpty()) {
|
||||
DownloadItem* item = new DownloadItem(0, this);
|
||||
auto* item = new DownloadItem(nullptr, this);
|
||||
|
||||
item->m_output.setFileName(file_name);
|
||||
item->m_url = url;
|
||||
|
@ -773,7 +773,7 @@ Qt::ItemFlags DownloadModel::flags(const QModelIndex& index) const {
|
|||
return Qt::NoItemFlags;
|
||||
}
|
||||
|
||||
Qt::ItemFlags default_flags = QAbstractItemModel::flags(index);
|
||||
Qt::ItemFlags default_flags = QAbstractListModel::flags(index);
|
||||
DownloadItem* item = m_downloadManager->m_downloads.at(index.row());
|
||||
|
||||
if (item->downloadedSuccessfully()) {
|
||||
|
@ -784,7 +784,7 @@ Qt::ItemFlags DownloadModel::flags(const QModelIndex& index) const {
|
|||
}
|
||||
|
||||
QMimeData* DownloadModel::mimeData(const QModelIndexList& indexes) const {
|
||||
QMimeData* mimeData = new QMimeData();
|
||||
auto* mimeData = new QMimeData();
|
||||
|
||||
QList<QUrl> urls;
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ GoogleSuggest::GoogleSuggest(LocationLineEdit* editor, QObject* parent)
|
|||
connect(editor, &LocationLineEdit::textEdited, timer, static_cast<void (QTimer::*)()>(&QTimer::start));
|
||||
}
|
||||
|
||||
GoogleSuggest::~GoogleSuggest() {}
|
||||
GoogleSuggest::~GoogleSuggest() = default;
|
||||
|
||||
bool GoogleSuggest::eventFilter(QObject* object, QEvent* event) {
|
||||
if (object != popup.data()) {
|
||||
|
@ -83,11 +83,13 @@ bool GoogleSuggest::eventFilter(QObject* object, QEvent* event) {
|
|||
case Qt::Key_Return:
|
||||
doneCompletion();
|
||||
consumed = true;
|
||||
break;
|
||||
|
||||
case Qt::Key_Escape:
|
||||
editor->setFocus();
|
||||
popup->hide();
|
||||
consumed = true;
|
||||
break;
|
||||
|
||||
case Qt::Key_Up:
|
||||
case Qt::Key_Down:
|
||||
|
@ -157,7 +159,7 @@ void GoogleSuggest::autoSuggest() {
|
|||
void GoogleSuggest::handleNetworkData() {
|
||||
QScopedPointer<QNetworkReply> reply(static_cast<QNetworkReply*>(sender()));
|
||||
|
||||
if (!reply->error()) {
|
||||
if (reply->error() == 0) {
|
||||
QStringList choices;
|
||||
QDomDocument xml;
|
||||
QByteArray response = reply->readAll();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "network-web/httpresponse.h"
|
||||
|
||||
HttpResponse::HttpResponse() : m_headers(QList<HttpHeader>()), m_body(QString()) {}
|
||||
HttpResponse::HttpResponse() : m_body(QString()) {}
|
||||
|
||||
QString HttpResponse::body() const {
|
||||
return m_body;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#include <QTextDocument>
|
||||
#include <QTimer>
|
||||
|
||||
NetworkFactory::NetworkFactory() {}
|
||||
NetworkFactory::NetworkFactory() = default;
|
||||
|
||||
QStringList NetworkFactory::extractFeedLinksFromHtmlPage(const QUrl& url, const QString& html) {
|
||||
QStringList feeds;
|
||||
|
@ -166,7 +166,7 @@ Downloader* NetworkFactory::performAsyncNetworkOperation(const QString& url, int
|
|||
QList<QPair<QByteArray, QByteArray>> additional_headers,
|
||||
bool protected_contents, const QString& username,
|
||||
const QString& password) {
|
||||
Downloader* downloader = new Downloader();
|
||||
auto* downloader = new Downloader();
|
||||
|
||||
QObject::connect(downloader, &Downloader::completed, downloader, &Downloader::deleteLater);
|
||||
|
||||
|
|
|
@ -45,10 +45,11 @@ Q_GLOBAL_STATIC(OAuthHttpHandler, qz_silent_acmanager)
|
|||
#include <QJsonObject>
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkRequest>
|
||||
#include <utility>
|
||||
|
||||
OAuth2Service::OAuth2Service(const QString& auth_url, const QString& token_url, const QString& client_id,
|
||||
const QString& client_secret, const QString& scope, QObject* parent)
|
||||
: QObject(parent), m_id(QString::number(std::rand())), m_timerId(-1), m_tokensExpireIn(QDateTime()) {
|
||||
: QObject(parent), m_id(QString::number(std::rand())), m_timerId(-1) {
|
||||
m_redirectUrl = QSL(LOCALHOST_ADDRESS);
|
||||
m_tokenGrantType = QSL("authorization_code");
|
||||
m_tokenUrl = QUrl(token_url);
|
||||
|
@ -102,7 +103,7 @@ bool OAuth2Service::isFullyLoggedIn() const {
|
|||
}
|
||||
|
||||
void OAuth2Service::setOAuthTokenGrantType(QString grant_type) {
|
||||
m_tokenGrantType = grant_type;
|
||||
m_tokenGrantType = std::move(grant_type);
|
||||
}
|
||||
|
||||
QString OAuth2Service::oAuthTokenGrantType() {
|
||||
|
@ -143,7 +144,7 @@ OAuthHttpHandler* OAuth2Service::handler() {
|
|||
|
||||
#endif
|
||||
|
||||
void OAuth2Service::retrieveAccessToken(QString auth_code) {
|
||||
void OAuth2Service::retrieveAccessToken(const QString& auth_code) {
|
||||
QNetworkRequest networkRequest;
|
||||
|
||||
networkRequest.setUrl(m_tokenUrl);
|
||||
|
|
|
@ -83,7 +83,7 @@ class OAuth2Service : public QObject {
|
|||
|
||||
public slots:
|
||||
void retrieveAuthCode();
|
||||
void retrieveAccessToken(QString auth_code);
|
||||
void retrieveAccessToken(const QString& auth_code);
|
||||
void refreshAccessToken(QString refresh_token = QString());
|
||||
|
||||
// Performs login if needed. If some refresh token is set, then
|
||||
|
|
|
@ -44,7 +44,7 @@ void OAuthHttpHandler::handleRedirection(const QVariantMap& data) {
|
|||
const QString code = data.value(QSL("code")).toString();
|
||||
const QString received_state = data.value(QSL("state")).toString();
|
||||
|
||||
if (error.size()) {
|
||||
if (error.size() != 0) {
|
||||
const QString uri = data.value(QSL("error_uri")).toString();
|
||||
const QString description = data.value(QSL("error_description")).toString();
|
||||
|
||||
|
@ -73,8 +73,8 @@ void OAuthHttpHandler::answerClient(QTcpSocket* socket, const QUrl& url) {
|
|||
const QUrlQuery query(url.query());
|
||||
const auto items = query.queryItems();
|
||||
|
||||
for (auto it = items.begin(), end = items.end(); it != end; ++it) {
|
||||
received_data.insert(it->first, it->second);
|
||||
for (const auto & item : items) {
|
||||
received_data.insert(item.first, item.second);
|
||||
}
|
||||
|
||||
handleRedirection(received_data);
|
||||
|
@ -144,10 +144,10 @@ void OAuthHttpHandler::readReceivedData(QTcpSocket* socket) {
|
|||
bool OAuthHttpHandler::QHttpRequest::readMethod(QTcpSocket* socket) {
|
||||
bool finished = false;
|
||||
|
||||
while (socket->bytesAvailable() && !finished) {
|
||||
while ((socket->bytesAvailable() != 0) && !finished) {
|
||||
const auto c = socket->read(1).at(0);
|
||||
|
||||
if (std::isupper(c) && m_fragment.size() < 6) {
|
||||
if ((std::isupper(c) != 0) && m_fragment.size() < 6) {
|
||||
m_fragment += c;
|
||||
}
|
||||
else {
|
||||
|
@ -187,10 +187,10 @@ bool OAuthHttpHandler::QHttpRequest::readMethod(QTcpSocket* socket) {
|
|||
bool OAuthHttpHandler::QHttpRequest::readUrl(QTcpSocket* socket) {
|
||||
bool finished = false;
|
||||
|
||||
while (socket->bytesAvailable() && !finished) {
|
||||
while ((socket->bytesAvailable() != 0) && !finished) {
|
||||
const auto c = socket->read(1).at(0);
|
||||
|
||||
if (std::isspace(c)) {
|
||||
if (std::isspace(c) != 0) {
|
||||
finished = true;
|
||||
}
|
||||
else {
|
||||
|
@ -222,7 +222,7 @@ bool OAuthHttpHandler::QHttpRequest::readUrl(QTcpSocket* socket) {
|
|||
bool OAuthHttpHandler::QHttpRequest::readStatus(QTcpSocket* socket) {
|
||||
bool finished = false;
|
||||
|
||||
while (socket->bytesAvailable() && !finished) {
|
||||
while ((socket->bytesAvailable() != 0) && !finished) {
|
||||
m_fragment += socket->read(1);
|
||||
|
||||
if (m_fragment.endsWith("\r\n")) {
|
||||
|
@ -232,7 +232,7 @@ bool OAuthHttpHandler::QHttpRequest::readStatus(QTcpSocket* socket) {
|
|||
}
|
||||
|
||||
if (finished) {
|
||||
if (!std::isdigit(m_fragment.at(m_fragment.size() - 3)) || !std::isdigit(m_fragment.at(m_fragment.size() - 1))) {
|
||||
if ((std::isdigit(m_fragment.at(m_fragment.size() - 3)) == 0) || (std::isdigit(m_fragment.at(m_fragment.size() - 1)) == 0)) {
|
||||
qWarning("OAuth HTTP handler: Invalid version");
|
||||
return false;
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ bool OAuthHttpHandler::QHttpRequest::readStatus(QTcpSocket* socket) {
|
|||
}
|
||||
|
||||
bool OAuthHttpHandler::QHttpRequest::readHeader(QTcpSocket* socket) {
|
||||
while (socket->bytesAvailable()) {
|
||||
while (socket->bytesAvailable() != 0) {
|
||||
m_fragment += socket->read(1);
|
||||
|
||||
if (m_fragment.endsWith("\r\n")) {
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
RssGuardSchemeHandler::RssGuardSchemeHandler(QObject* parent) : QWebEngineUrlSchemeHandler(parent) {}
|
||||
|
||||
RssGuardSchemeHandler::~RssGuardSchemeHandler() {}
|
||||
RssGuardSchemeHandler::~RssGuardSchemeHandler() = default;
|
||||
|
||||
void RssGuardSchemeHandler::requestStarted(QWebEngineUrlRequestJob* job) {
|
||||
// Decide which data we want.
|
||||
|
@ -39,7 +39,7 @@ void RssGuardSchemeHandler::requestStarted(QWebEngineUrlRequestJob* job) {
|
|||
job->fail(QWebEngineUrlRequestJob::UrlNotFound);
|
||||
}
|
||||
else {
|
||||
QBuffer* buf = new QBuffer(job);
|
||||
auto* buf = new QBuffer(job);
|
||||
|
||||
buf->setData(data);
|
||||
job->reply(QByteArray("text/html"), buf);
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#endif
|
||||
|
||||
WebFactory::WebFactory(QObject* parent)
|
||||
: QObject(parent), m_escapes(QMap<QString, QString>()), m_deEscapes(QMap<QString, QString>()) {
|
||||
: QObject(parent) {
|
||||
#if defined (USE_WEBENGINE)
|
||||
m_engineSettings = nullptr;
|
||||
#endif
|
||||
|
@ -182,7 +182,7 @@ void WebFactory::webEngineSettingChanged(bool enabled) {
|
|||
}
|
||||
|
||||
QAction* WebFactory::createEngineSettingsAction(const QString& title, QWebEngineSettings::WebAttribute attribute) {
|
||||
QAction* act = new QAction(title, m_engineSettings->menu());
|
||||
auto* act = new QAction(title, m_engineSettings->menu());
|
||||
|
||||
act->setData(attribute);
|
||||
act->setCheckable(true);
|
||||
|
|
|
@ -24,7 +24,7 @@ void WebPage::javaScriptAlert(const QUrl& securityOrigin, const QString& msg) {
|
|||
|
||||
if (parts.size() == 2) {
|
||||
int message_id = parts.at(0).toInt();
|
||||
QString action = parts.at(1);
|
||||
const QString& action = parts.at(1);
|
||||
|
||||
if (action == QSL("read")) {
|
||||
emit messageStatusChangeRequested(message_id, MarkRead);
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
#include "miscellaneous/iconfactory.h"
|
||||
|
||||
AccountCheckModel::AccountCheckModel(QObject* parent)
|
||||
: QAbstractItemModel(parent), m_rootItem(nullptr), m_checkStates(QHash<RootItem*, Qt::CheckState>()), m_recursiveChange(false) {}
|
||||
: QAbstractItemModel(parent), m_rootItem(nullptr), m_recursiveChange(false) {}
|
||||
|
||||
AccountCheckModel::~AccountCheckModel() {}
|
||||
AccountCheckModel::~AccountCheckModel() = default;
|
||||
|
||||
RootItem* AccountCheckModel::itemForIndex(const QModelIndex& index) const {
|
||||
if (index.isValid() && index.model() == this) {
|
||||
|
@ -25,9 +25,8 @@ RootItem* AccountCheckModel::rootItem() const {
|
|||
}
|
||||
|
||||
void AccountCheckModel::setRootItem(RootItem* root_item) {
|
||||
if (m_rootItem != nullptr) {
|
||||
delete m_rootItem;
|
||||
}
|
||||
|
||||
delete m_rootItem;
|
||||
|
||||
m_rootItem = root_item;
|
||||
}
|
||||
|
@ -60,7 +59,7 @@ QModelIndex AccountCheckModel::index(int row, int column, const QModelIndex& par
|
|||
RootItem* parent_item = itemForIndex(parent);
|
||||
RootItem* child_item = parent_item->child(row);
|
||||
|
||||
if (child_item) {
|
||||
if (child_item != nullptr) {
|
||||
return createIndex(row, column, child_item);
|
||||
}
|
||||
else {
|
||||
|
@ -258,7 +257,7 @@ Qt::ItemFlags AccountCheckModel::flags(const QModelIndex& index) const {
|
|||
}
|
||||
|
||||
bool AccountCheckModel::isItemChecked(RootItem* item) {
|
||||
return m_checkStates.contains(item) && m_checkStates.value(item, Qt::Unchecked);
|
||||
return m_checkStates.value(item, Qt::CheckState::Unchecked) == Qt::CheckState::Checked;
|
||||
}
|
||||
|
||||
bool AccountCheckModel::setItemChecked(RootItem* item, Qt::CheckState check) {
|
||||
|
|
|
@ -8,9 +8,7 @@
|
|||
#include <QDir>
|
||||
#include <QSet>
|
||||
|
||||
CacheForServiceRoot::CacheForServiceRoot() : m_cacheSaveMutex(new Mutex(QMutex::NonRecursive, nullptr)),
|
||||
m_cachedStatesRead(QMap<RootItem::ReadStatus, QStringList>()),
|
||||
m_cachedStatesImportant(QMap<RootItem::Importance, QList<Message>>()) {}
|
||||
CacheForServiceRoot::CacheForServiceRoot() : m_cacheSaveMutex(new Mutex(QMutex::NonRecursive, nullptr)) {}
|
||||
|
||||
CacheForServiceRoot::~CacheForServiceRoot() {
|
||||
m_cacheSaveMutex->deleteLater();
|
||||
|
|
|
@ -32,7 +32,7 @@ Category::Category(const QSqlRecord& record) : Category(nullptr) {
|
|||
setIcon(qApp->icons()->fromByteArray(record.value(CAT_DB_ICON_INDEX).toByteArray()));
|
||||
}
|
||||
|
||||
Category::~Category() {}
|
||||
Category::~Category() = default;
|
||||
|
||||
void Category::updateCounts(bool including_total_count) {
|
||||
QList<Feed*> feeds;
|
||||
|
@ -78,7 +78,7 @@ bool Category::cleanMessages(bool clean_read_only) {
|
|||
|
||||
bool Category::markAsReadUnread(RootItem::ReadStatus status) {
|
||||
ServiceRoot* service = getParentServiceRoot();
|
||||
CacheForServiceRoot* cache = dynamic_cast<CacheForServiceRoot*>(service);
|
||||
auto* cache = dynamic_cast<CacheForServiceRoot*>(service);
|
||||
|
||||
if (cache != nullptr) {
|
||||
cache->addMessageStatesToCache(service->customIDSOfMessagesForItem(this), status);
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
|
||||
Feed::Feed(RootItem* parent)
|
||||
: RootItem(parent), m_url(QString()), m_status(Normal), m_autoUpdateType(DefaultAutoUpdate),
|
||||
m_autoUpdateInitialInterval(DEFAULT_AUTO_UPDATE_INTERVAL), m_autoUpdateRemainingInterval(DEFAULT_AUTO_UPDATE_INTERVAL),
|
||||
m_totalCount(0), m_unreadCount(0) {
|
||||
m_autoUpdateInitialInterval(DEFAULT_AUTO_UPDATE_INTERVAL), m_autoUpdateRemainingInterval(DEFAULT_AUTO_UPDATE_INTERVAL) {
|
||||
setKind(RootItemKind::Feed);
|
||||
setAutoDelete(false);
|
||||
}
|
||||
|
@ -55,7 +54,7 @@ Feed::Feed(const Feed& other) : RootItem(other) {
|
|||
setAutoUpdateRemainingInterval(other.autoUpdateRemainingInterval());
|
||||
}
|
||||
|
||||
Feed::~Feed() {}
|
||||
Feed::~Feed() = default;
|
||||
|
||||
QList<Message> Feed::undeletedMessages() const {
|
||||
QSqlDatabase database = qApp->database()->connection(metaObject()->className());
|
||||
|
@ -176,19 +175,19 @@ void Feed::run() {
|
|||
<< QThread::currentThreadId() << "\'.";
|
||||
|
||||
// Now, do some general operations on messages (tweak encoding etc.).
|
||||
for (int i = 0; i < msgs.size(); i++) {
|
||||
for (auto& msg : msgs) {
|
||||
// Also, make sure that HTML encoding, encoding of special characters, etc., is fixed.
|
||||
msgs[i].m_contents = QUrl::fromPercentEncoding(msgs[i].m_contents.toUtf8());
|
||||
msgs[i].m_author = msgs[i].m_author.toUtf8();
|
||||
msg.m_contents = QUrl::fromPercentEncoding(msg.m_contents.toUtf8());
|
||||
msg.m_author = msg.m_author.toUtf8();
|
||||
|
||||
// Sanitize title. Remove newlines etc.
|
||||
msgs[i].m_title = QUrl::fromPercentEncoding(msgs[i].m_title.toUtf8())
|
||||
msg.m_title = QUrl::fromPercentEncoding(msg.m_title.toUtf8())
|
||||
|
||||
// Replace all continuous white space.
|
||||
.replace(QRegularExpression(QSL("[\\s]{2,}")), QSL(" "))
|
||||
// Replace all continuous white space.
|
||||
.replace(QRegularExpression(QSL("[\\s]{2,}")), QSL(" "))
|
||||
|
||||
// Remove all newlines and leading white space.
|
||||
.remove(QRegularExpression(QSL("([\\n\\r])|(^\\s)")));
|
||||
// Remove all newlines and leading white space.
|
||||
.remove(QRegularExpression(QSL("([\\n\\r])|(^\\s)")));
|
||||
}
|
||||
|
||||
emit messagesObtained(msgs, error_during_obtaining);
|
||||
|
@ -200,7 +199,7 @@ bool Feed::cleanMessages(bool clean_read_only) {
|
|||
|
||||
bool Feed::markAsReadUnread(RootItem::ReadStatus status) {
|
||||
ServiceRoot* service = getParentServiceRoot();
|
||||
CacheForServiceRoot* cache = dynamic_cast<CacheForServiceRoot*>(service);
|
||||
auto* cache = dynamic_cast<CacheForServiceRoot*>(service);
|
||||
|
||||
if (cache != nullptr) {
|
||||
cache->addMessageStatesToCache(service->customIDSOfMessagesForItem(this), status);
|
||||
|
@ -271,7 +270,7 @@ QString Feed::getAutoUpdateStatusDescription() const {
|
|||
|
||||
//: Describes feed auto-update status.
|
||||
auto_update_string = tr("uses global settings (%n minute(s) to next auto-update)",
|
||||
0,
|
||||
nullptr,
|
||||
qApp->feedReader()->autoUpdateRemainingInterval());
|
||||
break;
|
||||
|
||||
|
@ -279,7 +278,7 @@ QString Feed::getAutoUpdateStatusDescription() const {
|
|||
default:
|
||||
|
||||
//: Describes feed auto-update status.
|
||||
auto_update_string = tr("uses specific settings (%n minute(s) to next auto-update)", 0, autoUpdateRemainingInterval());
|
||||
auto_update_string = tr("uses specific settings (%n minute(s) to next auto-update)", nullptr, autoUpdateRemainingInterval());
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -94,10 +94,10 @@ class Feed : public RootItem, public QRunnable {
|
|||
QString m_url;
|
||||
Status m_status;
|
||||
AutoUpdateType m_autoUpdateType;
|
||||
int m_autoUpdateInitialInterval;
|
||||
int m_autoUpdateRemainingInterval;
|
||||
int m_totalCount;
|
||||
int m_unreadCount;
|
||||
int m_autoUpdateInitialInterval{};
|
||||
int m_autoUpdateRemainingInterval{};
|
||||
int m_totalCount{};
|
||||
int m_unreadCount{};
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(Feed::AutoUpdateType)
|
||||
|
|
|
@ -39,7 +39,7 @@ FormFeedDetails::FormFeedDetails(ServiceRoot* service_root, QWidget* parent)
|
|||
onPasswordChanged(QString());
|
||||
}
|
||||
|
||||
FormFeedDetails::~FormFeedDetails() {}
|
||||
FormFeedDetails::~FormFeedDetails() = default;
|
||||
|
||||
int FormFeedDetails::addEditFeed(Feed* input_feed, RootItem* parent_to_select, const QString& url) {
|
||||
// Load categories.
|
||||
|
@ -114,7 +114,7 @@ void FormFeedDetails::onUrlChanged(const QString& new_url) {
|
|||
else if (!new_url.simplified().isEmpty()) {
|
||||
// New url is not well-formed but is not empty on the other hand.
|
||||
m_ui->m_txtUrl->setStatus(LineEditWithStatus::Warning,
|
||||
tr("The URL does not meet standard pattern. Does your URL start with \"http://\" or \"https://\" prefix."));
|
||||
tr(R"(The URL does not meet standard pattern. Does your URL start with "http://" or "https://" prefix.)"));
|
||||
}
|
||||
else {
|
||||
// New url is empty.
|
||||
|
@ -376,7 +376,7 @@ void FormFeedDetails::initialize() {
|
|||
m_ui->m_txtUrl->lineEdit()->setFocus(Qt::TabFocusReason);
|
||||
}
|
||||
|
||||
void FormFeedDetails::loadCategories(const QList<Category*> categories, RootItem* root_item) {
|
||||
void FormFeedDetails::loadCategories(const QList<Category*>& categories, RootItem* root_item) {
|
||||
m_ui->m_cmbParentCategory->addItem(root_item->icon(),
|
||||
root_item->title(),
|
||||
QVariant::fromValue((void*) root_item));
|
||||
|
|
|
@ -67,16 +67,16 @@ class FormFeedDetails : public QDialog {
|
|||
void initialize();
|
||||
|
||||
// Loads categories into the dialog from the model.
|
||||
void loadCategories(const QList<Category*> categories, RootItem* root_item);
|
||||
void loadCategories(const QList<Category*>& categories, RootItem* root_item);
|
||||
|
||||
protected:
|
||||
QScopedPointer<Ui::FormFeedDetails> m_ui;
|
||||
Feed* m_editableFeed;
|
||||
ServiceRoot* m_serviceRoot;
|
||||
QMenu* m_iconMenu;
|
||||
QAction* m_actionLoadIconFromFile;
|
||||
QAction* m_actionUseDefaultIcon;
|
||||
QAction* m_actionFetchIcon;
|
||||
QMenu* m_iconMenu{};
|
||||
QAction* m_actionLoadIconFromFile{};
|
||||
QAction* m_actionUseDefaultIcon{};
|
||||
QAction* m_actionFetchIcon{};
|
||||
};
|
||||
|
||||
#endif // FORMFEEDDETAILS_H
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <QThread>
|
||||
|
||||
RecycleBin::RecycleBin(RootItem* parent_item) : RootItem(parent_item), m_totalCount(0),
|
||||
m_unreadCount(0), m_contextMenu(QList<QAction*>()) {
|
||||
m_unreadCount(0) {
|
||||
setKind(RootItemKind::Bin);
|
||||
setId(ID_RECYCLE_BIN);
|
||||
setIcon(qApp->icons()->fromTheme(QSL("user-trash")));
|
||||
|
@ -21,10 +21,10 @@ RecycleBin::RecycleBin(RootItem* parent_item) : RootItem(parent_item), m_totalCo
|
|||
setCreationDate(QDateTime::currentDateTime());
|
||||
}
|
||||
|
||||
RecycleBin::~RecycleBin() {}
|
||||
RecycleBin::~RecycleBin() = default;
|
||||
|
||||
QString RecycleBin::additionalTooltip() const {
|
||||
return tr("%n deleted message(s).", 0, countOfAllMessages());
|
||||
return tr("%n deleted message(s).", nullptr, countOfAllMessages());
|
||||
}
|
||||
|
||||
int RecycleBin::countOfUnreadMessages() const {
|
||||
|
@ -77,7 +77,7 @@ QList<Message> RecycleBin::undeletedMessages() const {
|
|||
bool RecycleBin::markAsReadUnread(RootItem::ReadStatus status) {
|
||||
QSqlDatabase database = qApp->database()->connection(metaObject()->className());
|
||||
ServiceRoot* parent_root = getParentServiceRoot();
|
||||
CacheForServiceRoot* cache = dynamic_cast<CacheForServiceRoot*>(parent_root);
|
||||
auto* cache = dynamic_cast<CacheForServiceRoot*>(parent_root);
|
||||
|
||||
if (cache != nullptr) {
|
||||
cache->addMessageStatesToCache(parent_root->customIDSOfMessagesForItem(this), status);
|
||||
|
|
|
@ -13,8 +13,7 @@
|
|||
|
||||
RootItem::RootItem(RootItem* parent_item)
|
||||
: QObject(nullptr), m_kind(RootItemKind::Root), m_id(NO_PARENT_CATEGORY), m_customId(QSL("")),
|
||||
m_title(QString()), m_description(QString()), m_icon(QIcon()), m_creationDate(QDateTime()),
|
||||
m_keepOnTop(false), m_childItems(QList<RootItem*>()), m_parentItem(parent_item) {}
|
||||
m_title(QString()), m_description(QString()), m_keepOnTop(false), m_parentItem(parent_item) {}
|
||||
|
||||
RootItem::RootItem(const RootItem& other) : RootItem(nullptr) {
|
||||
setTitle(other.title());
|
||||
|
@ -104,7 +103,7 @@ void RootItem::updateCounts(bool including_total_count) {
|
|||
}
|
||||
|
||||
int RootItem::row() const {
|
||||
if (m_parentItem) {
|
||||
if (m_parentItem != nullptr) {
|
||||
return m_parentItem->m_childItems.indexOf(const_cast<RootItem*>(this));
|
||||
}
|
||||
else {
|
||||
|
@ -136,7 +135,7 @@ QVariant RootItem::data(int column, int role) const {
|
|||
}
|
||||
else if (column == FDS_MODEL_COUNTS_INDEX) {
|
||||
//: Tooltip for "unread" column of feed list.
|
||||
return tr("%n unread message(s).", 0, countOfUnreadMessages());
|
||||
return tr("%n unread message(s).", nullptr, countOfUnreadMessages());
|
||||
}
|
||||
else {
|
||||
return QVariant();
|
||||
|
@ -439,15 +438,15 @@ void RootItem::setCustomId(const QString& custom_id) {
|
|||
}
|
||||
|
||||
Category* RootItem::toCategory() const {
|
||||
return static_cast<Category*>(const_cast<RootItem*>(this));
|
||||
return dynamic_cast<Category*>(const_cast<RootItem*>(this));
|
||||
}
|
||||
|
||||
Feed* RootItem::toFeed() const {
|
||||
return static_cast<Feed*>(const_cast<RootItem*>(this));
|
||||
return dynamic_cast<Feed*>(const_cast<RootItem*>(this));
|
||||
}
|
||||
|
||||
ServiceRoot* RootItem::toServiceRoot() const {
|
||||
return static_cast<ServiceRoot*>(const_cast<RootItem*>(this));
|
||||
return dynamic_cast<ServiceRoot*>(const_cast<RootItem*>(this));
|
||||
}
|
||||
|
||||
bool RootItem::keepOnTop() const {
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
#include "services/abstract/serviceentrypoint.h"
|
||||
|
||||
ServiceEntryPoint::~ServiceEntryPoint() {}
|
||||
ServiceEntryPoint::~ServiceEntryPoint() = default;
|
||||
|
|
|
@ -18,7 +18,7 @@ ServiceRoot::ServiceRoot(RootItem* parent) : RootItem(parent), m_recycleBin(new
|
|||
setCreationDate(QDateTime::currentDateTime());
|
||||
}
|
||||
|
||||
ServiceRoot::~ServiceRoot() {}
|
||||
ServiceRoot::~ServiceRoot() = default;
|
||||
|
||||
bool ServiceRoot::deleteViaGui() {
|
||||
QSqlDatabase database = qApp->database()->connection(metaObject()->className());
|
||||
|
@ -34,7 +34,7 @@ bool ServiceRoot::deleteViaGui() {
|
|||
}
|
||||
|
||||
bool ServiceRoot::markAsReadUnread(RootItem::ReadStatus status) {
|
||||
CacheForServiceRoot* cache = dynamic_cast<CacheForServiceRoot*>(this);
|
||||
auto* cache = dynamic_cast<CacheForServiceRoot*>(this);
|
||||
|
||||
if (cache != nullptr) {
|
||||
cache->addMessageStatesToCache(customIDSOfMessagesForItem(this), status);
|
||||
|
@ -424,8 +424,8 @@ QStringList ServiceRoot::textualFeedIds(const QList<Feed*>& feeds) const {
|
|||
QStringList ServiceRoot::customIDsOfMessages(const QList<ImportanceChange>& changes) {
|
||||
QStringList list;
|
||||
|
||||
for (int i = 0; i < changes.size(); i++) {
|
||||
list.append(changes.at(i).first.m_customId);
|
||||
for (const auto & change : changes) {
|
||||
list.append(change.first.m_customId);
|
||||
}
|
||||
|
||||
return list;
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
|
||||
#include <QFileDialog>
|
||||
|
||||
GmailServiceRoot::GmailServiceRoot(GmailNetworkFactory* network, RootItem* parent) : ServiceRoot(parent),
|
||||
CacheForServiceRoot(), m_serviceMenu(QList<QAction*>()), m_network(network) {
|
||||
GmailServiceRoot::GmailServiceRoot(GmailNetworkFactory* network, RootItem* parent) : ServiceRoot(parent), m_network(network) {
|
||||
if (network == nullptr) {
|
||||
m_network = new GmailNetworkFactory(this);
|
||||
}
|
||||
|
@ -33,14 +32,14 @@ GmailServiceRoot::GmailServiceRoot(GmailNetworkFactory* network, RootItem* paren
|
|||
setRecycleBin(nullptr);
|
||||
}
|
||||
|
||||
GmailServiceRoot::~GmailServiceRoot() {}
|
||||
GmailServiceRoot::~GmailServiceRoot() = default;
|
||||
|
||||
void GmailServiceRoot::updateTitle() {
|
||||
setTitle(m_network->userName() + QSL(" (Gmail)"));
|
||||
}
|
||||
|
||||
RootItem* GmailServiceRoot::obtainNewTreeForSyncIn() const {
|
||||
RootItem* root = new RootItem();
|
||||
auto* root = new RootItem();
|
||||
GmailFeed* inbox = new GmailFeed(tr("Inbox"), QSL(GMAIL_SYSTEM_LABEL_INBOX), qApp->icons()->fromTheme(QSL("mail-inbox")), root);
|
||||
|
||||
inbox->setKeepOnTop(true);
|
||||
|
|
|
@ -53,7 +53,7 @@ FormEditGmailAccount::FormEditGmailAccount(QWidget* parent) : QDialog(parent),
|
|||
hookNetwork();
|
||||
}
|
||||
|
||||
FormEditGmailAccount::~FormEditGmailAccount() {}
|
||||
FormEditGmailAccount::~FormEditGmailAccount() = default;
|
||||
|
||||
void FormEditGmailAccount::testSetup() {
|
||||
if (m_oauth->clientId() != m_ui.m_txtAppId->lineEdit()->text() ||
|
||||
|
@ -181,7 +181,7 @@ void FormEditGmailAccount::execForEdit(GmailServiceRoot* existing_root) {
|
|||
}
|
||||
|
||||
void FormEditGmailAccount::checkOAuthValue(const QString& value) {
|
||||
LineEditWithStatus* line_edit = qobject_cast<LineEditWithStatus*>(sender()->parent());
|
||||
auto* line_edit = qobject_cast<LineEditWithStatus*>(sender()->parent());
|
||||
|
||||
if (line_edit != nullptr) {
|
||||
if (value.isEmpty()) {
|
||||
|
|
|
@ -73,13 +73,13 @@ void GmailNetworkFactory::setUsername(const QString& username) {
|
|||
}
|
||||
|
||||
Downloader* GmailNetworkFactory::downloadAttachment(const QString& msg_id, const QString& attachment_id) {
|
||||
Downloader* downloader = new Downloader();
|
||||
QString bearer = m_oauth2->bearer().toLocal8Bit();
|
||||
|
||||
if (bearer.isEmpty()) {
|
||||
return nullptr;
|
||||
}
|
||||
else {
|
||||
auto* downloader = new Downloader();
|
||||
QString target_url = QString(GMAIL_API_GET_ATTACHMENT).arg(msg_id, attachment_id);
|
||||
|
||||
downloader->appendRawHeader(QString(HTTP_HEADERS_AUTHORIZATION).toLocal8Bit(), bearer.toLocal8Bit());
|
||||
|
@ -374,7 +374,7 @@ bool GmailNetworkFactory::fillFullMessage(Message& msg, const QJsonObject& json,
|
|||
bool GmailNetworkFactory::obtainAndDecodeFullMessages(const QList<Message>& lite_messages,
|
||||
const QString& feed_id,
|
||||
QList<Message>& full_messages) {
|
||||
QHttpMultiPart* multi = new QHttpMultiPart();
|
||||
auto* multi = new QHttpMultiPart();
|
||||
|
||||
multi->setContentType(QHttpMultiPart::ContentType::MixedType);
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ FormEditInoreaderAccount::FormEditInoreaderAccount(QWidget* parent) : QDialog(pa
|
|||
hookNetwork();
|
||||
}
|
||||
|
||||
FormEditInoreaderAccount::~FormEditInoreaderAccount() {}
|
||||
FormEditInoreaderAccount::~FormEditInoreaderAccount() = default;
|
||||
|
||||
void FormEditInoreaderAccount::testSetup() {
|
||||
if (m_oauth->clientId() != m_ui.m_txtAppId->lineEdit()->text() ||
|
||||
|
@ -178,7 +178,7 @@ void FormEditInoreaderAccount::execForEdit(InoreaderServiceRoot* existing_root)
|
|||
}
|
||||
|
||||
void FormEditInoreaderAccount::checkOAuthValue(const QString& value) {
|
||||
LineEditWithStatus* line_edit = qobject_cast<LineEditWithStatus*>(sender()->parent());
|
||||
auto* line_edit = qobject_cast<LineEditWithStatus*>(sender()->parent());
|
||||
|
||||
if (line_edit != nullptr) {
|
||||
if (value.isEmpty()) {
|
||||
|
|
|
@ -29,8 +29,7 @@
|
|||
#include "services/inoreader/network/inoreadernetworkfactory.h"
|
||||
#include "services/inoreader/network/inoreadernetworkfactory.h"
|
||||
|
||||
InoreaderServiceRoot::InoreaderServiceRoot(InoreaderNetworkFactory* network, RootItem* parent) : ServiceRoot(parent),
|
||||
CacheForServiceRoot(), m_serviceMenu(QList<QAction*>()), m_network(network) {
|
||||
InoreaderServiceRoot::InoreaderServiceRoot(InoreaderNetworkFactory* network, RootItem* parent) : ServiceRoot(parent), m_network(network) {
|
||||
if (network == nullptr) {
|
||||
m_network = new InoreaderNetworkFactory(this);
|
||||
}
|
||||
|
@ -42,7 +41,7 @@ InoreaderServiceRoot::InoreaderServiceRoot(InoreaderNetworkFactory* network, Roo
|
|||
setIcon(InoreaderEntryPoint().icon());
|
||||
}
|
||||
|
||||
InoreaderServiceRoot::~InoreaderServiceRoot() {}
|
||||
InoreaderServiceRoot::~InoreaderServiceRoot() = default;
|
||||
|
||||
void InoreaderServiceRoot::updateTitle() {
|
||||
setTitle(m_network->userName() + QSL(" (Inoreader)"));
|
||||
|
|
|
@ -361,7 +361,7 @@ QList<Message> InoreaderNetworkFactory::decodeMessages(const QString& messages_j
|
|||
}
|
||||
|
||||
RootItem* InoreaderNetworkFactory::decodeFeedCategoriesData(const QString& categories, const QString& feeds, bool obtain_icons) {
|
||||
RootItem* parent = new RootItem();
|
||||
auto* parent = new RootItem();
|
||||
QJsonArray json = QJsonDocument::fromJson(categories.toUtf8()).object()["tags"].toArray();
|
||||
|
||||
QMap<QString, RootItem*> cats;
|
||||
|
@ -373,7 +373,7 @@ RootItem* InoreaderNetworkFactory::decodeFeedCategoriesData(const QString& categ
|
|||
|
||||
if (label_id.contains(QSL("/label/"))) {
|
||||
// We have label (not "state").
|
||||
Category* category = new Category();
|
||||
auto* category = new Category();
|
||||
|
||||
category->setDescription(label["htmlUrl"].toString());
|
||||
category->setTitle(label_id.mid(label_id.lastIndexOf(QL1C('/')) + 1));
|
||||
|
@ -406,7 +406,7 @@ RootItem* InoreaderNetworkFactory::decodeFeedCategoriesData(const QString& categ
|
|||
}
|
||||
|
||||
// We have label (not "state").
|
||||
InoreaderFeed* feed = new InoreaderFeed();
|
||||
auto* feed = new InoreaderFeed();
|
||||
|
||||
feed->setDescription(url);
|
||||
feed->setUrl(url);
|
||||
|
|
|
@ -69,7 +69,7 @@ FormEditOwnCloudAccount::FormEditOwnCloudAccount(QWidget* parent)
|
|||
displayPassword(false);
|
||||
}
|
||||
|
||||
FormEditOwnCloudAccount::~FormEditOwnCloudAccount() {}
|
||||
FormEditOwnCloudAccount::~FormEditOwnCloudAccount() = default;
|
||||
|
||||
OwnCloudServiceRoot* FormEditOwnCloudAccount::execForCreate() {
|
||||
setWindowTitle(tr("Add new ownCloud News account"));
|
||||
|
|
|
@ -37,11 +37,11 @@ void FormOwnCloudFeedDetails::apply() {
|
|||
}
|
||||
|
||||
// User edited auto-update status. Save it.
|
||||
OwnCloudFeed* new_feed_data = new OwnCloudFeed();
|
||||
auto* new_feed_data = new OwnCloudFeed();
|
||||
|
||||
new_feed_data->setAutoUpdateType(static_cast<Feed::AutoUpdateType>(m_ui->m_cmbAutoUpdateType->itemData(
|
||||
m_ui->m_cmbAutoUpdateType->currentIndex()).toInt()));
|
||||
new_feed_data->setAutoUpdateInitialInterval(m_ui->m_spinAutoUpdateInterval->value());
|
||||
new_feed_data->setAutoUpdateInitialInterval(int(m_ui->m_spinAutoUpdateInterval->value()));
|
||||
qobject_cast<OwnCloudFeed*>(m_editableFeed)->editItself(new_feed_data);
|
||||
delete new_feed_data;
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QPixmap>
|
||||
#include <utility>
|
||||
|
||||
OwnCloudNetworkFactory::OwnCloudNetworkFactory()
|
||||
: m_url(QString()), m_fixedUrl(QString()), m_forceServerSideUpdate(false),
|
||||
|
@ -23,7 +24,7 @@ OwnCloudNetworkFactory::OwnCloudNetworkFactory()
|
|||
m_urlFolders(QString()), m_urlFeeds(QString()), m_urlMessages(QString()), m_urlFeedsUpdate(QString()),
|
||||
m_urlDeleteFeed(QString()), m_urlRenameFeed(QString()), m_userId(QString()) {}
|
||||
|
||||
OwnCloudNetworkFactory::~OwnCloudNetworkFactory() {}
|
||||
OwnCloudNetworkFactory::~OwnCloudNetworkFactory() = default;
|
||||
|
||||
QString OwnCloudNetworkFactory::url() const {
|
||||
return m_url;
|
||||
|
@ -434,7 +435,7 @@ OwnCloudResponse::OwnCloudResponse(const QString& raw_content) {
|
|||
m_emptyString = raw_content.isEmpty();
|
||||
}
|
||||
|
||||
OwnCloudResponse::~OwnCloudResponse() {}
|
||||
OwnCloudResponse::~OwnCloudResponse() = default;
|
||||
|
||||
bool OwnCloudResponse::isLoaded() const {
|
||||
return !m_emptyString && !m_rawContent.isEmpty();
|
||||
|
@ -446,7 +447,7 @@ QString OwnCloudResponse::toString() const {
|
|||
|
||||
OwnCloudUserResponse::OwnCloudUserResponse(const QString& raw_content) : OwnCloudResponse(raw_content) {}
|
||||
|
||||
OwnCloudUserResponse::~OwnCloudUserResponse() {}
|
||||
OwnCloudUserResponse::~OwnCloudUserResponse() = default;
|
||||
|
||||
QString OwnCloudUserResponse::displayName() const {
|
||||
if (isLoaded()) {
|
||||
|
@ -491,7 +492,7 @@ QIcon OwnCloudUserResponse::avatar() const {
|
|||
|
||||
OwnCloudStatusResponse::OwnCloudStatusResponse(const QString& raw_content) : OwnCloudResponse(raw_content) {}
|
||||
|
||||
OwnCloudStatusResponse::~OwnCloudStatusResponse() {}
|
||||
OwnCloudStatusResponse::~OwnCloudStatusResponse() = default;
|
||||
|
||||
QString OwnCloudStatusResponse::version() const {
|
||||
if (isLoaded()) {
|
||||
|
@ -511,14 +512,14 @@ bool OwnCloudStatusResponse::misconfiguredCron() const {
|
|||
}
|
||||
}
|
||||
|
||||
OwnCloudGetFeedsCategoriesResponse::OwnCloudGetFeedsCategoriesResponse(const QString& raw_categories,
|
||||
const QString& raw_feeds)
|
||||
: m_contentCategories(raw_categories), m_contentFeeds(raw_feeds) {}
|
||||
OwnCloudGetFeedsCategoriesResponse::OwnCloudGetFeedsCategoriesResponse(QString raw_categories,
|
||||
QString raw_feeds)
|
||||
: m_contentCategories(std::move(raw_categories)), m_contentFeeds(std::move(raw_feeds)) {}
|
||||
|
||||
OwnCloudGetFeedsCategoriesResponse::~OwnCloudGetFeedsCategoriesResponse() {}
|
||||
OwnCloudGetFeedsCategoriesResponse::~OwnCloudGetFeedsCategoriesResponse() = default;
|
||||
|
||||
RootItem* OwnCloudGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons) const {
|
||||
RootItem* parent = new RootItem();
|
||||
auto* parent = new RootItem();
|
||||
|
||||
QMap<QString, RootItem*> cats;
|
||||
|
||||
|
@ -528,7 +529,7 @@ RootItem* OwnCloudGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons)
|
|||
// Process categories first, then process feeds.
|
||||
foreach (const QJsonValue& cat, QJsonDocument::fromJson(m_contentCategories.toUtf8()).object()["folders"].toArray()) {
|
||||
QJsonObject item = cat.toObject();
|
||||
Category* category = new Category();
|
||||
auto* category = new Category();
|
||||
|
||||
category->setTitle(item["name"].toString());
|
||||
category->setCustomId(QString::number(item["id"].toInt()));
|
||||
|
@ -541,7 +542,7 @@ RootItem* OwnCloudGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons)
|
|||
// We have categories added, now add all feeds.
|
||||
foreach (const QJsonValue& fed, QJsonDocument::fromJson(m_contentFeeds.toUtf8()).object()["feeds"].toArray()) {
|
||||
QJsonObject item = fed.toObject();
|
||||
OwnCloudFeed* feed = new OwnCloudFeed();
|
||||
auto* feed = new OwnCloudFeed();
|
||||
|
||||
if (obtain_icons) {
|
||||
QString icon_path = item["faviconLink"].toString();
|
||||
|
@ -574,7 +575,7 @@ RootItem* OwnCloudGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons)
|
|||
|
||||
OwnCloudGetMessagesResponse::OwnCloudGetMessagesResponse(const QString& raw_content) : OwnCloudResponse(raw_content) {}
|
||||
|
||||
OwnCloudGetMessagesResponse::~OwnCloudGetMessagesResponse() {}
|
||||
OwnCloudGetMessagesResponse::~OwnCloudGetMessagesResponse() = default;
|
||||
|
||||
QList<Message>OwnCloudGetMessagesResponse::messages() const {
|
||||
QList<Message>msgs;
|
||||
|
|
|
@ -57,7 +57,7 @@ class RootItem;
|
|||
|
||||
class OwnCloudGetFeedsCategoriesResponse {
|
||||
public:
|
||||
explicit OwnCloudGetFeedsCategoriesResponse(const QString& raw_categories = QString(), const QString& raw_feeds = QString());
|
||||
explicit OwnCloudGetFeedsCategoriesResponse(QString raw_categories = QString(), QString raw_feeds = QString());
|
||||
virtual ~OwnCloudGetFeedsCategoriesResponse();
|
||||
|
||||
// Returns tree of feeds/categories.
|
||||
|
|
|
@ -14,7 +14,7 @@ OwnCloudFeed::OwnCloudFeed(RootItem* parent) : Feed(parent) {}
|
|||
|
||||
OwnCloudFeed::OwnCloudFeed(const QSqlRecord& record) : Feed(record) {}
|
||||
|
||||
OwnCloudFeed::~OwnCloudFeed() {}
|
||||
OwnCloudFeed::~OwnCloudFeed() = default;
|
||||
|
||||
bool OwnCloudFeed::canBeEdited() const {
|
||||
return true;
|
||||
|
|
|
@ -16,8 +16,7 @@
|
|||
#include "services/owncloud/owncloudserviceentrypoint.h"
|
||||
|
||||
OwnCloudServiceRoot::OwnCloudServiceRoot(RootItem* parent)
|
||||
: ServiceRoot(parent), CacheForServiceRoot(),
|
||||
m_actionSyncIn(nullptr), m_serviceMenu(QList<QAction*>()), m_network(new OwnCloudNetworkFactory()) {
|
||||
: ServiceRoot(parent), m_actionSyncIn(nullptr), m_network(new OwnCloudNetworkFactory()) {
|
||||
setIcon(OwnCloudServiceEntryPoint().icon());
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ AtomParser::AtomParser(const QString& data) : FeedParser(data) {
|
|||
}
|
||||
}
|
||||
|
||||
AtomParser::~AtomParser() {}
|
||||
AtomParser::~AtomParser() = default;
|
||||
|
||||
QString AtomParser::feedAuthor() const {
|
||||
QDomNodeList authors = m_xml.documentElement().elementsByTagNameNS(m_atomNamespace, QSL("author"));
|
||||
|
|
|
@ -6,12 +6,13 @@
|
|||
|
||||
#include <QDebug>
|
||||
#include <QRegularExpression>
|
||||
#include <utility>
|
||||
|
||||
FeedParser::FeedParser(const QString& data) : m_xmlData(data) {
|
||||
FeedParser::FeedParser(QString data) : m_xmlData(std::move(data)) {
|
||||
m_xml.setContent(m_xmlData, true);
|
||||
}
|
||||
|
||||
FeedParser::~FeedParser() {}
|
||||
FeedParser::~FeedParser() = default;
|
||||
|
||||
QList<Message> FeedParser::messages() {
|
||||
QString feed_author = feedAuthor();
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
class FeedParser {
|
||||
public:
|
||||
explicit FeedParser(const QString& data);
|
||||
explicit FeedParser(QString data);
|
||||
virtual ~FeedParser();
|
||||
|
||||
virtual QList<Message> messages();
|
||||
|
|
|
@ -94,7 +94,7 @@ int FormStandardCategoryDetails::addEditCategory(StandardCategory* input_categor
|
|||
|
||||
void FormStandardCategoryDetails::apply() {
|
||||
RootItem* parent = static_cast<RootItem*>(m_ui->m_cmbParentCategory->itemData(m_ui->m_cmbParentCategory->currentIndex()).value<void*>());
|
||||
StandardCategory* new_category = new StandardCategory();
|
||||
auto* new_category = new StandardCategory();
|
||||
|
||||
new_category->setTitle(m_ui->m_txtTitle->lineEdit()->text());
|
||||
new_category->setCreationDate(QDateTime::currentDateTime());
|
||||
|
@ -215,7 +215,7 @@ void FormStandardCategoryDetails::initialize() {
|
|||
m_ui->m_txtTitle->lineEdit()->setFocus(Qt::TabFocusReason);
|
||||
}
|
||||
|
||||
void FormStandardCategoryDetails::loadCategories(const QList<Category*> categories,
|
||||
void FormStandardCategoryDetails::loadCategories(const QList<Category*>& categories,
|
||||
RootItem* root_item,
|
||||
StandardCategory* input_category) {
|
||||
m_ui->m_cmbParentCategory->addItem(root_item->icon(),
|
||||
|
|
|
@ -60,15 +60,15 @@ class FormStandardCategoryDetails : public QDialog {
|
|||
// Loads categories into the dialog + give root "category"
|
||||
// and make sure that no childs of input category (including)
|
||||
// input category are loaded.
|
||||
void loadCategories(const QList<Category*> categories, RootItem* root_item, StandardCategory* input_category);
|
||||
void loadCategories(const QList<Category*>& categories, RootItem* root_item, StandardCategory* input_category);
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::FormStandardCategoryDetails> m_ui;
|
||||
StandardCategory* m_editableCategory;
|
||||
StandardServiceRoot* m_serviceRoot;
|
||||
QMenu* m_iconMenu;
|
||||
QAction* m_actionLoadIconFromFile;
|
||||
QAction* m_actionUseDefaultIcon;
|
||||
QMenu* m_iconMenu{};
|
||||
QAction* m_actionLoadIconFromFile{};
|
||||
QAction* m_actionUseDefaultIcon{};
|
||||
};
|
||||
|
||||
#endif // FORMCATEGORYDETAILS_H
|
||||
|
|
|
@ -13,7 +13,7 @@ void FormStandardFeedDetails::apply() {
|
|||
RootItem* parent = static_cast<RootItem*>(m_ui->m_cmbParentCategory->itemData(m_ui->m_cmbParentCategory->currentIndex()).value<void*>());
|
||||
|
||||
StandardFeed::Type type = static_cast<StandardFeed::Type>(m_ui->m_cmbType->itemData(m_ui->m_cmbType->currentIndex()).value<int>());
|
||||
StandardFeed* new_feed = new StandardFeed();
|
||||
auto* new_feed = new StandardFeed();
|
||||
|
||||
// Setup data for new_feed.
|
||||
new_feed->setTitle(m_ui->m_txtTitle->lineEdit()->text());
|
||||
|
@ -65,7 +65,7 @@ void FormStandardFeedDetails::apply() {
|
|||
|
||||
void FormStandardFeedDetails::setEditableFeed(Feed* editable_feed) {
|
||||
FormFeedDetails::setEditableFeed(editable_feed);
|
||||
StandardFeed* feed = qobject_cast<StandardFeed*>(editable_feed);
|
||||
auto* feed = qobject_cast<StandardFeed*>(editable_feed);
|
||||
|
||||
m_ui->m_cmbType->setCurrentIndex(m_ui->m_cmbType->findData(QVariant::fromValue(int(feed->type()))));
|
||||
m_ui->m_cmbEncoding->setCurrentIndex(m_ui->m_cmbEncoding->findData(feed->encoding(), Qt::DisplayRole, Qt::MatchFixedString));
|
||||
|
|
|
@ -33,7 +33,7 @@ FormStandardImportExport::FormStandardImportExport(StandardServiceRoot* service_
|
|||
connect(m_ui->m_btnUncheckAllItems, &QPushButton::clicked, m_model, &FeedsImportExportModel::uncheckAllItems);
|
||||
}
|
||||
|
||||
FormStandardImportExport::~FormStandardImportExport() {}
|
||||
FormStandardImportExport::~FormStandardImportExport() = default;
|
||||
|
||||
void FormStandardImportExport::setMode(const FeedsImportExportModel::Mode& mode) {
|
||||
m_model->setMode(mode);
|
||||
|
@ -284,7 +284,7 @@ void FormStandardImportExport::importFeeds() {
|
|||
}
|
||||
}
|
||||
|
||||
void FormStandardImportExport::loadCategories(const QList<Category*> categories, RootItem* root_item) {
|
||||
void FormStandardImportExport::loadCategories(const QList<Category*>& categories, RootItem* root_item) {
|
||||
m_ui->m_cmbRootNode->addItem(root_item->icon(), root_item->title(), QVariant::fromValue((void*) root_item));
|
||||
|
||||
foreach (Category* category, categories) {
|
||||
|
|
|
@ -46,7 +46,7 @@ class FormStandardImportExport : public QDialog {
|
|||
void exportFeeds();
|
||||
void importFeeds();
|
||||
|
||||
void loadCategories(const QList<Category*> categories, RootItem* root_item);
|
||||
void loadCategories(const QList<Category*>& categories, RootItem* root_item);
|
||||
|
||||
QScopedPointer<Ui::FormStandardImportExport> m_ui;
|
||||
ConversionType m_conversionType;
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
|
||||
#include <QDomDocument>
|
||||
|
||||
RdfParser::RdfParser() {}
|
||||
RdfParser::RdfParser() = default;
|
||||
|
||||
RdfParser::~RdfParser() {}
|
||||
RdfParser::~RdfParser() = default;
|
||||
|
||||
QList<Message> RdfParser::parseXmlData(const QString& data) {
|
||||
QList<Message> messages;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
RssParser::RssParser(const QString& data) : FeedParser(data) {}
|
||||
|
||||
RssParser::~RssParser() {}
|
||||
RssParser::~RssParser() = default;
|
||||
|
||||
QDomNodeList RssParser::messageElements() {
|
||||
QDomNode channel_elem = m_xml.namedItem(QSL("rss")).namedItem(QSL("channel"));
|
||||
|
|
|
@ -18,10 +18,6 @@
|
|||
|
||||
StandardCategory::StandardCategory(RootItem* parent_item) : Category(parent_item) {}
|
||||
|
||||
StandardCategory::StandardCategory(const StandardCategory& other) : Category(other) {}
|
||||
|
||||
StandardCategory::~StandardCategory() {}
|
||||
|
||||
StandardServiceRoot* StandardCategory::serviceRoot() const {
|
||||
return qobject_cast<StandardServiceRoot*>(getParentServiceRoot());
|
||||
}
|
||||
|
@ -31,7 +27,7 @@ Qt::ItemFlags StandardCategory::additionalFlags() const {
|
|||
}
|
||||
|
||||
bool StandardCategory::performDragDropChange(RootItem* target_item) {
|
||||
StandardCategory* category_new = new StandardCategory(*this);
|
||||
auto* category_new = new StandardCategory(*this);
|
||||
|
||||
category_new->clearChildren();
|
||||
category_new->setParent(target_item);
|
||||
|
@ -78,10 +74,10 @@ bool StandardCategory::removeItself() {
|
|||
// from the database.
|
||||
foreach (RootItem* child, childItems()) {
|
||||
if (child->kind() == RootItemKind::Category) {
|
||||
children_removed &= static_cast<StandardCategory*>(child)->removeItself();
|
||||
children_removed &= dynamic_cast<StandardCategory*>(child)->removeItself();
|
||||
}
|
||||
else if (child->kind() == RootItemKind::Feed) {
|
||||
children_removed &= static_cast<StandardFeed*>(child)->removeItself();
|
||||
children_removed &= dynamic_cast<StandardFeed*>(child)->removeItself();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,9 +19,9 @@ class StandardCategory : public Category {
|
|||
|
||||
public:
|
||||
explicit StandardCategory(RootItem* parent_item = nullptr);
|
||||
explicit StandardCategory(const StandardCategory& other);
|
||||
explicit StandardCategory(const StandardCategory& other) = default;
|
||||
explicit StandardCategory(const QSqlRecord& record);
|
||||
virtual ~StandardCategory();
|
||||
virtual ~StandardCategory() = default;
|
||||
|
||||
StandardServiceRoot* serviceRoot() const;
|
||||
|
||||
|
|
|
@ -282,7 +282,7 @@ Qt::ItemFlags StandardFeed::additionalFlags() const {
|
|||
}
|
||||
|
||||
bool StandardFeed::performDragDropChange(RootItem* target_item) {
|
||||
StandardFeed* feed_new = new StandardFeed(*this);
|
||||
auto* feed_new = new StandardFeed(*this);
|
||||
|
||||
feed_new->setParent(target_item);
|
||||
|
||||
|
|
|
@ -86,7 +86,7 @@ class StandardFeed : public Feed {
|
|||
QList<Message> obtainNewMessages(bool* error_during_obtaining);
|
||||
|
||||
private:
|
||||
bool m_passwordProtected;
|
||||
bool m_passwordProtected{};
|
||||
QString m_username;
|
||||
QString m_password;
|
||||
Type m_type;
|
||||
|
|
|
@ -82,7 +82,7 @@ bool FeedsImportExportModel::exportToOMPL20(QByteArray& result) {
|
|||
}
|
||||
|
||||
case RootItemKind::Feed: {
|
||||
StandardFeed* child_feed = static_cast<StandardFeed*>(child_item);
|
||||
auto* child_feed = dynamic_cast<StandardFeed*>(child_item);
|
||||
QDomElement outline_feed = opml_document.createElement("outline");
|
||||
|
||||
outline_feed.setAttribute(QSL("type"), QSL("rss"));
|
||||
|
@ -145,7 +145,7 @@ void FeedsImportExportModel::importAsOPML20(const QByteArray& data, bool fetch_m
|
|||
}
|
||||
|
||||
int completed = 0, total = 0, succeded = 0, failed = 0;
|
||||
StandardServiceRoot* root_item = new StandardServiceRoot();
|
||||
auto* root_item = new StandardServiceRoot();
|
||||
|
||||
QStack<RootItem*> model_items;
|
||||
model_items.push(root_item);
|
||||
|
@ -188,7 +188,7 @@ void FeedsImportExportModel::importAsOPML20(const QByteArray& data, bool fetch_m
|
|||
QString feed_type = child_element.attribute(QSL("version"), DEFAULT_FEED_TYPE).toUpper();
|
||||
QString feed_description = child_element.attribute(QSL("description"));
|
||||
QIcon feed_icon = qApp->icons()->fromByteArray(child_element.attribute(QSL("rssguard:icon")).toLocal8Bit());
|
||||
StandardFeed* new_feed = new StandardFeed(active_model_item);
|
||||
auto* new_feed = new StandardFeed(active_model_item);
|
||||
|
||||
new_feed->setTitle(feed_title);
|
||||
new_feed->setDescription(feed_description);
|
||||
|
@ -234,7 +234,7 @@ void FeedsImportExportModel::importAsOPML20(const QByteArray& data, bool fetch_m
|
|||
}
|
||||
}
|
||||
|
||||
StandardCategory* new_category = new StandardCategory(active_model_item);
|
||||
auto* new_category = new StandardCategory(active_model_item);
|
||||
|
||||
new_category->setTitle(category_title);
|
||||
new_category->setIcon(category_icon);
|
||||
|
@ -275,7 +275,7 @@ void FeedsImportExportModel::importAsTxtURLPerLine(const QByteArray& data, bool
|
|||
setRootItem(nullptr);
|
||||
emit layoutChanged();
|
||||
int completed = 0, succeded = 0, failed = 0;
|
||||
StandardServiceRoot* root_item = new StandardServiceRoot();
|
||||
auto* root_item = new StandardServiceRoot();
|
||||
|
||||
QList<QByteArray> urls = data.split('\n');
|
||||
|
||||
|
@ -290,7 +290,7 @@ void FeedsImportExportModel::importAsTxtURLPerLine(const QByteArray& data, bool
|
|||
succeded++;
|
||||
}
|
||||
else {
|
||||
StandardFeed* feed = new StandardFeed();
|
||||
auto* feed = new StandardFeed();
|
||||
|
||||
feed->setUrl(url);
|
||||
feed->setTitle(url);
|
||||
|
|
|
@ -38,7 +38,7 @@ ServiceRoot* StandardServiceEntryPoint::createNewRoot() const {
|
|||
int new_id = DatabaseQueries::createAccount(database, code(), &ok);
|
||||
|
||||
if (ok) {
|
||||
StandardServiceRoot* root = new StandardServiceRoot();
|
||||
auto* root = new StandardServiceRoot();
|
||||
|
||||
root->setAccountId(new_id);
|
||||
return root;
|
||||
|
|
|
@ -27,8 +27,7 @@
|
|||
|
||||
StandardServiceRoot::StandardServiceRoot(RootItem* parent)
|
||||
: ServiceRoot(parent),
|
||||
m_actionExportFeeds(nullptr), m_actionImportFeeds(nullptr), m_serviceMenu(QList<QAction*>()),
|
||||
m_feedContextMenu(QList<QAction*>()), m_actionFeedFetchMetadata(nullptr) {
|
||||
m_actionExportFeeds(nullptr), m_actionImportFeeds(nullptr), m_actionFeedFetchMetadata(nullptr) {
|
||||
setTitle(qApp->system()->loggedInUser() + QSL(" (RSS/RDF/ATOM)"));
|
||||
setIcon(StandardServiceEntryPoint().icon());
|
||||
setDescription(tr("This is obligatory service account for standard RSS/RDF/ATOM feeds."));
|
||||
|
@ -204,8 +203,8 @@ bool StandardServiceRoot::mergeImportExportModel(FeedsImportExportModel* model,
|
|||
}
|
||||
|
||||
if (source_item->kind() == RootItemKind::Category) {
|
||||
StandardCategory* source_category = static_cast<StandardCategory*>(source_item);
|
||||
StandardCategory* new_category = new StandardCategory(*source_category);
|
||||
auto* source_category = dynamic_cast<StandardCategory*>(source_item);
|
||||
auto* new_category = new StandardCategory(*source_category);
|
||||
QString new_category_title = new_category->title();
|
||||
|
||||
// Add category to model.
|
||||
|
@ -242,8 +241,8 @@ bool StandardServiceRoot::mergeImportExportModel(FeedsImportExportModel* model,
|
|||
}
|
||||
}
|
||||
else if (source_item->kind() == RootItemKind::Feed) {
|
||||
StandardFeed* source_feed = static_cast<StandardFeed*>(source_item);
|
||||
StandardFeed* new_feed = new StandardFeed(*source_feed);
|
||||
auto* source_feed = dynamic_cast<StandardFeed*>(source_item);
|
||||
auto* new_feed = new StandardFeed(*source_feed);
|
||||
|
||||
// Append this feed and end this iteration.
|
||||
if (new_feed->addItself(target_parent)) {
|
||||
|
|
|
@ -69,7 +69,7 @@ FormEditTtRssAccount::FormEditTtRssAccount(QWidget* parent)
|
|||
displayHttpPassword(false);
|
||||
}
|
||||
|
||||
FormEditTtRssAccount::~FormEditTtRssAccount() {}
|
||||
FormEditTtRssAccount::~FormEditTtRssAccount() = default;
|
||||
|
||||
TtRssServiceRoot* FormEditTtRssAccount::execForCreate() {
|
||||
setWindowTitle(tr("Add new Tiny Tiny RSS account"));
|
||||
|
|
|
@ -25,7 +25,7 @@ FormTtRssFeedDetails::FormTtRssFeedDetails(ServiceRoot* service_root, QWidget* p
|
|||
void FormTtRssFeedDetails::apply() {
|
||||
if (m_editableFeed != nullptr) {
|
||||
// User edited auto-update status. Save it.
|
||||
TtRssFeed* new_feed_data = new TtRssFeed();
|
||||
auto* new_feed_data = new TtRssFeed();
|
||||
|
||||
new_feed_data->setAutoUpdateType(static_cast<Feed::AutoUpdateType>(m_ui->m_cmbAutoUpdateType->itemData(
|
||||
m_ui->m_cmbAutoUpdateType->currentIndex()).toInt()));
|
||||
|
@ -36,7 +36,7 @@ void FormTtRssFeedDetails::apply() {
|
|||
else {
|
||||
RootItem* parent = static_cast<RootItem*>(m_ui->m_cmbParentCategory->itemData(
|
||||
m_ui->m_cmbParentCategory->currentIndex()).value<void*>());
|
||||
TtRssServiceRoot* root = qobject_cast<TtRssServiceRoot*>(parent->getParentServiceRoot());
|
||||
auto* root = qobject_cast<TtRssServiceRoot*>(parent->getParentServiceRoot());
|
||||
const int category_id = parent->kind() == RootItemKind::ServiceRoot ?
|
||||
0 :
|
||||
parent->customId().toInt();
|
||||
|
|
|
@ -19,11 +19,8 @@
|
|||
|
||||
TtRssNetworkFactory::TtRssNetworkFactory()
|
||||
: m_bareUrl(QString()), m_fullUrl(QString()), m_username(QString()), m_password(QString()), m_forceServerSideUpdate(false),
|
||||
m_authIsUsed(false),
|
||||
m_authUsername(QString()), m_authPassword(QString()), m_sessionId(QString()),
|
||||
m_lastLoginTime(QDateTime()), m_lastError(QNetworkReply::NoError) {}
|
||||
|
||||
TtRssNetworkFactory::~TtRssNetworkFactory() {}
|
||||
m_authIsUsed(false), m_authUsername(QString()), m_authPassword(QString()), m_sessionId(QString()),
|
||||
m_lastError(QNetworkReply::NoError) {}
|
||||
|
||||
QString TtRssNetworkFactory::url() const {
|
||||
return m_bareUrl;
|
||||
|
@ -404,8 +401,7 @@ TtRssResponse::TtRssResponse(const QString& raw_content) {
|
|||
m_rawContent = QJsonDocument::fromJson(raw_content.toUtf8()).object();
|
||||
}
|
||||
|
||||
TtRssResponse::~TtRssResponse() {}
|
||||
|
||||
TtRssResponse::~TtRssResponse() = default;
|
||||
bool TtRssResponse::isLoaded() const {
|
||||
return !m_rawContent.isEmpty();
|
||||
}
|
||||
|
@ -438,8 +434,7 @@ QString TtRssResponse::toString() const {
|
|||
|
||||
TtRssLoginResponse::TtRssLoginResponse(const QString& raw_content) : TtRssResponse(raw_content) {}
|
||||
|
||||
TtRssLoginResponse::~TtRssLoginResponse() {}
|
||||
|
||||
TtRssLoginResponse::~TtRssLoginResponse() = default;
|
||||
int TtRssLoginResponse::apiLevel() const {
|
||||
if (!isLoaded()) {
|
||||
return TTRSS_CONTENT_NOT_LOADED;
|
||||
|
@ -478,10 +473,9 @@ bool TtRssResponse::hasError() const {
|
|||
|
||||
TtRssGetFeedsCategoriesResponse::TtRssGetFeedsCategoriesResponse(const QString& raw_content) : TtRssResponse(raw_content) {}
|
||||
|
||||
TtRssGetFeedsCategoriesResponse::~TtRssGetFeedsCategoriesResponse() {}
|
||||
|
||||
TtRssGetFeedsCategoriesResponse::~TtRssGetFeedsCategoriesResponse() = default;
|
||||
RootItem* TtRssGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons, QString base_address) const {
|
||||
RootItem* parent = new RootItem();
|
||||
auto* parent = new RootItem();
|
||||
|
||||
// Chop the "api/" from the end of the address.
|
||||
base_address.chop(4);
|
||||
|
@ -515,7 +509,7 @@ RootItem* TtRssGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons, QS
|
|||
}
|
||||
}
|
||||
else {
|
||||
Category* category = new Category();
|
||||
auto* category = new Category();
|
||||
|
||||
category->setTitle(item["name"].toString());
|
||||
category->setCustomId(QString::number(item_id));
|
||||
|
@ -530,7 +524,7 @@ RootItem* TtRssGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons, QS
|
|||
}
|
||||
else {
|
||||
// We have feed.
|
||||
TtRssFeed* feed = new TtRssFeed();
|
||||
auto* feed = new TtRssFeed();
|
||||
|
||||
if (obtain_icons) {
|
||||
QString icon_path = item["icon"].type() == QJsonValue::String ? item["icon"].toString() : QString();
|
||||
|
@ -565,7 +559,7 @@ RootItem* TtRssGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons, QS
|
|||
|
||||
TtRssGetHeadlinesResponse::TtRssGetHeadlinesResponse(const QString& raw_content) : TtRssResponse(raw_content) {}
|
||||
|
||||
TtRssGetHeadlinesResponse::~TtRssGetHeadlinesResponse() {}
|
||||
TtRssGetHeadlinesResponse::~TtRssGetHeadlinesResponse() = default;
|
||||
|
||||
QList<Message> TtRssGetHeadlinesResponse::messages() const {
|
||||
QList<Message> messages;
|
||||
|
@ -580,8 +574,9 @@ QList<Message> TtRssGetHeadlinesResponse::messages() const {
|
|||
message.m_contents = mapped["content"].toString();
|
||||
|
||||
// Multiply by 1000 because Tiny Tiny RSS API does not include miliseconds in Unix
|
||||
// date/time number.
|
||||
// date/time number.
|
||||
const qint64 t = static_cast<qint64>(mapped["updated"].toDouble()) * 1000;
|
||||
|
||||
message.m_created = TextFactory::parseDateTime(t);
|
||||
message.m_createdFromFeed = true;
|
||||
message.m_customId = QString::number(mapped["id"].toInt());
|
||||
|
@ -609,7 +604,7 @@ QList<Message> TtRssGetHeadlinesResponse::messages() const {
|
|||
|
||||
TtRssUpdateArticleResponse::TtRssUpdateArticleResponse(const QString& raw_content) : TtRssResponse(raw_content) {}
|
||||
|
||||
TtRssUpdateArticleResponse::~TtRssUpdateArticleResponse() {}
|
||||
TtRssUpdateArticleResponse::~TtRssUpdateArticleResponse() = default;
|
||||
|
||||
QString TtRssUpdateArticleResponse::updateStatus() const {
|
||||
if (m_rawContent.contains(QSL("content"))) {
|
||||
|
@ -631,8 +626,7 @@ int TtRssUpdateArticleResponse::articlesUpdated() const {
|
|||
|
||||
TtRssSubscribeToFeedResponse::TtRssSubscribeToFeedResponse(const QString& raw_content) : TtRssResponse(raw_content) {}
|
||||
|
||||
TtRssSubscribeToFeedResponse::~TtRssSubscribeToFeedResponse() {}
|
||||
|
||||
TtRssSubscribeToFeedResponse::~TtRssSubscribeToFeedResponse() = default;
|
||||
int TtRssSubscribeToFeedResponse::code() const {
|
||||
if (m_rawContent.contains(QSL("content"))) {
|
||||
return m_rawContent["content"].toObject()["status"].toObject()["code"].toInt();
|
||||
|
@ -644,8 +638,7 @@ int TtRssSubscribeToFeedResponse::code() const {
|
|||
|
||||
TtRssUnsubscribeFeedResponse::TtRssUnsubscribeFeedResponse(const QString& raw_content) : TtRssResponse(raw_content) {}
|
||||
|
||||
TtRssUnsubscribeFeedResponse::~TtRssUnsubscribeFeedResponse() {}
|
||||
|
||||
TtRssUnsubscribeFeedResponse::~TtRssUnsubscribeFeedResponse() = default;
|
||||
QString TtRssUnsubscribeFeedResponse::code() const {
|
||||
if (m_rawContent.contains(QSL("content"))) {
|
||||
QJsonObject map = m_rawContent["content"].toObject();
|
||||
|
|
|
@ -100,7 +100,7 @@ namespace UpdateArticle {
|
|||
class TtRssNetworkFactory {
|
||||
public:
|
||||
explicit TtRssNetworkFactory();
|
||||
virtual ~TtRssNetworkFactory();
|
||||
virtual ~TtRssNetworkFactory() = default;
|
||||
|
||||
QString url() const;
|
||||
void setUrl(const QString& url);
|
||||
|
|
|
@ -19,7 +19,7 @@ TtRssFeed::TtRssFeed(RootItem* parent)
|
|||
|
||||
TtRssFeed::TtRssFeed(const QSqlRecord& record) : Feed(record) {}
|
||||
|
||||
TtRssFeed::~TtRssFeed() {}
|
||||
TtRssFeed::~TtRssFeed() = default;
|
||||
|
||||
TtRssServiceRoot* TtRssFeed::serviceRoot() const {
|
||||
return qobject_cast<TtRssServiceRoot*>(getParentServiceRoot());
|
||||
|
|
|
@ -22,8 +22,7 @@
|
|||
#include <QSqlTableModel>
|
||||
|
||||
TtRssServiceRoot::TtRssServiceRoot(RootItem* parent)
|
||||
: ServiceRoot(parent), CacheForServiceRoot(),
|
||||
m_actionSyncIn(nullptr), m_serviceMenu(QList<QAction*>()), m_network(new TtRssNetworkFactory()) {
|
||||
: ServiceRoot(parent), m_actionSyncIn(nullptr), m_network(new TtRssNetworkFactory()) {
|
||||
setIcon(TtRssServiceEntryPoint().icon());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue