1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

tools: port foreach -> range-based for

Signed-off-by: Juraj Oravec <sgd.orava@gmail.com>
This commit is contained in:
Juraj Oravec 2019-12-30 21:21:06 +01:00
parent 7f654409c5
commit ef48b4725e
No known key found for this signature in database
GPG Key ID: 63ACB65056BC8D07
5 changed files with 16 additions and 12 deletions

View File

@ -76,7 +76,7 @@ void ButtonWithMenu::addItem(const Item &item)
void ButtonWithMenu::addItems(const QVector<Item> &items)
{
foreach (const Item &item, items) {
for (const Item &item : items) {
addItem(item);
}
}
@ -158,7 +158,7 @@ void ButtonWithMenu::generateMenu()
{
m_menu->clear();
foreach (const Item &item, m_items) {
for (const Item &item : qAsConst(m_items)) {
QVariant variant;
variant.setValue<Item>(item);
m_menu->addAction(item.icon, item.text, this, SLOT(setCurrentItem()))->setData(variant);

View File

@ -53,7 +53,8 @@ void HTML5PermissionsDialog::showFeaturePermissions(QWebEnginePage::Feature feat
ui->treeWidget->clear();
foreach (const QString &site, m_granted.value(feature)) {
const auto grantedSites = m_granted.value(feature);
for (const QString &site : grantedSites) {
QTreeWidgetItem* item = new QTreeWidgetItem(ui->treeWidget);
item->setText(0, site);
item->setText(1, tr("Allow"));
@ -61,7 +62,8 @@ void HTML5PermissionsDialog::showFeaturePermissions(QWebEnginePage::Feature feat
ui->treeWidget->addTopLevelItem(item);
}
foreach (const QString &site, m_denied.value(feature)) {
const auto deniedSites = m_denied.value(feature);
for (const QString &site : deniedSites) {
QTreeWidgetItem* item = new QTreeWidgetItem(ui->treeWidget);
item->setText(0, site);
item->setText(1, tr("Deny"));

View File

@ -195,7 +195,8 @@ QImage IconProvider::imageForUrl(const QUrl &url, bool allowNull)
return img->isNull() && !allowNull ? IconProvider::emptyWebImage() : *img;
}
foreach (const BufferedIcon &ic, instance()->m_iconBuffer) {
const auto iconBuffer = instance()->m_iconBuffer;
for (const BufferedIcon &ic : iconBuffer) {
if (encodeUrl(ic.first) == encodedUrl) {
return ic.second;
}
@ -228,7 +229,8 @@ QImage IconProvider::imageForDomain(const QUrl &url, bool allowNull)
QMutexLocker locker(&instance()->m_iconCacheMutex);
foreach (const BufferedIcon &ic, instance()->m_iconBuffer) {
const auto iconBuffer = instance()->m_iconBuffer;
for (const BufferedIcon &ic : iconBuffer) {
if (ic.first.host() == url.host()) {
return ic.second;
}
@ -255,7 +257,7 @@ void IconProvider::saveIconsToDatabase()
{
QMutexLocker locker(&instance()->m_iconCacheMutex);
foreach (const BufferedIcon &ic, m_iconBuffer) {
for (const BufferedIcon &ic : qAsConst(m_iconBuffer)) {
QByteArray ba;
QBuffer buffer(&ba);
buffer.open(QIODevice::WriteOnly);

View File

@ -515,9 +515,9 @@ QString QzTools::resolveFromPath(const QString &name)
return QString();
}
QStringList dirs = path.split(QLatin1Char(':'), QString::SkipEmptyParts);
const QStringList dirs = path.split(QLatin1Char(':'), QString::SkipEmptyParts);
foreach (const QString &dir, dirs) {
for (const QString &dir : dirs) {
QDir d(dir);
if (d.exists(name)) {
return d.absoluteFilePath(name);
@ -609,7 +609,7 @@ bool QzTools::isUtf8(const char* string)
bool QzTools::containsSpace(const QString &str)
{
Q_FOREACH (const QChar &c, str) {
for (const QChar &c : str) {
if (c.isSpace())
return true;
}

View File

@ -103,10 +103,10 @@ QList<QTreeWidgetItem*> TreeWidget::allItems()
void TreeWidget::filterString(const QString &string)
{
QList<QTreeWidgetItem*> _allItems = allItems();
const QList<QTreeWidgetItem*> _allItems = allItems();
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) {
item->setHidden(false);