shift-shell/containments/homescreens/halcyon/pinnedmodel.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

66 lines
1.7 KiB
C
Raw Normal View History

2022-06-18 19:42:29 +00:00
// SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include "application.h"
#include "applicationfolder.h"
#include "halcyonsettings.h"
2022-06-18 19:42:29 +00:00
#include <QAbstractListModel>
#include <QList>
#include <QObject>
#include <QQuickItem>
#include <QSet>
#include <KWayland/Client/connection_thread.h>
#include <KWayland/Client/plasmawindowmanagement.h>
#include <KWayland/Client/registry.h>
#include <KWayland/Client/surface.h>
#include <qqmlregistration.h>
/**
* @short The applications and folders model on the main page.
*/
2022-06-18 19:42:29 +00:00
class PinnedModel : public QAbstractListModel
{
Q_OBJECT
QML_ELEMENT
QML_UNCREATABLE("")
2022-06-18 19:42:29 +00:00
public:
enum Roles {
IsFolderRole = Qt::UserRole + 1,
ApplicationRole,
FolderRole
};
2022-06-18 19:42:29 +00:00
PinnedModel(HalcyonSettings *settings = nullptr, QObject *parent = nullptr);
2022-06-18 19:42:29 +00:00
~PinnedModel() override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
QHash<int, QByteArray> roleNames() const override;
Q_INVOKABLE void addApp(const QString &storageId, int row);
Q_INVOKABLE void addFolder(QString name, int row);
Q_INVOKABLE void removeEntry(int row);
Q_INVOKABLE void moveEntry(int fromRow, int toRow);
Q_INVOKABLE void createFolderFromApps(int sourceAppRow, int draggedAppRow);
Q_INVOKABLE void addAppToFolder(int appRow, int folderRow);
Q_INVOKABLE void load();
2022-06-18 19:42:29 +00:00
void save();
public Q_SLOTS:
void addAppFromFolder(const QString &storageId);
2022-06-18 19:42:29 +00:00
private:
QList<Application *> m_applications;
QList<ApplicationFolder *> m_folders;
HalcyonSettings *m_settings;
2022-06-18 19:42:29 +00:00
};