Replaced all foreach instances with for.
This commit is contained in:
parent
2c6afa1bb7
commit
d7d3be2914
65 changed files with 189 additions and 190 deletions
|
@ -61,7 +61,7 @@ QMimeData* FeedsModel::mimeData(const QModelIndexList& indexes) const {
|
|||
QByteArray encoded_data;
|
||||
QDataStream stream(&encoded_data, QIODevice::WriteOnly);
|
||||
|
||||
foreach (const QModelIndex& index, indexes) {
|
||||
for (const QModelIndex& index : indexes) {
|
||||
if (index.column() != 0) {
|
||||
continue;
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ void FeedsModel::reassignNodeToNewParent(RootItem* original_node, RootItem* new_
|
|||
QList<ServiceRoot*>FeedsModel::serviceRoots() const {
|
||||
QList<ServiceRoot*>roots;
|
||||
|
||||
foreach (RootItem* root, m_rootItem->childItems()) {
|
||||
for (RootItem* root : m_rootItem->childItems()) {
|
||||
if (root->kind() == RootItemKind::ServiceRoot) {
|
||||
roots.append(root->toServiceRoot());
|
||||
}
|
||||
|
@ -303,7 +303,7 @@ QList<ServiceRoot*>FeedsModel::serviceRoots() const {
|
|||
}
|
||||
|
||||
bool FeedsModel::containsServiceRootFromEntryPoint(const ServiceEntryPoint* point) const {
|
||||
foreach (const ServiceRoot* root, serviceRoots()) {
|
||||
for (const ServiceRoot* root : serviceRoots()) {
|
||||
if (root->code() == point->code()) {
|
||||
return true;
|
||||
}
|
||||
|
@ -313,7 +313,7 @@ bool FeedsModel::containsServiceRootFromEntryPoint(const ServiceEntryPoint* poin
|
|||
}
|
||||
|
||||
StandardServiceRoot* FeedsModel::standardServiceRoot() const {
|
||||
foreach (ServiceRoot* root, serviceRoots()) {
|
||||
for (ServiceRoot* root : serviceRoots()) {
|
||||
StandardServiceRoot* std_service_root;
|
||||
|
||||
if ((std_service_root = dynamic_cast<StandardServiceRoot*>(root)) != nullptr) {
|
||||
|
@ -327,7 +327,7 @@ StandardServiceRoot* FeedsModel::standardServiceRoot() const {
|
|||
QList<Feed*>FeedsModel::feedsForScheduledUpdate(bool auto_update_now) {
|
||||
QList<Feed*>feeds_for_update;
|
||||
|
||||
foreach (Feed* feed, m_rootItem->getSubTreeFeeds()) {
|
||||
for (Feed* feed : m_rootItem->getSubTreeFeeds()) {
|
||||
switch (feed->autoUpdateType()) {
|
||||
case Feed::DontAutoUpdate:
|
||||
|
||||
|
@ -412,7 +412,7 @@ QModelIndex FeedsModel::indexForItem(const RootItem* item) const {
|
|||
}
|
||||
|
||||
bool FeedsModel::hasAnyFeedNewMessages() const {
|
||||
foreach (const Feed* feed, m_rootItem->getSubTreeFeeds()) {
|
||||
for (const Feed* feed : m_rootItem->getSubTreeFeeds()) {
|
||||
if (feed->status() == Feed::NewMessages) {
|
||||
return true;
|
||||
}
|
||||
|
@ -456,7 +456,7 @@ void FeedsModel::onItemDataChanged(const QList<RootItem*>& items) {
|
|||
else {
|
||||
qDebug("There is request to reload feed model, reloading the %d items individually.", items.size());
|
||||
|
||||
foreach (RootItem* item, items) {
|
||||
for (RootItem* item : items) {
|
||||
reloadChangedItem(item);
|
||||
}
|
||||
}
|
||||
|
@ -508,7 +508,7 @@ bool FeedsModel::addServiceAccount(ServiceRoot* root, bool freshly_activated) {
|
|||
bool FeedsModel::restoreAllBins() {
|
||||
bool result = true;
|
||||
|
||||
foreach (ServiceRoot* root, serviceRoots()) {
|
||||
for (ServiceRoot* root : serviceRoots()) {
|
||||
RecycleBin* bin_of_root = root->recycleBin();
|
||||
|
||||
if (bin_of_root != nullptr) {
|
||||
|
@ -522,7 +522,7 @@ bool FeedsModel::restoreAllBins() {
|
|||
bool FeedsModel::emptyAllBins() {
|
||||
bool result = true;
|
||||
|
||||
foreach (ServiceRoot* root, serviceRoots()) {
|
||||
for (ServiceRoot* root : serviceRoots()) {
|
||||
RecycleBin* bin_of_root = root->recycleBin();
|
||||
|
||||
if (bin_of_root != nullptr) {
|
||||
|
@ -535,11 +535,11 @@ bool FeedsModel::emptyAllBins() {
|
|||
|
||||
void FeedsModel::loadActivatedServiceAccounts() {
|
||||
// Iterate all globally available feed "service plugins".
|
||||
foreach (const ServiceEntryPoint* entry_point, qApp->feedReader()->feedServices()) {
|
||||
for (const ServiceEntryPoint* entry_point : qApp->feedReader()->feedServices()) {
|
||||
// Load all stored root nodes from the entry point and add those to the model.
|
||||
QList<ServiceRoot*>roots = entry_point->initializeSubtree();
|
||||
|
||||
foreach (ServiceRoot* root, roots) {
|
||||
for (ServiceRoot* root : roots) {
|
||||
addServiceAccount(root, false);
|
||||
}
|
||||
}
|
||||
|
@ -554,7 +554,7 @@ void FeedsModel::loadActivatedServiceAccounts() {
|
|||
}
|
||||
|
||||
void FeedsModel::stopServiceAccounts() {
|
||||
foreach (ServiceRoot* account, serviceRoots()) {
|
||||
for (ServiceRoot* account : serviceRoots()) {
|
||||
account->stop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -255,7 +255,7 @@ void FeedsProxyModel::setShowUnreadOnly(bool show_unread_only) {
|
|||
QModelIndexList FeedsProxyModel::mapListToSource(const QModelIndexList& indexes) const {
|
||||
QModelIndexList source_indexes;
|
||||
|
||||
foreach (const QModelIndex& index, indexes) {
|
||||
for (const QModelIndex& index : indexes) {
|
||||
source_indexes << mapToSource(index);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ Enclosure::Enclosure(QString url, QString mime) : m_url(std::move(url)), m_mimeT
|
|||
QList<Enclosure> Enclosures::decodeEnclosuresFromString(const QString& enclosures_data) {
|
||||
QList<Enclosure> enclosures;
|
||||
|
||||
foreach (const QString& single_enclosure, enclosures_data.split(ENCLOSURES_OUTER_SEPARATOR, QString::SkipEmptyParts)) {
|
||||
for (const QString& single_enclosure : enclosures_data.split(ENCLOSURES_OUTER_SEPARATOR, QString::SkipEmptyParts)) {
|
||||
Enclosure enclosure;
|
||||
|
||||
if (single_enclosure.contains(ECNLOSURES_INNER_SEPARATOR)) {
|
||||
|
@ -33,7 +33,7 @@ QList<Enclosure> Enclosures::decodeEnclosuresFromString(const QString& enclosure
|
|||
QString Enclosures::encodeEnclosuresToString(const QList<Enclosure>& enclosures) {
|
||||
QStringList enclosures_str;
|
||||
|
||||
foreach (const Enclosure& enclosure, enclosures) {
|
||||
for (const Enclosure& enclosure : enclosures) {
|
||||
if (enclosure.m_mimeType.isEmpty()) {
|
||||
enclosures_str.append(enclosure.m_url.toLocal8Bit().toBase64());
|
||||
}
|
||||
|
|
|
@ -419,7 +419,7 @@ bool MessagesModel::switchBatchMessageImportance(const QModelIndexList& messages
|
|||
QList<QPair<Message, RootItem::Importance>> message_states;
|
||||
|
||||
// Obtain IDs of all desired messages.
|
||||
foreach (const QModelIndex& message, messages) {
|
||||
for (const QModelIndex& message : messages) {
|
||||
const Message msg = messageAt(message.row());
|
||||
|
||||
RootItem::Importance message_importance = messageImportance((message.row()));
|
||||
|
@ -454,7 +454,7 @@ bool MessagesModel::setBatchMessagesDeleted(const QModelIndexList& messages) {
|
|||
QList<Message> msgs;
|
||||
|
||||
// Obtain IDs of all desired messages.
|
||||
foreach (const QModelIndex& message, messages) {
|
||||
for (const QModelIndex& message : messages) {
|
||||
const Message msg = messageAt(message.row());
|
||||
|
||||
msgs.append(msg);
|
||||
|
@ -497,7 +497,7 @@ bool MessagesModel::setBatchMessagesRead(const QModelIndexList& messages, RootIt
|
|||
QList<Message> msgs;
|
||||
|
||||
// Obtain IDs of all desired messages.
|
||||
foreach (const QModelIndex& message, messages) {
|
||||
for (const QModelIndex& message : messages) {
|
||||
Message msg = messageAt(message.row());
|
||||
|
||||
msgs.append(msg);
|
||||
|
@ -525,7 +525,7 @@ bool MessagesModel::setBatchMessagesRestored(const QModelIndexList& messages) {
|
|||
QList<Message> msgs;
|
||||
|
||||
// Obtain IDs of all desired messages.
|
||||
foreach (const QModelIndex& message, messages) {
|
||||
for (const QModelIndex& message : messages) {
|
||||
const Message msg = messageAt(message.row());
|
||||
|
||||
msgs.append(msg);
|
||||
|
|
|
@ -63,7 +63,7 @@ bool MessagesProxyModel::lessThan(const QModelIndex& left, const QModelIndex& ri
|
|||
QModelIndexList MessagesProxyModel::mapListFromSource(const QModelIndexList& indexes, bool deep) const {
|
||||
QModelIndexList mapped_indexes;
|
||||
|
||||
foreach (const QModelIndex& index, indexes) {
|
||||
for (const QModelIndex& index : indexes) {
|
||||
if (deep) {
|
||||
// Construct new source index.
|
||||
mapped_indexes << mapFromSource(m_sourceModel->index(index.row(), index.column()));
|
||||
|
@ -180,7 +180,7 @@ void MessagesProxyModel::sort(int column, Qt::SortOrder order) {
|
|||
QModelIndexList MessagesProxyModel::mapListToSource(const QModelIndexList& indexes) const {
|
||||
QModelIndexList source_indexes;
|
||||
|
||||
foreach (const QModelIndex& index, indexes) {
|
||||
for (const QModelIndex& index : indexes) {
|
||||
source_indexes << mapToSource(index);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
void DynamicShortcuts::save(const QList<QAction*>& actions) {
|
||||
Settings* settings = qApp->settings();
|
||||
|
||||
foreach (const QAction* action, actions) {
|
||||
for (const QAction* action : actions) {
|
||||
settings->setValue(GROUP(Keyboard), action->objectName(), action->shortcut().toString(QKeySequence::PortableText));
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ void DynamicShortcuts::save(const QList<QAction*>& actions) {
|
|||
void DynamicShortcuts::load(const QList<QAction*>& actions) {
|
||||
Settings* settings = qApp->settings();
|
||||
|
||||
foreach (QAction* action, actions) {
|
||||
for (QAction* action : actions) {
|
||||
QString shortcut_for_action = settings->value(GROUP(Keyboard),
|
||||
action->objectName(),
|
||||
action->shortcut().toString(QKeySequence::PortableText)).toString();
|
||||
|
|
|
@ -25,7 +25,7 @@ bool DynamicShortcutsWidget::areShortcutsUnique() const {
|
|||
QList<QKeySequence> all_shortcuts;
|
||||
|
||||
// Obtain all shortcuts.
|
||||
foreach (const ActionBinding& binding, m_actionBindings) {
|
||||
for (const ActionBinding& binding : m_actionBindings) {
|
||||
const QKeySequence new_shortcut = binding.second->shortcut();
|
||||
|
||||
if (!new_shortcut.isEmpty() && all_shortcuts.contains(new_shortcut)) {
|
||||
|
@ -41,7 +41,7 @@ bool DynamicShortcutsWidget::areShortcutsUnique() const {
|
|||
}
|
||||
|
||||
void DynamicShortcutsWidget::updateShortcuts() {
|
||||
foreach (const ActionBinding& binding, m_actionBindings) {
|
||||
for (const ActionBinding& binding : m_actionBindings) {
|
||||
binding.first->setShortcut(binding.second->shortcut());
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ void DynamicShortcutsWidget::populate(QList<QAction*> actions) {
|
|||
// This will be setup in FormMain::allActions().
|
||||
// Then here I will process actions into categories.
|
||||
|
||||
foreach (QAction* action, actions) {
|
||||
for (QAction* action : actions) {
|
||||
// Create shortcut catcher for this action and set default shortcut.
|
||||
auto* catcher = new ShortcutCatcher(this);
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ void BaseBar::loadSavedActions() {
|
|||
}
|
||||
|
||||
QAction* BaseBar::findMatchingAction(const QString& action, const QList<QAction*>& actions) const {
|
||||
foreach (QAction* act, actions) {
|
||||
for (QAction* act : actions) {
|
||||
if (act->objectName() == action) {
|
||||
return act;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ ServiceEntryPoint* FormAddAccount::selectedEntryPoint() const {
|
|||
}
|
||||
|
||||
void FormAddAccount::loadEntryPoints() {
|
||||
foreach (const ServiceEntryPoint* entry_point, m_entryPoints) {
|
||||
for (const ServiceEntryPoint* entry_point : m_entryPoints) {
|
||||
QListWidgetItem* item = new QListWidgetItem(entry_point->icon(), entry_point->name(), m_ui->m_listEntryPoints);
|
||||
|
||||
if (entry_point->isSingleInstanceService() && m_model->containsServiceRootFromEntryPoint(entry_point)) {
|
||||
|
|
|
@ -242,7 +242,7 @@ void FormMain::updateAddItemMenu() {
|
|||
// NOTE: Clear here deletes items from memory but only those OWNED by the menu.
|
||||
m_ui->m_menuAddItem->clear();
|
||||
|
||||
foreach (ServiceRoot* activated_root, qApp->feedReader()->feedsModel()->serviceRoots()) {
|
||||
for (ServiceRoot* activated_root : qApp->feedReader()->feedsModel()->serviceRoots()) {
|
||||
QMenu* root_menu = new QMenu(activated_root->title(), m_ui->m_menuAddItem);
|
||||
|
||||
root_menu->setIcon(activated_root->icon());
|
||||
|
@ -293,7 +293,7 @@ void FormMain::updateAddItemMenu() {
|
|||
void FormMain::updateRecycleBinMenu() {
|
||||
m_ui->m_menuRecycleBin->clear();
|
||||
|
||||
foreach (const ServiceRoot* activated_root, qApp->feedReader()->feedsModel()->serviceRoots()) {
|
||||
for (const ServiceRoot* activated_root : qApp->feedReader()->feedsModel()->serviceRoots()) {
|
||||
QMenu* root_menu = new QMenu(activated_root->title(), m_ui->m_menuRecycleBin);
|
||||
|
||||
root_menu->setIcon(activated_root->icon());
|
||||
|
@ -335,7 +335,7 @@ void FormMain::updateRecycleBinMenu() {
|
|||
void FormMain::updateAccountsMenu() {
|
||||
m_ui->m_menuAccounts->clear();
|
||||
|
||||
foreach (ServiceRoot* activated_root, qApp->feedReader()->feedsModel()->serviceRoots()) {
|
||||
for (ServiceRoot* activated_root : qApp->feedReader()->feedsModel()->serviceRoots()) {
|
||||
QMenu* root_menu = new QMenu(activated_root->title(), m_ui->m_menuAccounts);
|
||||
|
||||
root_menu->setIcon(activated_root->icon());
|
||||
|
|
|
@ -90,14 +90,14 @@ void FormRestoreDatabaseSettings::selectFolder(QString folder) {
|
|||
m_ui.m_listDatabase->clear();
|
||||
m_ui.m_listSettings->clear();
|
||||
|
||||
foreach (const QFileInfo& database_file, available_databases) {
|
||||
for (const QFileInfo& database_file : available_databases) {
|
||||
QListWidgetItem* database_item = new QListWidgetItem(database_file.fileName(), m_ui.m_listDatabase);
|
||||
|
||||
database_item->setData(Qt::UserRole, database_file.absoluteFilePath());
|
||||
database_item->setToolTip(QDir::toNativeSeparators(database_file.absoluteFilePath()));
|
||||
}
|
||||
|
||||
foreach (const QFileInfo& settings_file, available_settings) {
|
||||
for (const QFileInfo& settings_file : available_settings) {
|
||||
QListWidgetItem* settings_item = new QListWidgetItem(settings_file.fileName(), m_ui.m_listSettings);
|
||||
|
||||
settings_item->setData(Qt::UserRole, settings_file.absoluteFilePath());
|
||||
|
|
|
@ -56,7 +56,7 @@ void FormSettings::applySettings() {
|
|||
m_settings.checkSettings();
|
||||
QStringList panels_for_restart;
|
||||
|
||||
foreach (SettingsPanel* panel, m_panels) {
|
||||
for (SettingsPanel* panel : m_panels) {
|
||||
if (panel->isDirty()) {
|
||||
panel->saveSettings();
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ void FormSettings::applySettings() {
|
|||
void FormSettings::cancelSettings() {
|
||||
QStringList changed_panels;
|
||||
|
||||
foreach (SettingsPanel* panel, m_panels) {
|
||||
for (SettingsPanel* panel : m_panels) {
|
||||
if (panel->isDirty()) {
|
||||
changed_panels.append(panel->title().toLower());
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ void FormUpdate::saveUpdateFile(const QByteArray& file_contents) {
|
|||
void FormUpdate::loadAvailableFiles() {
|
||||
m_ui.m_listFiles->clear();
|
||||
|
||||
foreach (const UpdateUrl& url, m_updateInfo.m_urls) {
|
||||
for (const UpdateUrl& url : m_updateInfo.m_urls) {
|
||||
if (SystemFactory::supportedUpdateFiles().match(url.m_name).hasMatch()) {
|
||||
QListWidgetItem* item = new QListWidgetItem(url.m_name + tr(" (size ") + url.m_size + QSL(")"));
|
||||
|
||||
|
|
|
@ -61,10 +61,10 @@ void DiscoverFeedsButton::linkTriggered(QAction* action) {
|
|||
void DiscoverFeedsButton::fillMenu() {
|
||||
menu()->clear();
|
||||
|
||||
foreach (const ServiceRoot* root, qApp->feedReader()->feedsModel()->serviceRoots()) {
|
||||
for (const ServiceRoot* root : qApp->feedReader()->feedsModel()->serviceRoots()) {
|
||||
QMenu* root_menu = menu()->addMenu(root->icon(), root->title());
|
||||
|
||||
foreach (const QString& url, m_addresses) {
|
||||
for (const QString& url : m_addresses) {
|
||||
if (root->supportsFeedAdding()) {
|
||||
QAction* url_action = root_menu->addAction(root->icon(), url);
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ QList<QAction*> FeedsToolBar::getSpecificActions(const QStringList& actions) {
|
|||
QList<QAction*> spec_actions;
|
||||
|
||||
// Iterate action names and add respectable actions into the toolbar.
|
||||
foreach (const QString& action_name, actions) {
|
||||
for (const QString& action_name : actions) {
|
||||
QAction* matching_action = findMatchingAction(action_name, available_actions);
|
||||
|
||||
if (matching_action != nullptr) {
|
||||
|
|
|
@ -99,7 +99,7 @@ void FeedsView::saveExpandStates(RootItem* item) {
|
|||
QList<RootItem*> items = item->getSubTree(RootItemKind::Category | RootItemKind::ServiceRoot);
|
||||
|
||||
// Iterate all categories and save their expand statuses.
|
||||
foreach (const RootItem* item, items) {
|
||||
for (const RootItem* item : items) {
|
||||
const QString setting_name = item->hashCode();
|
||||
QModelIndex source_index = sourceModel()->indexForItem(item);
|
||||
QModelIndex visible_index = model()->mapFromSource(source_index);
|
||||
|
@ -117,7 +117,7 @@ void FeedsView::loadAllExpandStates() {
|
|||
expandable_items.append(sourceModel()->rootItem()->getSubTree(RootItemKind::Category | RootItemKind::ServiceRoot));
|
||||
|
||||
// Iterate all categories and save their expand statuses.
|
||||
foreach (const RootItem* item, expandable_items) {
|
||||
for (const RootItem* item : expandable_items) {
|
||||
const QString setting_name = item->hashCode();
|
||||
|
||||
setExpanded(model()->mapFromSource(sourceModel()->indexForItem(item)),
|
||||
|
@ -677,7 +677,7 @@ void FeedsView::validateItemAfterDragDrop(const QModelIndex& source_index) {
|
|||
}
|
||||
|
||||
void FeedsView::onItemExpandRequested(const QList<RootItem*>& items, bool exp) {
|
||||
foreach (const RootItem* item, items) {
|
||||
for (const RootItem* item : items) {
|
||||
QModelIndex source_index = m_sourceModel->indexForItem(item);
|
||||
QModelIndex proxy_index = m_proxyModel->mapFromSource(source_index);
|
||||
|
||||
|
|
|
@ -229,7 +229,7 @@ QString MessagePreviewer::prepareHtmlForMessage(const Message& message) {
|
|||
html += QString("[url] <a href=\"%1\">%1</a><br/>").arg(message.m_url);
|
||||
}
|
||||
|
||||
foreach (const Enclosure& enc, message.m_enclosures) {
|
||||
for (const Enclosure& enc : message.m_enclosures) {
|
||||
QString enc_url;
|
||||
|
||||
if (!enc.m_url.contains(QRegularExpression(QSL("^(http|ftp|\\/)")))) {
|
||||
|
|
|
@ -45,7 +45,7 @@ QList<QAction*> MessagesToolBar::getSpecificActions(const QStringList& actions)
|
|||
QList<QAction*> spec_actions;
|
||||
|
||||
// Iterate action names and add respectable actions into the toolbar.
|
||||
foreach (const QString& action_name, actions) {
|
||||
for (const QString& action_name : actions) {
|
||||
auto* matching_action = findMatchingAction(action_name, available_actions);
|
||||
|
||||
if (matching_action != nullptr) {
|
||||
|
@ -90,7 +90,7 @@ void MessagesToolBar::loadSpecificActions(const QList<QAction*>& actions, bool i
|
|||
|
||||
clear();
|
||||
|
||||
foreach (QAction* act, actions) {
|
||||
for (QAction* act : actions) {
|
||||
addAction(act);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -207,7 +207,7 @@ void MessagesView::initializeContextMenu() {
|
|||
|
||||
menu->setIcon(qApp->icons()->fromTheme(QSL("document-open")));
|
||||
|
||||
foreach (const ExternalTool& tool, ExternalTool::toolsFromSettings()) {
|
||||
for (const ExternalTool& tool : ExternalTool::toolsFromSettings()) {
|
||||
QAction* act_tool = new QAction(QFileInfo(tool.executable()).fileName(), menu);
|
||||
|
||||
act_tool->setIcon(icon_provider.icon(tool.executable()));
|
||||
|
@ -325,7 +325,7 @@ void MessagesView::loadItem(RootItem* item) {
|
|||
}
|
||||
|
||||
void MessagesView::openSelectedSourceMessagesExternally() {
|
||||
foreach (const QModelIndex& index, selectionModel()->selectedRows()) {
|
||||
for (const QModelIndex& index : selectionModel()->selectedRows()) {
|
||||
QString link = m_sourceModel->messageAt(m_proxyModel->mapToSource(index).row())
|
||||
.m_url
|
||||
.replace(QRegularExpression("[\\t\\n]"), QString());
|
||||
|
@ -347,7 +347,7 @@ void MessagesView::openSelectedSourceMessagesExternally() {
|
|||
void MessagesView::openSelectedMessagesInternally() {
|
||||
QList<Message> messages;
|
||||
|
||||
foreach (const QModelIndex& index, selectionModel()->selectedRows()) {
|
||||
for (const QModelIndex& index : selectionModel()->selectedRows()) {
|
||||
messages << m_sourceModel->messageAt(m_proxyModel->mapToSource(index).row());
|
||||
}
|
||||
|
||||
|
@ -467,7 +467,7 @@ void MessagesView::reselectIndexes(const QModelIndexList& indexes) {
|
|||
if (indexes.size() < RESELECT_MESSAGE_THRESSHOLD) {
|
||||
QItemSelection selection;
|
||||
|
||||
foreach (const QModelIndex& index, indexes) {
|
||||
for (const QModelIndex& index : indexes) {
|
||||
selection.merge(QItemSelection(index, index), QItemSelectionModel::Select);
|
||||
}
|
||||
|
||||
|
@ -539,7 +539,7 @@ void MessagesView::openSelectedMessagesWithExternalTool() {
|
|||
if (sndr != nullptr) {
|
||||
auto tool = sndr->data().value<ExternalTool>();
|
||||
|
||||
foreach (const QModelIndex& index, selectionModel()->selectedRows()) {
|
||||
for (const QModelIndex& index : selectionModel()->selectedRows()) {
|
||||
const QString link = m_sourceModel->messageAt(m_proxyModel->mapToSource(index).row())
|
||||
.m_url
|
||||
.replace(QRegularExpression("[\\t\\n]"), QString());
|
||||
|
|
|
@ -126,7 +126,7 @@ QList<ExternalTool> SettingsBrowserMail::externalTools() const {
|
|||
}
|
||||
|
||||
void SettingsBrowserMail::setExternalTools(const QList<ExternalTool>& list) {
|
||||
foreach (const ExternalTool& tool, list) {
|
||||
for (const ExternalTool& tool : list) {
|
||||
QTreeWidgetItem* item = new QTreeWidgetItem(m_ui->m_listTools,
|
||||
QStringList() << tool.executable() << tool.parameters().join(QL1C(' ')));
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ void SettingsFeedsMessages::initializeMessageDateFormats() {
|
|||
const QDateTime current_dt = QDateTime::currentDateTime();
|
||||
const QLocale current_locale = qApp->localization()->loadedLocale();
|
||||
|
||||
foreach (const Language& lang, qApp->localization()->installedLanguages()) {
|
||||
for (const Language& lang : qApp->localization()->installedLanguages()) {
|
||||
QLocale locale(lang.m_code);
|
||||
|
||||
best_formats << locale.dateTimeFormat(QLocale::LongFormat)
|
||||
|
@ -95,7 +95,7 @@ void SettingsFeedsMessages::initializeMessageDateFormats() {
|
|||
|
||||
best_formats.removeDuplicates();
|
||||
|
||||
foreach (const QString& format, best_formats) {
|
||||
for (const QString& format : best_formats) {
|
||||
m_ui->m_cmbMessagesDateTimeFormat->addItem(current_locale.toString(current_dt, format), format);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ void SettingsGui::loadSettings() {
|
|||
// Load settings of icon theme.
|
||||
const QString current_theme = qApp->icons()->currentIconTheme();
|
||||
|
||||
foreach (const QString& icon_theme_name, qApp->icons()->installedIconThemes()) {
|
||||
for (const QString& icon_theme_name : qApp->icons()->installedIconThemes()) {
|
||||
if (icon_theme_name == APP_NO_THEME) {
|
||||
// Add just "no theme" on other systems.
|
||||
//: Label for disabling icon theme.
|
||||
|
@ -129,7 +129,7 @@ void SettingsGui::loadSettings() {
|
|||
// Load skin.
|
||||
const QString selected_skin = qApp->skins()->selectedSkinName();
|
||||
|
||||
foreach (const Skin& skin, qApp->skins()->installedSkins()) {
|
||||
for (const Skin& skin : qApp->skins()->installedSkins()) {
|
||||
QTreeWidgetItem* new_item = new QTreeWidgetItem(QStringList() <<
|
||||
skin.m_visibleName <<
|
||||
skin.m_version <<
|
||||
|
@ -154,7 +154,7 @@ void SettingsGui::loadSettings() {
|
|||
}
|
||||
|
||||
// Load styles.
|
||||
foreach (const QString& style_name, QStyleFactory::keys()) {
|
||||
for (const QString& style_name : QStyleFactory::keys()) {
|
||||
m_ui->m_listStyles->addItem(style_name);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ SettingsLocalization::~SettingsLocalization() {
|
|||
void SettingsLocalization::loadSettings() {
|
||||
onBeginLoadSettings();
|
||||
|
||||
foreach (const Language& language, qApp->localization()->installedLanguages()) {
|
||||
for (const Language& language : qApp->localization()->installedLanguages()) {
|
||||
auto* item = new QTreeWidgetItem(m_ui->m_treeLanguages);
|
||||
|
||||
item->setText(0, language.m_name);
|
||||
|
|
|
@ -88,7 +88,7 @@ QList<QAction*> StatusBar::getSpecificActions(const QStringList& actions) {
|
|||
|
||||
// Iterate action names and add respectable
|
||||
// actions into the toolbar.
|
||||
foreach (const QString& action_name, actions) {
|
||||
for (const QString& action_name : actions) {
|
||||
QAction* matching_action = findMatchingAction(action_name, available_actions);
|
||||
QAction* action_to_add;
|
||||
QWidget* widget_to_add;
|
||||
|
@ -162,7 +162,7 @@ QList<QAction*> StatusBar::getSpecificActions(const QStringList& actions) {
|
|||
}
|
||||
|
||||
void StatusBar::loadSpecificActions(const QList<QAction*>& actions, bool initial_load) {
|
||||
foreach (QAction* act, this->actions()) {
|
||||
for (QAction* act : this->actions()) {
|
||||
QWidget* widget = act->property("widget").isValid() ? static_cast<QWidget*>(act->property("widget").value<void*>()) : nullptr;
|
||||
|
||||
if (widget != nullptr) {
|
||||
|
@ -179,7 +179,7 @@ void StatusBar::loadSpecificActions(const QList<QAction*>& actions, bool initial
|
|||
|
||||
clear();
|
||||
|
||||
foreach (QAction* act, actions) {
|
||||
for (QAction* act : actions) {
|
||||
QWidget* widget = act->property("widget").isValid() ? static_cast<QWidget*>(act->property("widget").value<void*>()) : nullptr;
|
||||
|
||||
addAction(act);
|
||||
|
|
|
@ -63,7 +63,7 @@ void ToolBarEditor::loadEditor(const QList<QAction*> activated_actions, const QL
|
|||
m_ui->m_listActivatedActions->clear();
|
||||
m_ui->m_listAvailableActions->clear();
|
||||
|
||||
foreach (const QAction* action, activated_actions) {
|
||||
for (const QAction* action : activated_actions) {
|
||||
QListWidgetItem* action_item = new QListWidgetItem(action->icon(), action->text().replace('&', ""), m_ui->m_listActivatedActions);
|
||||
|
||||
if (action->isSeparator()) {
|
||||
|
@ -83,7 +83,7 @@ void ToolBarEditor::loadEditor(const QList<QAction*> activated_actions, const QL
|
|||
}
|
||||
}
|
||||
|
||||
foreach (QAction* action, available_actions) {
|
||||
for (QAction* action : available_actions) {
|
||||
if (!activated_actions.contains(action)) {
|
||||
QListWidgetItem* action_item = new QListWidgetItem(action->icon(), action->text().replace('&', ""), m_ui->m_listAvailableActions);
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ void TreeWidget::filterString(const QString& string) {
|
|||
QList<QTreeWidgetItem*> parents;
|
||||
bool stringIsEmpty = string.isEmpty();
|
||||
|
||||
foreach (QTreeWidgetItem* item, _allItems) {
|
||||
for (QTreeWidgetItem* item : _allItems) {
|
||||
bool containsString = stringIsEmpty || item->text(0).contains(string, Qt::CaseInsensitive);
|
||||
|
||||
if (containsString) {
|
||||
|
|
|
@ -94,11 +94,11 @@ void WebViewer::loadMessages(const QList<Message>& messages, RootItem* root) {
|
|||
QString messages_layout;
|
||||
QString single_message_layout = skin.m_layoutMarkup;
|
||||
|
||||
foreach (const Message& message, messages) {
|
||||
for (const Message& message : messages) {
|
||||
QString enclosures;
|
||||
QString enclosure_images;
|
||||
|
||||
foreach (const Enclosure& enclosure, message.m_enclosures) {
|
||||
for (const Enclosure& enclosure : message.m_enclosures) {
|
||||
QString enc_url;
|
||||
|
||||
if (!enclosure.m_url.contains(QRegularExpression(QSL("^(http|ftp|\\/)")))) {
|
||||
|
|
|
@ -341,7 +341,7 @@ void Application::processExecutionMessage(const QString& message) {
|
|||
quit();
|
||||
}
|
||||
else {
|
||||
foreach (const QString& msg, messages) {
|
||||
for (const QString& msg : messages) {
|
||||
if (msg == APP_IS_RUNNING) {
|
||||
showGuiMessage(APP_NAME, tr("Application is already running."), QSystemTrayIcon::Information);
|
||||
mainForm()->display();
|
||||
|
|
|
@ -222,7 +222,7 @@ QSqlDatabase DatabaseFactory::sqliteInitializeInMemoryDatabase() {
|
|||
|
||||
database.transaction();
|
||||
|
||||
foreach (const QString& statement, statements) {
|
||||
for (const QString& statement : statements) {
|
||||
query_db.exec(statement);
|
||||
|
||||
if (query_db.lastError().isValid()) {
|
||||
|
@ -258,7 +258,7 @@ QSqlDatabase DatabaseFactory::sqliteInitializeInMemoryDatabase() {
|
|||
qFatal("Cannot obtain list of table names from file-base SQLite database.");
|
||||
}
|
||||
|
||||
foreach (const QString& table, tables) {
|
||||
for (const QString& table : tables) {
|
||||
copy_contents.exec(QString("INSERT INTO main.%1 SELECT * FROM storage.%1;").arg(table));
|
||||
}
|
||||
|
||||
|
@ -331,7 +331,7 @@ QSqlDatabase DatabaseFactory::sqliteInitializeFileBasedDatabase(const QString& c
|
|||
|
||||
database.transaction();
|
||||
|
||||
foreach (const QString& statement, statements) {
|
||||
for (const QString& statement : statements) {
|
||||
query_db.exec(statement);
|
||||
|
||||
if (query_db.lastError().isValid()) {
|
||||
|
@ -409,7 +409,7 @@ bool DatabaseFactory::sqliteUpdateDatabaseSchema(const QSqlDatabase& database, c
|
|||
|
||||
const QStringList statements = QString(update_file_handle.readAll()).split(APP_DB_COMMENT_SPLIT, QString::SkipEmptyParts);
|
||||
|
||||
foreach (const QString& statement, statements) {
|
||||
for (const QString& statement : statements) {
|
||||
QSqlQuery query = database.exec(statement);
|
||||
|
||||
if (query.lastError().isValid()) {
|
||||
|
@ -449,7 +449,7 @@ bool DatabaseFactory::mysqlUpdateDatabaseSchema(const QSqlDatabase& database,
|
|||
|
||||
QStringList statements = QString(update_file_handle.readAll()).split(APP_DB_COMMENT_SPLIT, QString::SkipEmptyParts);
|
||||
|
||||
foreach (QString statement, statements) {
|
||||
for (QString statement : statements) {
|
||||
QSqlQuery query = database.exec(statement.replace(APP_DB_NAME_PLACEHOLDER, db_name));
|
||||
|
||||
if (query.lastError().isValid()) {
|
||||
|
@ -536,7 +536,7 @@ void DatabaseFactory::sqliteSaveMemoryDatabase() {
|
|||
qFatal("Cannot obtain list of table names from file-base SQLite database.");
|
||||
}
|
||||
|
||||
foreach (const QString& table, tables) {
|
||||
for (const QString& table : tables) {
|
||||
copy_contents.exec(QString(QSL("DELETE FROM storage.%1;")).arg(table));
|
||||
copy_contents.exec(QString(QSL("INSERT INTO storage.%1 SELECT * FROM main.%1;")).arg(table));
|
||||
}
|
||||
|
@ -660,7 +660,7 @@ QSqlDatabase DatabaseFactory::mysqlInitializeDatabase(const QString& connection_
|
|||
|
||||
database.transaction();
|
||||
|
||||
foreach (QString statement, statements) {
|
||||
for (QString statement : statements) {
|
||||
// Assign real database name and run the query.
|
||||
query_db.exec(statement.replace(APP_DB_NAME_PLACEHOLDER, database_name));
|
||||
|
||||
|
|
|
@ -494,7 +494,7 @@ int DatabaseQueries::updateMessages(QSqlDatabase db,
|
|||
return updated_messages;
|
||||
}
|
||||
|
||||
foreach (Message message, messages) {
|
||||
for (Message message : messages) {
|
||||
// Check if messages contain relative URLs and if they do, then replace them.
|
||||
if (message.m_url.startsWith(QL1S("//"))) {
|
||||
message.m_url = QString(URI_SCHEME_HTTP) + message.m_url.mid(2);
|
||||
|
@ -695,7 +695,7 @@ bool DatabaseQueries::deleteAccount(const QSqlDatabase& db, int account_id) {
|
|||
QSL("DELETE FROM Categories WHERE account_id = :account_id;") <<
|
||||
QSL("DELETE FROM Accounts WHERE id = :account_id;");
|
||||
|
||||
foreach (const QString& q, queries) {
|
||||
for (const QString& q : queries) {
|
||||
query.prepare(q);
|
||||
query.bindValue(QSL(":account_id"), account_id);
|
||||
|
||||
|
@ -791,7 +791,7 @@ bool DatabaseQueries::storeAccountTree(const QSqlDatabase& db, RootItem* tree_ro
|
|||
"VALUES (:title, :icon, :category, :protected, :update_type, :update_interval, :account_id, :custom_id);");
|
||||
|
||||
// Iterate all children.
|
||||
foreach (RootItem* child, tree_root->getSubTree()) {
|
||||
for (RootItem* child : tree_root->getSubTree()) {
|
||||
if (child->kind() == RootItemKind::Category) {
|
||||
query_category.bindValue(QSL(":parent_id"), child->parent()->id());
|
||||
query_category.bindValue(QSL(":title"), child->title());
|
||||
|
|
|
@ -57,7 +57,7 @@ QList<ExternalTool> ExternalTool::toolsFromSettings() {
|
|||
|
||||
QList<ExternalTool> tools;
|
||||
|
||||
foreach (const QString& tool_encoded, tools_encoded) {
|
||||
for (const QString& tool_encoded : tools_encoded) {
|
||||
tools.append(ExternalTool::fromString(tool_encoded));
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ QList<ExternalTool> ExternalTool::toolsFromSettings() {
|
|||
void ExternalTool::setToolsToSettings(QList<ExternalTool>& tools) {
|
||||
QStringList encode;
|
||||
|
||||
foreach (ExternalTool tool, tools) {
|
||||
for (ExternalTool tool : tools) {
|
||||
encode.append(tool.toString());
|
||||
}
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ void FeedReader::executeNextAutoUpdate() {
|
|||
}
|
||||
|
||||
void FeedReader::checkServicesForAsyncOperations() {
|
||||
foreach (ServiceRoot* service, m_feedsModel->serviceRoots()) {
|
||||
for (ServiceRoot* service : m_feedsModel->serviceRoots()) {
|
||||
auto cache = dynamic_cast<CacheForServiceRoot*>(service);
|
||||
|
||||
if (cache != nullptr) {
|
||||
|
|
|
@ -117,11 +117,11 @@ QStringList IconFactory::installedIconThemes() const {
|
|||
filters_index.append("index.theme");
|
||||
icon_themes_paths.removeDuplicates();
|
||||
|
||||
foreach (const QString& icon_path, icon_themes_paths) {
|
||||
for (const QString& icon_path : icon_themes_paths) {
|
||||
const QDir icon_dir(icon_path);
|
||||
|
||||
// Iterate all icon themes in this directory.
|
||||
foreach (const QFileInfo& icon_theme_path, icon_dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot |
|
||||
for (const QFileInfo& icon_theme_path : icon_dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot |
|
||||
QDir::Readable | QDir::CaseSensitive |
|
||||
QDir::NoSymLinks,
|
||||
QDir::Time)) {
|
||||
|
|
|
@ -60,7 +60,7 @@ QList<Language> Localization::installedLanguages() const {
|
|||
QTranslator translator;
|
||||
|
||||
// Iterate all found language files.
|
||||
foreach (const QFileInfo& file, file_dir.entryInfoList(QStringList() << "rssguard_*.qm", QDir::Files, QDir::Name)) {
|
||||
for (const QFileInfo& file : file_dir.entryInfoList(QStringList() << "rssguard_*.qm", QDir::Files, QDir::Name)) {
|
||||
if (translator.load(file.absoluteFilePath())) {
|
||||
Language new_language;
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ QList<Skin> SkinFactory::installedSkins() const {
|
|||
QDir::NoSymLinks |
|
||||
QDir::Readable));
|
||||
|
||||
foreach (const QString& base_directory, skin_directories) {
|
||||
for (const QString& base_directory : skin_directories) {
|
||||
const Skin skin_info = skinInfo(base_directory, &skin_load_ok);
|
||||
|
||||
if (skin_load_ok) {
|
||||
|
|
|
@ -29,7 +29,7 @@ int TextFactory::stringWidth(const QString& string, const QFontMetrics& metrics)
|
|||
const QStringList lines = string.split(QL1C('\n'));
|
||||
int width = 0;
|
||||
|
||||
foreach (const QString& line, lines) {
|
||||
for (const QString& line : lines) {
|
||||
#if QT_VERSION >= 0x050B00 // Qt >= 5.11.0
|
||||
int line_width = metrics.horizontalAdvance(line);
|
||||
#else
|
||||
|
@ -63,7 +63,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.
|
||||
foreach (const QString& pattern, date_patterns) {
|
||||
for (const QString& pattern : date_patterns) {
|
||||
dt = locale.toDateTime(input_date.left(pattern.size()), pattern);
|
||||
|
||||
if (dt.isValid()) {
|
||||
|
@ -74,7 +74,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());
|
||||
|
||||
foreach (const QString& pattern_t, timezone_offset_patterns) {
|
||||
for (const QString& pattern_t : timezone_offset_patterns) {
|
||||
time_zone_offset = QTime::fromString(offset_sanitized.left(pattern_t.size()), pattern_t);
|
||||
|
||||
if (time_zone_offset.isValid()) {
|
||||
|
|
|
@ -51,7 +51,7 @@ AdBlockAddSubscriptionDialog::AdBlockAddSubscriptionDialog(QWidget* parent)
|
|||
<< Subscription(QSL("Anti-Adblock Killer"),
|
||||
QSL("https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt"));
|
||||
|
||||
foreach (const Subscription& subscription, m_knownSubscriptions) {
|
||||
for (const Subscription& subscription : m_knownSubscriptions) {
|
||||
m_ui->m_cmbPresets->addItem(subscription.m_title);
|
||||
}
|
||||
|
||||
|
|
|
@ -153,7 +153,7 @@ void AdBlockDialog::load() {
|
|||
return;
|
||||
}
|
||||
|
||||
foreach (AdBlockSubscription* subscription, m_manager->subscriptions()) {
|
||||
for (AdBlockSubscription* subscription : m_manager->subscriptions()) {
|
||||
auto* tree = new AdBlockTreeWidget(subscription, m_ui->m_tabSubscriptions);
|
||||
|
||||
m_ui->m_tabSubscriptions->addTab(tree, subscription->title());
|
||||
|
|
|
@ -206,7 +206,7 @@ bool AdBlockManager::removeSubscription(AdBlockSubscription* subscription) {
|
|||
}
|
||||
|
||||
AdBlockCustomList* AdBlockManager::customList() const {
|
||||
foreach (AdBlockSubscription* subscription, m_subscriptions) {
|
||||
for (AdBlockSubscription* subscription : m_subscriptions) {
|
||||
auto* list = qobject_cast<AdBlockCustomList*>(subscription);
|
||||
|
||||
if (list != nullptr) {
|
||||
|
@ -243,7 +243,7 @@ void AdBlockManager::load() {
|
|||
QDir().mkpath(storedListsPath());
|
||||
}
|
||||
|
||||
foreach (const QString& fileName, adblockDir.entryList(QStringList("*.txt"), QDir::Files)) {
|
||||
for (const QString& fileName : adblockDir.entryList(QStringList("*.txt"), QDir::Files)) {
|
||||
if (fileName == ADBLOCK_CUSTOMLIST_NAME) {
|
||||
continue;
|
||||
}
|
||||
|
@ -279,7 +279,7 @@ void AdBlockManager::load() {
|
|||
m_subscriptions.append(customList);
|
||||
|
||||
// Load all subscriptions.
|
||||
foreach (AdBlockSubscription* subscription, m_subscriptions) {
|
||||
for (AdBlockSubscription* subscription : m_subscriptions) {
|
||||
subscription->loadSubscription(m_disabledRules);
|
||||
connect(subscription, SIGNAL(subscriptionChanged()), this, SLOT(updateMatcher()));
|
||||
}
|
||||
|
@ -300,7 +300,7 @@ void AdBlockManager::updateMatcher() {
|
|||
}
|
||||
|
||||
void AdBlockManager::updateAllSubscriptions() {
|
||||
foreach (AdBlockSubscription* subscription, m_subscriptions) {
|
||||
for (AdBlockSubscription* subscription : m_subscriptions) {
|
||||
subscription->updateSubscription();
|
||||
}
|
||||
|
||||
|
@ -312,7 +312,7 @@ void AdBlockManager::save() {
|
|||
return;
|
||||
}
|
||||
|
||||
foreach (AdBlockSubscription* subscription, m_subscriptions) {
|
||||
for (AdBlockSubscription* subscription : m_subscriptions) {
|
||||
subscription->saveSubscription();
|
||||
}
|
||||
|
||||
|
@ -351,7 +351,7 @@ QString AdBlockManager::elementHidingRulesForDomain(const QUrl& url) const {
|
|||
}
|
||||
|
||||
AdBlockSubscription* AdBlockManager::subscriptionByName(const QString& name) const {
|
||||
foreach (AdBlockSubscription* subscription, m_subscriptions) {
|
||||
for (AdBlockSubscription* subscription : m_subscriptions) {
|
||||
if (subscription->title() == name) {
|
||||
return subscription;
|
||||
}
|
||||
|
|
|
@ -134,8 +134,8 @@ void AdBlockMatcher::update() {
|
|||
QHash<QString, const AdBlockRule*> cssRulesHash;
|
||||
QVector<const AdBlockRule*> exceptionCssRules;
|
||||
|
||||
foreach (AdBlockSubscription* subscription, m_manager->subscriptions()) {
|
||||
foreach (const AdBlockRule* rule, subscription->allRules()) {
|
||||
for (AdBlockSubscription* subscription : m_manager->subscriptions()) {
|
||||
for (const AdBlockRule* rule : subscription->allRules()) {
|
||||
// Don't add internally disabled rules to cache.
|
||||
if (rule->isInternalDisabled()) {
|
||||
continue;
|
||||
|
@ -174,7 +174,7 @@ void AdBlockMatcher::update() {
|
|||
}
|
||||
}
|
||||
|
||||
foreach (const AdBlockRule* rule, exceptionCssRules) {
|
||||
for (const AdBlockRule* rule : exceptionCssRules) {
|
||||
const AdBlockRule* originalRule = cssRulesHash.value(rule->cssSelector());
|
||||
|
||||
// If we don't have this selector, the exception does nothing.
|
||||
|
|
|
@ -245,14 +245,14 @@ bool AdBlockRule::matchDomain(const QString& domain) const {
|
|||
}
|
||||
|
||||
if (m_blockedDomains.isEmpty()) {
|
||||
foreach (const QString& d, m_allowedDomains) {
|
||||
for (const QString& d : m_allowedDomains) {
|
||||
if (isMatchingDomain(domain, d)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (m_allowedDomains.isEmpty()) {
|
||||
foreach (const QString& d, m_blockedDomains) {
|
||||
for (const QString& d : m_blockedDomains) {
|
||||
if (isMatchingDomain(domain, d)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -261,13 +261,13 @@ bool AdBlockRule::matchDomain(const QString& domain) const {
|
|||
return true;
|
||||
}
|
||||
else {
|
||||
foreach (const QString& d, m_blockedDomains) {
|
||||
for (const QString& d : m_blockedDomains) {
|
||||
if (isMatchingDomain(domain, d)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (const QString& d, m_allowedDomains) {
|
||||
for (const QString& d : m_allowedDomains) {
|
||||
if (isMatchingDomain(domain, d)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -373,7 +373,7 @@ void AdBlockRule::parseFilter() {
|
|||
const QStringList options = parsedLine.mid(optionsIndex + 1).split(QL1C(','), QString::SkipEmptyParts);
|
||||
int handledOptions = 0;
|
||||
|
||||
foreach (const QString& option, options) {
|
||||
for (const QString& option : options) {
|
||||
if (option.startsWith(QL1S("domain="))) {
|
||||
parseDomains(option.mid(7), QL1C('|'));
|
||||
++handledOptions;
|
||||
|
@ -499,7 +499,7 @@ void AdBlockRule::parseFilter() {
|
|||
void AdBlockRule::parseDomains(const QString& domains, const QChar& separator) {
|
||||
QStringList domainsList = domains.split(separator, QString::SkipEmptyParts);
|
||||
|
||||
foreach (const QString domain, domainsList) {
|
||||
for (const QString domain : domainsList) {
|
||||
if (domain.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -621,7 +621,7 @@ QList<QStringMatcher> AdBlockRule::createStringMatchers(const QStringList& filte
|
|||
QList<QStringMatcher> matchers;
|
||||
matchers.reserve(filters.size());
|
||||
|
||||
foreach (const QString& filter, filters) {
|
||||
for (const QString& filter : filters) {
|
||||
matchers.append(QStringMatcher(filter, m_caseSensitivity));
|
||||
}
|
||||
|
||||
|
|
|
@ -317,7 +317,7 @@ void AdBlockCustomList::saveSubscription() {
|
|||
textStream << "Url: " << url().toString() << endl;
|
||||
textStream << "[Adblock Plus 1.1.1]" << endl;
|
||||
|
||||
foreach (const AdBlockRule* rule, m_rules) {
|
||||
for (const AdBlockRule* rule : m_rules) {
|
||||
textStream << rule->filter() << endl;
|
||||
}
|
||||
|
||||
|
@ -333,7 +333,7 @@ bool AdBlockCustomList::canBeRemoved() const {
|
|||
}
|
||||
|
||||
bool AdBlockCustomList::containsFilter(const QString& filter) const {
|
||||
foreach (const AdBlockRule* rule, m_rules) {
|
||||
for (const AdBlockRule* rule : m_rules) {
|
||||
if (rule->filter() == filter) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -235,7 +235,7 @@ void AdBlockTreeWidget::refresh() {
|
|||
const QVector<AdBlockRule*>& allRules = m_subscription->allRules();
|
||||
int index = 0;
|
||||
|
||||
foreach (const AdBlockRule* rule, allRules) {
|
||||
for (const AdBlockRule* rule : allRules) {
|
||||
auto* item = new QTreeWidgetItem(m_topItem);
|
||||
|
||||
item->setText(0, rule->filter());
|
||||
|
|
|
@ -53,7 +53,6 @@ void Downloader::manipulateData(const QString& url,
|
|||
const QString& password) {
|
||||
QNetworkRequest request;
|
||||
QString non_const_url = url;
|
||||
|
||||
QHashIterator<QByteArray, QByteArray> i(m_customHeaders);
|
||||
|
||||
while (i.hasNext()) {
|
||||
|
@ -102,6 +101,7 @@ void Downloader::finished() {
|
|||
auto* reply = qobject_cast<QNetworkReply*>(sender());
|
||||
|
||||
QNetworkAccessManager::Operation reply_operation = reply->operation();
|
||||
|
||||
m_timer->stop();
|
||||
|
||||
// In this phase, some part of downloading process is completed.
|
||||
|
@ -182,12 +182,11 @@ QList<HttpResponse> Downloader::decodeMultipartAnswer(QNetworkReply* reply) {
|
|||
QString boundary = content_type.mid(content_type.indexOf(QL1S("boundary=")) + 9);
|
||||
QRegularExpression regex(QL1S("--") + boundary + QL1S("(--)?(\\r\\n)?"));
|
||||
QStringList list = QString::fromUtf8(data).split(regex, QString::SplitBehavior::SkipEmptyParts);
|
||||
|
||||
QList<HttpResponse> parts;
|
||||
|
||||
parts.reserve(list.size());
|
||||
|
||||
foreach (const QString& http_response_str, list) {
|
||||
for (const QString& http_response_str : list) {
|
||||
// We separate headers and body.
|
||||
HttpResponse new_part;
|
||||
int start_of_http = http_response_str.indexOf(QL1S("HTTP/1.1"));
|
||||
|
@ -198,7 +197,7 @@ QList<HttpResponse> Downloader::decodeMultipartAnswer(QNetworkReply* reply) {
|
|||
start_of_body - start_of_headers).replace(QRegularExpression(QSL("[\\n\\r]+")),
|
||||
QSL("\n"));
|
||||
|
||||
foreach (const QString& header_line, headers.split(QL1C('\n'), QString::SplitBehavior::SkipEmptyParts)) {
|
||||
for (const QString& header_line : headers.split(QL1C('\n'), QString::SplitBehavior::SkipEmptyParts)) {
|
||||
int index_colon = header_line.indexOf(QL1C(':'));
|
||||
|
||||
if (index_colon > 0) {
|
||||
|
|
|
@ -443,7 +443,7 @@ DownloadManager::~DownloadManager() {
|
|||
int DownloadManager::activeDownloads() const {
|
||||
int count = 0;
|
||||
|
||||
foreach (const DownloadItem* download, m_downloads) {
|
||||
for (const DownloadItem* download : m_downloads) {
|
||||
if (download->downloading()) {
|
||||
count++;
|
||||
}
|
||||
|
@ -456,7 +456,7 @@ int DownloadManager::downloadProgress() const {
|
|||
qint64 bytes_total = 0;
|
||||
qint64 bytes_received = 0;
|
||||
|
||||
foreach (const DownloadItem* download, m_downloads) {
|
||||
for (const DownloadItem* download : m_downloads) {
|
||||
if (download->downloading()) {
|
||||
bytes_total += download->bytesTotal();
|
||||
bytes_received += download->bytesReceived();
|
||||
|
@ -787,7 +787,7 @@ QMimeData* DownloadModel::mimeData(const QModelIndexList& indexes) const {
|
|||
auto* mimeData = new QMimeData();
|
||||
QList<QUrl> urls;
|
||||
|
||||
foreach (const QModelIndex& index, indexes) {
|
||||
for (const QModelIndex& index : indexes) {
|
||||
if (!index.isValid()) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ QString NetworkFactory::networkErrorText(QNetworkReply::NetworkError error_code)
|
|||
QNetworkReply::NetworkError NetworkFactory::downloadIcon(const QList<QString>& urls, int timeout, QIcon& output) {
|
||||
QNetworkReply::NetworkError network_result = QNetworkReply::UnknownNetworkError;
|
||||
|
||||
foreach (const QString& url, urls) {
|
||||
for (const QString& url : urls) {
|
||||
const QString google_s2_with_url = QString("http://www.google.com/s2/favicons?domain=%1").arg(QUrl(url).host());
|
||||
QByteArray icon_data;
|
||||
|
||||
|
@ -170,7 +170,7 @@ Downloader* NetworkFactory::performAsyncNetworkOperation(const QString& url, int
|
|||
|
||||
QObject::connect(downloader, &Downloader::completed, downloader, &Downloader::deleteLater);
|
||||
|
||||
foreach (const auto& header, additional_headers) {
|
||||
for (const auto& header : additional_headers) {
|
||||
if (!header.first.isEmpty()) {
|
||||
downloader->appendRawHeader(header.first, header.second);
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ NetworkResult NetworkFactory::performNetworkOperation(const QString& url, int ti
|
|||
// We need to quit event loop when the download finishes.
|
||||
QObject::connect(&downloader, &Downloader::completed, &loop, &QEventLoop::quit);
|
||||
|
||||
foreach (const auto& header, additional_headers) {
|
||||
for (const auto& header : additional_headers) {
|
||||
if (!header.first.isEmpty()) {
|
||||
downloader.appendRawHeader(header.first, header.second);
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ NetworkResult NetworkFactory::performNetworkOperation(const QString& url,
|
|||
// We need to quit event loop when the download finishes.
|
||||
QObject::connect(&downloader, &Downloader::completed, &loop, &QEventLoop::quit);
|
||||
|
||||
foreach (const auto& header, additional_headers) {
|
||||
for (const auto& header : additional_headers) {
|
||||
if (!header.first.isEmpty()) {
|
||||
downloader.appendRawHeader(header.first, header.second);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ void NetworkUrlInterceptor::interceptRequest(QWebEngineUrlRequestInfo& info) {
|
|||
|
||||
// NOTE: Here we can add custom headers for each webengine request, for example "User-Agent".
|
||||
|
||||
foreach (UrlInterceptor* interceptor, m_interceptors) {
|
||||
for (UrlInterceptor* interceptor : m_interceptors) {
|
||||
interceptor->interceptRequest(info);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ void AccountCheckModel::setRootItem(RootItem* root_item) {
|
|||
|
||||
void AccountCheckModel::checkAllItems() {
|
||||
if (m_rootItem != nullptr) {
|
||||
foreach (RootItem* root_child, m_rootItem->childItems()) {
|
||||
for (RootItem* root_child : m_rootItem->childItems()) {
|
||||
if (root_child->kind() == RootItemKind::Feed || root_child->kind() == RootItemKind::Category) {
|
||||
setItemChecked(root_child, Qt::Checked);
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ void AccountCheckModel::checkAllItems() {
|
|||
|
||||
void AccountCheckModel::uncheckAllItems() {
|
||||
if (m_rootItem != nullptr) {
|
||||
foreach (RootItem* root_child, m_rootItem->childItems()) {
|
||||
for (RootItem* root_child : m_rootItem->childItems()) {
|
||||
if (root_child->kind() == RootItemKind::Feed || root_child->kind() == RootItemKind::Category) {
|
||||
setData(indexForItem(root_child), Qt::Unchecked, Qt::CheckStateRole);
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ bool AccountCheckModel::setData(const QModelIndex& index, const QVariant& value,
|
|||
}
|
||||
|
||||
// Set new data for all descendants of this actual item.
|
||||
foreach (RootItem* child, item->childItems()) {
|
||||
for (RootItem* child : item->childItems()) {
|
||||
setData(indexForItem(child), value, Qt::CheckStateRole);
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ bool AccountCheckModel::setData(const QModelIndex& index, const QVariant& value,
|
|||
// Check children of this new parent item.
|
||||
Qt::CheckState parent_state = Qt::Unchecked;
|
||||
|
||||
foreach (RootItem* child_of_parent, item->childItems()) {
|
||||
for (RootItem* child_of_parent : item->childItems()) {
|
||||
if (m_checkStates.contains(child_of_parent) && m_checkStates[child_of_parent] == Qt::Checked) {
|
||||
// We found out, that some child of this item is checked,
|
||||
// therefore this item must be checked too.
|
||||
|
|
|
@ -37,7 +37,7 @@ Category::~Category() = default;
|
|||
void Category::updateCounts(bool including_total_count) {
|
||||
QList<Feed*> feeds;
|
||||
|
||||
foreach (RootItem* child, getSubTree()) {
|
||||
for (RootItem* child : getSubTree()) {
|
||||
if (child->kind() == RootItemKind::Feed) {
|
||||
feeds.append(child->toFeed());
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ void Category::updateCounts(bool including_total_count) {
|
|||
&ok);
|
||||
|
||||
if (ok) {
|
||||
foreach (Feed* feed, feeds) {
|
||||
for (Feed* feed : feeds) {
|
||||
if (counts.contains(feed->customId())) {
|
||||
feed->setCountOfUnreadMessages(counts.value(feed->customId()).first);
|
||||
|
||||
|
|
|
@ -324,7 +324,7 @@ void FormFeedDetails::initialize() {
|
|||
const QList<QByteArray> encodings = QTextCodec::availableCodecs();
|
||||
QStringList encoded_encodings;
|
||||
|
||||
foreach (const QByteArray& encoding, encodings) {
|
||||
for (const QByteArray& encoding : encodings) {
|
||||
encoded_encodings.append(encoding);
|
||||
}
|
||||
|
||||
|
@ -383,7 +383,7 @@ void FormFeedDetails::loadCategories(const QList<Category*>& categories, RootIte
|
|||
root_item->title(),
|
||||
QVariant::fromValue((void*) root_item));
|
||||
|
||||
foreach (Category* category, categories) {
|
||||
for (Category* category : categories) {
|
||||
m_ui->m_cmbParentCategory->addItem(category->icon(),
|
||||
category->title(),
|
||||
QVariant::fromValue((void*) category));
|
||||
|
|
|
@ -67,7 +67,7 @@ bool RootItem::deleteViaGui() {
|
|||
bool RootItem::markAsReadUnread(ReadStatus status) {
|
||||
bool result = true;
|
||||
|
||||
foreach (RootItem* child, m_childItems) {
|
||||
for (RootItem* child : m_childItems) {
|
||||
result &= child->markAsReadUnread(status);
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ bool RootItem::markAsReadUnread(ReadStatus status) {
|
|||
QList<Message> RootItem::undeletedMessages() const {
|
||||
QList<Message> messages;
|
||||
|
||||
foreach (RootItem* child, m_childItems) {
|
||||
for (RootItem* child : m_childItems) {
|
||||
messages.append(child->undeletedMessages());
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ QList<Message> RootItem::undeletedMessages() const {
|
|||
bool RootItem::cleanMessages(bool clear_only_read) {
|
||||
bool result = true;
|
||||
|
||||
foreach (RootItem* child, m_childItems) {
|
||||
for (RootItem* child : m_childItems) {
|
||||
if (child->kind() != RootItemKind::Bin) {
|
||||
result &= child->cleanMessages(clear_only_read);
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ bool RootItem::cleanMessages(bool clear_only_read) {
|
|||
}
|
||||
|
||||
void RootItem::updateCounts(bool including_total_count) {
|
||||
foreach (RootItem* child, m_childItems) {
|
||||
for (RootItem* child : m_childItems) {
|
||||
child->updateCounts(including_total_count);
|
||||
}
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ bool RootItem::performDragDropChange(RootItem* target_item) {
|
|||
int RootItem::countOfAllMessages() const {
|
||||
int total_count = 0;
|
||||
|
||||
foreach (RootItem* child_item, m_childItems) {
|
||||
for (RootItem* child_item : m_childItems) {
|
||||
total_count += child_item->countOfAllMessages();
|
||||
}
|
||||
|
||||
|
@ -460,7 +460,7 @@ void RootItem::setKeepOnTop(bool keep_on_top) {
|
|||
int RootItem::countOfUnreadMessages() const {
|
||||
int total_count = 0;
|
||||
|
||||
foreach (RootItem* child_item, m_childItems) {
|
||||
for (RootItem* child_item : m_childItems) {
|
||||
total_count += child_item->countOfUnreadMessages();
|
||||
}
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ void ServiceRoot::stop() {}
|
|||
void ServiceRoot::updateCounts(bool including_total_count) {
|
||||
QList<Feed*> feeds;
|
||||
|
||||
foreach (RootItem* child, getSubTree()) {
|
||||
for (RootItem* child : getSubTree()) {
|
||||
if (child->kind() == RootItemKind::Feed) {
|
||||
feeds.append(child->toFeed());
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ void ServiceRoot::updateCounts(bool including_total_count) {
|
|||
QMap<QString, QPair<int, int>> counts = DatabaseQueries::getMessageCountsForAccount(database, accountId(), including_total_count, &ok);
|
||||
|
||||
if (ok) {
|
||||
foreach (Feed* feed, feeds) {
|
||||
for (Feed* feed : feeds) {
|
||||
if (counts.contains(feed->customId())) {
|
||||
feed->setCountOfUnreadMessages(counts.value(feed->customId()).first);
|
||||
|
||||
|
@ -137,7 +137,7 @@ void ServiceRoot::removeOldFeedTree(bool including_messages) {
|
|||
}
|
||||
|
||||
void ServiceRoot::cleanAllItems() {
|
||||
foreach (RootItem* top_level_item, childItems()) {
|
||||
for (RootItem* top_level_item : childItems()) {
|
||||
if (top_level_item->kind() != RootItemKind::Bin) {
|
||||
requestItemRemoval(top_level_item);
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ bool ServiceRoot::cleanFeeds(QList<Feed*> items, bool clean_read_only) {
|
|||
// Messages are cleared, now inform model about need to reload data.
|
||||
QList<RootItem*> itemss;
|
||||
|
||||
foreach (Feed* feed, items) {
|
||||
for (Feed* feed : items) {
|
||||
feed->updateCounts(true);
|
||||
itemss.append(feed);
|
||||
}
|
||||
|
@ -239,7 +239,7 @@ void ServiceRoot::addNewCategory() {}
|
|||
QMap<QString, QVariant> ServiceRoot::storeCustomFeedsData() {
|
||||
QMap<QString, QVariant> custom_data;
|
||||
|
||||
foreach (const Feed* feed, getSubTreeFeeds()) {
|
||||
for (const Feed* feed : getSubTreeFeeds()) {
|
||||
QVariantMap feed_custom_data;
|
||||
|
||||
feed_custom_data.insert(QSL("auto_update_interval"), feed->autoUpdateInitialInterval());
|
||||
|
@ -294,7 +294,7 @@ void ServiceRoot::syncIn() {
|
|||
// so remove left over messages.
|
||||
removeLeftOverMessages();
|
||||
|
||||
foreach (RootItem* top_level_item, new_tree->childItems()) {
|
||||
for (RootItem* top_level_item : new_tree->childItems()) {
|
||||
top_level_item->setParent(nullptr);
|
||||
requestItemReassignment(top_level_item, this);
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ void ServiceRoot::syncIn() {
|
|||
// Now we must refresh expand states.
|
||||
QList<RootItem*> items_to_expand;
|
||||
|
||||
foreach (RootItem* item, all_items) {
|
||||
for (RootItem* item : all_items) {
|
||||
if (qApp->settings()->value(GROUP(CategoriesExpandStates), item->hashCode(), item->childCount() > 0).toBool()) {
|
||||
items_to_expand.append(item);
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ QStringList ServiceRoot::customIDSOfMessagesForItem(RootItem* item) {
|
|||
|
||||
switch (item->kind()) {
|
||||
case RootItemKind::Category: {
|
||||
foreach (RootItem* child, item->childItems()) {
|
||||
for (RootItem* child : item->childItems()) {
|
||||
list.append(customIDSOfMessagesForItem(child));
|
||||
}
|
||||
|
||||
|
@ -383,7 +383,7 @@ bool ServiceRoot::markFeedsReadUnread(QList<Feed*> items, RootItem::ReadStatus r
|
|||
if (DatabaseQueries::markFeedsReadUnread(database, textualFeedIds(items), accountId(), read)) {
|
||||
QList<RootItem*> itemss;
|
||||
|
||||
foreach (Feed* feed, items) {
|
||||
for (Feed* feed : items) {
|
||||
feed->updateCounts(false);
|
||||
itemss.append(feed);
|
||||
}
|
||||
|
@ -402,7 +402,7 @@ QStringList ServiceRoot::textualFeedUrls(const QList<Feed*>& feeds) const {
|
|||
|
||||
stringy_urls.reserve(feeds.size());
|
||||
|
||||
foreach (const Feed* feed, feeds) {
|
||||
for (const Feed* feed : feeds) {
|
||||
stringy_urls.append(!feed->url().isEmpty() ? feed->url() : QL1S("no-url"));
|
||||
}
|
||||
|
||||
|
@ -414,7 +414,7 @@ QStringList ServiceRoot::textualFeedIds(const QList<Feed*>& feeds) const {
|
|||
|
||||
stringy_ids.reserve(feeds.size());
|
||||
|
||||
foreach (const Feed* feed, feeds) {
|
||||
for (const Feed* feed : feeds) {
|
||||
stringy_ids.append(QString("'%1'").arg(feed->customId()));
|
||||
}
|
||||
|
||||
|
@ -434,7 +434,7 @@ QStringList ServiceRoot::customIDsOfMessages(const QList<ImportanceChange>& chan
|
|||
QStringList ServiceRoot::customIDsOfMessages(const QList<Message>& messages) {
|
||||
QStringList list;
|
||||
|
||||
foreach (const Message& message, messages) {
|
||||
for (const Message& message : messages) {
|
||||
list.append(message.m_customId);
|
||||
}
|
||||
|
||||
|
@ -500,7 +500,7 @@ bool ServiceRoot::onBeforeSwitchMessageImportance(RootItem* selected_item, const
|
|||
QList<Message> mark_starred_msgs;
|
||||
QList<Message> mark_unstarred_msgs;
|
||||
|
||||
foreach (const ImportanceChange& pair, changes) {
|
||||
for (const ImportanceChange& pair : changes) {
|
||||
if (pair.second == RootItem::Important) {
|
||||
mark_starred_msgs.append(pair.first);
|
||||
}
|
||||
|
@ -574,7 +574,7 @@ bool ServiceRoot::onAfterMessagesRestoredFromBin(RootItem* selected_item, const
|
|||
void ServiceRoot::assembleFeeds(Assignment feeds) {
|
||||
QHash<int, Category*> categories = getHashedSubTreeCategories();
|
||||
|
||||
foreach (const AssignmentItem& feed, feeds) {
|
||||
for (const AssignmentItem& feed : feeds) {
|
||||
if (feed.first == NO_PARENT_CATEGORY) {
|
||||
// This is top-level feed, add it to the root item.
|
||||
appendChild(feed.second);
|
||||
|
|
|
@ -65,7 +65,7 @@ void GmailServiceRoot::loadFromDatabase() {
|
|||
assembleCategories(categories);
|
||||
assembleFeeds(feeds);
|
||||
|
||||
foreach (RootItem* feed, childItems()) {
|
||||
for (RootItem* feed : childItems()) {
|
||||
if (feed->customId() == QL1S("INBOX")) {
|
||||
feed->setKeepOnTop(true);
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ void GmailServiceRoot::saveAllCachedData(bool async) {
|
|||
if (!messages.isEmpty()) {
|
||||
QStringList custom_ids;
|
||||
|
||||
foreach (const Message& msg, messages) {
|
||||
for (const Message& msg : messages) {
|
||||
custom_ids.append(msg.m_customId);
|
||||
}
|
||||
|
||||
|
|
|
@ -289,14 +289,14 @@ void GmailNetworkFactory::onAuthFailed() {
|
|||
bool GmailNetworkFactory::fillFullMessage(Message& msg, const QJsonObject& json, const QString& feed_id) {
|
||||
QHash<QString, QString> headers;
|
||||
|
||||
foreach (const QJsonValue& header, json["payload"].toObject()["headers"].toArray()) {
|
||||
for (const QJsonValue& header : json["payload"].toObject()["headers"].toArray()) {
|
||||
headers.insert(header.toObject()["name"].toString(), header.toObject()["value"].toString());
|
||||
}
|
||||
|
||||
msg.m_isRead = true;
|
||||
|
||||
// Assign correct main labels/states.
|
||||
foreach (const QVariant& label, json["labelIds"].toArray().toVariantList()) {
|
||||
for (const QVariant& label : json["labelIds"].toArray().toVariantList()) {
|
||||
QString lbl = label.toString();
|
||||
|
||||
if (lbl == QL1S(GMAIL_SYSTEM_LABEL_UNREAD)) {
|
||||
|
@ -338,7 +338,7 @@ bool GmailNetworkFactory::fillFullMessage(Message& msg, const QJsonObject& json,
|
|||
parts.append(json["payload"].toObject());
|
||||
}
|
||||
|
||||
foreach (const QJsonValue& part, parts) {
|
||||
for (const QJsonValue& part : parts) {
|
||||
QJsonObject part_obj = part.toObject();
|
||||
QJsonObject body = part_obj["body"].toObject();
|
||||
QString filename = part_obj["filename"].toString();
|
||||
|
@ -380,7 +380,7 @@ bool GmailNetworkFactory::obtainAndDecodeFullMessages(const QList<Message>& lite
|
|||
|
||||
QHash<QString, Message> msgs;
|
||||
|
||||
foreach (const Message& msg, lite_messages) {
|
||||
for (const Message& msg : lite_messages) {
|
||||
QHttpPart part;
|
||||
|
||||
part.setRawHeader(HTTP_HEADERS_CONTENT_TYPE, GMAIL_CONTENT_TYPE_HTTP);
|
||||
|
@ -413,7 +413,7 @@ bool GmailNetworkFactory::obtainAndDecodeFullMessages(const QList<Message>& lite
|
|||
|
||||
if (res.first == QNetworkReply::NetworkError::NoError) {
|
||||
// We parse each part of HTTP response (it contains HTTP headers and payload with msg full data).
|
||||
foreach (const HttpResponse& part, output) {
|
||||
for (const HttpResponse& part : output) {
|
||||
QJsonObject msg_doc = QJsonDocument::fromJson(part.body().toUtf8()).object();
|
||||
QString msg_id = msg_doc["id"].toString();
|
||||
|
||||
|
@ -442,7 +442,7 @@ QList<Message> GmailNetworkFactory::decodeLiteMessages(const QString& messages_j
|
|||
next_page_token = top_object["nextPageToken"].toString();
|
||||
messages.reserve(json_msgs.count());
|
||||
|
||||
foreach (const QJsonValue& obj, json_msgs) {
|
||||
for (const QJsonValue& obj : json_msgs) {
|
||||
auto message_obj = obj.toObject();
|
||||
Message message;
|
||||
|
||||
|
@ -463,7 +463,7 @@ QList<Message> GmailNetworkFactory::decodeLiteMessages(const QString& messages_j
|
|||
QMap<QString, RootItem*> cats;
|
||||
cats.insert(QString(), parent);
|
||||
|
||||
foreach (const QJsonValue& obj, json) {
|
||||
for (const QJsonValue& obj : json) {
|
||||
auto label = obj.toObject();
|
||||
QString label_id = label["id"].toString();
|
||||
QString label_name = label["name"].toString();
|
||||
|
@ -499,7 +499,7 @@ QList<Message> GmailNetworkFactory::decodeLiteMessages(const QString& messages_j
|
|||
|
||||
json = QJsonDocument::fromJson(feeds.toUtf8()).object()["subscriptions"].toArray();
|
||||
|
||||
foreach (const QJsonValue& obj, json) {
|
||||
for (const QJsonValue& obj : json) {
|
||||
auto subscription = obj.toObject();
|
||||
QString id = subscription["id"].toString();
|
||||
QString title = subscription["title"].toString();
|
||||
|
@ -507,7 +507,7 @@ QList<Message> GmailNetworkFactory::decodeLiteMessages(const QString& messages_j
|
|||
QString parent_label;
|
||||
QJsonArray categories = subscription["categories"].toArray();
|
||||
|
||||
foreach (const QJsonValue& cat, categories) {
|
||||
for (const QJsonValue& cat : categories) {
|
||||
QString potential_id = cat.toObject()["id"].toString();
|
||||
|
||||
if (potential_id.contains(QSL("/label/"))) {
|
||||
|
|
|
@ -192,7 +192,7 @@ void InoreaderServiceRoot::saveAllCachedData(bool async) {
|
|||
if (!messages.isEmpty()) {
|
||||
QStringList custom_ids;
|
||||
|
||||
foreach (const Message& msg, messages) {
|
||||
for (const Message& msg : messages) {
|
||||
custom_ids.append(msg.m_customId);
|
||||
}
|
||||
|
||||
|
|
|
@ -162,7 +162,7 @@ void InoreaderNetworkFactory::markMessagesRead(RootItem::ReadStatus status, cons
|
|||
QStringList trimmed_ids;
|
||||
QRegularExpression regex_short_id(QSL("[0-9a-zA-Z]+$"));
|
||||
|
||||
foreach (const QString& id, custom_ids) {
|
||||
for (const QString& id : custom_ids) {
|
||||
QString simplified_id = regex_short_id.match(id).captured();
|
||||
|
||||
trimmed_ids.append(QString("i=") + simplified_id);
|
||||
|
@ -230,7 +230,7 @@ void InoreaderNetworkFactory::markMessagesStarred(RootItem::Importance importanc
|
|||
QStringList trimmed_ids;
|
||||
QRegularExpression regex_short_id(QSL("[0-9a-zA-Z]+$"));
|
||||
|
||||
foreach (const QString& id, custom_ids) {
|
||||
for (const QString& id : custom_ids) {
|
||||
QString simplified_id = regex_short_id.match(id).captured();
|
||||
|
||||
trimmed_ids.append(QString("i=") + simplified_id);
|
||||
|
@ -305,7 +305,7 @@ QList<Message> InoreaderNetworkFactory::decodeMessages(const QString& messages_j
|
|||
|
||||
messages.reserve(json.count());
|
||||
|
||||
foreach (const QJsonValue& obj, json) {
|
||||
for (const QJsonValue& obj : json) {
|
||||
auto message_obj = obj.toObject();
|
||||
Message message;
|
||||
|
||||
|
@ -319,7 +319,7 @@ QList<Message> InoreaderNetworkFactory::decodeMessages(const QString& messages_j
|
|||
auto enclosures = message_obj["enclosure"].toArray();
|
||||
auto categories = message_obj["categories"].toArray();
|
||||
|
||||
foreach (const QJsonValue& alt, alternates) {
|
||||
for (const QJsonValue& alt : alternates) {
|
||||
auto alt_obj = alt.toObject();
|
||||
QString mime = alt_obj["type"].toString();
|
||||
QString href = alt_obj["href"].toString();
|
||||
|
@ -332,7 +332,7 @@ QList<Message> InoreaderNetworkFactory::decodeMessages(const QString& messages_j
|
|||
}
|
||||
}
|
||||
|
||||
foreach (const QJsonValue& enc, enclosures) {
|
||||
for (const QJsonValue& enc : enclosures) {
|
||||
auto enc_obj = enc.toObject();
|
||||
QString mime = enc_obj["type"].toString();
|
||||
QString href = enc_obj["href"].toString();
|
||||
|
@ -340,7 +340,7 @@ QList<Message> InoreaderNetworkFactory::decodeMessages(const QString& messages_j
|
|||
message.m_enclosures.append(Enclosure(href, mime));
|
||||
}
|
||||
|
||||
foreach (const QJsonValue& cat, categories) {
|
||||
for (const QJsonValue& cat : categories) {
|
||||
QString category = cat.toString();
|
||||
|
||||
if (category.contains(INOREADER_STATE_READ)) {
|
||||
|
@ -367,7 +367,7 @@ RootItem* InoreaderNetworkFactory::decodeFeedCategoriesData(const QString& categ
|
|||
QMap<QString, RootItem*> cats;
|
||||
cats.insert(QString(), parent);
|
||||
|
||||
foreach (const QJsonValue& obj, json) {
|
||||
for (const QJsonValue& obj : json) {
|
||||
auto label = obj.toObject();
|
||||
QString label_id = label["id"].toString();
|
||||
|
||||
|
@ -388,7 +388,7 @@ RootItem* InoreaderNetworkFactory::decodeFeedCategoriesData(const QString& categ
|
|||
|
||||
json = QJsonDocument::fromJson(feeds.toUtf8()).object()["subscriptions"].toArray();
|
||||
|
||||
foreach (const QJsonValue& obj, json) {
|
||||
for (const QJsonValue& obj : json) {
|
||||
auto subscription = obj.toObject();
|
||||
QString id = subscription["id"].toString();
|
||||
QString title = subscription["title"].toString();
|
||||
|
@ -396,7 +396,7 @@ RootItem* InoreaderNetworkFactory::decodeFeedCategoriesData(const QString& categ
|
|||
QString parent_label;
|
||||
QJsonArray categories = subscription["categories"].toArray();
|
||||
|
||||
foreach (const QJsonValue& cat, categories) {
|
||||
for (const QJsonValue& cat : categories) {
|
||||
QString potential_id = cat.toObject()["id"].toString();
|
||||
|
||||
if (potential_id.contains(QSL("/label/"))) {
|
||||
|
|
|
@ -334,7 +334,7 @@ void OwnCloudNetworkFactory::markMessagesRead(RootItem::ReadStatus status, const
|
|||
final_url = m_fixedUrl + OWNCLOUD_API_PATH + "items/unread/multiple";
|
||||
}
|
||||
|
||||
foreach (const QString& id, custom_ids) {
|
||||
for (const QString& id : custom_ids) {
|
||||
ids.append(QJsonValue(id.toInt()));
|
||||
}
|
||||
|
||||
|
@ -527,7 +527,7 @@ RootItem* OwnCloudGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons)
|
|||
cats.insert(QSL("0"), parent);
|
||||
|
||||
// Process categories first, then process feeds.
|
||||
foreach (const QJsonValue& cat, QJsonDocument::fromJson(m_contentCategories.toUtf8()).object()["folders"].toArray()) {
|
||||
for (const QJsonValue& cat : QJsonDocument::fromJson(m_contentCategories.toUtf8()).object()["folders"].toArray()) {
|
||||
QJsonObject item = cat.toObject();
|
||||
auto* category = new Category();
|
||||
|
||||
|
@ -540,7 +540,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()) {
|
||||
for (const QJsonValue& fed : QJsonDocument::fromJson(m_contentFeeds.toUtf8()).object()["feeds"].toArray()) {
|
||||
QJsonObject item = fed.toObject();
|
||||
auto* feed = new OwnCloudFeed();
|
||||
|
||||
|
@ -580,7 +580,7 @@ OwnCloudGetMessagesResponse::~OwnCloudGetMessagesResponse() = default;
|
|||
QList<Message>OwnCloudGetMessagesResponse::messages() const {
|
||||
QList<Message>msgs;
|
||||
|
||||
foreach (const QJsonValue& message, m_rawContent["items"].toArray()) {
|
||||
for (const QJsonValue& message : m_rawContent["items"].toArray()) {
|
||||
QJsonObject message_map = message.toObject();
|
||||
Message msg;
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ void OwnCloudServiceRoot::saveAllCachedData(bool async) {
|
|||
if (!messages.isEmpty()) {
|
||||
QStringList feed_ids, guid_hashes;
|
||||
|
||||
foreach (const Message& msg, messages) {
|
||||
for (const Message& msg : messages) {
|
||||
feed_ids.append(msg.m_feedId);
|
||||
guid_hashes.append(msg.m_customHash);
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ QStringList FeedParser::textsFromPath(const QDomElement& element, const QString&
|
|||
QList<QDomElement> next_elements;
|
||||
QString next_local_name = paths.takeFirst();
|
||||
|
||||
foreach (const QDomElement& elem, current_elements) {
|
||||
for (const QDomElement& elem : current_elements) {
|
||||
QDomNodeList elements = elem.elementsByTagNameNS(namespace_uri, next_local_name);
|
||||
|
||||
for (int i = 0; i < elements.size(); i++) {
|
||||
|
@ -112,7 +112,7 @@ QStringList FeedParser::textsFromPath(const QDomElement& element, const QString&
|
|||
}
|
||||
|
||||
if (!current_elements.isEmpty()) {
|
||||
foreach (const QDomElement& elem, current_elements) {
|
||||
for (const QDomElement& elem : current_elements) {
|
||||
result.append(elem.text());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -222,7 +222,7 @@ void FormStandardCategoryDetails::loadCategories(const QList<Category*>& categor
|
|||
root_item->title(),
|
||||
QVariant::fromValue((void*) root_item));
|
||||
|
||||
foreach (Category* category, categories) {
|
||||
for (Category* category : categories) {
|
||||
if (input_category != nullptr && (category == input_category || category->isChildOf(input_category))) {
|
||||
// This category cannot be selected as the new
|
||||
// parent for currently edited category, so
|
||||
|
|
|
@ -288,7 +288,7 @@ void FormStandardImportExport::importFeeds() {
|
|||
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) {
|
||||
for (Category* category : categories) {
|
||||
m_ui->m_cmbRootNode->addItem(category->icon(), category->title(), QVariant::fromValue((void*) category));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ bool StandardCategory::removeItself() {
|
|||
|
||||
// Remove all child items (feeds and categories)
|
||||
// from the database.
|
||||
foreach (RootItem* child, childItems()) {
|
||||
for (RootItem* child : childItems()) {
|
||||
if (child->kind() == RootItemKind::Category) {
|
||||
children_removed &= dynamic_cast<StandardCategory*>(child)->removeItself();
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ bool FeedsImportExportModel::exportToOMPL20(QByteArray& result) {
|
|||
QDomElement active_element = elements_to_use.pop();
|
||||
RootItem* active_item = items_to_process.pop();
|
||||
|
||||
foreach (RootItem* child_item, active_item->childItems()) {
|
||||
for (RootItem* child_item : active_item->childItems()) {
|
||||
if (!isItemChecked(child_item)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -261,7 +261,7 @@ void FeedsImportExportModel::importAsOPML20(const QByteArray& data, bool fetch_m
|
|||
}
|
||||
|
||||
bool FeedsImportExportModel::exportToTxtURLPerLine(QByteArray& result) {
|
||||
foreach (const Feed* const feed, m_rootItem->getSubTreeFeeds()) {
|
||||
for (const Feed* const feed : m_rootItem->getSubTreeFeeds()) {
|
||||
result += feed->url() + QL1S("\n");
|
||||
}
|
||||
|
||||
|
@ -279,7 +279,7 @@ void FeedsImportExportModel::importAsTxtURLPerLine(const QByteArray& data, bool
|
|||
|
||||
QList<QByteArray> urls = data.split('\n');
|
||||
|
||||
foreach (const QByteArray& url, urls) {
|
||||
for (const QByteArray& url : urls) {
|
||||
if (!url.isEmpty()) {
|
||||
QPair<StandardFeed*, QNetworkReply::NetworkError> guessed;
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ void StandardServiceRoot::loadFromDatabase() {
|
|||
}
|
||||
|
||||
void StandardServiceRoot::checkArgumentsForFeedAdding() {
|
||||
foreach (const QString& arg, qApp->arguments().mid(1)) {
|
||||
for (const QString& arg : qApp->arguments().mid(1)) {
|
||||
checkArgumentForFeedAdding(arg);
|
||||
}
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ bool StandardServiceRoot::mergeImportExportModel(FeedsImportExportModel* model,
|
|||
RootItem* target_parent = original_parents.pop();
|
||||
RootItem* source_parent = new_parents.pop();
|
||||
|
||||
foreach (RootItem* source_item, source_parent->childItems()) {
|
||||
for (RootItem* source_item : source_parent->childItems()) {
|
||||
if (!model->isItemChecked(source_item)) {
|
||||
// We can skip this item, because it is not checked and should not be imported.
|
||||
// NOTE: All descendants are thus skipped too.
|
||||
|
@ -225,7 +225,7 @@ bool StandardServiceRoot::mergeImportExportModel(FeedsImportExportModel* model,
|
|||
// add descendants to it.
|
||||
RootItem* existing_category = nullptr;
|
||||
|
||||
foreach (RootItem* child, target_parent->childItems()) {
|
||||
for (RootItem* child : target_parent->childItems()) {
|
||||
if (child->kind() == RootItemKind::Category && child->title() == new_category_title) {
|
||||
existing_category = child;
|
||||
}
|
||||
|
|
|
@ -487,7 +487,7 @@ RootItem* TtRssGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons, QS
|
|||
|
||||
QVector<QPair<RootItem*, QJsonValue>> pairs;
|
||||
|
||||
foreach (const QJsonValue& item, items_to_process) {
|
||||
for (const QJsonValue& item : items_to_process) {
|
||||
pairs.append(QPair<RootItem*, QJsonValue>(parent, item));
|
||||
}
|
||||
|
||||
|
@ -503,7 +503,7 @@ RootItem* TtRssGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons, QS
|
|||
if (item_id == 0) {
|
||||
// This is "Uncategorized" category, all its feeds belong to top-level root.
|
||||
if (item.contains("items")) {
|
||||
foreach (const QJsonValue& child_feed, item["items"].toArray()) {
|
||||
for (const QJsonValue& child_feed : item["items"].toArray()) {
|
||||
pairs.append(QPair<RootItem*, QJsonValue>(parent, child_feed));
|
||||
}
|
||||
}
|
||||
|
@ -516,7 +516,7 @@ RootItem* TtRssGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons, QS
|
|||
act_parent->appendChild(category);
|
||||
|
||||
if (item.contains("items")) {
|
||||
foreach (const QJsonValue& child, item["items"].toArray()) {
|
||||
for (const QJsonValue& child : item["items"].toArray()) {
|
||||
pairs.append(QPair<RootItem*, QJsonValue>(category, child));
|
||||
}
|
||||
}
|
||||
|
@ -564,7 +564,7 @@ TtRssGetHeadlinesResponse::~TtRssGetHeadlinesResponse() = default;
|
|||
QList<Message> TtRssGetHeadlinesResponse::messages() const {
|
||||
QList<Message> messages;
|
||||
|
||||
foreach (const QJsonValue& item, m_rawContent["content"].toArray()) {
|
||||
for (const QJsonValue& item : m_rawContent["content"].toArray()) {
|
||||
QJsonObject mapped = item.toObject();
|
||||
Message message;
|
||||
|
||||
|
@ -586,7 +586,7 @@ QList<Message> TtRssGetHeadlinesResponse::messages() const {
|
|||
|
||||
if (mapped.contains(QSL("attachments"))) {
|
||||
// Process enclosures.
|
||||
foreach (const QJsonValue& attachment, mapped["attachments"].toArray()) {
|
||||
for (const QJsonValue& attachment : mapped["attachments"].toArray()) {
|
||||
QJsonObject mapped_attachemnt = attachment.toObject();
|
||||
Enclosure enclosure;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue