[plasma-framework] make it compiles without foreach
Summary: compile without foreach Test Plan: autotest ok Reviewers: dfaure, apol Reviewed By: dfaure, apol Subscribers: ahmadsamir, nicolasfella, broulik, apol, kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D19913
This commit is contained in:
parent
298ce0ed7f
commit
48f60533b9
@ -39,7 +39,7 @@ if(KDE_PLATFORM_FEATURE_DISABLE_DEPRECATED)
|
||||
set(KDE_NO_DEPRECATED TRUE)
|
||||
set(CMAKE_AUTOMOC_MOC_OPTIONS "-DKDE_NO_DEPRECATED")
|
||||
endif()
|
||||
|
||||
add_definitions(-DQT_NO_FOREACH)
|
||||
################# now find all used packages #################
|
||||
|
||||
set (REQUIRED_QT_VERSION 5.12.0)
|
||||
|
@ -142,7 +142,8 @@ void CoronaTest::restore()
|
||||
m_corona->loadLayout(QStringLiteral("plasma-test-appletsrc"));
|
||||
QCOMPARE(m_corona->containments().count(), 3);
|
||||
|
||||
foreach (auto cont, m_corona->containments()) {
|
||||
const auto containments = m_corona->containments();
|
||||
for (auto cont : containments) {
|
||||
switch (cont->id()) {
|
||||
case 1:
|
||||
QCOMPARE(cont->applets().count(), 2);
|
||||
@ -208,9 +209,11 @@ void CoronaTest::immutability()
|
||||
m_corona->setImmutability(Plasma::Types::UserImmutable);
|
||||
QCOMPARE(m_corona->immutability(), Plasma::Types::UserImmutable);
|
||||
|
||||
foreach (Plasma::Containment *cont, m_corona->containments()) {
|
||||
auto containments = m_corona->containments();
|
||||
for (Plasma::Containment *cont : qAsConst(containments)) {
|
||||
QCOMPARE(cont->immutability(), Plasma::Types::UserImmutable);
|
||||
foreach (Plasma::Applet *app, cont->applets()) {
|
||||
const auto lstApplets = cont->applets();
|
||||
for (Plasma::Applet *app : lstApplets) {
|
||||
QCOMPARE(app->immutability(), Plasma::Types::UserImmutable);
|
||||
}
|
||||
}
|
||||
@ -218,9 +221,11 @@ void CoronaTest::immutability()
|
||||
m_corona->setImmutability(Plasma::Types::Mutable);
|
||||
QCOMPARE(m_corona->immutability(), Plasma::Types::Mutable);
|
||||
|
||||
foreach (Plasma::Containment *cont, m_corona->containments()) {
|
||||
containments = m_corona->containments();
|
||||
for (Plasma::Containment *cont : qAsConst(containments)) {
|
||||
QCOMPARE(cont->immutability(), Plasma::Types::Mutable);
|
||||
foreach (Plasma::Applet *app, cont->applets()) {
|
||||
const auto lstApplets = cont->applets();
|
||||
for (Plasma::Applet *app : lstApplets) {
|
||||
QCOMPARE(app->immutability(), Plasma::Types::Mutable);
|
||||
}
|
||||
}
|
||||
@ -228,9 +233,11 @@ void CoronaTest::immutability()
|
||||
m_corona->setImmutability(Plasma::Types::SystemImmutable);
|
||||
QCOMPARE(m_corona->immutability(), Plasma::Types::SystemImmutable);
|
||||
|
||||
foreach (Plasma::Containment *cont, m_corona->containments()) {
|
||||
containments = m_corona->containments();
|
||||
for (Plasma::Containment *cont : qAsConst(containments)) {
|
||||
QCOMPARE(cont->immutability(), Plasma::Types::SystemImmutable);
|
||||
foreach (Plasma::Applet *app, cont->applets()) {
|
||||
const auto lstApplets = cont->applets();
|
||||
for (Plasma::Applet *app : lstApplets) {
|
||||
QCOMPARE(app->immutability(), Plasma::Types::SystemImmutable);
|
||||
}
|
||||
}
|
||||
@ -239,9 +246,11 @@ void CoronaTest::immutability()
|
||||
m_corona->setImmutability(Plasma::Types::Mutable);
|
||||
QCOMPARE(m_corona->immutability(), Plasma::Types::SystemImmutable);
|
||||
|
||||
foreach (Plasma::Containment *cont, m_corona->containments()) {
|
||||
containments = m_corona->containments();
|
||||
for (Plasma::Containment *cont : qAsConst(containments)) {
|
||||
QCOMPARE(cont->immutability(), Plasma::Types::SystemImmutable);
|
||||
foreach (Plasma::Applet *app, cont->applets()) {
|
||||
const auto lstApplets = cont->applets();
|
||||
for (Plasma::Applet *app : lstApplets) {
|
||||
QCOMPARE(app->immutability(), Plasma::Types::SystemImmutable);
|
||||
}
|
||||
}
|
||||
|
@ -31,13 +31,15 @@ static void copyPath(const QString &src, const QString &dst)
|
||||
{
|
||||
QDir dir(src);
|
||||
|
||||
foreach (const auto &d, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) {
|
||||
const auto dirList = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||
for (const auto &d : dirList ) {
|
||||
QString dst_path = dst + QLatin1Char('/') + d;
|
||||
dir.mkpath(dst_path);
|
||||
copyPath(src + QLatin1Char('/') + d, dst_path);
|
||||
}
|
||||
|
||||
foreach (const auto &f, dir.entryList(QDir::Files)) {
|
||||
const auto entryList = dir.entryList(QDir::Files);
|
||||
for (const auto &f : entryList) {
|
||||
QFile::copy(src + QLatin1Char('/') + f, dst + QLatin1Char('/') + f);
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,8 @@ void DaysModel::update()
|
||||
const QDate modelFirstDay(m_data->at(0).yearNumber, m_data->at(0).monthNumber, m_data->at(0).dayNumber);
|
||||
|
||||
if (m_pluginsManager) {
|
||||
Q_FOREACH (CalendarEvents::CalendarEventsPlugin *eventsPlugin, m_pluginsManager->plugins()) {
|
||||
const auto plugins = m_pluginsManager->plugins();
|
||||
for (CalendarEvents::CalendarEventsPlugin *eventsPlugin : plugins) {
|
||||
eventsPlugin->loadEventsForDateRange(modelFirstDay, modelFirstDay.addDays(42));
|
||||
}
|
||||
}
|
||||
@ -140,7 +141,7 @@ void DaysModel::onEventModified(const CalendarEvents::EventData &data)
|
||||
m_agendaNeedsUpdate = true;
|
||||
}
|
||||
|
||||
Q_FOREACH (const QDate date, updatesList) {
|
||||
for (const QDate date : qAsConst(updatesList)) {
|
||||
const QModelIndex changedIndex = indexForDate(date);
|
||||
if (changedIndex.isValid()) {
|
||||
Q_EMIT dataChanged(changedIndex, changedIndex,
|
||||
@ -167,7 +168,7 @@ void DaysModel::onEventRemoved(const QString &uid)
|
||||
m_agendaNeedsUpdate = true;
|
||||
}
|
||||
|
||||
Q_FOREACH (const QDate date, updatesList) {
|
||||
for (const QDate date : qAsConst(updatesList)) {
|
||||
const QModelIndex changedIndex = indexForDate(date);
|
||||
if (changedIndex.isValid()) {
|
||||
Q_EMIT dataChanged(changedIndex, changedIndex,
|
||||
@ -195,7 +196,7 @@ QList<QObject*> DaysModel::eventsForDate(const QDate &date)
|
||||
return b.type() > a.type() || b.startDateTime() > a.startDateTime();
|
||||
});
|
||||
|
||||
Q_FOREACH (const CalendarEvents::EventData &event, events) {
|
||||
for (const CalendarEvents::EventData &event : qAsConst(events)) {
|
||||
m_qmlData << new EventDataDecorator(event, this);
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ EventPluginsManager::EventPluginsManager(QObject *parent)
|
||||
[](const KPluginMetaData &md) {
|
||||
return md.serviceTypes().contains(QLatin1String("PlasmaCalendar/Plugin"));
|
||||
});
|
||||
Q_FOREACH (const KPluginMetaData &plugin, plugins) {
|
||||
for (const KPluginMetaData &plugin : qAsConst(plugins)) {
|
||||
m_availablePlugins.insert(plugin.fileName(),
|
||||
{ plugin.name(),
|
||||
plugin.description(),
|
||||
@ -152,7 +152,7 @@ EventPluginsManager::EventPluginsManager(QObject *parent)
|
||||
|
||||
// Fallback for legacy pre-KPlugin plugins so we can still load them
|
||||
const QStringList paths = QCoreApplication::libraryPaths();
|
||||
Q_FOREACH (const QString &libraryPath, paths) {
|
||||
for (const QString &libraryPath : paths) {
|
||||
const QString path(libraryPath + QStringLiteral("/plasmacalendarplugins"));
|
||||
QDir dir(path);
|
||||
|
||||
@ -160,9 +160,9 @@ EventPluginsManager::EventPluginsManager(QObject *parent)
|
||||
continue;
|
||||
}
|
||||
|
||||
QStringList entryList = dir.entryList(QDir::Files | QDir::NoDotAndDotDot);
|
||||
const QStringList entryList = dir.entryList(QDir::Files | QDir::NoDotAndDotDot);
|
||||
|
||||
Q_FOREACH (const QString &fileName, entryList) {
|
||||
for (const QString &fileName : entryList) {
|
||||
const QString absolutePath = dir.absoluteFilePath(fileName);
|
||||
if (m_availablePlugins.contains(absolutePath)) {
|
||||
continue;
|
||||
@ -217,7 +217,7 @@ void EventPluginsManager::setEnabledPlugins(QStringList &pluginsList)
|
||||
}
|
||||
|
||||
// Now load all the plugins left in pluginsList
|
||||
Q_FOREACH (const QString &pluginPath, pluginsList) {
|
||||
for (const QString &pluginPath : qAsConst(pluginsList)) {
|
||||
loadPlugin(pluginPath);
|
||||
}
|
||||
|
||||
|
@ -268,7 +268,8 @@ void DataModel::dataUpdated(const QString &sourceName, const QVariantMap &data)
|
||||
QVariantList list;
|
||||
|
||||
if (!m_dataSource->data()->isEmpty()) {
|
||||
foreach (const QString &key, m_dataSource->data()->keys()) {
|
||||
const auto lst = m_dataSource->data()->keys();
|
||||
for (const QString &key : lst) {
|
||||
if (!m_sourceFilter.isEmpty() && m_sourceFilterRE.isValid() && !m_sourceFilterRE.exactMatch(key)) {
|
||||
continue;
|
||||
}
|
||||
@ -317,7 +318,8 @@ void DataModel::setDataSource(QObject *object)
|
||||
|
||||
m_dataSource = source;
|
||||
|
||||
foreach (const QString &key, m_dataSource->data()->keys()) {
|
||||
const auto keys = m_dataSource->data()->keys();
|
||||
for (const QString &key : keys) {
|
||||
dataUpdated(key, m_dataSource->data()->value(key).value<Plasma::DataEngine::Data>());
|
||||
}
|
||||
|
||||
@ -408,7 +410,7 @@ void DataModel::setItems(const QString &sourceName, const QVariantList &list)
|
||||
|
||||
if (!list.isEmpty()) {
|
||||
if (list.first().canConvert<QVariantMap>()) {
|
||||
foreach (const QVariant &item, list) {
|
||||
for (const QVariant &item : list) {
|
||||
const QVariantMap &vh = item.value<QVariantMap>();
|
||||
QMapIterator<QString, QVariant> it(vh);
|
||||
while (it.hasNext()) {
|
||||
@ -422,7 +424,7 @@ void DataModel::setItems(const QString &sourceName, const QVariantList &list)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
foreach (const QVariant &item, list) {
|
||||
for (const QVariant &item : list) {
|
||||
const QVariantMap &vh = item.value<QVariantMap>();
|
||||
QMapIterator<QString, QVariant> it(vh);
|
||||
while (it.hasNext()) {
|
||||
|
@ -261,7 +261,7 @@ private:
|
||||
int DataModel::countItems() const
|
||||
{
|
||||
int count = 0;
|
||||
foreach (const QVector<QVariant> &v, m_items) {
|
||||
for (const QVector<QVariant> &v : qAsConst(m_items)) {
|
||||
count += v.count();
|
||||
}
|
||||
return count;
|
||||
|
@ -49,7 +49,7 @@ void DataSource::componentComplete()
|
||||
void DataSource::setConnectedSources(const QStringList &sources)
|
||||
{
|
||||
bool sourcesChanged = false;
|
||||
foreach (const QString &source, sources) {
|
||||
for (const QString &source : sources) {
|
||||
if (!m_connectedSources.contains(source)) {
|
||||
sourcesChanged = true;
|
||||
if (m_dataEngine) {
|
||||
@ -60,7 +60,7 @@ void DataSource::setConnectedSources(const QStringList &sources)
|
||||
}
|
||||
}
|
||||
|
||||
foreach (const QString &source, m_connectedSources) {
|
||||
for (const QString &source : qAsConst(m_connectedSources)) {
|
||||
if (!sources.contains(source)) {
|
||||
m_data->clear(source);
|
||||
sourcesChanged = true;
|
||||
@ -161,7 +161,7 @@ void DataSource::setupData()
|
||||
qDeleteAll(m_services);
|
||||
m_services.clear();
|
||||
|
||||
foreach (const QString &source, m_connectedSources) {
|
||||
for (const QString &source : qAsConst(m_connectedSources)) {
|
||||
m_dataEngine->connectSource(source, this, m_interval, m_intervalAlignment);
|
||||
emit sourceConnected(source);
|
||||
}
|
||||
|
@ -614,7 +614,7 @@ void IconItem::loadPixmap()
|
||||
// It is more efficient to do it here, as KIconLoader::drawOverlays()
|
||||
// assumes that an overlay will be drawn and has some additional
|
||||
// setup time.
|
||||
foreach (const QString& overlay, m_overlays) {
|
||||
for (const QString &overlay : qAsConst(m_overlays)) {
|
||||
if (!overlay.isEmpty()) {
|
||||
// There is at least one overlay, draw all overlays above m_pixmap
|
||||
// and cancel the check
|
||||
|
@ -56,7 +56,8 @@ QQuickItem *ToolTipDialog::loadDefaultItem()
|
||||
|
||||
if (!m_qmlObject->rootObject()) {
|
||||
//HACK: search our own import
|
||||
foreach (const QString &path, m_qmlObject->engine()->importPathList()) {
|
||||
const auto paths = m_qmlObject->engine()->importPathList();
|
||||
for (const QString &path : paths) {
|
||||
if (QFile::exists(path + QStringLiteral("/org/kde/plasma/core"))) {
|
||||
m_qmlObject->setSource(QUrl::fromLocalFile(path + QStringLiteral("/org/kde/plasma/core/private/DefaultToolTip.qml")));
|
||||
break;
|
||||
|
@ -99,7 +99,7 @@ void QMenuProxy::setVisualParent(QObject *parent)
|
||||
if (action) {
|
||||
action->setMenu(m_menu);
|
||||
m_menu->clear();
|
||||
foreach (QMenuItem *item, m_items) {
|
||||
for (QMenuItem *item : qAsConst(m_items)) {
|
||||
if (item->section()) {
|
||||
if (!item->isVisible()) {
|
||||
continue;
|
||||
@ -289,7 +289,7 @@ void QMenuProxy::rebuildMenu()
|
||||
{
|
||||
m_menu->clear();
|
||||
|
||||
foreach (QMenuItem *item, m_items) {
|
||||
for (QMenuItem *item : qAsConst(m_items)) {
|
||||
if (item->section()) {
|
||||
if (!item->isVisible()) {
|
||||
continue;
|
||||
|
@ -58,7 +58,7 @@ QString FallbackComponent::filePath(const QString &key)
|
||||
{
|
||||
QString resolved;
|
||||
|
||||
foreach (const QString &path, m_candidates) {
|
||||
for (const QString &path : qAsConst(m_candidates)) {
|
||||
// qDebug() << "Searching for:" << path + path;
|
||||
if (m_possiblePaths.contains(path + key)) {
|
||||
resolved = *m_possiblePaths.object(path + key);
|
||||
|
@ -191,7 +191,8 @@ void Containment::restore(KConfigGroup &group)
|
||||
|
||||
//qCDebug(LOG_PLASMA) << cfg.keyList();
|
||||
if (cfg.exists()) {
|
||||
foreach (const QString &key, cfg.keyList()) {
|
||||
const auto keyList = cfg.keyList();
|
||||
for (const QString &key : keyList) {
|
||||
//qCDebug(LOG_PLASMA) << "loading" << key;
|
||||
setContainmentActions(key, cfg.readEntry(key, QString()));
|
||||
}
|
||||
@ -213,7 +214,8 @@ void Containment::restore(KConfigGroup &group)
|
||||
}
|
||||
if (defaultActionsCfg.isValid()) {
|
||||
defaultActionsCfg = KConfigGroup(&defaultActionsCfg, "ContainmentActions");
|
||||
foreach (const QString &key, defaultActionsCfg.keyList()) {
|
||||
const auto keyList = defaultActionsCfg.keyList();
|
||||
for (const QString &key : keyList) {
|
||||
setContainmentActions(key, defaultActionsCfg.readEntry(key, QString()));
|
||||
}
|
||||
}
|
||||
@ -258,7 +260,7 @@ void Containment::save(KConfigGroup &g) const
|
||||
void Containment::saveContents(KConfigGroup &group) const
|
||||
{
|
||||
KConfigGroup applets(&group, "Applets");
|
||||
foreach (const Applet *applet, d->applets) {
|
||||
for (const Applet *applet : qAsConst(d->applets)) {
|
||||
KConfigGroup appletConfig(&applets, QString::number(applet->id()));
|
||||
applet->save(appletConfig);
|
||||
}
|
||||
@ -275,7 +277,7 @@ void Containment::restoreContents(KConfigGroup &group)
|
||||
// Sort the applet configs in order of geometry to ensure that applets
|
||||
// are added from left to right or top to bottom for a panel containment
|
||||
QList<KConfigGroup> appletConfigs;
|
||||
foreach (const QString &appletGroup, groups) {
|
||||
for (const QString &appletGroup : qAsConst(groups)) {
|
||||
//qCDebug(LOG_PLASMA) << "reading from applet group" << appletGroup;
|
||||
KConfigGroup appletConfig(&applets, appletGroup);
|
||||
appletConfigs.append(appletConfig);
|
||||
@ -299,7 +301,8 @@ void Containment::restoreContents(KConfigGroup &group)
|
||||
if (Containment::applets().isEmpty()) {
|
||||
d->appletsUiReady = true;
|
||||
}
|
||||
foreach (Applet *applet, Containment::applets()) {
|
||||
const auto lstApplets = Containment::applets();
|
||||
for (Applet *applet : lstApplets) {
|
||||
if (!applet->pluginMetaData().isValid()) {
|
||||
applet->updateConstraints(Plasma::Types::UiReadyConstraint);
|
||||
}
|
||||
@ -361,7 +364,7 @@ void Containment::setLocation(Types::Location location)
|
||||
|
||||
d->location = location;
|
||||
|
||||
foreach (Applet *applet, d->applets) {
|
||||
for (Applet *applet : qAsConst(d->applets)) {
|
||||
applet->updateConstraints(Plasma::Types::LocationConstraint);
|
||||
}
|
||||
|
||||
@ -426,7 +429,8 @@ void Containment::addApplet(Applet *applet)
|
||||
|
||||
applet->configScheme()->setCurrentGroup(applet->configScheme()->currentGroup().replace(0, oldGroupPrefix.length(), newGroupPrefix));
|
||||
|
||||
foreach (KConfigSkeletonItem *item, applet->configScheme()->items()) {
|
||||
const auto items = applet->configScheme()->items();
|
||||
for (KConfigSkeletonItem *item : items) {
|
||||
item->setGroup(item->group().replace(0, oldGroupPrefix.length(), newGroupPrefix));
|
||||
}
|
||||
}
|
||||
|
@ -110,7 +110,8 @@ void Corona::saveLayout(const QString &configName) const
|
||||
|
||||
void Corona::exportLayout(KConfigGroup &config, QList<Containment *> containments)
|
||||
{
|
||||
foreach (const QString &group, config.groupList()) {
|
||||
const auto groupList = config.groupList();
|
||||
for (const QString &group : groupList) {
|
||||
KConfigGroup cg(&config, group);
|
||||
cg.deleteGroup();
|
||||
}
|
||||
@ -121,14 +122,15 @@ void Corona::exportLayout(KConfigGroup &config, QList<Containment *> containment
|
||||
|
||||
KConfigGroup dest(&config, "Containments");
|
||||
KConfigGroup dummy;
|
||||
foreach (Plasma::Containment *c, containments) {
|
||||
for (Plasma::Containment *c : qAsConst(containments)) {
|
||||
c->save(dummy);
|
||||
c->config().reparent(&dest);
|
||||
|
||||
//ensure the containment is unlocked
|
||||
//this is done directly because we have to bypass any Types::SystemImmutable checks
|
||||
c->Applet::d->immutability = Types::Mutable;
|
||||
foreach (Applet *a, c->applets()) {
|
||||
const auto lstApplet = c->applets();
|
||||
for (Applet *a : lstApplet) {
|
||||
a->d->immutability = Types::Mutable;
|
||||
}
|
||||
|
||||
@ -191,7 +193,7 @@ QList<Plasma::Containment *> Corona::importLayout(const KConfigGroup &conf)
|
||||
|
||||
Containment *Corona::containmentForScreen(int screen) const
|
||||
{
|
||||
foreach (Containment *containment, d->containments) {
|
||||
for (Containment *containment : qAsConst(d->containments)) {
|
||||
if (containment->screen() == screen &&
|
||||
(containment->containmentType() == Plasma::Types::DesktopContainment ||
|
||||
containment->containmentType() == Plasma::Types::CustomContainment)) {
|
||||
@ -214,7 +216,7 @@ Containment *Corona::containmentForScreen(int screen,
|
||||
{
|
||||
Containment *containment = nullptr;
|
||||
|
||||
foreach (Containment *cont, d->containments) {
|
||||
for (Containment *cont : qAsConst(d->containments)) {
|
||||
if (cont->lastScreen() == screen &&
|
||||
(cont->activity().isEmpty() || cont->activity() == activity) &&
|
||||
(cont->containmentType() == Plasma::Types::DesktopContainment ||
|
||||
@ -435,7 +437,8 @@ QList<Plasma::Types::Location> Corona::freeEdges(int screen) const
|
||||
freeEdges << Plasma::Types::TopEdge << Plasma::Types::BottomEdge
|
||||
<< Plasma::Types::LeftEdge << Plasma::Types::RightEdge;
|
||||
|
||||
foreach (Containment *containment, containments()) {
|
||||
const auto containments = this->containments();
|
||||
for (Containment *containment : containments) {
|
||||
if (containment->screen() == screen &&
|
||||
freeEdges.contains(containment->location())) {
|
||||
freeEdges.removeAll(containment->location());
|
||||
@ -519,7 +522,7 @@ void CoronaPrivate::toggleImmutability()
|
||||
void CoronaPrivate::saveLayout(KSharedConfigPtr cg) const
|
||||
{
|
||||
KConfigGroup containmentsGroup(cg, "Containments");
|
||||
foreach (const Containment *containment, containments) {
|
||||
for (const Containment *containment : containments) {
|
||||
QString cid = QString::number(containment->id());
|
||||
KConfigGroup containmentConfig(&containmentsGroup, cid);
|
||||
containment->save(containmentConfig);
|
||||
@ -528,7 +531,7 @@ void CoronaPrivate::saveLayout(KSharedConfigPtr cg) const
|
||||
|
||||
void CoronaPrivate::updateContainmentImmutability()
|
||||
{
|
||||
foreach (Containment *c, containments) {
|
||||
for (Containment *c : qAsConst(containments)) {
|
||||
// we need to tell each containment that immutability has been altered
|
||||
c->updateConstraints(Types::ImmutableConstraint);
|
||||
}
|
||||
@ -651,7 +654,7 @@ QList<Plasma::Containment *> CoronaPrivate::importLayout(const KConfigGroup &con
|
||||
QList<Plasma::Containment *> newContainments;
|
||||
QSet<uint> containmentsIds;
|
||||
|
||||
foreach (Containment *containment, containments) {
|
||||
for (Containment *containment : qAsConst(containments)) {
|
||||
containmentsIds.insert(containment->id());
|
||||
}
|
||||
|
||||
@ -659,7 +662,7 @@ QList<Plasma::Containment *> CoronaPrivate::importLayout(const KConfigGroup &con
|
||||
QStringList groups = containmentsGroup.groupList();
|
||||
std::sort(groups.begin(), groups.end());
|
||||
|
||||
foreach (const QString &group, groups) {
|
||||
for (const QString &group : qAsConst(groups)) {
|
||||
KConfigGroup containmentConfig(&containmentsGroup, group);
|
||||
|
||||
if (containmentConfig.entryMap().isEmpty()) {
|
||||
@ -708,7 +711,7 @@ QList<Plasma::Containment *> CoronaPrivate::importLayout(const KConfigGroup &con
|
||||
void CoronaPrivate::notifyContainmentsReady()
|
||||
{
|
||||
containmentsStarting = 0;
|
||||
foreach (Containment *containment, containments) {
|
||||
for (Containment *containment : qAsConst(containments)) {
|
||||
if (!containment->isUiReady() && containment->screen() >= 0) {
|
||||
++containmentsStarting;
|
||||
QObject::connect(containment, &Plasma::Containment::uiReadyChanged, q, [this](bool ready) { containmentReady(ready); } );
|
||||
|
@ -353,7 +353,7 @@ void DataContainer::checkForUpdate()
|
||||
if (d->dirty) {
|
||||
emit dataUpdated(objectName(), d->data);
|
||||
|
||||
foreach (SignalRelay *relay, d->relays) {
|
||||
for (SignalRelay *relay : qAsConst(d->relays)) {
|
||||
relay->checkQueueing();
|
||||
}
|
||||
|
||||
@ -368,7 +368,7 @@ void DataContainer::forceImmediateUpdate()
|
||||
emit dataUpdated(objectName(), d->data);
|
||||
}
|
||||
|
||||
foreach (SignalRelay *relay, d->relays) {
|
||||
for (SignalRelay *relay : qAsConst(d->relays)) {
|
||||
relay->forceImmediateUpdate();
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ void DataEngine::connectSource(const QString &source, QObject *visualization,
|
||||
void DataEngine::connectAllSources(QObject *visualization, uint pollingInterval,
|
||||
Plasma::Types::IntervalAlignment intervalAlignment) const
|
||||
{
|
||||
foreach (DataContainer *s, d->sources) {
|
||||
for (DataContainer *s : qAsConst(d->sources)) {
|
||||
d->connectSource(s, visualization, pollingInterval, intervalAlignment);
|
||||
}
|
||||
}
|
||||
@ -396,7 +396,7 @@ void DataEngine::updateAllSources()
|
||||
|
||||
void DataEngine::forceImmediateUpdateOfAllVisualizations()
|
||||
{
|
||||
foreach (DataContainer *source, d->sources) {
|
||||
for (DataContainer *source : qAsConst(d->sources)) {
|
||||
if (source->isUsed()) {
|
||||
source->forceImmediateUpdate();
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ DataEngineConsumer::DataEngineConsumer()
|
||||
|
||||
DataEngineConsumer::~DataEngineConsumer()
|
||||
{
|
||||
foreach (const QString &engine, d->loadedEngines) {
|
||||
for (const QString &engine : qAsConst(d->loadedEngines)) {
|
||||
DataEngineManager::self()->unloadEngine(engine);
|
||||
}
|
||||
|
||||
|
@ -260,7 +260,8 @@ void Package::setMimeTypes(const char *key, QStringList mimeTypes)
|
||||
QList<const char *> Package::directories() const
|
||||
{
|
||||
QList<const char *> dirs;
|
||||
foreach (const auto &data, d->internalPackage->directories()) {
|
||||
const auto directories = d->internalPackage->directories();
|
||||
for (const auto &data : directories) {
|
||||
dirs << data.constData();
|
||||
}
|
||||
|
||||
@ -270,7 +271,8 @@ QList<const char *> Package::directories() const
|
||||
QList<const char *> Package::requiredDirectories() const
|
||||
{
|
||||
QList<const char *> dirs;
|
||||
foreach (const auto &data, d->internalPackage->requiredDirectories()) {
|
||||
const auto directories = d->internalPackage->requiredDirectories();
|
||||
for (const auto &data : directories) {
|
||||
dirs << data.constData();
|
||||
}
|
||||
|
||||
@ -280,7 +282,8 @@ QList<const char *> Package::requiredDirectories() const
|
||||
QList<const char *> Package::files() const
|
||||
{
|
||||
QList<const char *> files;
|
||||
foreach (const auto &data, d->internalPackage->files()) {
|
||||
const auto lstFiles = d->internalPackage->files();
|
||||
for (const auto &data : lstFiles) {
|
||||
files << data.constData();
|
||||
}
|
||||
|
||||
@ -290,7 +293,8 @@ QList<const char *> Package::files() const
|
||||
QList<const char *> Package::requiredFiles() const
|
||||
{
|
||||
QList<const char *> files;
|
||||
foreach (const auto &data, d->internalPackage->requiredFiles()) {
|
||||
const auto lstFiles = d->internalPackage->requiredFiles();
|
||||
for (const auto &data : lstFiles) {
|
||||
files << data.constData();
|
||||
}
|
||||
|
||||
|
@ -134,7 +134,7 @@ PluginLoader::PluginLoader()
|
||||
PluginLoader::~PluginLoader()
|
||||
{
|
||||
typedef QPointer<PackageStructure> pswp;
|
||||
foreach (pswp wp, d->structures) {
|
||||
for (pswp wp : qAsConst(d->structures)) {
|
||||
delete wp.data();
|
||||
}
|
||||
delete d;
|
||||
@ -272,12 +272,12 @@ QStringList PluginLoader::listAllEngines(const QString &parentApp)
|
||||
plugins = KPluginLoader::findPlugins(PluginLoaderPrivate::s_dataEnginePluginDir, filter);
|
||||
}
|
||||
|
||||
foreach (auto& plugin, plugins) {
|
||||
for (auto& plugin : qAsConst(plugins)) {
|
||||
engines << plugin.pluginId();
|
||||
}
|
||||
|
||||
const QList<KPluginMetaData> packagePlugins = KPackage::PackageLoader::self()->listPackages(QStringLiteral("Plasma/DataEngine"));
|
||||
for (auto& plugin : packagePlugins) {
|
||||
for (const auto &plugin : packagePlugins) {
|
||||
engines << plugin.pluginId();
|
||||
}
|
||||
|
||||
@ -507,7 +507,7 @@ KPluginInfo::List PluginLoader::listAppletInfo(const QString &category, const QS
|
||||
|
||||
//NOTE: it still produces kplugininfos from KServices because some user code expects
|
||||
//info.service() to be valid and would crash otherwise
|
||||
foreach (auto& md, plugins) {
|
||||
for (const auto &md : plugins) {
|
||||
auto pi = md.metaDataFileName().endsWith(QLatin1String(".json")) ? KPluginInfo(md) : KPluginInfo(KService::serviceByStorageId(md.metaDataFileName()));
|
||||
if (!pi.isValid()) {
|
||||
qCWarning(LOG_PLASMA) << "Could not load plugin info for plugin :" << md.pluginId() << "skipping plugin";
|
||||
@ -548,9 +548,9 @@ QList<KPluginMetaData> PluginLoader::listAppletMetaDataForUrl(const QUrl &url)
|
||||
const QList<KPluginMetaData> allApplets = KPackage::PackageLoader::self()->findPackages(QStringLiteral("Plasma/Applet"), QString(), filter);
|
||||
|
||||
QList<KPluginMetaData> filtered;
|
||||
foreach (const KPluginMetaData &md, allApplets) {
|
||||
QStringList urlPatterns = KPluginMetaData::readStringList(md.rawData(), QStringLiteral("X-Plasma-DropUrlPatterns"));
|
||||
foreach (const QString &glob, urlPatterns) {
|
||||
for (const KPluginMetaData &md : allApplets) {
|
||||
const QStringList urlPatterns = KPluginMetaData::readStringList(md.rawData(), QStringLiteral("X-Plasma-DropUrlPatterns"));
|
||||
for (const QString &glob : urlPatterns) {
|
||||
QRegExp rx(glob);
|
||||
rx.setPatternSyntax(QRegExp::Wildcard);
|
||||
if (rx.exactMatch(url.toString())) {
|
||||
@ -585,7 +585,7 @@ QStringList PluginLoader::listAppletCategories(const QString &parentApp, bool vi
|
||||
|
||||
|
||||
QStringList categories;
|
||||
foreach (auto& plugin, allApplets) {
|
||||
for (auto &plugin : allApplets) {
|
||||
if (plugin.category().isEmpty()) {
|
||||
if (!categories.contains(i18nc("misc category", "Miscellaneous"))) {
|
||||
categories << i18nc("misc category", "Miscellaneous");
|
||||
@ -669,12 +669,12 @@ KPluginInfo::List PluginLoader::listContainmentsForMimeType(const QString &mimeT
|
||||
|
||||
QStringList PluginLoader::listContainmentTypes()
|
||||
{
|
||||
KPluginInfo::List containmentInfos = listContainments();
|
||||
const KPluginInfo::List containmentInfos = listContainments();
|
||||
QSet<QString> types;
|
||||
|
||||
foreach (const KPluginInfo &containmentInfo, containmentInfos) {
|
||||
QStringList theseTypes = containmentInfo.service()->property(QStringLiteral("X-Plasma-ContainmentType")).toStringList();
|
||||
foreach (const QString &type, theseTypes) {
|
||||
for (const KPluginInfo &containmentInfo : containmentInfos) {
|
||||
const QStringList theseTypes = containmentInfo.service()->property(QStringLiteral("X-Plasma-ContainmentType")).toStringList();
|
||||
for (const QString &type : theseTypes) {
|
||||
types.insert(type);
|
||||
}
|
||||
}
|
||||
@ -715,14 +715,14 @@ KPluginInfo::List PluginLoader::listContainmentActionsInfo(const QString &parent
|
||||
list.append(KPluginTrader::self()->query(PluginLoaderPrivate::s_containmentActionsPluginDir, QStringLiteral("Plasma/ContainmentActions"), constraint));
|
||||
|
||||
QSet<QString> knownPlugins;
|
||||
foreach (const KPluginInfo &p, list) {
|
||||
for (const KPluginInfo &p : qAsConst(list)) {
|
||||
knownPlugins.insert(p.pluginName());
|
||||
}
|
||||
|
||||
//FIXME: this is only for backwards compatibility, but probably will have to stay
|
||||
//for the time being
|
||||
KService::List offers = KServiceTypeTrader::self()->query(QStringLiteral("Plasma/ContainmentActions"), constraint);
|
||||
foreach (KService::Ptr s, offers) {
|
||||
const KService::List offers = KServiceTypeTrader::self()->query(QStringLiteral("Plasma/ContainmentActions"), constraint);
|
||||
for (KService::Ptr s : offers) {
|
||||
if (!knownPlugins.contains(s->pluginKeyword())) {
|
||||
list.append(KPluginInfo(s));
|
||||
}
|
||||
@ -795,14 +795,14 @@ static KPluginInfo::List standardInternalInfo(const QString &type, const QString
|
||||
QLatin1String(PLASMA_RELATIVE_DATA_INSTALL_DIR "/internal/") + type + QLatin1String("/*.desktop"),
|
||||
QStandardPaths::LocateFile);
|
||||
|
||||
KPluginInfo::List allInfo = KPluginInfo::fromFiles(files);
|
||||
const KPluginInfo::List allInfo = KPluginInfo::fromFiles(files);
|
||||
|
||||
if (category.isEmpty() || allInfo.isEmpty()) {
|
||||
return allInfo;
|
||||
}
|
||||
|
||||
KPluginInfo::List matchingInfo;
|
||||
foreach (const KPluginInfo &info, allInfo) {
|
||||
for (const KPluginInfo &info : allInfo) {
|
||||
if (info.category().compare(category, Qt::CaseInsensitive) == 0) {
|
||||
matchingInfo << info;
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ void AppletPrivate::init(const QString &_packagePath, const QVariantList &args)
|
||||
auto filter = [&provides](const KPluginMetaData &md) -> bool
|
||||
{
|
||||
const QStringList provided = KPluginMetaData::readStringList(md.rawData(), QStringLiteral("X-Plasma-Provides"));
|
||||
foreach (const QString &p, provides) {
|
||||
for (const QString &p : provides) {
|
||||
if (provided.contains(p)) {
|
||||
return true;
|
||||
}
|
||||
@ -246,7 +246,8 @@ void AppletPrivate::setDestroyed(bool destroyed)
|
||||
|
||||
Plasma::Containment *asContainment = qobject_cast<Plasma::Containment *>(q);
|
||||
if (asContainment) {
|
||||
foreach(Applet *a , asContainment->applets())
|
||||
const auto lstApplets = asContainment->applets();
|
||||
for (Applet *a : lstApplets)
|
||||
a->d->setDestroyed(destroyed);
|
||||
}
|
||||
}
|
||||
@ -411,10 +412,9 @@ void AppletPrivate::updateShortcuts()
|
||||
if (q->isContainment()) {
|
||||
//a horrible hack to avoid clobbering corona settings
|
||||
//we pull them out, then read, then put them back
|
||||
QList<QString> names;
|
||||
QList<QAction *> qactions;
|
||||
names << QStringLiteral("add sibling containment") << QStringLiteral("configure shortcuts") << QStringLiteral("lock widgets");
|
||||
foreach (const QString &name, names) {
|
||||
const QList<QString> names = { QStringLiteral("add sibling containment"), QStringLiteral("configure shortcuts"), QStringLiteral("lock widgets")};
|
||||
for (const QString &name : names) {
|
||||
QAction *a = actions->action(name);
|
||||
actions->takeAction(a); //FIXME this is stupid, KActionCollection needs a takeAction(QString) method
|
||||
qactions << a;
|
||||
|
@ -115,7 +115,7 @@ void ContainmentPrivate::checkStatus(Plasma::Types::ItemStatus appletStatus)
|
||||
if (appletStatus < q->status() || appletStatus == Plasma::Types::HiddenStatus) {
|
||||
// check to see if any other applet has a higher status, and stick with that if we do
|
||||
// we'll treat HiddenStatus as lowest as we cannot change the enum value which is highest anymore
|
||||
foreach (Applet *applet, applets) {
|
||||
for (Applet *applet : qAsConst(applets)) {
|
||||
if (applet->status() > appletStatus && applet->status() != Plasma::Types::HiddenStatus) {
|
||||
appletStatus = applet->status();
|
||||
}
|
||||
@ -156,7 +156,7 @@ void ContainmentPrivate::containmentConstraintsEvent(Plasma::Types::Constraints
|
||||
}
|
||||
|
||||
// tell the applets too
|
||||
foreach (Applet *a, applets) {
|
||||
for (Applet *a : qAsConst(applets)) {
|
||||
/*Why qMin?
|
||||
* the applets immutability() is the maximum between internal applet immutability
|
||||
* and the immutability of its containment.
|
||||
@ -179,7 +179,7 @@ void ContainmentPrivate::containmentConstraintsEvent(Plasma::Types::Constraints
|
||||
}
|
||||
|
||||
if (appletConstraints != Types::NoConstraint) {
|
||||
foreach (Applet *applet, applets) {
|
||||
for (Applet *applet : qAsConst(applets)) {
|
||||
applet->updateConstraints(appletConstraints);
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ public:
|
||||
|
||||
~DataEngineManagerPrivate()
|
||||
{
|
||||
foreach (Plasma::DataEngine *engine, engines) {
|
||||
for (Plasma::DataEngine *engine : qAsConst(engines)) {
|
||||
delete engine;
|
||||
}
|
||||
engines.clear();
|
||||
@ -177,7 +177,8 @@ void DataEngineManager::timerEvent(QTimerEvent *)
|
||||
out << " Actual # of sources: " << engine->containerDict().count() << '\n';
|
||||
out << "\n Source Details" << '\n';
|
||||
|
||||
foreach (DataContainer *dc, engine->containerDict()) {
|
||||
const auto lst = engine->containerDict();
|
||||
for (DataContainer *dc : lst) {
|
||||
out << " * " << dc->objectName() << '\n';
|
||||
out << " Data count: " << dc->d->data.count() << '\n';
|
||||
out << " Stored: " << dc->isStorageEnabled() << " \n";
|
||||
@ -190,7 +191,7 @@ void DataEngineManager::timerEvent(QTimerEvent *)
|
||||
if (relays > 0) {
|
||||
out << " Relays: " << dc->d->relays.count() << '\n';
|
||||
QString times;
|
||||
foreach (SignalRelay *relay, dc->d->relays) {
|
||||
for (SignalRelay *relay : qAsConst(dc->d->relays)) {
|
||||
times.append(QLatin1Char(' ') + QString::number(relay->m_interval));
|
||||
}
|
||||
out << " Relay Timeouts: " << times << " \n";
|
||||
|
@ -825,7 +825,7 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings
|
||||
while (!fallback.isEmpty() && !fallbackThemes.contains(fallback)) {
|
||||
fallbackThemes.append(fallback);
|
||||
|
||||
QString metadataPath(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String(PLASMA_RELATIVE_DATA_INSTALL_DIR "/desktoptheme/") % fallback % QLatin1String("/metadata.desktop")));
|
||||
QString metadataPath(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String(PLASMA_RELATIVE_DATA_INSTALL_DIR "/desktoptheme/") % fallback % QStringLiteral("/metadata.desktop")));
|
||||
KConfig metadata(metadataPath, KConfig::SimpleConfig);
|
||||
KConfigGroup cg(&metadata, "Settings");
|
||||
fallback = cg.readEntry("FallbackTheme", QString());
|
||||
@ -835,8 +835,8 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings
|
||||
fallbackThemes.append(QLatin1String(ThemePrivate::defaultTheme));
|
||||
}
|
||||
|
||||
foreach (const QString &theme, fallbackThemes) {
|
||||
QString metadataPath(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String(PLASMA_RELATIVE_DATA_INSTALL_DIR "/desktoptheme/") % theme % QLatin1String("/metadata.desktop")));
|
||||
for (const QString &theme : qAsConst(fallbackThemes)) {
|
||||
QString metadataPath(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1Literal(PLASMA_RELATIVE_DATA_INSTALL_DIR "/desktoptheme/") % theme % QStringLiteral("/metadata.desktop")));
|
||||
KConfig metadata(metadataPath, KConfig::SimpleConfig);
|
||||
processWallpaperSettings(&metadata);
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
void print() {
|
||||
QJsonArray array;
|
||||
|
||||
Q_FOREACH(const ObjectHistory& history, m_data) {
|
||||
for (const ObjectHistory &history : qAsConst(m_data)) {
|
||||
array.append(QJsonObject {
|
||||
{ QStringLiteral("events"), serializeEvents(history.events) },
|
||||
{ QStringLiteral("initial"), QJsonValue::fromVariant(history.initial) }
|
||||
@ -68,7 +68,7 @@ private:
|
||||
QJsonArray serializeEvents(const QVector<TimeEvent>& events) const {
|
||||
QJsonArray ret;
|
||||
Q_ASSERT(!events.isEmpty());
|
||||
foreach(const TimeEvent& ev, events) {
|
||||
for (const TimeEvent &ev : events) {
|
||||
ret.append(QJsonObject {
|
||||
{ QStringLiteral("comment"), ev.comment },
|
||||
{ QStringLiteral("time"), ev.moment.toMSecsSinceEpoch() - *s_beginning }
|
||||
|
@ -176,10 +176,12 @@ void Service::setOperationsScheme(QIODevice *xml)
|
||||
KSharedConfigPtr config = KSharedConfig::openConfig(QStringLiteral("/dev/null"), KConfig::SimpleConfig);
|
||||
KConfigLoader loader(config, xml);
|
||||
|
||||
foreach (const QString &group, loader.groupList()) {
|
||||
const auto groupList = loader.groupList();
|
||||
for (const QString &group : groupList) {
|
||||
d->operationsMap[group][QStringLiteral("_name")] = group;
|
||||
}
|
||||
foreach (KConfigSkeletonItem *item, loader.items()) {
|
||||
const auto itemsList = loader.items();
|
||||
for (KConfigSkeletonItem *item : itemsList) {
|
||||
d->operationsMap[item->group()][item->key()] = item->property();
|
||||
}
|
||||
}
|
||||
|
@ -312,13 +312,13 @@ QPixmap SvgPrivate::findInCache(const QString &elementId, qreal ratio, const QSi
|
||||
// and store them locally.
|
||||
const QRegularExpression sizeHintedKeyExpr(QLatin1String("^") + CACHE_ID_NATURAL_SIZE(QStringLiteral("(\\d+)-(\\d+)-(.+)"), status, ratio) + QLatin1String("$"));
|
||||
|
||||
foreach (const QString &key, cacheAndColorsTheme()->listCachedRectKeys(path)) {
|
||||
const auto lst = cacheAndColorsTheme()->listCachedRectKeys(path);
|
||||
for (const QString &key : lst) {
|
||||
const auto match = sizeHintedKeyExpr.match(key);
|
||||
if (match.hasMatch()) {
|
||||
QString baseElementId = match.captured(3);
|
||||
QSize sizeHint(match.capturedRef(1).toInt(),
|
||||
match.capturedRef(2).toInt());
|
||||
|
||||
if (sizeHint.isValid()) {
|
||||
elementsWithSizeHints.insert(baseElementId, sizeHint);
|
||||
}
|
||||
|
@ -117,7 +117,8 @@ void AppletQuickItemPrivate::connectLayoutAttached(QObject *item)
|
||||
|
||||
//Search a child that has the needed Layout properties
|
||||
//HACK: here we are not type safe, but is the only way to access to a pointer of Layout
|
||||
foreach (QObject *child, item->children()) {
|
||||
const auto lstChildren = item->children();
|
||||
for (QObject *child : lstChildren) {
|
||||
//find for the needed property of Layout: minimum/maximum/preferred sizes and fillWidth/fillHeight
|
||||
if (child->property("minimumWidth").isValid() && child->property("minimumHeight").isValid() &&
|
||||
child->property("preferredWidth").isValid() && child->property("preferredHeight").isValid() &&
|
||||
@ -158,7 +159,8 @@ void AppletQuickItemPrivate::connectLayoutAttached(QObject *item)
|
||||
|
||||
QObject *ownLayout = nullptr;
|
||||
|
||||
foreach (QObject *child, q->children()) {
|
||||
const auto children = q->children();
|
||||
for (QObject *child : children) {
|
||||
//find for the needed property of Layout: minimum/maximum/preferred sizes and fillWidth/fillHeight
|
||||
if (child->property("minimumWidth").isValid() && child->property("minimumHeight").isValid() &&
|
||||
child->property("preferredWidth").isValid() && child->property("preferredHeight").isValid() &&
|
||||
@ -606,7 +608,8 @@ void AppletQuickItem::init()
|
||||
if (d->applet->failedToLaunch()) {
|
||||
reason = d->applet->launchErrorMessage();
|
||||
} else if (d->applet->kPackage().isValid()) {
|
||||
foreach (QQmlError error, d->qmlObject->mainComponent()->errors()) {
|
||||
const auto errors = d->qmlObject->mainComponent()->errors();
|
||||
for (QQmlError error : errors) {
|
||||
reason += error.toString() + QLatin1Char('\n');
|
||||
}
|
||||
reason = i18n("Error loading QML file: %1", reason);
|
||||
|
@ -163,7 +163,7 @@ void ConfigViewPrivate::init()
|
||||
configModel = new ConfigModel(q);
|
||||
}
|
||||
|
||||
foreach (const QString &kcm, kcms) {
|
||||
for (const QString &kcm : qAsConst(kcms)) {
|
||||
KPluginLoader loader(KPluginLoader::findPlugin(QLatin1String("kcms/") + kcm));
|
||||
KPluginMetaData md(loader.fileName());
|
||||
|
||||
@ -246,7 +246,8 @@ void ConfigViewPrivate::mainItemLoaded()
|
||||
|
||||
//Search a child that has the needed Layout properties
|
||||
//HACK: here we are not type safe, but is the only way to access to a pointer of Layout
|
||||
foreach (QObject *child, q->rootObject()->children()) {
|
||||
const auto children = q->rootObject()->children();
|
||||
for (QObject *child : children) {
|
||||
//find for the needed property of Layout: minimum/maximum/preferred sizes and fillWidth/fillHeight
|
||||
if (child->property("minimumWidth").isValid() && child->property("minimumHeight").isValid() &&
|
||||
child->property("preferredWidth").isValid() && child->property("preferredHeight").isValid() &&
|
||||
|
@ -179,7 +179,8 @@ QRect DialogPrivate::availableScreenGeometryForPosition(const QPoint& pos) const
|
||||
// we simply iterate over the virtual screens and pick the one our QWindow
|
||||
// says it's at.
|
||||
QRect avail;
|
||||
Q_FOREACH (QScreen *screen, QGuiApplication::screens()) {
|
||||
const auto screens = QGuiApplication::screens();
|
||||
for (QScreen *screen : screens) {
|
||||
//we check geometry() but then take availableGeometry()
|
||||
//to reliably check in which screen a position is, we need the full
|
||||
//geometry, including areas for panels
|
||||
@ -875,7 +876,8 @@ void Dialog::setMainItem(QQuickItem *mainItem)
|
||||
|
||||
//Search a child that has the needed Layout properties
|
||||
//HACK: here we are not type safe, but is the only way to access to a pointer of Layout
|
||||
foreach (QObject *child, mainItem->children()) {
|
||||
const auto lstChild = mainItem->children();
|
||||
for (QObject *child : lstChild) {
|
||||
//find for the needed property of Layout: minimum/maximum/preferred sizes and fillWidth/fillHeight
|
||||
if (child->property("minimumWidth").isValid() && child->property("minimumHeight").isValid() &&
|
||||
child->property("preferredWidth").isValid() && child->property("preferredHeight").isValid() &&
|
||||
|
@ -452,7 +452,7 @@ void DialogShadows::Private::freeX11Pixmaps()
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (const QPixmap &pixmap, m_shadowPixmaps) {
|
||||
for (const QPixmap &pixmap : qAsConst(m_shadowPixmaps)) {
|
||||
if (!pixmap.isNull()) {
|
||||
XFreePixmap(display, reinterpret_cast<unsigned long>(createPixmap(pixmap)));
|
||||
}
|
||||
|
@ -438,7 +438,7 @@ QList<QAction *> AppletInterface::contextualActions() const
|
||||
return actions;
|
||||
}
|
||||
|
||||
foreach (const QString &name, m_actions) {
|
||||
for (const QString &name : qAsConst(m_actions)) {
|
||||
QAction *action = a->actions()->action(name);
|
||||
|
||||
if (action) {
|
||||
@ -504,7 +504,8 @@ void AppletInterface::removeAction(const QString &name)
|
||||
|
||||
void AppletInterface::clearActions()
|
||||
{
|
||||
Q_FOREACH (const QString &action, m_actions) {
|
||||
const auto oldActionsList = m_actions;
|
||||
for (const QString &action : oldActionsList) {
|
||||
removeAction(action);
|
||||
}
|
||||
}
|
||||
@ -767,7 +768,7 @@ bool AppletInterface::event(QEvent *event)
|
||||
}
|
||||
|
||||
bool keySequenceUsed = false;
|
||||
foreach (auto a, actions) {
|
||||
for (auto a : qAsConst(actions)) {
|
||||
|
||||
if (a->shortcut().isEmpty()) {
|
||||
continue;
|
||||
|
@ -235,7 +235,8 @@ void ContainmentInterface::setAppletArgs(Plasma::Applet *applet, const QString &
|
||||
QObject *ContainmentInterface::containmentAt(int x, int y)
|
||||
{
|
||||
QObject *desktop = nullptr;
|
||||
foreach (Plasma::Containment *c, m_containment->corona()->containments()) {
|
||||
const auto lst = m_containment->corona()->containments();
|
||||
for (Plasma::Containment *c : lst) {
|
||||
ContainmentInterface *contInterface = c->property("_plasma_graphicObject").value<ContainmentInterface *>();
|
||||
|
||||
if (contInterface && contInterface->isVisible()) {
|
||||
@ -459,7 +460,7 @@ void ContainmentInterface::processMimeData(QMimeData *mimeData, int x, int y, KI
|
||||
if (mimeData->hasFormat(QStringLiteral("text/x-plasmoidservicename"))) {
|
||||
QString data = QString::fromUtf8( mimeData->data(QStringLiteral("text/x-plasmoidservicename")) );
|
||||
const QStringList appletNames = data.split(QLatin1Char('\n'), QString::SkipEmptyParts);
|
||||
foreach (const QString &appletName, appletNames) {
|
||||
for (const QString &appletName : appletNames) {
|
||||
qDebug() << "adding" << appletName;
|
||||
|
||||
metaObject()->invokeMethod(this, "createApplet", Qt::QueuedConnection, Q_ARG(QString, appletName), Q_ARG(QVariantList, QVariantList()), Q_ARG(QRectF, QRectF(x, y, -1, -1)));
|
||||
@ -477,7 +478,7 @@ void ContainmentInterface::processMimeData(QMimeData *mimeData, int x, int y, KI
|
||||
|
||||
QMimeDatabase db;
|
||||
QMimeType firstMimetype = db.mimeTypeForUrl(urls.at(0));
|
||||
foreach (const QUrl &url, urls) {
|
||||
for (const QUrl &url : urls) {
|
||||
if (firstMimetype != db.mimeTypeForUrl(url)) {
|
||||
m_dropMenu->setMultipleMimetypes(true);
|
||||
break;
|
||||
@ -496,14 +497,14 @@ void ContainmentInterface::processMimeData(QMimeData *mimeData, int x, int y, KI
|
||||
} else {
|
||||
bool deleteDropMenu = true;
|
||||
|
||||
QStringList formats = mimeData->formats();
|
||||
const QStringList formats = mimeData->formats();
|
||||
QHash<QString, KPluginMetaData> seenPlugins;
|
||||
QHash<QString, QString> pluginFormats;
|
||||
|
||||
foreach (const QString &format, formats) {
|
||||
for (const QString &format : formats) {
|
||||
const auto plugins = Plasma::PluginLoader::self()->listAppletMetaDataForMimeType(format);
|
||||
|
||||
foreach (const auto &plugin, plugins) {
|
||||
for (const auto &plugin : plugins) {
|
||||
if (seenPlugins.contains(plugin.pluginId())) {
|
||||
continue;
|
||||
}
|
||||
@ -525,7 +526,7 @@ void ContainmentInterface::processMimeData(QMimeData *mimeData, int x, int y, KI
|
||||
setAppletArgs(applet, pluginFormats[selectedPlugin], QString::fromUtf8(mimeData->data(pluginFormats[selectedPlugin])));
|
||||
} else {
|
||||
QHash<QAction *, QString> actionsToPlugins;
|
||||
foreach (const auto &info, seenPlugins) {
|
||||
for (const auto &info : qAsConst(seenPlugins)) {
|
||||
QAction *action;
|
||||
if (!info.iconName().isEmpty()) {
|
||||
action = new QAction(QIcon::fromTheme(info.iconName()), info.name(), m_dropMenu);
|
||||
@ -664,7 +665,7 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet
|
||||
action->setSeparator(true);
|
||||
m_dropMenu->addAction(action);
|
||||
|
||||
foreach (const auto &info, appletList) {
|
||||
for (const auto &info : qAsConst(appletList)) {
|
||||
const QString actionText = i18nc("Add widget", "Add %1", info.name());
|
||||
QAction *action = new QAction(actionText, m_dropMenu);
|
||||
if (!info.iconName().isEmpty()) {
|
||||
@ -696,11 +697,11 @@ void ContainmentInterface::mimeTypeRetrieved(KIO::Job *job, const QString &mimet
|
||||
m_dropMenu->addAction(action);
|
||||
|
||||
QMap<QString, KPluginMetaData> sorted;
|
||||
foreach (const auto &info, appletList) {
|
||||
for (const auto &info : qAsConst(appletList)) {
|
||||
sorted.insert(info.name(), info);
|
||||
}
|
||||
|
||||
foreach (const KPluginMetaData &info, wallpaperList) {
|
||||
for (const KPluginMetaData &info : qAsConst(wallpaperList)) {
|
||||
const QString actionText = i18nc("Set wallpaper", "Set %1", info.name());
|
||||
QAction *action = new QAction(actionText, m_dropMenu);
|
||||
if (!info.iconName().isEmpty()) {
|
||||
@ -836,7 +837,8 @@ QList<QObject *> ContainmentInterface::actions() const
|
||||
//use a multimap to sort by action type
|
||||
QMultiMap<int, QObject *> actions;
|
||||
int i = 0;
|
||||
foreach (QAction *a, m_containment->actions()->actions()) {
|
||||
auto listActions = m_containment->actions()->actions();
|
||||
for (QAction *a : qAsConst(listActions)) {
|
||||
if (!actionOrder.contains(a->objectName())) {
|
||||
//FIXME QML visualizations don't support menus for now, *and* there is no way to
|
||||
//distinguish them on QML side
|
||||
@ -850,7 +852,8 @@ QList<QObject *> ContainmentInterface::actions() const
|
||||
}
|
||||
|
||||
i = 0;
|
||||
foreach (QAction *a, m_containment->corona()->actions()->actions()) {
|
||||
listActions = m_containment->corona()->actions()->actions();
|
||||
for (QAction *a : qAsConst(listActions)) {
|
||||
if (a->objectName() == QLatin1String("lock widgets") || a->menu()) {
|
||||
//It is up to the Containment to decide if the user is allowed or not
|
||||
//to lock/unluck the widgets, so corona should not add one when there is none
|
||||
@ -868,7 +871,7 @@ QList<QObject *> ContainmentInterface::actions() const
|
||||
}
|
||||
QList<QObject *> actionList = actions.values();
|
||||
|
||||
foreach (const QString &name, actionOrder) {
|
||||
for (const QString &name : qAsConst(actionOrder)) {
|
||||
QAction *a = orderedActions.value(name);
|
||||
if (a && !a->menu()) {
|
||||
actionList << a;
|
||||
@ -917,7 +920,7 @@ void ContainmentInterface::mousePressEvent(QMouseEvent *event)
|
||||
|
||||
//FIXME: very inefficient appletAt() implementation
|
||||
Plasma::Applet *applet = nullptr;
|
||||
foreach (QObject *appletObject, m_appletInterfaces) {
|
||||
for (QObject *appletObject : qAsConst(m_appletInterfaces)) {
|
||||
if (AppletInterface *ai = qobject_cast<AppletInterface *>(appletObject)) {
|
||||
if (ai->isVisible() && ai->contains(ai->mapFromItem(this, event->localPos()))) {
|
||||
applet = ai->applet();
|
||||
@ -1045,7 +1048,8 @@ void ContainmentInterface::keyPressEvent(QKeyEvent *event)
|
||||
|
||||
void ContainmentInterface::addAppletActions(QMenu *desktopMenu, Plasma::Applet *applet, QEvent *event)
|
||||
{
|
||||
foreach (QAction *action, applet->contextualActions()) {
|
||||
const auto listActions = applet->contextualActions();
|
||||
for (QAction *action : listActions) {
|
||||
if (action) {
|
||||
desktopMenu->addAction(action);
|
||||
}
|
||||
|
@ -77,9 +77,7 @@ void DropMenu::show()
|
||||
m_dropJob->setApplicationActions(m_dropActions);
|
||||
m_dropJob->showMenu(m_dropPoint);
|
||||
} else if (m_menu) {
|
||||
foreach (QAction *action, m_dropActions) {
|
||||
m_menu->addAction(action);
|
||||
}
|
||||
m_menu->addActions(m_dropActions);
|
||||
m_menu->popup(m_dropPoint);
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ bool PluginTest::loadFromPlasma()
|
||||
bool ok = false;
|
||||
const QStringList allEngines = Plasma::PluginLoader::self()->listAllEngines();
|
||||
qDebug() << "All engines: " << allEngines;
|
||||
foreach (const QString &e, allEngines) {
|
||||
for (const QString &e : allEngines) {
|
||||
Plasma::DataEngine *engine = Plasma::PluginLoader::self()->loadDataEngine(e);
|
||||
if (engine) {
|
||||
engine->connectSource(QStringLiteral("Europe/Amsterdam"), this);
|
||||
|
Loading…
Reference in New Issue
Block a user