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#include "provider.h"
14
15/**
16 * @short A model which shows the categories found in an Engine
17 * @since 5.63
18 */
20{
22public:
24 ~CategoriesModel() override;
25
26 enum Roles {
27 NameRole = Qt::UserRole + 1,
28 IdRole,
29 DisplayNameRole,
30 };
31 Q_ENUM(Roles)
32
33 QHash<int, QByteArray> roleNames() const override;
34 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
35 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
36
37 /**
38 * Get the display name for the category with the id passed to the function
39 *
40 * @param id The ID of the category you want to get the display name for
41 * @return The display name (or the translated string "Unknown Category" for the requested category
42 */
44
45private:
46 KNSCore::EngineBase *const m_engine;
47};
48
49#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:51
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 Tue Mar 26 2024 11:21:35 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.