Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qabstractfileiconengine_p.h
Go to the documentation of this file.
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// Qt-Security score:significant reason:default
4
5#ifndef QABSTRACTFILEICONENGINE_P_H
6#define QABSTRACTFILEICONENGINE_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtCore/qfileinfo.h>
20#include <private/qicon_p.h>
21#include <qpa/qplatformtheme.h>
22
24
25class Q_GUI_EXPORT QAbstractFileIconEngine : public QPixmapIconEngine
26{
27public:
28 explicit QAbstractFileIconEngine(const QFileInfo &info, QPlatformTheme::IconOptions opts)
29 : QPixmapIconEngine(), m_fileInfo(info), m_options(opts) {}
30
31 QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State) override;
32 QPixmap scaledPixmap(const QSize &size, QIcon::Mode mode, QIcon::State, qreal scale) override;
33 QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) override;
34 bool isNull() override { return false; }
35
36 QFileInfo fileInfo() const { return m_fileInfo; }
37 QPlatformTheme::IconOptions options() const { return m_options; }
38
39 // Helper to convert a sequence of ints to a list of QSize
40 template <class It> static QList<QSize> toSizeList(It i1, It i2);
41
42protected:
43 virtual QPixmap filePixmap(const QSize &size, QIcon::Mode mode, QIcon::State) = 0;
44 virtual QString cacheKey() const;
45
46private:
47 const QFileInfo m_fileInfo;
48 const QPlatformTheme::IconOptions m_options;
49};
50
51template <class It>
52inline QList<QSize> QAbstractFileIconEngine::toSizeList(It i1, It i2)
53{
54 QList<QSize> result;
55 result.reserve(int(i2 - i1));
56 for ( ; i1 != i2; ++i1)
57 result.append(QSize(*i1, *i1));
58 return result;
59}
60
61QT_END_NAMESPACE
62
63#endif // QABSTRACTFILEICONENGINE_P_H
Helper base class for retrieving icons for files for usage by QFileIconProvider and related.