2023-10-22 03:59:27 +00:00
|
|
|
// SPDX-FileCopyrightText: 2014 Antonis Tsiapaliokas <antonis.tsiapaliokas@kde.org>
|
|
|
|
|
// SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
|
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <QAbstractListModel>
|
|
|
|
|
#include <QList>
|
|
|
|
|
#include <QObject>
|
|
|
|
|
#include <QQuickItem>
|
|
|
|
|
#include <QSet>
|
|
|
|
|
|
2025-03-19 19:10:08 +00:00
|
|
|
#include <KService>
|
|
|
|
|
|
2023-10-22 03:59:27 +00:00
|
|
|
#include "foliodelegate.h"
|
2024-06-21 04:42:14 +00:00
|
|
|
#include "homescreen.h"
|
|
|
|
|
|
|
|
|
|
class HomeScreen;
|
|
|
|
|
class FolioDelegate;
|
2023-10-22 03:59:27 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @short The base application list, used directly by the app drawer.
|
|
|
|
|
*/
|
|
|
|
|
class ApplicationListModel : public QAbstractListModel
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2025-07-16 17:02:18 +00:00
|
|
|
QML_ELEMENT
|
|
|
|
|
QML_UNCREATABLE("")
|
2023-10-22 03:59:27 +00:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
enum Roles {
|
|
|
|
|
DelegateRole = Qt::UserRole + 1,
|
2024-07-01 16:04:32 +00:00
|
|
|
NameRole,
|
2023-10-22 03:59:27 +00:00
|
|
|
};
|
|
|
|
|
|
2024-06-21 04:42:14 +00:00
|
|
|
ApplicationListModel(HomeScreen *parent = nullptr);
|
2023-10-22 03:59:27 +00:00
|
|
|
~ApplicationListModel() override;
|
|
|
|
|
|
|
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
|
|
|
|
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
|
|
|
|
|
QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE;
|
|
|
|
|
|
2024-06-21 04:42:14 +00:00
|
|
|
void load();
|
2023-10-22 03:59:27 +00:00
|
|
|
|
2025-03-20 00:47:30 +00:00
|
|
|
Q_SIGNALS:
|
|
|
|
|
// Emitted when an application was detected to have been removed from the system
|
|
|
|
|
void applicationRemoved(QString storageId);
|
|
|
|
|
|
2023-10-22 03:59:27 +00:00
|
|
|
public Q_SLOTS:
|
|
|
|
|
void sycocaDbChanged();
|
|
|
|
|
|
|
|
|
|
protected:
|
2025-03-19 19:10:08 +00:00
|
|
|
KService::List queryApplications();
|
|
|
|
|
|
2024-06-21 04:42:14 +00:00
|
|
|
HomeScreen *m_homeScreen{nullptr};
|
2025-02-13 16:39:28 +00:00
|
|
|
|
2025-02-21 18:06:24 +00:00
|
|
|
QList<std::shared_ptr<FolioDelegate>> m_delegates;
|
2025-02-13 16:39:28 +00:00
|
|
|
QTimer *m_reloadAppsTimer{nullptr};
|
2023-10-22 03:59:27 +00:00
|
|
|
};
|
2024-07-01 16:04:32 +00:00
|
|
|
|
|
|
|
|
class ApplicationListSearchModel : public QSortFilterProxyModel
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2025-07-16 17:02:18 +00:00
|
|
|
QML_ELEMENT
|
|
|
|
|
QML_UNCREATABLE("")
|
2024-07-01 16:04:32 +00:00
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
ApplicationListSearchModel(HomeScreen *parent = nullptr, ApplicationListModel *model = nullptr);
|
|
|
|
|
};
|