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 #include "loadingcacheinterface.h" 0016 0017 // Local includes 0018 0019 #include "loadingcache.h" 0020 0021 namespace Digikam 0022 { 0023 0024 void LoadingCacheInterface::initialize() 0025 { 0026 LoadingCache::cache(); 0027 } 0028 0029 void LoadingCacheInterface::cleanUp() 0030 { 0031 LoadingCache::cleanUp(); 0032 } 0033 0034 void LoadingCacheInterface::fileChanged(const QString& filePath, bool notify) 0035 { 0036 LoadingCache* const cache = LoadingCache::cache(); 0037 LoadingCache::CacheLock lock(cache); 0038 0039 cache->notifyFileChanged(filePath, notify); 0040 } 0041 0042 void LoadingCacheInterface::connectToSignalFileChanged(QObject* const object, const char* slot) 0043 { 0044 LoadingCache* const cache = LoadingCache::cache(); 0045 0046 QObject::connect(cache, SIGNAL(fileChanged(QString)), 0047 object, slot, 0048 Qt::QueuedConnection); 0049 0050 // make it a queued connection because the signal is emitted when the CacheLock is held! 0051 } 0052 0053 void LoadingCacheInterface::cleanCache() 0054 { 0055 LoadingCache* const cache = LoadingCache::cache(); 0056 LoadingCache::CacheLock lock(cache); 0057 0058 cache->removeImages(); 0059 } 0060 0061 void LoadingCacheInterface::cleanThumbnailCache() 0062 { 0063 LoadingCache* const cache = LoadingCache::cache(); 0064 LoadingCache::CacheLock lock(cache); 0065 0066 cache->removeThumbnails(); 0067 } 0068 0069 void LoadingCacheInterface::putImage(const QString& filePath, const DImg& img) 0070 { 0071 LoadingCache* const cache = LoadingCache::cache(); 0072 LoadingCache::CacheLock lock(cache); 0073 0074 if (cache->isCacheable(img)) 0075 { 0076 cache->putImage(filePath, img, filePath); 0077 } 0078 } 0079 0080 void LoadingCacheInterface::setCacheOptions(int cacheSize) 0081 { 0082 LoadingCache* const cache = LoadingCache::cache(); 0083 LoadingCache::CacheLock lock(cache); 0084 0085 cache->setCacheSize(cacheSize); 0086 } 0087 0088 } // namespace Digikam