1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QABSTRACTFILEICONENGINE_P_H
5#define QABSTRACTFILEICONENGINE_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/qfileinfo.h>
19#include <private/qicon_p.h>
20#include <qpa/qplatformtheme.h>
21
22QT_BEGIN_NAMESPACE
23
24class Q_GUI_EXPORT QAbstractFileIconEngine : public QPixmapIconEngine
25{
26public:
27 explicit QAbstractFileIconEngine(const QFileInfo &info, QPlatformTheme::IconOptions opts)
28 : QPixmapIconEngine(), m_fileInfo(info), m_options(opts) {}
29
30 QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State) override;
31 QPixmap scaledPixmap(const QSize &size, QIcon::Mode mode, QIcon::State, qreal scale) override;
32 QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) override;
33
34 QFileInfo fileInfo() const { return m_fileInfo; }
35 QPlatformTheme::IconOptions options() const { return m_options; }
36
37 // Helper to convert a sequence of ints to a list of QSize
38 template <class It> static QList<QSize> toSizeList(It i1, It i2);
39
40protected:
41 virtual QPixmap filePixmap(const QSize &size, QIcon::Mode mode, QIcon::State) = 0;
42 virtual QString cacheKey() const;
43
44private:
45 const QFileInfo m_fileInfo;
46 const QPlatformTheme::IconOptions m_options;
47};
48
49template <class It>
50inline QList<QSize> QAbstractFileIconEngine::toSizeList(It i1, It i2)
51{
52 QList<QSize> result;
53 result.reserve(size: int(i2 - i1));
54 for ( ; i1 != i2; ++i1)
55 result.append(t: QSize(*i1, *i1));
56 return result;
57}
58
59QT_END_NAMESPACE
60
61#endif // QABSTRACTFILEICONENGINE_P_H
62

source code of qtbase/src/gui/image/qabstractfileiconengine_p.h