Warning, file /plasma/plasma-mobile/containments/homescreens/halcyon/pinnedmodel.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
0002 // SPDX-License-Identifier: GPL-2.0-or-later
0003 
0004 #pragma once
0005 
0006 #include "application.h"
0007 #include "applicationfolder.h"
0008 
0009 #include <QAbstractListModel>
0010 #include <QList>
0011 #include <QObject>
0012 #include <QQuickItem>
0013 #include <QSet>
0014 
0015 #include <Plasma/Applet>
0016 
0017 #include <KWayland/Client/connection_thread.h>
0018 #include <KWayland/Client/plasmawindowmanagement.h>
0019 #include <KWayland/Client/registry.h>
0020 #include <KWayland/Client/surface.h>
0021 
0022 /**
0023  * @short The applications and folders model on the main page.
0024  */
0025 class PinnedModel : public QAbstractListModel
0026 {
0027     Q_OBJECT
0028 
0029 public:
0030     enum Roles { IsFolderRole = Qt::UserRole + 1, ApplicationRole, FolderRole };
0031 
0032     PinnedModel(QObject *parent = nullptr, Plasma::Applet *applet = nullptr);
0033     ~PinnedModel() override;
0034 
0035     int rowCount(const QModelIndex &parent = QModelIndex()) const override;
0036     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
0037     QHash<int, QByteArray> roleNames() const override;
0038 
0039     Q_INVOKABLE void addApp(const QString &storageId, int row);
0040     Q_INVOKABLE void addFolder(QString name, int row);
0041     Q_INVOKABLE void removeEntry(int row);
0042     Q_INVOKABLE void moveEntry(int fromRow, int toRow);
0043 
0044     Q_INVOKABLE void createFolderFromApps(int sourceAppRow, int draggedAppRow);
0045     Q_INVOKABLE void addAppToFolder(int appRow, int folderRow);
0046 
0047     Q_INVOKABLE void load();
0048     void save();
0049 
0050 public Q_SLOTS:
0051     void addAppFromFolder(const QString &storageId);
0052 
0053 private:
0054     QList<Application *> m_applications;
0055     QList<ApplicationFolder *> m_folders;
0056 
0057     Plasma::Applet *m_applet;
0058 };