File indexing completed on 2025-01-19 03:50:37
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2009-02-15 0007 * Description : contextmenu helper class 0008 * 0009 * SPDX-FileCopyrightText: 2009-2011 by Andi Clemens <andi dot clemens at gmail dot com> 0010 * SPDX-FileCopyrightText: 2010-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0011 * 0012 * SPDX-License-Identifier: GPL-2.0-or-later 0013 * 0014 * ============================================================ */ 0015 0016 #include "contextmenuhelper_p.h" 0017 0018 namespace Digikam 0019 { 0020 0021 ContextMenuHelper::ContextMenuHelper(QMenu* const parent) 0022 : QObject(parent), 0023 d (new Private(this)) 0024 { 0025 d->parent = parent; 0026 d->stdActionCollection = DigikamApp::instance()->actionCollection(); 0027 } 0028 0029 ContextMenuHelper::~ContextMenuHelper() 0030 { 0031 delete d; 0032 } 0033 0034 void ContextMenuHelper::setItemFilterModel(ItemFilterModel* const model) 0035 { 0036 d->imageFilterModel = model; 0037 } 0038 0039 void ContextMenuHelper::setSelectedIds(const imageIds& ids) 0040 { 0041 if (d->selectedIds.isEmpty()) 0042 { 0043 d->selectedIds = ids; 0044 } 0045 } 0046 0047 void ContextMenuHelper::setSelectedItems(const QList<QUrl>& urls) 0048 { 0049 if (d->selectedItems.isEmpty()) 0050 { 0051 d->selectedItems = urls; 0052 } 0053 } 0054 0055 bool ContextMenuHelper::imageIdsHaveSameCategory(const imageIds& ids, DatabaseItem::Category category) 0056 { 0057 bool sameCategory = true; 0058 QVariantList varList; 0059 0060 Q_FOREACH (const qlonglong& id, ids) 0061 { 0062 varList = CoreDbAccess().db()->getImagesFields(id, DatabaseFields::Category); 0063 0064 if (varList.isEmpty() || 0065 ((DatabaseItem::Category)varList.first().toInt() != category)) 0066 { 0067 sameCategory = false; 0068 break; 0069 } 0070 } 0071 0072 return sameCategory; 0073 } 0074 0075 } // namespace Digikam 0076 0077 #include "moc_contextmenuhelper.cpp"