KNewStuff

categoriesmodel.h
1 /*
2  SPDX-FileCopyrightText: 2019 Dan Leinir Turthra Jensen <[email protected]>
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 "provider.h"
13 #include "quickengine.h"
14 
20 {
21  Q_OBJECT
22 public:
23  explicit CategoriesModel(Engine *parent = nullptr);
24  virtual ~CategoriesModel();
25 
26  enum Roles {
27  NameRole = Qt::UserRole + 1,
28  IdRole,
29  DisplayNameRole
30  };
31  Q_ENUMS(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 
43  Q_INVOKABLE QString idToDisplayName(const QString &id) const;
44 private:
45  class Private;
46  // TODO KF6: Switch all the pimpls to const std::unique_ptr<Private> d;
47  Private *d;
48 };
49 
50 #endif//CATEGORIESMODEL_H
A model which shows the categories found in an Engine.
Encapsulates a KNSCore::Engine for use in Qt Quick.
Definition: quickengine.h:23
Q_INVOKABLE QString idToDisplayName(const QString &id) const
Get the display name for the category with the id passed to the function.
Q_OBJECTQ_OBJECT
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
UserRole
Q_ENUMS(...)
Q_INVOKABLEQ_INVOKABLE
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue Aug 11 2020 22:43:23 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.