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

# Cppcheck report - digiKam-nl-search-more-criteria-rev-e2466e0973: ../../core/utilities/geolocation/engine/geodata/data/GeoDataLineStyle.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
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    /* ============================================================
     *
     * This file is a part of digiKam project
     * https://www.digikam.org
     *
     * Date        : 2023-05-15
     * Description : geolocation engine based on Marble.
     *               (c) 2007-2022 Marble Team
     *               https://invent.kde.org/education/marble/-/raw/master/data/credits_authors.html
     *
     * SPDX-FileCopyrightText: 2023-2026 by Gilles Caulier <caulier dot gilles at gmail dot com>
     *
     * SPDX-License-Identifier: LGPL-2.1-or-later
     *
     * ============================================================ */

    #include "GeoDataLineStyle.h"

    // Qt includes

    #include <QDataStream>

    // Local includes

    #include "GeoDataTypes.h"

    namespace Marble
    {

    class Q_DECL_HIDDEN GeoDataLineStylePrivate
    {
    public:

        GeoDataLineStylePrivate()
            : m_width(1.0), m_physicalWidth(0.0),
              m_capStyle(Qt::FlatCap), m_penStyle(Qt::SolidLine),
              m_cosmeticOutline(false), m_background(false)
        {
        }

        /// The current width of the line
        float               m_width;
        /// The current real width of the line
        float               m_physicalWidth;
        Qt::PenCapStyle     m_capStyle;
        Qt::PenStyle        m_penStyle;
        bool                m_cosmeticOutline;
        bool                m_background;
        QVector< qreal >    m_pattern;
    };

    GeoDataLineStyle::GeoDataLineStyle()
        : d(new GeoDataLineStylePrivate)
    {
    }

    GeoDataLineStyle::GeoDataLineStyle(const GeoDataLineStyle& other)
        : GeoDataColorStyle(other), d(new GeoDataLineStylePrivate(*other.d))
    {
    }

    GeoDataLineStyle::GeoDataLineStyle(const QColor& color)
        : d(new GeoDataLineStylePrivate)
    {
        setColor(color);
    }

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

    GeoDataLineStyle& GeoDataLineStyle::operator=(const GeoDataLineStyle& other)
    {
        GeoDataColorStyle::operator=(other);
        *d = *other.d;
        return *this;
    }

    bool GeoDataLineStyle::operator==(const GeoDataLineStyle& other) const
    {
        if (GeoDataColorStyle::operator!=(other))
        {
            return false;
        }

        return d->m_width == other.d->m_width &&
               d->m_physicalWidth == other.d->m_physicalWidth &&
               d->m_capStyle == other.d->m_capStyle &&
               d->m_penStyle == other.d->m_penStyle &&
               d->m_background == other.d->m_background &&
               d->m_pattern == other.d->m_pattern;
    }

    bool GeoDataLineStyle::operator!=(const GeoDataLineStyle& other) const
    {
        return !this->operator==(other);
    }

    const char* GeoDataLineStyle::nodeType() const
    {
        return GeoDataTypes::GeoDataLineStyleType;
    }

    void GeoDataLineStyle::setWidth(float width)<--- Shadow argument
    {
        d->m_width = width;
    }

    float GeoDataLineStyle::width() const
    {
        return d->m_width;
    }

    float GeoDataLineStyle::physicalWidth() const
    {
        return d->m_physicalWidth;
    }

    void GeoDataLineStyle::setPhysicalWidth(float realWidth)
    {
        d->m_physicalWidth = realWidth;
    }

    bool GeoDataLineStyle::cosmeticOutline() const
    {
        return d->m_cosmeticOutline;
    }

    void GeoDataLineStyle::setCosmeticOutline(bool enabled)
    {
        d->m_cosmeticOutline = enabled;
    }

    Qt::PenCapStyle GeoDataLineStyle::capStyle() const
    {
        return d->m_capStyle;
    }

    void GeoDataLineStyle::setCapStyle(Qt::PenCapStyle style)
    {
        d->m_capStyle = style;
    }

    Qt::PenStyle GeoDataLineStyle::penStyle() const
    {
        return d->m_penStyle;
    }

    void GeoDataLineStyle::setPenStyle(Qt::PenStyle style)
    {
        d->m_penStyle = style;
    }

    bool GeoDataLineStyle::background() const
    {
        return d->m_background;
    }

    void GeoDataLineStyle::setBackground(bool background)<--- Shadow argument
    {
        d->m_background = background;
    }

    QVector< qreal > GeoDataLineStyle::dashPattern() const
    {
        return d->m_pattern;
    }

    void GeoDataLineStyle::setDashPattern(const QVector< qreal >& pattern)
    {
        d->m_pattern = pattern;
    }

    void GeoDataLineStyle::pack(QDataStream& stream) const
    {
        GeoDataColorStyle::pack(stream);

        stream << d->m_width;
        stream << d->m_physicalWidth;
        stream << (int)d->m_penStyle;
        stream << (int)d->m_capStyle;
        stream << d->m_background;
    }

    void GeoDataLineStyle::unpack(QDataStream& stream)
    {
        GeoDataColorStyle::unpack(stream);

        stream >> d->m_width;
        stream >> d->m_physicalWidth;
        int style;
        stream >> style;
        d->m_penStyle = (Qt::PenStyle) style;
        stream >> style;
        d->m_capStyle = (Qt::PenCapStyle) style;
        stream >> d->m_background;
    }

    } // namespace Marble