D19913: [plasma-framework] make it compiles without foreach

Ahmad Samir noreply at phabricator.kde.org
Wed Apr 15 09:41:45 BST 2020


ahmadsamir added inline comments.

INLINE COMMENTS

> iconitem.cpp:628
>      // setup time.
> -    foreach (const QString& overlay, m_overlays) {
> +    for (const QString& overlay : qAsConst(m_overlays)) {
>          if (!overlay.isEmpty()) {

Coding style &overlay

> pluginloader.cpp:328
>      const QList<KPluginMetaData> packagePlugins = KPackage::PackageLoader::self()->listPackages(QStringLiteral("Plasma/DataEngine"));
>      for (auto& plugin : packagePlugins) {
>          engines << plugin.pluginId();

Coding style, auto &plugin

> pluginloader.cpp:567
>      //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()));

Style, '&md'

> pluginloader.cpp:645
>      QStringList categories;
> -    foreach (auto& plugin, allApplets) {
> +    for (auto& plugin : allApplets) {
>          if (plugin.category().isEmpty()) {

const, and style '&plugin'.

> applet_p.cpp:416
>          QList<QAction *> qactions;
> -        names << QStringLiteral("add sibling containment") << QStringLiteral("configure shortcuts") << QStringLiteral("lock widgets");
> -        foreach (const QString &name, names) {
> +        const QList<QString> names = QList<QString>() << QStringLiteral("add sibling containment") << QStringLiteral("configure shortcuts") << QStringLiteral("lock widgets");
> +        for (const QString &name : names) {

Nit-pick: initializer list instead of <<.

> theme_p.cpp:837
> +        for (const QString &theme : qAsConst(fallbackThemes)) {
>              QString metadataPath(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1Literal(PLASMA_RELATIVE_DATA_INSTALL_DIR "/desktoptheme/") % theme % QLatin1Literal("/metadata.desktop")));
>              KConfig metadata(metadataPath, KConfig::SimpleConfig);

s/QLatin1Literal/QStringLiteral/

> timetracker.cpp:44
>  
> -        Q_FOREACH(const ObjectHistory& history, m_data) {
> +        for (const ObjectHistory& history : qAsConst(m_data)) {
>              array.append(QJsonObject {

Style "&history".

> timetracker.cpp:71
>          Q_ASSERT(!events.isEmpty());
> -        foreach(const TimeEvent& ev, events) {
> +        for (const TimeEvent& ev : events) {
>              ret.append(QJsonObject {

"&ev"

> containmentinterface.cpp:857
> +    for (QAction *a : qAsConst(listActions)) {
> +        if (a->objectName() == QStringLiteral("lock widgets") || a->menu()) {
>              //It is up to the Containment to decide if the user is allowed or not

QLatin1String

REPOSITORY
  R242 Plasma Framework (Library)

BRANCH
  compile_without_foreach (branched from master)

REVISION DETAIL
  https://phabricator.kde.org/D19913

To: mlaurent, dfaure
Cc: ahmadsamir, nicolasfella, broulik, apol, kde-frameworks-devel, LeGast00n, cblack, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20200415/04b7db26/attachment-0001.html>


More information about the Kde-frameworks-devel mailing list