File indexing completed on 2025-01-19 03:59:30
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2007-14-02 0007 * Description : interface to get item info from an albums list. 0008 * 0009 * SPDX-FileCopyrightText: 2007-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #include "iteminfoalbumsjob.h" 0016 0017 // Qt includes 0018 0019 #include <QString> 0020 #include <QUrl> 0021 0022 // Local includes 0023 0024 #include "iteminfojob.h" 0025 0026 namespace Digikam 0027 { 0028 0029 class Q_DECL_HIDDEN ItemInfoAlbumsJob::Private 0030 { 0031 public: 0032 0033 explicit Private() 0034 { 0035 } 0036 0037 AlbumList albumsList; 0038 AlbumList::Iterator albumIt; 0039 0040 ItemInfoList itemsList; 0041 0042 ItemInfoJob imageInfoJob; 0043 }; 0044 0045 ItemInfoAlbumsJob::ItemInfoAlbumsJob(QObject* const parent) 0046 : QObject(parent), 0047 d (new Private) 0048 { 0049 connect(&d->imageInfoJob, SIGNAL(signalItemsInfo(ItemInfoList)), 0050 this, SLOT(slotItemsInfo(ItemInfoList))); 0051 0052 connect(&d->imageInfoJob, SIGNAL(signalCompleted()), 0053 this, SLOT(slotComplete())); 0054 } 0055 0056 ItemInfoAlbumsJob::~ItemInfoAlbumsJob() 0057 { 0058 delete d; 0059 } 0060 0061 void ItemInfoAlbumsJob::allItemsFromAlbums(const AlbumList& albumsList) 0062 { 0063 if (albumsList.isEmpty()) 0064 { 0065 return; 0066 } 0067 0068 d->albumsList = albumsList; 0069 d->albumIt = d->albumsList.begin(); 0070 parseAlbum(); 0071 } 0072 0073 void ItemInfoAlbumsJob::parseAlbum() 0074 { 0075 d->imageInfoJob.allItemsFromAlbum(*d->albumIt); 0076 } 0077 0078 void ItemInfoAlbumsJob::stop() 0079 { 0080 d->imageInfoJob.stop(); 0081 d->albumsList.clear(); 0082 } 0083 0084 void ItemInfoAlbumsJob::slotItemsInfo(const ItemInfoList& items) 0085 { 0086 d->itemsList += items; 0087 } 0088 0089 void ItemInfoAlbumsJob::slotComplete() 0090 { 0091 ++d->albumIt; 0092 0093 if (d->albumIt == d->albumsList.end()) 0094 { 0095 stop(); 0096 Q_EMIT signalCompleted(d->itemsList); 0097 return; 0098 } 0099 0100 parseAlbum(); 0101 } 0102 0103 } // namespace Digikam 0104 0105 #include "moc_iteminfoalbumsjob.cpp"