File indexing completed on 2024-05-12 04:33:18

0001 /*
0002     SPDX-FileCopyrightText: 2009-2010 Michael G. Hansen <mike at mghansen dot de>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "kipiimagecollectionshared.h"
0008 
0009 // Qt includes
0010 
0011 #include <QDir>
0012 
0013 namespace KXMLKipiCmd
0014 {
0015 
0016 KipiImageCollectionShared::KipiImageCollectionShared(const QUrl& albumPath)
0017     : ImageCollectionShared(),
0018       m_albumPath(albumPath),
0019       m_images()
0020 {
0021     // go through the album and add its images:
0022     const QString albumPathString = m_albumPath.toLocalFile();
0023 
0024     // add only the files, because recursion through directories should be
0025     // handled in KipiInterface::add[Selected]Album
0026     // TODO: restrict the search to images!
0027     const QFileInfoList files     = QDir(albumPathString).entryInfoList(QDir::Files);
0028 
0029     for (QFileInfoList::const_iterator it = files.constBegin(); it!=files.constEnd(); ++it)
0030     {
0031             m_images.append(QUrl::fromLocalFile(it->absoluteFilePath()));
0032     }
0033 }
0034 
0035 KipiImageCollectionShared::KipiImageCollectionShared(const QList<QUrl>& images)
0036     : ImageCollectionShared(),
0037       m_images(images)
0038 {
0039 }
0040 
0041 KipiImageCollectionShared::~KipiImageCollectionShared()
0042 {
0043 }
0044 
0045 QString KipiImageCollectionShared::name()
0046 {
0047     return m_albumPath.url();
0048 }
0049 
0050 QList<QUrl> KipiImageCollectionShared::images()
0051 {
0052     return m_images;
0053 }
0054 
0055 void KipiImageCollectionShared::addImages(const QList<QUrl>& images)
0056 {
0057     m_images.append(images);
0058 }
0059 
0060 void KipiImageCollectionShared::addImage(const QUrl &image)
0061 {
0062     m_images.append(image);
0063 }
0064 
0065 QUrl KipiImageCollectionShared::path()
0066 {
0067     return m_albumPath;
0068 }
0069 
0070 QUrl KipiImageCollectionShared::uploadPath()
0071 {
0072     return m_albumPath;
0073 }
0074 
0075 QUrl KipiImageCollectionShared::uploadRoot()
0076 {
0077     return m_albumPath;
0078 }
0079 
0080 bool KipiImageCollectionShared::isDirectory()
0081 {
0082     return true;
0083 }
0084 
0085 } // namespace KXMLKipiCmd