aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicklistview2/typerolemodel.h
blob: 4db39c90595b0a2b134729846a9c3348aa72a249 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#include <QAbstractListModel>
#include <qqml.h>

class TypeRoleModel : public QAbstractListModel
{
    Q_OBJECT
    QML_ELEMENT

public:
    enum Role {
        TypeRole = Qt::UserRole + 1,
        TextRole,
    };
    Q_ENUM(Role)

    enum class Type { PlainText, Markdown, Rect };
    Q_ENUM(Type)

    explicit TypeRoleModel(QObject *parent = nullptr);

    int rowCount(const QModelIndex &parent = QModelIndex()) const override;
    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
    QHash<int, QByteArray> roleNames() const override { return _mapRoleNames; }

private:
    QHash<int, QByteArray> _mapRoleNames;
};