File indexing completed on 2024-09-29 04:54:00

0001 /*
0002     SPDX-FileCopyrightText: 2020 Michail Vourlakos <mvourlakos@gmail.com>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef VIEWTASKSMODEL_H
0007 #define VIEWTASKSMODEL_H
0008 
0009 #include <QAbstractListModel>
0010 
0011 namespace PlasmaQuick {
0012 class AppletQuickItem;
0013 }
0014 
0015 namespace Latte {
0016 namespace ViewPart {
0017 
0018 class TasksModel : public QAbstractListModel
0019 {
0020     Q_OBJECT
0021     Q_PROPERTY(int count READ count NOTIFY countChanged)
0022 
0023 public:
0024     TasksModel(QObject *parent = nullptr);
0025 
0026     int count() const;
0027 
0028     int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0029     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
0030     QHash<int, QByteArray> roleNames() const override;
0031 
0032    void addTask(PlasmaQuick::AppletQuickItem *plasmoid);
0033    void removeTask(PlasmaQuick::AppletQuickItem *plasmoid);
0034 
0035 signals:
0036    void countChanged();
0037 
0038 private slots:
0039    void moveIntoWaitingTasks(PlasmaQuick::AppletQuickItem *plasmoid);
0040    void restoreFromWaitingTasks(PlasmaQuick::AppletQuickItem *plasmoid);
0041 
0042 private:
0043     QList<PlasmaQuick::AppletQuickItem *> m_tasks;
0044     QList<PlasmaQuick::AppletQuickItem *> m_tasksWaiting;
0045 };
0046 
0047 }
0048 }
0049 
0050 #endif