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

# Cppcheck report - digiKam-nl-search-more-criteria-rev-e2466e0973: ../../core/libs/widgets/graphicsview/graphicsdimgview.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
    /* ============================================================
     *
     * This file is a part of digiKam project
     * https://www.digikam.org
     *
     * Date        : 2010-04-30
     * Description : Graphics View for DImg preview
     *
     * SPDX-FileCopyrightText: 2010-2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
     * SPDX-FileCopyrightText: 2011-2026 by Gilles Caulier <caulier dot gilles at gmail dot com>
     *
     * SPDX-License-Identifier: GPL-2.0-or-later
     *
     * ============================================================ */

    #include "graphicsdimgview_p.h"

    namespace Digikam
    {

    GraphicsDImgView::GraphicsDImgView(QWidget* const parent)
        : QGraphicsView(parent),
          d            (new Private)
    {
        setMouseTracking(true);

        d->scene  = new QGraphicsScene(this);
        d->scene->setItemIndexMethod(QGraphicsScene::NoIndex);

        setScene(d->scene);
        d->layout = new SinglePhotoPreviewLayout(this);
        d->layout->setGraphicsView(this);

        setViewportUpdateMode(QGraphicsView::MinimalViewportUpdate);

        horizontalScrollBar()->setSingleStep(1);
        horizontalScrollBar()->setPageStep(1);
        verticalScrollBar()->setSingleStep(1);
        verticalScrollBar()->setPageStep(1);

        // Enable the gesture support

        grabGesture(Qt::PinchGesture);
        grabGesture(Qt::PanGesture);
        grabGesture(Qt::SwipeGesture);

        // ---

        d->magnifier = new MagnifierItem();
        d->magnifier->setVisible(false);
        d->magnifier->setMagnifierSize(150);
        d->scene->addItem(d->magnifier);

        connect(d->layout, &SinglePhotoPreviewLayout::zoomFactorChanged,
                this, &GraphicsDImgView::slotZoomFactorChanged);

        // ---

        connect(horizontalScrollBar(), SIGNAL(valueChanged(int)),
                this, SLOT(slotContentsMoved()));

        connect(verticalScrollBar(), SIGNAL(valueChanged(int)),
                this, SLOT(slotContentsMoved()));
    }

    GraphicsDImgView::~GraphicsDImgView()
    {
        if (d->magnifier)
        {
            d->scene->removeItem(d->magnifier);
            delete d->magnifier;
        }

        delete d;
    }

    int GraphicsDImgView::contentsX() const
    {
        return horizontalScrollBar()->value();
    }

    int GraphicsDImgView::contentsY() const
    {
        return verticalScrollBar()->value();
    }

    void GraphicsDImgView::setContentsPos(int x, int y)
    {
        horizontalScrollBar()->setValue(x);
        verticalScrollBar()->setValue(y);
    }

    void GraphicsDImgView::setShowText(bool val)
    {
        d->showText = val;
    }

    QRect GraphicsDImgView::visibleArea() const
    {
        return (mapToScene(viewport()->geometry()).boundingRect().toRect());
    }

    void GraphicsDImgView::setItem(GraphicsDImgItem* const item)<--- Shadow argument
    {
        d->item = item;
        d->item->setDisplayWidget(this);

        d->scene->addItem(d->item);
        d->layout->addItem(d->item);
    }

    GraphicsDImgItem* GraphicsDImgView::item() const
    {
        return d->item;
    }

    DImgPreviewItem* GraphicsDImgView::previewItem() const
    {
        return dynamic_cast<DImgPreviewItem*>(item());
    }

    SinglePhotoPreviewLayout* GraphicsDImgView::layout() const
    {
        return d->layout;
    }

    void GraphicsDImgView::setScaleFitToWindow(bool value)
    {
        d->layout->setScaleFitToWindow(value);
    }

    void GraphicsDImgView::fitToWindow()
    {
        d->layout->fitToWindow();
        update();
    }

    void GraphicsDImgView::toggleFullScreen(bool set)
    {
        if (set)
        {
            d->scene->setBackgroundBrush(Qt::black);
            setFrameShape(QFrame::NoFrame);
        }
        else
        {
            d->scene->setBackgroundBrush(Qt::NoBrush);
            setFrameShape(QFrame::StyledPanel);
        }
    }

    void GraphicsDImgView::slotZoomFactorChanged()
    {
        if (d->magnifierEnabled && d->item)
        {
            updateMagnifier();
        }

        Q_EMIT signalZoomFactorChanged();
    }

    } // namespace Digikam

    #include "moc_graphicsdimgview.cpp"