File indexing completed on 2025-01-05 03:51:10
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2009-04-19 0007 * Description : Qt model-view for items - the delegate 0008 * 0009 * SPDX-FileCopyrightText: 2002-2005 by Renchi Raju <renchi dot raju at gmail dot com> 0010 * SPDX-FileCopyrightText: 2002-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0011 * SPDX-FileCopyrightText: 2009-2011 by Andi Clemens <andi dot clemens at gmail dot com> 0012 * SPDX-FileCopyrightText: 2006-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de> 0013 * 0014 * SPDX-License-Identifier: GPL-2.0-or-later 0015 * 0016 * ============================================================ */ 0017 0018 #include "digikamitemdelegate.h" 0019 #include "digikamitemdelegate_p.h" 0020 0021 // Local includes 0022 0023 #include "itemcategorydrawer.h" 0024 #include "itemcategorizedview.h" 0025 #include "itemdelegateoverlay.h" 0026 #include "itemmodel.h" 0027 #include "itemfiltermodel.h" 0028 #include "applicationsettings.h" 0029 #include "digikam_debug.h" 0030 0031 namespace Digikam 0032 { 0033 0034 void DigikamItemDelegatePrivate::init(DigikamItemDelegate* const q, ItemCategorizedView* const parent) 0035 { 0036 categoryDrawer = new ItemCategoryDrawer(parent); 0037 0038 QObject::connect(ApplicationSettings::instance(), SIGNAL(setupChanged()), 0039 q, SLOT(slotSetupChanged())); 0040 } 0041 0042 DigikamItemDelegatePrivate::~DigikamItemDelegatePrivate() 0043 { 0044 delete categoryDrawer; 0045 } 0046 0047 // ------------------------------------------------------------------------------------------------ 0048 0049 DigikamItemDelegate::DigikamItemDelegate(ItemCategorizedView* parent) 0050 : ItemDelegate(*new DigikamItemDelegatePrivate, parent) 0051 { 0052 Q_D(DigikamItemDelegate); 0053 d->init(this, parent); 0054 } 0055 0056 DigikamItemDelegate::DigikamItemDelegate(DigikamItemDelegatePrivate& dd, ItemCategorizedView* parent) 0057 : ItemDelegate(dd, parent) 0058 { 0059 Q_D(DigikamItemDelegate); 0060 d->init(this, parent); 0061 } 0062 0063 DigikamItemDelegate::~DigikamItemDelegate() 0064 { 0065 } 0066 0067 void DigikamItemDelegate::updateRects() 0068 { 0069 Q_D(DigikamItemDelegate); 0070 0071 int y = d->margin; 0072 d->pixmapRect = QRect(d->margin, y, d->contentWidth, d->contentWidth); 0073 y = d->pixmapRect.bottom(); 0074 d->imageInformationRect = QRect(d->margin, y, d->contentWidth, 0); 0075 ApplicationSettings* const albumSettings = ApplicationSettings::instance(); 0076 d->drawImageFormat = albumSettings->getIconShowImageFormat(); 0077 d->drawCoordinates = albumSettings->getIconShowCoordinates(); 0078 const int iconSize = qBound(16, (d->contentWidth + 2*d->margin) / 8 - 2, 48); 0079 0080 if (albumSettings->getIconShowPickLabel()) 0081 { 0082 d->pickLabelRect = QRect(d->margin, y - d->margin, iconSize, iconSize); 0083 } 0084 d->coordinatesRect = QRect(d->contentWidth - iconSize+2, d->pixmapRect.top(), iconSize, iconSize); 0085 d->groupRect = QRect(d->contentWidth - iconSize + d->margin, y - d->margin, iconSize, iconSize); 0086 const bool showInfos = ((d->contentWidth - 2*d->radius) > ThumbnailSize::Small); 0087 0088 if (albumSettings->getIconShowRating()) 0089 { 0090 d->ratingRect = QRect(d->margin, y, d->contentWidth, d->starPolygonSize.height()); 0091 y = d->ratingRect.bottom(); 0092 } 0093 0094 if (albumSettings->getIconShowName()) 0095 { 0096 d->nameRect = QRect(d->margin, y, d->contentWidth-d->margin, d->oneRowRegRect.height()); 0097 y = d->nameRect.bottom(); 0098 } 0099 0100 if (albumSettings->getIconShowTitle()) 0101 { 0102 d->titleRect = QRect(d->margin, y, d->contentWidth, d->oneRowRegRect.height()); 0103 y = d->titleRect.bottom(); 0104 } 0105 0106 if (showInfos && albumSettings->getIconShowComments()) 0107 { 0108 d->commentsRect = QRect(d->margin, y, d->contentWidth, d->oneRowComRect.height()); 0109 y = d->commentsRect.bottom(); 0110 } 0111 0112 if (showInfos && albumSettings->getIconShowDate()) 0113 { 0114 d->dateRect = QRect(d->margin, y, d->contentWidth, d->oneRowXtraRect.height()); 0115 y = d->dateRect.bottom(); 0116 } 0117 0118 if (showInfos && albumSettings->getIconShowModDate()) 0119 { 0120 d->modDateRect = QRect(d->margin, y, d->contentWidth, d->oneRowXtraRect.height()); 0121 y = d->modDateRect.bottom(); 0122 } 0123 0124 if (showInfos && albumSettings->getIconShowResolution()) 0125 { 0126 d->resolutionRect = QRect(d->margin, y, d->contentWidth, d->oneRowXtraRect.height()); 0127 y = d->resolutionRect.bottom() ; 0128 } 0129 0130 if (showInfos && albumSettings->getIconShowAspectRatio()) 0131 { 0132 d->arRect = QRect(d->margin, y, d->contentWidth, d->oneRowXtraRect.height()); 0133 y = d->arRect.bottom() ; 0134 } 0135 0136 if (showInfos && albumSettings->getIconShowSize()) 0137 { 0138 d->sizeRect = QRect(d->margin, y, d->contentWidth, d->oneRowXtraRect.height()); 0139 y = d->sizeRect.bottom(); 0140 } 0141 0142 if (showInfos && albumSettings->getIconShowTags()) 0143 { 0144 d->tagRect = QRect(d->margin, y, d->contentWidth, d->oneRowComRect.height()); 0145 y = d->tagRect.bottom(); 0146 } 0147 0148 d->imageInformationRect.setBottom(y); 0149 0150 d->rect = QRect(0, 0, d->contentWidth + 2*d->margin, y+d->margin+d->radius); 0151 d->gridSize = QSize(d->rect.width() + d->spacing, d->rect.height() + d->spacing); 0152 } 0153 0154 } // namespace Digikam 0155 0156 #include "moc_digikamitemdelegate.cpp"