File indexing completed on 2024-05-05 04:33:14

0001 /*
0002     SPDX-FileCopyrightText: 2004-2018 Gilles Caulier <caulier dot gilles at gmail dot com>
0003     SPDX-FileCopyrightText: 2004-2005 Renchi Raju <renchi dot raju at gmail dot com>
0004     SPDX-FileCopyrightText: 2004-2005 Jesper K. Pedersen <blackie at kde dot org>
0005     SPDX-FileCopyrightText: 2004-2005 Aurelien Gateau <aurelien dot gateau at free dot fr>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 // Local includes
0011 
0012 #include "imagecollectionshared.h"
0013 #include "imagecollection.h"
0014 #include "libkipi_debug.h"
0015 
0016 // Macros
0017 
0018 #define PrintWarningMessageFeature(feature)                                                       \
0019         qCWarning(LIBKIPI_LOG) << "This should only be invoked if the host application supports " \
0020                                   "KIPI::Features (" << feature << "). If host application do "   \
0021                                   "support that, then this function should have been overridden " \
0022                                   "in the KIPI host interface."
0023 
0024 namespace KIPI
0025 {
0026 
0027 ImageCollectionShared::ImageCollectionShared()
0028     : m_count(1)
0029 {
0030 }
0031 
0032 ImageCollectionShared::~ImageCollectionShared()
0033 {
0034 }
0035 
0036 void ImageCollectionShared::addRef()
0037 {
0038     m_count++;
0039 }
0040 
0041 void ImageCollectionShared::removeRef()
0042 {
0043     m_count--;
0044 
0045     if ( m_count == 0 )
0046     {
0047         //qCDebug(LIBKIPI_LOG) << "Deleting!";
0048         delete this;
0049     }
0050 }
0051 
0052 QUrl ImageCollectionShared::url()
0053 {
0054     qCWarning(LIBKIPI_LOG) << "This method should only be invoked if this imagecollection is a directory. "
0055                            << "See KIPI::ImageCollectionShared::isDirectory()";
0056     return QUrl();
0057 }
0058 
0059 QUrl ImageCollectionShared::uploadUrl()
0060 {
0061     PrintWarningMessageFeature("AcceptNewImages");
0062     return QUrl();
0063 }
0064 
0065 QUrl ImageCollectionShared::uploadRootUrl()
0066 {
0067     QUrl path = uploadUrl();
0068 
0069     if ( path.isValid() )
0070     {
0071         path.setPath(QString::fromLatin1("/"));
0072         return path;
0073     }
0074     else
0075     {
0076         return QUrl::fromLocalFile( QString::fromLatin1("file:/") );
0077     }
0078 }
0079 
0080 QString ImageCollectionShared::uploadRootName()
0081 {
0082    return (QString::fromLatin1("Images"));   // No i18n here. This must be done on KIPI host interface.
0083 }
0084 
0085 bool ImageCollectionShared::isDirectory()
0086 {
0087     return false;
0088 }
0089 
0090 QString ImageCollectionShared::comment()
0091 {
0092     PrintWarningMessageFeature("AlbumsHaveComments");
0093     return QString();
0094 }
0095 
0096 QString ImageCollectionShared::category()
0097 {
0098     PrintWarningMessageFeature("AlbumsHaveCategory");
0099     return QString();
0100 }
0101 
0102 QDate ImageCollectionShared::date()
0103 {
0104     PrintWarningMessageFeature("AlbumsHaveCreationDate");
0105     return QDate();
0106 }
0107 
0108 bool ImageCollectionShared::operator==(ImageCollectionShared& ics)
0109 {
0110     return (images() == ics.images());
0111 }
0112 
0113 } // namespace KIPI