aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/studiowelcome/stylemodel.h
blob: 463eb7c3994425db4f67beedb5c1d203660b8b48 (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
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include <QSortFilterProxyModel>
#include <QStandardItemModel>

namespace StudioWelcome {

class StyleModel : public QSortFilterProxyModel
{
    Q_OBJECT

public:
    explicit StyleModel(QObject *parent = nullptr);

    Q_INVOKABLE void filter(const QString &what = "all");
    QVariant data(const QModelIndex &index, int role) const override;
    QHash<int, QByteArray> roleNames() const override;

    Q_INVOKABLE int findIndex(const QString &styleName) const;
    Q_INVOKABLE int findSourceIndex(const QString &styleName) const;

private:
    enum Roles{IconNameRole = Qt::UserRole + 1};
};

} // namespace StudioWelcome