File indexing completed on 2024-04-28 08:49:11

0001 /**
0002  * SPDX-FileCopyrightText: 2015 Holger Kaelberer <holger.k@elberer.de>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #pragma once
0008 
0009 #include <QAbstractTableModel>
0010 
0011 #include "notifyingapplication.h"
0012 
0013 class NotifyingApplicationModel : public QAbstractTableModel
0014 {
0015     Q_OBJECT
0016 
0017 public:
0018     explicit NotifyingApplicationModel(QObject *parent = nullptr);
0019 
0020     QVariant data(const QModelIndex &index, int role) const override;
0021     bool setData(const QModelIndex &index, const QVariant &value, int role) override;
0022     int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0023     int columnCount(const QModelIndex &parent = QModelIndex()) const override;
0024     Qt::ItemFlags flags(const QModelIndex &index) const override;
0025     QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
0026     void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;
0027 
0028     QVector<NotifyingApplication> apps();
0029     void clearApplications();
0030     void appendApp(const NotifyingApplication &app);
0031     bool containsApp(const QString &name) const;
0032 
0033 Q_SIGNALS:
0034     void applicationsChanged();
0035 
0036 private:
0037     QVector<NotifyingApplication> m_apps;
0038 };