File indexing completed on 2024-05-12 16:27:22

0001 /*
0002    SPDX-FileCopyrightText: 2020 David Faure <faure@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "libruqolawidgets_private_export.h"
0010 
0011 #include "lrucache.h"
0012 #include <QPixmap>
0013 
0014 // QPixmapCache is too small for the big images in messages, let's have our own LRU cache
0015 class LIBRUQOLAWIDGETS_TESTS_EXPORT PixmapCache
0016 {
0017 public:
0018     void setMaxEntries(int maxEntries);
0019 
0020     [[nodiscard]] QPixmap pixmapForLocalFile(const QString &path);
0021 
0022     [[nodiscard]] QPixmap findCachedPixmap(const QString &path);
0023     void insertCachedPixmap(const QString &path, const QPixmap &pixmap);
0024     void clear();
0025     void remove(const QString &path);
0026 
0027 private:
0028     friend class PixmapCacheTest;
0029     LRUCache<QString, QPixmap> mCachedImages;
0030 };