File indexing completed on 2025-01-19 03:57:56

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2010-09-17
0007  * Description : Face tag region item
0008  *
0009  * SPDX-FileCopyrightText: 2010      by Aditya Bhatt <adityabhatt1991 at gmail dot com>
0010  * SPDX-FileCopyrightText: 2010-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #include "faceitem.h"
0017 
0018 // Local includes
0019 
0020 #include "digikam_debug.h"
0021 #include "assignnamewidgetstates.h"
0022 
0023 namespace Digikam
0024 {
0025 
0026 FaceItem::FaceItem(QGraphicsItem* const parent)
0027     : RegionFrameItem(parent),
0028       m_widget       (nullptr),
0029       m_changer      (nullptr)
0030 {
0031 }
0032 
0033 FaceItem::~FaceItem()
0034 {
0035 }
0036 
0037 void FaceItem::setFace(const FaceTagsIface& face)
0038 {
0039     m_face = face;
0040     updateCurrentTag();
0041     setEditable(!(m_face.isIgnoredName()  ||
0042                   m_face.isConfirmedName()));
0043 }
0044 
0045 FaceTagsIface FaceItem::face() const
0046 {
0047     return m_face;
0048 }
0049 
0050 void FaceItem::setHudWidget(AssignNameWidget* const widget)
0051 {
0052     m_widget = widget;
0053     updateCurrentTag();
0054     RegionFrameItem::setHudWidget(widget);
0055 
0056     // Ensure that all HUD widgets are stacked before the frame items
0057 
0058     hudWidget()->setZValue(1);
0059 }
0060 
0061 AssignNameWidget* FaceItem::widget() const
0062 {
0063     return m_widget;
0064 }
0065 
0066 void FaceItem::switchMode(AssignNameWidget::Mode mode)
0067 {
0068     if (!m_widget || (m_widget->mode() == mode))
0069     {
0070         return;
0071     }
0072 
0073     if (!m_changer)
0074     {
0075         m_changer = new AssignNameWidgetStates(this);
0076     }
0077 
0078     m_changer->changeValue(mode);
0079 }
0080 
0081 void FaceItem::setEditable(bool allowEdit)
0082 {
0083     changeFlags(ShowResizeHandles | MoveByDrag, allowEdit);
0084 }
0085 
0086 void FaceItem::updateCurrentTag()
0087 {
0088     if (m_widget)
0089     {
0090         m_widget->setCurrentFace(m_face);
0091     }
0092 }
0093 
0094 } // namespace Digikam
0095 
0096 #include "moc_faceitem.cpp"