Warning, file /plasma/plasma-mobile/containments/homescreens/folio/desktopmodel.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: 2021 Marco Martin <mart@kde.org>
0002 // SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
0003 // SPDX-License-Identifier: GPL-2.0-or-later
0004 
0005 #pragma once
0006 
0007 // Qt
0008 #include <QAbstractListModel>
0009 #include <QList>
0010 #include <QObject>
0011 #include <QSet>
0012 
0013 // KDE
0014 #include <Plasma/Applet>
0015 
0016 #include "applicationlistmodel.h"
0017 
0018 /**
0019  * @short Filtered application list for applications on the desktop and pinned bar.
0020  */
0021 class DesktopModel : public ApplicationListModel
0022 {
0023     Q_OBJECT
0024     Q_PROPERTY(int count READ count NOTIFY countChanged)
0025     Q_PROPERTY(int favoriteCount READ favoriteCount NOTIFY favoriteCountChanged)
0026     Q_PROPERTY(int maxFavoriteCount READ maxFavoriteCount CONSTANT)
0027 
0028 public:
0029     DesktopModel(QObject *parent = nullptr, Plasma::Applet *applet = nullptr);
0030     ~DesktopModel() override;
0031 
0032     QString storageToUniqueId(const QString &storageId) const;
0033     QString uniqueToStorageId(const QString &uniqueId) const;
0034 
0035     void loadSettings();
0036     Q_INVOKABLE void load() override;
0037 
0038     int count();
0039     int favoriteCount();
0040     int maxFavoriteCount();
0041 
0042     Q_INVOKABLE void setLocation(int row, LauncherLocation location);
0043     Q_INVOKABLE void moveItem(int row, int destination);
0044 
0045     Q_INVOKABLE void addFavorite(const QString &storageId, int row, LauncherLocation location);
0046     Q_INVOKABLE void removeFavorite(int row);
0047 
0048 Q_SIGNALS:
0049     void countChanged();
0050     void favoriteCountChanged();
0051 
0052 private:
0053     QStringList m_appOrder;
0054     QStringList m_favorites;
0055     QSet<QString> m_desktopItems;
0056     QHash<QString, int> m_appPositions;
0057 
0058     Plasma::Applet *m_applet = nullptr;
0059 };