blob: 5d4ae79f0dc37b929ba358ae06779fe5b9c89b39 (
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#pragma once
#include "itemlibrarymodel.h"
#include <QObject>
#include <QPointer>
namespace QmlDesigner {
class ItemLibraryCategory;
class ItemLibraryCategoriesModel : public QAbstractListModel
{
Q_OBJECT
public:
ItemLibraryCategoriesModel(QObject *parent = nullptr);
~ItemLibraryCategoriesModel() override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
QHash<int, QByteArray> roleNames() const override;
void addCategory(ItemLibraryCategory *category);
void expandCategories(bool expand = true);
const QList<QPointer<ItemLibraryCategory>> &categorySections() const;
bool isAllCategoriesHidden() const;
void sortCategorySections();
void resetModel();
void showAllCategories();
void hideCategory(const QString &categoryName);
void clearSelectedCategory(int categoryIndex);
int selectFirstVisibleCategory();
QPointer<ItemLibraryCategory> selectCategory(int categoryIndex);
private:
void addRoleNames();
QList<QPointer<ItemLibraryCategory>> m_categoryList;
QHash<int, QByteArray> m_roleNames;
};
} // namespace QmlDesigner
|