File indexing completed on 2025-01-19 03:53:38
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2007-03-20 0007 * Description : Container for image info objects 0008 * 0009 * SPDX-FileCopyrightText: 2007-2013 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de> 0010 * SPDX-FileCopyrightText: 2007-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 "iteminfolist.h" 0017 0018 // Local includes 0019 0020 0021 namespace Digikam 0022 { 0023 0024 ItemInfoList::ItemInfoList() 0025 { 0026 } 0027 0028 ItemInfoList::ItemInfoList(const QList<ItemInfo>& list) 0029 : QList<ItemInfo>(list) 0030 { 0031 } 0032 0033 ItemInfoList::ItemInfoList(const QList<qlonglong>& idList) 0034 { 0035 Q_FOREACH (const qlonglong& id, idList) 0036 { 0037 append(ItemInfo(id)); 0038 } 0039 } 0040 0041 QList<qlonglong> ItemInfoList::toImageIdList() const 0042 { 0043 QList<qlonglong> idList; 0044 0045 Q_FOREACH (const ItemInfo& info, *this) 0046 { 0047 idList << info.id(); 0048 } 0049 0050 return idList; 0051 } 0052 0053 QList<QUrl> ItemInfoList::toImageUrlList() const 0054 { 0055 QList<QUrl> urlList; 0056 0057 Q_FOREACH (const ItemInfo& info, *this) 0058 { 0059 urlList << info.fileUrl(); 0060 } 0061 0062 return urlList; 0063 } 0064 0065 bool ItemInfoList::namefileLessThan(const ItemInfo& d1, const ItemInfo& d2) 0066 { 0067 return d1.name().toLower() < d2.name().toLower(); // sort by name 0068 } 0069 0070 ItemInfo ItemInfoList::singleGroupMainItem() const 0071 { 0072 if (length() == 1) 0073 { 0074 return first(); 0075 } 0076 0077 ItemInfo mainItem; 0078 ItemInfoList grouped; 0079 0080 if (first().isGrouped()) 0081 { 0082 mainItem = first().groupImage(); 0083 0084 if (!this->contains(mainItem)) 0085 { 0086 return ItemInfo(); 0087 } 0088 } 0089 else if (first().hasGroupedImages()) 0090 { 0091 mainItem = first(); 0092 } 0093 else 0094 { 0095 return ItemInfo(); 0096 } 0097 0098 grouped << mainItem << mainItem.groupedImages(); 0099 0100 Q_FOREACH (const ItemInfo& info, *this) 0101 { 0102 if (!grouped.contains(info)) 0103 { 0104 return ItemInfo(); 0105 } 0106 } 0107 0108 return mainItem; 0109 } 0110 0111 } // namespace Digikam