Cppcheck - HTML report - digiKam-master-rev-70b072e127

# Cppcheck report - digiKam-master-rev-70b072e127: ../../core/utilities/queuemanager/dplugins/dpluginbqm.cpp

      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    /* ============================================================
     *
     * This file is a part of digiKam project
     * https://www.digikam.org
     *
     * Date        : 2018-07-30
     * Description : Batch Queue Manager digiKam plugin definition.
     *
     * SPDX-FileCopyrightText: 2018-2026 by Gilles Caulier <caulier dot gilles at gmail dot com>
     *
     * SPDX-License-Identifier: GPL-2.0-or-later
     *
     * ============================================================ */

    #include "dpluginbqm.h"

    // Qt includes

    #include <QApplication>

    // Local includes

    #include "digikam_version.h"
    #include "digikam_debug.h"
    #include "batchtoolsfactory.h"

    namespace Digikam
    {

    class Q_DECL_HIDDEN DPluginBqm::Private
    {
    public:

        Private() = default;

    public:

        QList<BatchTool*> tools;
    };

    DPluginBqm::DPluginBqm(QObject* const parent)
        : DPlugin(parent),
          d      (new Private)
    {
    }

    DPluginBqm::~DPluginBqm()
    {
        delete d;
    }

    void DPluginBqm::setVisible(bool b)
    {
        Q_EMIT signalVisible(b);
    }

    int DPluginBqm::count() const
    {
        return d->tools.count();
    }

    QList<BatchTool*> DPluginBqm::tools(QObject* const parent) const<--- Either there is a missing override/final keyword, or the parameter 'parent' can be declared as pointer to const
    {
        QList<BatchTool*> list;

        for (BatchTool* const t : std::as_const(d->tools))
        {
            if (t && (t->parent() == parent))
            {
                list << t;
            }
        }

        return list;
    }

    BatchTool* DPluginBqm::findToolByName(const QString& name, QObject* const parent) const
    {
        const auto ts = tools(parent);

        for (BatchTool* const t : ts)
        {
            if (t && (t->objectName() == name))
            {   // cppcheck-suppress useStlAlgorithm
                return t;
            }
        }

        return nullptr;
    }

    void DPluginBqm::addTool(BatchTool* const t)
    {
        t->setProperty("DPluginIId",      iid());
        t->setProperty("DPluginIfaceIId", ifaceIid());
        d->tools.append(t);
    }

    BqmInfoIface* DPluginBqm::infoIface() const
    {
        BqmInfoIface* const iface = BatchToolsFactory::instance()->infoIface();

        if (iface)
        {
            return iface;
        }

        return nullptr;
    }

    QStringList DPluginBqm::categories() const
    {
        QStringList list;

        for (const BatchTool* const t : std::as_const(d->tools))
        {
            QString cat = t->toolGroupToString();

            if (!list.contains(cat))
            {
                list << cat;
            }
        }

        list.sort();

        return list;
    }

    bool DPluginBqm::hasVisibilityProperty() const
    {
        // NOTE: all BQM plugins are not configurable.
        // Code is missing in BQM to check workflow tools list validity if a plugin is disabled from setup dialog.

        return false;
    }

    QString DPluginBqm::ifaceIid() const
    {
        return QLatin1String(DIGIKAM_DPLUGIN_BQM_IID);
    }

    } // namespace Digikam

    #include "moc_dpluginbqm.cpp"