KNewStuff

categoriesmodel.h
1/*
2 SPDX-FileCopyrightText: 2019 Dan Leinir Turthra Jensen <admin@leinir.dk>
3
4 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5*/
6
7#ifndef CATEGORIESMODEL_H
8#define CATEGORIESMODEL_H
9
10#include <QAbstractListModel>
11
12#include "enginebase.h"
13
14/**
15 * @short A model which shows the categories found in an Engine
16 * @since 5.63
17 */
19{
21public:
23 ~CategoriesModel() override;
24
25 enum Roles {
26 NameRole = Qt::UserRole + 1,
27 IdRole,
28 DisplayNameRole,
29 };
30 Q_ENUM(Roles)
31
32 QHash<int, QByteArray> roleNames() const override;
33 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
34 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
35
36 /**
37 * Get the display name for the category with the id passed to the function
38 *
39 * @param id The ID of the category you want to get the display name for
40 * @return The display name (or the translated string "Unknown Category" for the requested category
41 */
43
44private:
45 KNSCore::EngineBase *const m_engine;
46};
47
48#endif // CATEGORIESMODEL_H
A model which shows the categories found in an Engine.
Q_INVOKABLE QString idToDisplayName(const QString &id) const
Get the display name for the category with the id passed to the function.
KNewStuff engine.
Definition enginebase.h:56
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
Q_ENUM(...)
Q_INVOKABLEQ_INVOKABLE
Q_OBJECTQ_OBJECT
QObject * parent() const const
UserRole
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:02:29 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.