File indexing completed on 2024-09-08 12:18:04
0001 /* 0002 SPDX-FileCopyrightText: 2021 Kai Uwe Broulik <kde@broulik.de> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KICONDIALOGMODEL_P_H 0008 #define KICONDIALOGMODEL_P_H 0009 0010 #include <QAbstractListModel> 0011 #include <QPixmap> 0012 #include <QSize> 0013 #include <QString> 0014 #include <QStringList> 0015 #include <QVector> 0016 0017 struct KIconDialogModelData { 0018 QString name; 0019 QString path; 0020 QPixmap pixmap; 0021 }; 0022 Q_DECLARE_TYPEINFO(KIconDialogModelData, Q_MOVABLE_TYPE); 0023 0024 class KIconDialogModel : public QAbstractListModel 0025 { 0026 Q_OBJECT 0027 0028 public: 0029 KIconDialogModel(QObject *parent); 0030 ~KIconDialogModel() override; 0031 0032 enum Roles { PathRole = Qt::UserRole }; 0033 0034 qreal devicePixelRatio() const; 0035 void setDevicePixelRatio(qreal dpr); 0036 0037 QSize iconSize() const; 0038 void setIconSize(const QSize &iconSize); 0039 0040 void load(const QStringList &paths); 0041 0042 int rowCount(const QModelIndex &parent) const override; 0043 QVariant data(const QModelIndex &index, int role) const override; 0044 0045 private: 0046 void loadPixmap(const QModelIndex &index); 0047 0048 QVector<KIconDialogModelData> m_data; 0049 0050 qreal m_dpr = 1; 0051 QSize m_iconSize; 0052 }; 0053 0054 #endif // KICONDIALOGMODEL_P_H