90 lines
2.6 KiB
C++
90 lines
2.6 KiB
C++
/* ============================================================
|
|
* KCMOpenRC - OpenRC Service Manager
|
|
* Copyright (C) 2025 Juraj Oravec <jurajoravec@mailo.com>
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
* ============================================================ */
|
|
#ifndef OPENRC_SERVICE_MODEL_H
|
|
#define OPENRC_SERVICE_MODEL_H
|
|
|
|
#include <QAbstractItemModel>
|
|
#include <QSortFilterProxyModel>
|
|
#include <QQmlEngine>
|
|
|
|
#include <rc.h>
|
|
|
|
#include "openrc_tree_item.h"
|
|
|
|
class QTimer;
|
|
|
|
#ifdef BUILD_TESTING
|
|
#define OPENRC_SERVICE_MODEL_DEBUG
|
|
#endif
|
|
|
|
#ifdef OPENRC_SERVICE_MODEL_DEBUG
|
|
class QAbstractItemModelTester;
|
|
#endif
|
|
|
|
class OpenRCServiceModel : public QAbstractItemModel
|
|
{
|
|
Q_OBJECT
|
|
QML_NAMED_ELEMENT(OpenRCServiceModel)
|
|
|
|
public:
|
|
Q_DISABLE_COPY_MOVE(OpenRCServiceModel)
|
|
|
|
OpenRCServiceModel(QObject *parent = nullptr);
|
|
~OpenRCServiceModel() override;
|
|
|
|
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
|
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
|
|
QModelIndex index(int row, int column, const QModelIndex &parent = {}) const override;
|
|
QModelIndex parent(const QModelIndex &index) const override;
|
|
int rowCount(const QModelIndex &parent = {}) const override;
|
|
int columnCount(const QModelIndex &parent = {}) const override;
|
|
|
|
private:
|
|
void reload_services();
|
|
|
|
std::unique_ptr<OpenRCTreeItem> rootItem;
|
|
QStringList m_runlevels;
|
|
|
|
#ifdef OPENRC_SERVICE_MODEL_DEBUG
|
|
QAbstractItemModelTester *m_tester;
|
|
#endif
|
|
};
|
|
|
|
#if 0
|
|
class FALKON_EXPORT AdBlockFilterModel : public QSortFilterProxyModel
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit AdBlockFilterModel(QAbstractItemModel *parent);
|
|
|
|
public Q_SLOTS:
|
|
void setFilterFixedString(const QString &pattern);
|
|
|
|
private Q_SLOTS:
|
|
void startFiltering();
|
|
|
|
private:
|
|
QString m_pattern;
|
|
QTimer *m_filterTimer;
|
|
};
|
|
#endif /* 0 - disabled */
|
|
|
|
#endif /* OPENRC_SERVICE_MODEL_H */
|