File indexing completed on 2025-04-27 03:58:07

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2006-02-06
0007  * Description : shared image loading and caching
0008  *
0009  * SPDX-FileCopyrightText: 2005-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
0010  *
0011  * SPDX-License-Identifier: GPL-2.0-or-later
0012  *
0013  * ============================================================ */
0014 
0015 #ifndef DIGIKAM_LOADING_CACHE_INTERFACE_H
0016 #define DIGIKAM_LOADING_CACHE_INTERFACE_H
0017 
0018 // Qt includes
0019 
0020 #include <QString>
0021 
0022 // Local includes
0023 
0024 #include "digikam_export.h"
0025 #include "dimg.h"
0026 
0027 namespace Digikam
0028 {
0029 
0030 class DIGIKAM_EXPORT LoadingCacheInterface
0031 {
0032 public:
0033 
0034     static void initialize();
0035 
0036     /**
0037      * clean up cache at shutdown
0038      */
0039     static void cleanUp();
0040 
0041     /**
0042      * Remove an image from the cache
0043      * because it may have changed on disk
0044      */
0045     static void fileChanged(const QString& filePath, bool notify = true);
0046 
0047     /**
0048      * Connect the given object/slot to the signal
0049      *  void fileChanged(const QString& filePath);
0050      * which is emitted when the cache gains knowledge about a possible
0051      * change of this file on disk.
0052      */
0053     static void connectToSignalFileChanged(QObject* const object, const char* slot);
0054 
0055     /**
0056      * remove all images from the cache
0057      * (e.g. when loading settings changed)
0058      * Does not affect thumbnails.
0059      */
0060     static void cleanCache();
0061 
0062     /**
0063      * Remove all thumbnails from the thumbnail cache.
0064      * Does not affect main image cache.
0065      */
0066     static void cleanThumbnailCache();
0067 
0068     /**
0069      * add a copy of the image to cache
0070      */
0071     static void putImage(const QString& filePath, const DImg& img);
0072 
0073     /**
0074      * Set cache size in Megabytes.
0075      * Set to 0 to disable caching.
0076      */
0077     static void setCacheOptions(int cacheSize);
0078 
0079 private:
0080 
0081     explicit LoadingCacheInterface();
0082     ~LoadingCacheInterface();
0083 
0084     // Disable
0085     LoadingCacheInterface(const LoadingCacheInterface&)            = delete;
0086     LoadingCacheInterface& operator=(const LoadingCacheInterface&) = delete;
0087 };
0088 
0089 } // namespace Digikam
0090 
0091 #endif // DIGIKAM_LOADING_CACHE_INTERFACE_H