File indexing completed on 2025-01-05 03:58:06

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2008-07-23
0007  * Description : QGraphicsRectItem wrapper for FacesEngine Demo
0008  *
0009  * SPDX-FileCopyrightText: 2009-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0010  * SPDX-FileCopyrightText:      2008 by Adrien Bustany <madcat at mymadcat dot com>
0011  * SPDX-FileCopyrightText:      2010 by Aditya Bhatt <adityabhatt1991 at gmail dot com>
0012  *
0013  * SPDX-License-Identifier: GPL-2.0-or-later
0014  *
0015  * ============================================================ */
0016 
0017 #include "demofancyrect.h"
0018 
0019 // Qt includes
0020 
0021 #include <QGraphicsScene>
0022 
0023 namespace FaceEngineDemo
0024 {
0025 
0026 FancyRect::FancyRect(QGraphicsItem* const parent)
0027     : QGraphicsRectItem(parent)
0028 {
0029 }
0030 
0031 FancyRect::FancyRect(const QRectF& rect, QGraphicsItem* const parent)
0032     : QGraphicsRectItem(rect, parent)
0033 {
0034 }
0035 
0036 FancyRect::FancyRect(qreal x, qreal y, qreal w, qreal h, QGraphicsItem* const parent)
0037     : QGraphicsRectItem(x, y, w, h, parent)
0038 {
0039 }
0040 
0041 FancyRect::FancyRect(QGraphicsRectItem* const other, QGraphicsItem* const parent)
0042     : QGraphicsRectItem(parent)
0043 {
0044     setPos(other->pos());
0045     setRect(other->rect());
0046     setPen(other->pen());
0047 }
0048 
0049 void FancyRect::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
0050 {
0051     if (option->state.testFlag(QStyle::State_Selected))
0052     {
0053         QPen selectedPen = pen();
0054         selectedPen.setColor(Qt::red);
0055         painter->setPen(selectedPen);
0056         painter->drawRect(rect());
0057     }
0058     else
0059     {
0060         QGraphicsRectItem::paint(painter, option, widget);
0061     }
0062 }
0063 
0064 } // Namespace FacesEngineDemo