File indexing completed on 2024-05-19 04:27:40
0001 /* 0002 * SPDX-FileCopyrightText: 2023 Sharaf Zaman <shzam@sdf.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef __KISRESOURCETHUMBNAILCACHE_H_ 0008 #define __KISRESOURCETHUMBNAILCACHE_H_ 0009 0010 #include <QImage> 0011 #include <QScopedPointer> 0012 0013 #include "kritaresources_export.h" 0014 0015 class QModelIndex; 0016 0017 class KRITARESOURCES_EXPORT KisResourceThumbnailCache 0018 { 0019 public: 0020 KisResourceThumbnailCache(); 0021 ~KisResourceThumbnailCache(); 0022 0023 static KisResourceThumbnailCache *instance(); 0024 0025 QImage getImage(const QModelIndex &index, 0026 const QSize size = QSize(-1, -1), 0027 Qt::AspectRatioMode aspectMode = Qt::IgnoreAspectRatio, 0028 Qt::TransformationMode transformMode = Qt::FastTransformation); 0029 0030 private: 0031 friend class KisResourceQueryMapper; 0032 friend class KisResourceLocator; 0033 friend class KisStorageModel; 0034 0035 /* 0036 * Check if we have the original image in the cache. 0037 */ 0038 QImage originalImage(const QString &storageLocation, const QString &resourceType, const QString &filename) const; 0039 void insert(const QString &storageLocation, 0040 const QString &resourceType, 0041 const QString &filename, 0042 const QImage &image); 0043 void insert(const QPair<QString, QString> &key, const QImage &image); 0044 0045 void remove(const QString &storageLocation, const QString &resourceType, const QString &filename); 0046 void remove(const QPair<QString, QString> &key); 0047 0048 private: 0049 struct Private; 0050 QScopedPointer<Private> m_d; 0051 }; 0052 0053 #endif // __KISRESOURCETHUMBNAILCACHE_H_