mirror of
https://invent.kde.org/marcoa/shift-shell.git
synced 2026-04-29 15:03:09 +00:00
Currently delegates do not get deleted when removed from models. Due to the complexity of drag state and other objects, we can't simply delete the delegate when removed from the model because they might still be involved in animations or other state at the time of removal. Use smart pointers to have the delegate objects deleted instead. QML unfortunately doesn't support QSharedPointer, so we need to expose raw pointers to it.
57 lines
1.3 KiB
C++
57 lines
1.3 KiB
C++
// 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>
|
|
|
|
#include "foliodelegate.h"
|
|
#include "homescreen.h"
|
|
|
|
class HomeScreen;
|
|
class FolioDelegate;
|
|
|
|
/**
|
|
* @short The base application list, used directly by the app drawer.
|
|
*/
|
|
class ApplicationListModel : public QAbstractListModel
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
enum Roles {
|
|
DelegateRole = Qt::UserRole + 1,
|
|
NameRole,
|
|
};
|
|
|
|
ApplicationListModel(HomeScreen *parent = nullptr);
|
|
~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;
|
|
|
|
void load();
|
|
|
|
public Q_SLOTS:
|
|
void sycocaDbChanged();
|
|
|
|
protected:
|
|
HomeScreen *m_homeScreen{nullptr};
|
|
|
|
QList<std::shared_ptr<FolioDelegate>> m_delegates;
|
|
QTimer *m_reloadAppsTimer{nullptr};
|
|
};
|
|
|
|
class ApplicationListSearchModel : public QSortFilterProxyModel
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
ApplicationListSearchModel(HomeScreen *parent = nullptr, ApplicationListModel *model = nullptr);
|
|
};
|