Cppcheck - HTML report - digiKam-nl-search-more-criteria-rev-e2466e0973

# Cppcheck report - digiKam-nl-search-more-criteria-rev-e2466e0973: ../../core/utilities/focuspointmanagement/focuspointitem.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
    /* ============================================================
     *
     * This file is a part of digiKam project
     * https://www.digikam.org
     *
     * Date        : 28/08/2021
     * Description : Managing of focus point items on a GraphicsDImgView
     *
     * SPDX-FileCopyrightText: 2021-2026 by Gilles Caulier <caulier dot gilles at gmail dot com>
     * SPDX-FileCopyrightText: 2021 by Phuoc Khanh Le <phuockhanhnk94 at gmail dot com>
     *
     * SPDX-License-Identifier: GPL-2.0-or-later
     *
     * ============================================================ */

    #include "focuspointitem.h"

    // Qt includes

    #include <QPainter>
    #include <QPen>

    // Local includes

    #include "digikam_debug.h"
    #include "assignnamewidgetstates.h"

    namespace Digikam
    {

    class Q_DECL_HIDDEN FocusPointItem::Private
    {
    public:

        Private() = default;

        FocusPoint point;
        QColor     color = QColor::fromRgb(0, 0, 0, 255); ///< alpha is 100 to let more transparency;
        float      width = 3.0F;
    };

    FocusPointItem::FocusPointItem(QGraphicsItem* const parent)
        : RegionFrameItem(parent),
          d              (new Private)
    {
    }

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

    void FocusPointItem::setPoint(const FocusPoint& point)<--- Shadow argument
    {
        d->point = point;
        setEditable(false);

        switch (d->point.getType())
        {
            case FocusPoint::TypePoint::Inactive:
            {
                d->color.setAlpha(130);
                d->width = 1;

                break;
            }

            case FocusPoint::TypePoint::Selected:
            case FocusPoint::TypePoint::SelectedInFocus:
            {
                d->color.setRed(255);

                break;
            }

            default: // FocusPoint::TypePoint::InFocus
            {
                // TODO

                break;
            }
        }
    }

    FocusPoint FocusPointItem::point() const
    {
        return d->point;
    }

    void FocusPointItem::paint(QPainter* painter, const QStyleOptionGraphicsItem*, QWidget*)
    {
        QPen pen;
        pen.setWidth(d->width);
        pen.setColor(d->color);

        QRectF drawRect = boundingRect();

        qCDebug(DIGIKAM_GENERAL_LOG) << "FocusPointsItem: rectangle:" << drawRect;

        painter->setPen(pen);
        painter->drawRect(drawRect);
    }

    void FocusPointItem::setEditable(bool allowEdit)
    {
        changeFlags(GeometryEditable, allowEdit);
    }

    } // namespace Digikam

    #include "moc_focuspointitem.cpp"