"Fossies" - the Fresh Open Source Software Archive

Member "digikam-6.3.0/core/libs/threadimageio/fileio/loadingcacheinterface.cpp" (4 Sep 2019, 2571 Bytes) of package /linux/misc/digikam-6.3.0.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "loadingcacheinterface.cpp" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 6.2.0_vs_6.3.0.

    1 /* ============================================================
    2  *
    3  * This file is a part of digiKam project
    4  * https://www.digikam.org
    5  *
    6  * Date        : 2006-02-06
    7  * Description : shared image loading and caching
    8  *
    9  * Copyright (C) 2005-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
   10  *
   11  * This program is free software; you can redistribute it
   12  * and/or modify it under the terms of the GNU General
   13  * Public License as published by the Free Software Foundation;
   14  * either version 2, or (at your option)
   15  * any later version.
   16  *
   17  * This program is distributed in the hope that it will be useful,
   18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   20  * GNU General Public License for more details.
   21  *
   22  * ============================================================ */
   23 
   24 #include "loadingcacheinterface.h"
   25 
   26 // Local includes
   27 
   28 #include "loadingcache.h"
   29 
   30 namespace Digikam
   31 {
   32 
   33 void LoadingCacheInterface::initialize()
   34 {
   35     LoadingCache::cache();
   36 }
   37 
   38 void LoadingCacheInterface::cleanUp()
   39 {
   40     LoadingCache::cleanUp();
   41 }
   42 
   43 void LoadingCacheInterface::fileChanged(const QString& filePath, bool notify)
   44 {
   45     LoadingCache* const cache = LoadingCache::cache();
   46     LoadingCache::CacheLock lock(cache);
   47 
   48     cache->notifyFileChanged(filePath, notify);
   49 }
   50 
   51 void LoadingCacheInterface::connectToSignalFileChanged(QObject* const object, const char* slot)
   52 {
   53     LoadingCache* const cache = LoadingCache::cache();
   54     QObject::connect(cache, SIGNAL(fileChanged(QString)),
   55                      object, slot,
   56                      Qt::QueuedConnection);
   57     // make it a queued connection because the signal is emitted when the CacheLock is held!
   58 }
   59 
   60 void LoadingCacheInterface::cleanCache()
   61 {
   62     LoadingCache* const cache = LoadingCache::cache();
   63     LoadingCache::CacheLock lock(cache);
   64     cache->removeImages();
   65 }
   66 
   67 void LoadingCacheInterface::cleanThumbnailCache()
   68 {
   69     LoadingCache* const cache = LoadingCache::cache();
   70     LoadingCache::CacheLock lock(cache);
   71     cache->removeThumbnails();
   72 }
   73 
   74 void LoadingCacheInterface::putImage(const QString& filePath, const DImg& img)
   75 {
   76     LoadingCache* const cache = LoadingCache::cache();
   77     LoadingCache::CacheLock lock(cache);
   78 
   79     if (cache->isCacheable(img))
   80     {
   81         cache->putImage(filePath, img, filePath);
   82     }
   83 }
   84 
   85 void LoadingCacheInterface::setCacheOptions(int cacheSize)
   86 {
   87     LoadingCache* const cache = LoadingCache::cache();
   88     LoadingCache::CacheLock lock(cache);
   89     cache->setCacheSize(cacheSize);
   90 }
   91 
   92 } // namespace Digikam