File indexing completed on 2025-01-19 03:57:58
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 28/08/2021 0007 * Description : Managing of focus point items on a GraphicsDImgView 0008 * 0009 * SPDX-FileCopyrightText: 2021-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0010 * SPDX-FileCopyrightText: 2021 by Phuoc Khanh Le <phuockhanhnk94 at gmail dot com> 0011 * 0012 * SPDX-License-Identifier: GPL-2.0-or-later 0013 * 0014 * ============================================================ */ 0015 0016 #include "focuspointgroup_p.h" 0017 0018 namespace Digikam 0019 { 0020 0021 FocusPointGroup::Private::Private(FocusPointGroup* const q) 0022 : view (nullptr), 0023 exifRotate (true), 0024 manuallyAddWrapItem (nullptr), 0025 manuallyAddedItem (nullptr), 0026 state (NoPoints), 0027 visibilityController (nullptr), 0028 q (q) 0029 { 0030 } 0031 0032 void FocusPointGroup::Private::applyVisible() 0033 { 0034 if (state == NoPoints) 0035 { 0036 // If not yet loaded, load. load() will transitionToVisible after loading. 0037 0038 q->load(); 0039 } 0040 else if (state == PointsLoaded) 0041 { 0042 if (view->previewItem()->isLoaded()) 0043 { 0044 visibilityController->show(); 0045 } 0046 } 0047 } 0048 0049 FocusPointItem* FocusPointGroup::Private::createItem(const FocusPoint& point) const 0050 { 0051 FocusPointItem* const item = new FocusPointItem(view->previewItem()); 0052 item->setPoint(point); 0053 0054 QRect pointRect = point.getRectBySize(info.dimensions()); 0055 0056 if (!exifRotate) 0057 { 0058 TagRegion::reverseToOrientation(pointRect, 0059 info.orientation(), 0060 info.dimensions()); 0061 } 0062 0063 item->setOriginalRect(pointRect); 0064 item->setVisible(false); 0065 0066 return item; 0067 } 0068 0069 FocusPointItem* FocusPointGroup::Private::addItem(const FocusPoint& point) 0070 { 0071 qCDebug(DIGIKAM_GENERAL_LOG) << "FocusPointsGroup: create item with point" << point; 0072 0073 FocusPointItem* const item = createItem(point); 0074 0075 visibilityController->addItem(item); 0076 0077 items << item; 0078 0079 return item; 0080 } 0081 0082 } // namspace Digikam