File indexing completed on 2024-04-21 16:12:19

0001 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0002 // SPDX-FileCopyrightText: 2022 Harald Sitter <sitter@kde.org>
0003 
0004 #pragma once
0005 
0006 #include <QAbstractListModel>
0007 #include <QMetaEnum>
0008 
0009 class QObjectListModel : public QAbstractListModel
0010 {
0011     Q_OBJECT
0012 public:
0013     enum class Role {
0014         Object = Qt::UserRole,
0015         UserRole,
0016     };
0017     Q_ENUM(Role)
0018 
0019     using QAbstractListModel::QAbstractListModel;
0020 
0021     virtual QObject *object(const QModelIndex &index) const = 0;
0022 
0023     [[nodiscard]] QVariant data(const QModelIndex &index, int intRole) const override;
0024     [[nodiscard]] QHash<int, QByteArray> roleNames() const override;
0025 };