refactoring with clazy

This commit is contained in:
Martin Rotter 2021-03-19 14:02:42 +01:00
parent aa18d074a3
commit 1538c1261f
26 changed files with 129 additions and 85 deletions

View File

@ -30,7 +30,7 @@
<url type="donation">https://martinrotter.github.io/donate/</url>
<content_rating type="oars-1.1" />
<releases>
<release version="3.9.0" date="2021-03-17"/>
<release version="3.9.0" date="2021-03-19"/>
</releases>
<content_rating type="oars-1.0">
<content_attribute id="violence-cartoon">none</content_attribute>

View File

@ -99,8 +99,9 @@ void SettingsGui::loadSettings() {
// Load settings of icon theme.
const QString current_theme = qApp->icons()->currentIconTheme();
auto icons = qApp->icons()->installedIconThemes();
for (const QString& icon_theme_name : qApp->icons()->installedIconThemes()) {
for (const QString& icon_theme_name : qAsConst(icons)) {
if (icon_theme_name == APP_NO_THEME) {
// Add just "no theme" on other systems.
//: Label for disabling icon theme.
@ -129,8 +130,9 @@ void SettingsGui::loadSettings() {
// Load skin.
const QString selected_skin = qApp->skins()->selectedSkinName();
auto skins = qApp->skins()->installedSkins();
for (const Skin& skin : qApp->skins()->installedSkins()) {
for (const Skin& skin : qAsConst(skins)) {
QTreeWidgetItem* new_item = new QTreeWidgetItem(QStringList() <<
skin.m_visibleName <<
skin.m_version <<
@ -155,7 +157,9 @@ void SettingsGui::loadSettings() {
}
// Load styles.
for (const QString& style_name : QStyleFactory::keys()) {
auto styles = QStyleFactory::keys();
for (const QString& style_name : qAsConst(styles)) {
m_ui->m_cmbStyles->addItem(style_name);
}

View File

@ -32,7 +32,9 @@ SettingsLocalization::~SettingsLocalization() {
void SettingsLocalization::loadSettings() {
onBeginLoadSettings();
for (const Language& language : qApp->localization()->installedLanguages()) {
auto langs = qApp->localization()->installedLanguages();
for (const Language& language : qAsConst(langs)) {
auto* item = new QTreeWidgetItem(m_ui->m_treeLanguages);
item->setText(0, language.m_name);

View File

@ -178,10 +178,11 @@ void WebViewer::contextMenuEvent(QContextMenuEvent* event) {
if (menu_data.mediaUrl().isValid() || menu_data.linkUrl().isValid()) {
QFileIconProvider icon_provider;
QMenu* menu_ext_tools = new QMenu(tr("Open with external tool"), menu);
auto tools = ExternalTool::toolsFromSettings();
menu_ext_tools->setIcon(qApp->icons()->fromTheme(QSL("document-open")));
for (const ExternalTool& tool : ExternalTool::toolsFromSettings()) {
for (const ExternalTool& tool : qAsConst(tools)) {
QAction* act_tool = new QAction(QFileInfo(tool.executable()).fileName(), menu_ext_tools);
act_tool->setIcon(icon_provider.icon(tool.executable()));

View File

@ -8,9 +8,9 @@
#include "core/feedsproxymodel.h"
#include "core/messagesmodel.h"
#include "core/messagesproxymodel.h"
#include "database/databasequeries.h"
#include "gui/dialogs/formmessagefiltersmanager.h"
#include "miscellaneous/application.h"
#include "database/databasequeries.h"
#include "miscellaneous/mutex.h"
#include "services/abstract/cacheforserviceroot.h"
#include "services/abstract/serviceroot.h"
@ -164,7 +164,7 @@ void FeedReader::loadSavedMessageFilters() {
// all feeds.
m_messageFilters = DatabaseQueries::getMessageFilters(qApp->database()->driver()->connection(metaObject()->className()));
for (auto* filter : m_messageFilters) {
for (auto* filter : qAsConst(m_messageFilters)) {
filter->setParent(this);
}
}

View File

@ -57,14 +57,15 @@ QIcon IconFactory::miscIcon(const QString& name) {
}
void IconFactory::setupSearchPaths() {
QIcon::setThemeSearchPaths(QIcon::themeSearchPaths()
<< APP_THEME_PATH
<< qApp->applicationDirPath() + QDir::separator() + APP_LOCAL_THEME_FOLDER);
auto paths = QIcon::themeSearchPaths();
paths << APP_THEME_PATH
<< qApp->applicationDirPath() + QDir::separator() + APP_LOCAL_THEME_FOLDER;
QIcon::setThemeSearchPaths(paths);
qDebugNN << LOGSEC_GUI
<< "Available icon theme paths: "
<< QIcon::themeSearchPaths()
.replaceInStrings(QRegularExpression(QSL("^|$")), QSL("\'"))
.replaceInStrings(QRegularExpression(QSL("/")), QDir::separator()).join(QSL(", "));
<< paths;
}
void IconFactory::setCurrentIconTheme(const QString& theme_name) {
@ -129,12 +130,13 @@ QStringList IconFactory::installedIconThemes() const {
for (const QString& icon_path : icon_themes_paths) {
const QDir icon_dir(icon_path);
auto icon_paths = icon_dir.entryInfoList(QDir::Filter::Dirs | QDir::Filter::NoDotAndDotDot |
QDir::Filter::Readable | QDir::Filter::CaseSensitive |
QDir::Filter::NoSymLinks,
QDir::SortFlag::Time);
// Iterate all icon themes in this directory.
for (const QFileInfo& icon_theme_path : icon_dir.entryInfoList(QDir::Filter::Dirs | QDir::Filter::NoDotAndDotDot |
QDir::Filter::Readable | QDir::Filter::CaseSensitive |
QDir::Filter::NoSymLinks,
QDir::SortFlag::Time)) {
for (const QFileInfo& icon_theme_path : qAsConst(icon_paths)) {
QDir icon_theme_dir = QDir(icon_theme_path.absoluteFilePath());
if (icon_theme_dir.exists(filters_index.at(0))) {

View File

@ -72,9 +72,10 @@ QList<Language> Localization::installedLanguages() const {
QList<Language> languages;
const QDir file_dir(APP_LANG_PATH);
QTranslator translator;
auto lang_files = file_dir.entryInfoList(QStringList() << QSL("rssguard_*.qm"), QDir::Files, QDir::Name);
// Iterate all found language files.
for (const QFileInfo& file : file_dir.entryInfoList(QStringList() << "rssguard_*.qm", QDir::Files, QDir::Name)) {
for (const QFileInfo& file : qAsConst(lang_files)) {
if (translator.load(file.absoluteFilePath())) {
Language new_language;

View File

@ -86,7 +86,7 @@ QDateTime TextFactory::parseDateTime(const QString& date_time) {
<< QSL("-hhmm") << QSL("+hh") << QSL("-hh");
// Iterate over patterns and check if input date/time matches the pattern.
for (const QString& pattern : date_patterns) {
for (const QString& pattern : qAsConst(date_patterns)) {
dt = locale.toDateTime(input_date.left(pattern.size()), pattern);
if (dt.isValid()) {
@ -97,7 +97,7 @@ QDateTime TextFactory::parseDateTime(const QString& date_time) {
if (input_date.size() >= TIMEZONE_OFFSET_LIMIT) {
QString offset_sanitized = input_date.mid(pattern.size()).replace(QL1S(" "), QString());
for (const QString& pattern_t : timezone_offset_patterns) {
for (const QString& pattern_t : qAsConst(timezone_offset_patterns)) {
time_zone_offset = QTime::fromString(offset_sanitized.left(pattern_t.size()), pattern_t);
if (time_zone_offset.isValid()) {

View File

@ -22,7 +22,7 @@ class TextFactory {
// Tries to parse input textual date/time representation.
// Returns invalid date/time if processing fails.
// NOTE: This method tries to always return time in UTC+00:00.
// NOTE: This method tries to always return time in UTC.
static QDateTime parseDateTime(const QString& date_time);
// Converts 1970-epoch miliseconds to date/time.

View File

@ -28,16 +28,12 @@ AdBlockAddSubscriptionDialog::AdBlockAddSubscriptionDialog(QWidget* parent)
: QDialog(parent), m_ui(new Ui::AdBlockAddSubscriptionDialog) {
m_ui->setupUi(this);
m_knownSubscriptions
<< Subscription(QSL("EasyList"),
QSL(ADBLOCK_EASYLIST_URL))
<< Subscription(QSL("EasyPrivacy"),
QSL("https://easylist.to/easylist/easyprivacy.txt"))
<< Subscription(QSL("EasyPrivacy Tracking Protection List"),
QSL("https://easylist-downloads.adblockplus.org/easyprivacy.tpl"))
<< Subscription(QSL("Adblock Warning Removal List"),
QSL("https://easylist-downloads.adblockplus.org/antiadblockfilters.txt"));
<< Subscription(QSL("EasyList"), QSL(ADBLOCK_EASYLIST_URL))
<< Subscription(QSL("EasyPrivacy"), QSL("https://easylist.to/easylist/easyprivacy.txt"))
<< Subscription(QSL("EasyPrivacy Tracking Protection List"), QSL("https://easylist-downloads.adblockplus.org/easyprivacy.tpl"))
<< Subscription(QSL("Adblock Warning Removal List"), QSL("https://easylist-downloads.adblockplus.org/antiadblockfilters.txt"));
for (const Subscription& subscription : m_knownSubscriptions) {
for (const Subscription& subscription : qAsConst(m_knownSubscriptions)) {
m_ui->m_cmbPresets->addItem(subscription.m_title);
}

View File

@ -159,7 +159,9 @@ void AdBlockDialog::load() {
return;
}
for (AdBlockSubscription* subscription : m_manager->subscriptions()) {
auto subs = m_manager->subscriptions();
for (AdBlockSubscription* subscription : qAsConst(subs)) {
auto* tree = new AdBlockTreeWidget(subscription, m_ui->m_tabSubscriptions);
m_ui->m_tabSubscriptions->addTab(tree, subscription->title());

View File

@ -178,7 +178,9 @@ void AdBlockManager::load(bool initial_load) {
QDir().mkpath(storedListsPath());
}
for (const QString& subscription_file_name : adblock_dir.entryList(QStringList("*.txt"), QDir::Files)) {
auto subs_files = adblock_dir.entryList({ QSL("*.txt") }, QDir::Filter::Files);
for (const QString& subscription_file_name : qAsConst(subs_files)) {
if (subscription_file_name == ADBLOCK_CUSTOMLIST_NAME) {
continue;
}
@ -216,7 +218,7 @@ void AdBlockManager::load(bool initial_load) {
m_subscriptions.append(custom_list);
// Load all subscriptions.
for (AdBlockSubscription* subscription : m_subscriptions) {
for (AdBlockSubscription* subscription : qAsConst(m_subscriptions)) {
subscription->loadSubscription(m_disabledRules);
connect(subscription, &AdBlockSubscription::subscriptionChanged, this, &AdBlockManager::updateMatcher);
}
@ -244,7 +246,7 @@ void AdBlockManager::updateMatcher() {
}
void AdBlockManager::updateAllSubscriptions() {
for (AdBlockSubscription* subscription : m_subscriptions) {
for (AdBlockSubscription* subscription : qAsConst(m_subscriptions)) {
subscription->updateSubscription();
}
@ -256,7 +258,7 @@ void AdBlockManager::save() {
return;
}
for (AdBlockSubscription* subscription : m_subscriptions) {
for (AdBlockSubscription* subscription : qAsConst(m_subscriptions)) {
subscription->saveSubscription();
}

View File

@ -133,9 +133,12 @@ void AdBlockMatcher::update() {
clear();
QHash<QString, const AdBlockRule*> cssRulesHash;
QVector<const AdBlockRule*> exceptionCssRules;
auto subs = m_manager->subscriptions();
for (AdBlockSubscription* subscription : m_manager->subscriptions()) {
for (const AdBlockRule* rule : subscription->allRules()) {
for (AdBlockSubscription* subscription : qAsConst(subs)) {
auto rls = subscription->allRules();
for (const AdBlockRule* rule : qAsConst(rls)) {
// Don't add internally disabled rules to cache.
if (rule->isInternalDisabled()) {
continue;

View File

@ -329,7 +329,7 @@ void AdBlockCustomList::saveSubscription() {
textStream << "Url: " << url().toString() << QL1C('\n');
textStream << "[Adblock Plus 1.1.1]" << QL1C('\n');
for (const AdBlockRule* rule : m_rules) {
for (const AdBlockRule* rule : qAsConst(m_rules)) {
textStream << rule->filter() << QL1C('\n');
}

View File

@ -171,17 +171,18 @@ QList<HttpResponse> Downloader::decodeMultipartAnswer(QNetworkReply* reply) {
start_of_body - start_of_headers).replace(QRegularExpression(QSL("[\\n\\r]+")),
QSL("\n"));
for (const QString& header_line : headers.split(QL1C('\n'),
auto header_lines = headers.split(QL1C('\n'),
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
Qt::SplitBehaviorFlags::SkipEmptyParts)) {
Qt::SplitBehaviorFlags::SkipEmptyParts);
#else
QString::SplitBehavior::SkipEmptyParts)) {
QString::SplitBehavior::SkipEmptyParts);
#endif
for (const QString& header_line : qAsConst(header_lines)) {
int index_colon = header_line.indexOf(QL1C(':'));
if (index_colon > 0) {
new_part.appendHeader(header_line.mid(0, index_colon),
header_line.mid(index_colon + 2));
new_part.appendHeader(header_line.mid(0, index_colon), header_line.mid(index_colon + 2));
}
}

View File

@ -33,7 +33,7 @@ void NetworkUrlInterceptor::interceptRequest(QWebEngineUrlRequestInfo& info) {
// NOTE: Here we can add custom headers for each webengine request, for example "User-Agent".
for (UrlInterceptor* interceptor : m_interceptors) {
for (UrlInterceptor* interceptor : qAsConst(m_interceptors)) {
interceptor->interceptRequest(info);
}
}

View File

@ -156,7 +156,7 @@ QString WebFactory::unescapeHtml(const QString& html) {
}
else {
// Failed to convert to number, leave intact.
output.append(html.mid(pos, pos_end - pos + 1));
output.append(html.midRef(pos, pos_end - pos + 1));
}
pos = pos_end + 1;

View File

@ -41,7 +41,6 @@ class WebFactory : public QObject {
NetworkUrlInterceptor* urlIinterceptor();
#endif
public slots:
void updateProxy();
bool openUrlInExternalBrowser(const QString& url) const;
bool sendMessageViaEmail(const Message& message);

View File

@ -42,7 +42,9 @@ void AccountCheckModel::setRootItem(RootItem* root_item, bool delete_previous_ro
void AccountCheckModel::checkAllItems() {
if (m_rootItem != nullptr) {
for (RootItem* root_child : m_rootItem->childItems()) {
auto chi = m_rootItem->childItems();
for (RootItem* root_child : qAsConst(chi)) {
if (root_child->kind() == RootItem::Kind::Feed || root_child->kind() == RootItem::Kind::Category) {
setItemChecked(root_child, Qt::Checked);
}
@ -52,7 +54,9 @@ void AccountCheckModel::checkAllItems() {
void AccountCheckModel::uncheckAllItems() {
if (m_rootItem != nullptr) {
for (RootItem* root_child : m_rootItem->childItems()) {
auto chi = m_rootItem->childItems();
for (RootItem* root_child : qAsConst(chi)) {
if (root_child->kind() == RootItem::Kind::Feed || root_child->kind() == RootItem::Kind::Category) {
setData(indexForItem(root_child), Qt::Unchecked, Qt::CheckStateRole);
}
@ -161,7 +165,7 @@ QVariant AccountCheckModel::data(const QModelIndex& index, int role) const {
RootItem* item = itemForIndex(index);
if (role == Qt::CheckStateRole) {
if (role == Qt::ItemDataRole::CheckStateRole) {
if (m_checkStates.contains(item)) {
return m_checkStates.value(item);
}
@ -169,15 +173,13 @@ QVariant AccountCheckModel::data(const QModelIndex& index, int role) const {
return static_cast<int>(Qt::Unchecked);
}
}
else if (role == Qt::DecorationRole) {
auto ic = item->icon();
else if (role == Qt::ItemDataRole::DecorationRole) {
return item->data(0, Qt::ItemDataRole::DecorationRole);
}
else if (role == Qt::EditRole) {
else if (role == Qt::ItemDataRole::EditRole) {
return QVariant::fromValue(item);
}
else if (role == Qt::DisplayRole) {
else if (role == Qt::ItemDataRole::DisplayRole) {
switch (item->kind()) {
case RootItem::Kind::Category:
return QVariant(item->data(index.column(), role).toString() + QSL(" ") + tr("(category)"));
@ -213,7 +215,9 @@ bool AccountCheckModel::setData(const QModelIndex& index, const QVariant& value,
}
// Set new data for all descendants of this actual item.
for (RootItem* child : item->childItems()) {
auto chi = item->childItems();
for (RootItem* child : qAsConst(chi)) {
setData(indexForItem(child), value, Qt::CheckStateRole);
}
@ -230,8 +234,9 @@ bool AccountCheckModel::setData(const QModelIndex& index, const QVariant& value,
// Check children of this new parent item.
bool all_checked = true;
bool all_unchecked = true;
auto chi = item->childItems();
for (RootItem* child_of_parent : item->childItems()) {
for (RootItem* child_of_parent : qAsConst(chi)) {
if (m_checkStates.contains(child_of_parent)) {
all_checked &= m_checkStates[child_of_parent] == Qt::CheckState::Checked;
all_unchecked &= m_checkStates[child_of_parent] == Qt::CheckState::Unchecked;

View File

@ -2,8 +2,8 @@
#include "services/abstract/category.h"
#include "miscellaneous/application.h"
#include "database/databasequeries.h"
#include "miscellaneous/application.h"
#include "miscellaneous/iconfactory.h"
#include "miscellaneous/textfactory.h"
#include "services/abstract/cacheforserviceroot.h"
@ -20,8 +20,9 @@ Category::Category(const Category& other) : RootItem(other) {
void Category::updateCounts(bool including_total_count) {
QList<Feed*> feeds;
auto str = getSubTree();
for (RootItem* child : getSubTree()) {
for (RootItem* child : qAsConst(str)) {
if (child->kind() == RootItem::Kind::Feed) {
feeds.append(child->toFeed());
}

View File

@ -97,7 +97,7 @@ void Feed::setCountOfAllMessages(int count_all_messages) {
}
void Feed::setCountOfUnreadMessages(int count_unread_messages) {
if (status() == Status::NewMessages && count_unread_messages < countOfUnreadMessages()) {
if (status() == Status::NewMessages && count_unread_messages < m_unreadCount) {
setStatus(Status::Normal);
}

View File

@ -74,7 +74,7 @@ bool RootItem::deleteViaGui() {
bool RootItem::markAsReadUnread(ReadStatus status) {
bool result = true;
for (RootItem* child : m_childItems) {
for (RootItem* child : qAsConst(m_childItems)) {
result &= child->markAsReadUnread(status);
}
@ -84,7 +84,7 @@ bool RootItem::markAsReadUnread(ReadStatus status) {
QList<Message> RootItem::undeletedMessages() const {
QList<Message> messages;
for (RootItem* child : m_childItems) {
for (RootItem* child : qAsConst(m_childItems)) {
if (child->kind() != Kind::Bin && child->kind() != Kind::Labels && child->kind() != Kind::Label) {
messages.append(child->undeletedMessages());
}
@ -96,7 +96,7 @@ QList<Message> RootItem::undeletedMessages() const {
bool RootItem::cleanMessages(bool clear_only_read) {
bool result = true;
for (RootItem* child : m_childItems) {
for (RootItem* child : qAsConst(m_childItems)) {
if (child->kind() != RootItem::Kind::Bin) {
result &= child->cleanMessages(clear_only_read);
}
@ -106,7 +106,7 @@ bool RootItem::cleanMessages(bool clear_only_read) {
}
void RootItem::updateCounts(bool including_total_count) {
for (RootItem* child : m_childItems) {
for (RootItem* child : qAsConst(m_childItems)) {
child->updateCounts(including_total_count);
}
}

View File

@ -120,8 +120,9 @@ void ServiceRoot::stop() {}
void ServiceRoot::updateCounts(bool including_total_count) {
QList<Feed*> feeds;
auto str = getSubTree();
for (RootItem* child : getSubTree()) {
for (RootItem* child : qAsConst(str)) {
if (child->kind() == RootItem::Kind::Feed) {
feeds.append(child->toFeed());
}
@ -194,7 +195,9 @@ void ServiceRoot::removeOldAccountFromDatabase(bool including_messages) {
}
void ServiceRoot::cleanAllItemsFromModel() {
for (RootItem* top_level_item : childItems()) {
auto chi = childItems();
for (RootItem* top_level_item : qAsConst(chi)) {
if (top_level_item->kind() != RootItem::Kind::Bin &&
top_level_item->kind() != RootItem::Kind::Important &&
top_level_item->kind() != RootItem::Kind::Labels) {
@ -203,7 +206,9 @@ void ServiceRoot::cleanAllItemsFromModel() {
}
if (labelsNode() != nullptr) {
for (RootItem* lbl : labelsNode()->childItems()) {
auto lbl_chi = labelsNode()->childItems();
for (RootItem* lbl : qAsConst(lbl_chi)) {
requestItemRemoval(lbl);
}
}
@ -218,10 +223,8 @@ void ServiceRoot::appendCommonNodes() {
appendChild(importantNode());
}
if (labelsNode() != nullptr) {
if (!childItems().contains(labelsNode())) {
appendChild(labelsNode());
}
if (labelsNode() != nullptr && !childItems().contains(labelsNode())) {
appendChild(labelsNode());
}
}
@ -338,10 +341,13 @@ void ServiceRoot::addNewCategory(RootItem* selected_item) {
QMap<QString, QVariantMap> ServiceRoot::storeCustomFeedsData() {
QMap<QString, QVariantMap> custom_data;
auto str = getSubTreeFeeds();
for (const Feed* feed : getSubTreeFeeds()) {
for (const Feed* feed : qAsConst(str)) {
QVariantMap feed_custom_data;
// TODO: This could potentially call Feed::customDatabaseData() and append it
// to this map and also subsequently restore.
feed_custom_data.insert(QSL("auto_update_interval"), feed->autoUpdateInitialInterval());
feed_custom_data.insert(QSL("auto_update_type"), int(feed->autoUpdateType()));
feed_custom_data.insert(QSL("msg_filters"), QVariant::fromValue(feed->messageFilters()));
@ -412,7 +418,9 @@ void ServiceRoot::syncIn() {
removeLeftOverMessageFilterAssignments();
removeLeftOverMessageLabelAssignments();
for (RootItem* top_level_item : new_tree->childItems()) {
auto chi = new_tree->childItems();
for (RootItem* top_level_item : qAsConst(chi)) {
if (top_level_item->kind() != Kind::Labels) {
top_level_item->setParent(nullptr);
requestItemReassignment(top_level_item, this);
@ -420,7 +428,9 @@ void ServiceRoot::syncIn() {
else {
// It seems that some labels got synced-in.
if (labelsNode() != nullptr) {
for (RootItem* new_lbl : top_level_item->childItems()) {
auto lbl_chi = top_level_item->childItems();
for (RootItem* new_lbl : qAsConst(lbl_chi)) {
new_lbl->setParent(nullptr);
requestItemReassignment(new_lbl, labelsNode());
}
@ -464,7 +474,9 @@ QStringList ServiceRoot::customIDSOfMessagesForItem(RootItem* item) {
switch (item->kind()) {
case RootItem::Kind::Labels:
case RootItem::Kind::Category: {
for (RootItem* child : item->childItems()) {
auto chi = item->childItems();
for (RootItem* child : qAsConst(chi)) {
list.append(customIDSOfMessagesForItem(child));
}

View File

@ -40,13 +40,14 @@ class ServiceRoot : public RootItem {
virtual ~ServiceRoot();
// These methods bellow are part of "interface".
RecycleBin* recycleBin() const;
ImportantNode* importantNode() const;
LabelsNode* labelsNode() const;
virtual void updateCounts(bool including_total_count);
virtual bool canBeDeleted() const;
virtual bool deleteViaGui();
virtual bool markAsReadUnread(ReadStatus status);
virtual RecycleBin* recycleBin() const;
virtual ImportantNode* importantNode() const;
virtual LabelsNode* labelsNode() const;
virtual bool downloadAttachmentOnMyOwn(const QUrl& url) const;
virtual QList<Message> undeletedMessages() const;
virtual bool supportsFeedAdding() const;

View File

@ -231,7 +231,9 @@ QList<Message> FeedlyNetwork::decodeStreamContents(const QByteArray& stream_cont
continuation = json.object()["continuation"].toString();
for (const QJsonValue& entry : json.object()["items"].toArray()) {
auto items = json.object()["items"].toArray();
for (const QJsonValue& entry : qAsConst(items)) {
const QJsonObject& entry_obj = entry.toObject();
Message message;
@ -255,7 +257,9 @@ QList<Message> FeedlyNetwork::decodeStreamContents(const QByteArray& stream_cont
message.m_url = entry_obj["canonical"].toObject()["href"].toString();
}
for (const QJsonValue& enc : entry_obj["enclosure"].toArray()) {
auto enclosures = entry_obj["enclosure"].toArray();
for (const QJsonValue& enc : qAsConst(enclosures)) {
const QJsonObject& enc_obj = enc.toObject();
const QString& enc_href = enc_obj["href"].toString();
@ -266,7 +270,9 @@ QList<Message> FeedlyNetwork::decodeStreamContents(const QByteArray& stream_cont
}
}
for (const QJsonValue& tag : entry_obj["tags"].toArray()) {
auto tags = entry_obj["tags"].toArray();
for (const QJsonValue& tag : qAsConst(tags)) {
const QJsonObject& tag_obj = tag.toObject();
const QString& tag_id = tag_obj["id"].toString();
@ -332,15 +338,18 @@ RootItem* FeedlyNetwork::decodeCollections(const QByteArray& json, bool obtain_i
QJsonDocument doc = QJsonDocument::fromJson(json);
auto* parent = new RootItem();
QList<QString> used_feeds;
auto coll = doc.array();
for (const QJsonValue& cat : doc.array()) {
for (const QJsonValue& cat : qAsConst(coll)) {
QJsonObject cat_obj = cat.toObject();
auto* category = new Category(parent);
category->setTitle(cat_obj["label"].toString());
category->setCustomId(cat_obj["id"].toString());
for (const QJsonValue& fee : cat["feeds"].toArray()) {
auto feeds = cat["feeds"].toArray();
for (const QJsonValue& fee : qAsConst(feeds)) {
QJsonObject fee_obj = fee.toObject();
if (used_feeds.contains(fee_obj["id"].toString())) {
@ -446,8 +455,9 @@ QList<RootItem*> FeedlyNetwork::tags() {
QJsonDocument json = QJsonDocument::fromJson(output);
QList<RootItem*> lbls;
auto tags = json.array();
for (const QJsonValue& tag : json.array()) {
for (const QJsonValue& tag : qAsConst(tags)) {
const QJsonObject& tag_obj = tag.toObject();
QString name_id = tag_obj["id"].toString();

View File

@ -130,7 +130,9 @@ void FeedlyAccountDetails::performTest(const QNetworkProxy& custom_proxy) {
factory.setDeveloperAccessToken(m_ui.m_txtDeveloperAccessToken->lineEdit()->text());
try {
m_ui.m_txtUsername->lineEdit()->setText(factory.profile(custom_proxy)["email"].toString());
auto prof = factory.profile(custom_proxy);
m_ui.m_txtUsername->lineEdit()->setText(prof["email"].toString());
m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Ok,
tr("Login was successful."),
tr("Access granted."));