KCMUtils

kpluginproxymodel.h
1/*
2 SPDX-FileCopyrightText: 2021 Alexander Lohnau <alexander.lohnau@gmx.de>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4*/
5
6#ifndef KPLUGINPROXYMODEL_H
7#define KPLUGINPROXYMODEL_H
8
9#include "kcmutilscore_export.h"
10#include "kpluginmodel.h"
11
12#include <KCategorizedSortFilterProxyModel>
13
14class Q_DECL_HIDDEN KPluginProxyModel : public KCategorizedSortFilterProxyModel
15{
16 Q_OBJECT
17 Q_PROPERTY(QString query READ query WRITE setQuery NOTIFY queryChanged)
18 Q_PROPERTY(QAbstractListModel *model WRITE setModel)
19public:
20 explicit KPluginProxyModel(QObject *parent = nullptr);
21 ~KPluginProxyModel() override;
22
23 QString query() const;
24 void setQuery(const QString &query);
25 void setModel(QAbstractListModel *model)
26 {
27 setSourceModel(model);
28 m_model = qobject_cast<KPluginModel *>(model);
29 Q_ASSERT(m_model);
30 }
31
33 void queryChanged();
34
35protected:
36 bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
37 bool subSortLessThan(const QModelIndex &left, const QModelIndex &right) const override;
38 int compareCategories(const QModelIndex &left, const QModelIndex &right) const override;
39
40private:
41 QString m_query;
42 KPluginModel *m_model;
43};
44
45#endif
virtual int compareCategories(const QModelIndex &left, const QModelIndex &right) const
virtual bool subSortLessThan(const QModelIndex &left, const QModelIndex &right) const
A model that provides a list of available plugins and allows to disable/enable them.
std::optional< QSqlQuery > query(const QString &queryStatement)
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
T qobject_cast(QObject *object)
virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const const
virtual void setSourceModel(QAbstractItemModel *sourceModel) override
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:02:19 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.