Commit 209b21e2 authored by Méven Car's avatar Méven Car

Startkde: Foreach conversion, prevents warnings, improve some variables naming

Test Plan: Builds

Reviewers: apol, #plasma

Reviewed By: apol

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D26805
parent 63eea455
......@@ -105,7 +105,7 @@ bool KCMInit::runModule(const QString &libName, KService::Ptr service)
void KCMInit::runModules( int phase )
{
QString KCMINIT_PREFIX=QStringLiteral("kcminit_");
foreach (const KService::Ptr & service, list) {
for (const KService::Ptr & service : qAsConst(m_list)) {
const QVariant tmp = service->property(QStringLiteral("X-KDE-Init-Library"), QVariant::String);
QString library;
if( tmp.isValid() )
......@@ -135,9 +135,9 @@ void KCMInit::runModules( int phase )
continue;
// try to load the library
if (!alreadyInitialized.contains(library)) {
if (!m_alreadyInitialized.contains(library)) {
runModule(library, service);
alreadyInitialized.insert(library);
m_alreadyInitialized.insert(library);
}
}
}
......@@ -150,9 +150,9 @@ KCMInit::KCMInit( const QCommandLineParser& args )
}
if (args.isSet(QStringLiteral("list"))) {
list = KServiceTypeTrader::self()->query( QStringLiteral("KCModuleInit") );
m_list = KServiceTypeTrader::self()->query( QStringLiteral("KCModuleInit") );
foreach (const KService::Ptr & service, list) {
for (const KService::Ptr &service : qAsConst(m_list)) {
if (service->library().isEmpty())
continue; // Skip
printf("%s\n", QFile::encodeName(service->desktopEntryName()).data());
......@@ -170,11 +170,11 @@ KCMInit::KCMInit( const QCommandLineParser& args )
qCritical() << i18n("Module %1 not found", module);
return;
} else {
list.append(serv);
m_list.append(serv);
}
} else {
// locate the desktop files
list = KServiceTypeTrader::self()->query( QStringLiteral("KCModuleInit") );
m_list = KServiceTypeTrader::self()->query( QStringLiteral("KCModuleInit") );
}
if( startup ) {
......
......@@ -39,8 +39,8 @@ class KCMInit : public QObject
private:
bool runModule(const QString &libName, KService::Ptr service);
void runModules( int phase );
KService::List list;
QSet<QString> alreadyInitialized;
KService::List m_list;
QSet<QString> m_alreadyInitialized;
};
#endif // MAIN_H
......@@ -29,8 +29,8 @@ int main(int argc, char **argv)
// the internal QEventLoopLocker expires and our app exits
app.setQuitLockEnabled(false);
auto startup = new Startup(&app);
auto shutdown = new Shutdown(&app);
new Startup(&app);
new Shutdown(&app);
app.exec();
}
......@@ -76,11 +76,11 @@ void Shutdown::logoutComplete() {
void Shutdown::runShutdownScripts()
{
const QStringList shutdownFolders = QStandardPaths::locateAll(QStandardPaths::GenericConfigLocation, QStringLiteral("plasma-workspace/shutdown"), QStandardPaths::LocateDirectory);
foreach (const QString &shutDownFolder, shutdownFolders) {
for (const QString &shutDownFolder : shutdownFolders) {
QDir dir(shutDownFolder);
const QStringList entries = dir.entryList(QDir::Files);
foreach (const QString &file, entries) {
for (const QString &file : entries) {
// Don't execute backup files
if (!file.endsWith(QLatin1Char('~')) && !file.endsWith(QLatin1String(".bak")) &&
(file[0] != QLatin1Char('%') || !file.endsWith(QLatin1Char('%'))) &&
......
......@@ -323,7 +323,7 @@ void StartupPhase2::runUserAutostart()
}
const QStringList entries = dir.entryList(QDir::Files);
foreach (const QString &file, entries) {
for (const QString &file : entries) {
// Don't execute backup files
if (!file.endsWith(QLatin1Char('~')) && !file.endsWith(QLatin1String(".bak")) &&
(file[0] != QLatin1Char('%') || !file.endsWith(QLatin1Char('%'))) &&
......@@ -361,7 +361,7 @@ bool StartupPhase2::migrateKDE4Autostart(const QString &autostartFolder)
const QDir oldFolder(oldAutostart);
qCDebug(PLASMA_SESSION) << "Copying autostart files from" << oldFolder.path();
const QStringList entries = oldFolder.entryList(QDir::Files);
foreach (const QString &file, entries) {
for (const QString &file : entries) {
const QString src = oldFolder.absolutePath() + QLatin1Char('/') + file;
const QString dest = autostartFolder + QLatin1Char('/') + file;
QFileInfo info(src);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment