File indexing completed on 2024-04-28 17:06:21

0001 /*
0002     SPDX-FileCopyrightText: 2009 Jan Lepper <krusader@users.sourceforge.net>
0003     SPDX-FileCopyrightText: 2009-2022 Krusader Krew <https://krusader.org>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #ifndef KRPREVIEWS_H
0009 #define KRPREVIEWS_H
0010 
0011 // QtCore
0012 #include <QHash>
0013 #include <QList>
0014 // QtGui
0015 #include <QColor>
0016 #include <QPixmap>
0017 
0018 class KJob;
0019 class KrView;
0020 class KrViewItem;
0021 class KrPreviewJob;
0022 class FileItem;
0023 
0024 class KrPreviews : public QObject
0025 {
0026     friend class KrPreviewJob;
0027     Q_OBJECT
0028 public:
0029     explicit KrPreviews(KrView *view);
0030     ~KrPreviews() override;
0031 
0032     bool getPreview(const FileItem *file, QPixmap &pixmap, bool active);
0033     void updatePreview(KrViewItem *item);
0034     void deletePreview(KrViewItem *item);
0035     // updates all items for which no preview has been loaded yet
0036     void update();
0037     void clear();
0038 
0039 protected slots:
0040     void slotRefreshColors();
0041     void slotJobResult(KJob *job);
0042 
0043 protected:
0044     void addPreview(const FileItem *file, const QPixmap &preview);
0045     void removePreview(const FileItem *file);
0046 
0047     KrPreviewJob *_job;
0048     bool _dim;
0049     QColor _dimColor;
0050     int _dimFactor;
0051     QHash<const FileItem *, QPixmap> _previews;
0052     QHash<const FileItem *, QPixmap> _previewsInactive;
0053     KrView *_view;
0054 };
0055 
0056 #endif // __krpreviews__