File: plasmaappletitemmodel_p.h

package info (click to toggle)
plasma-workspace 4%3A5.27.5-2%2Bdeb12u2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 102,040 kB
  • sloc: cpp: 121,800; xml: 3,238; python: 645; perl: 586; sh: 254; javascript: 113; ruby: 62; makefile: 15; ansic: 13
file content (105 lines) | stat: -rw-r--r-- 2,824 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
    SPDX-FileCopyrightText: 2007 Ivan Cukic <ivan.cukic+kde@gmail.com>

    SPDX-License-Identifier: LGPL-2.0-or-later
*/

#pragma once

#include "kcategorizeditemsviewmodels_p.h"
#include <KConfigGroup>
#include <KPluginMetaData>

class PlasmaAppletItemModel;

/**
 * Implementation of the KCategorizedItemsViewModels::AbstractItem
 */
class PlasmaAppletItem : public KCategorizedItemsViewModels::AbstractItem
{
public:
    explicit PlasmaAppletItem(const KPluginMetaData &info);

    QString pluginName() const;
    QString name() const override;
    QString category() const;
    QString description() const override;
    QString license() const;
    QString website() const;
    QString version() const;
    QString author() const;
    QString email() const;
    QVariant data(int role = Qt::UserRole + 1) const override;

    int running() const override;
    bool isLocal() const;
    bool matches(const QString &pattern) const override;
    QStringList keywords() const override;

    // set how many instances of this applet are running
    void setRunning(int count) override;
    bool passesFiltering(const KCategorizedItemsViewModels::Filter &filter) const override;
    QMimeData *mimeData() const;
    QStringList mimeTypes() const;

private:
    KPluginMetaData m_info;
    QString m_screenshot;
    QString m_icon;
    int m_runningCount;
    bool m_local;
};

class PlasmaAppletItemModel : public QStandardItemModel
{
    Q_OBJECT

public:
    enum Roles {
        NameRole = Qt::UserRole + 1,
        PluginNameRole = Qt::UserRole + 2,
        DescriptionRole = Qt::UserRole + 3,
        CategoryRole = Qt::UserRole + 4,
        LicenseRole = Qt::UserRole + 5,
        WebsiteRole = Qt::UserRole + 6,
        VersionRole = Qt::UserRole + 7,
        AuthorRole = Qt::UserRole + 8,
        EmailRole = Qt::UserRole + 9,
        RunningRole = Qt::UserRole + 10,
        LocalRole = Qt::UserRole + 11,
        ScreenshotRole = Qt::UserRole + 12,
    };

    explicit PlasmaAppletItemModel(QObject *parent = nullptr);

    QStringList mimeTypes() const override;
    QSet<QString> categories() const;

    QMimeData *mimeData(const QModelIndexList &indexes) const override;

    void setApplication(const QString &app);
    void setRunningApplets(const QHash<QString, int> &apps);
    void setRunningApplets(const QString &name, int count);

    QString &Application();

    QStringList provides() const;
    void setProvides(const QStringList &provides);

    QHash<int, QByteArray> roleNames() const override;

    bool startupCompleted() const;
    void setStartupCompleted(bool complete);

Q_SIGNALS:
    void modelPopulated();

private:
    QString m_application;
    QStringList m_provides;
    KConfigGroup m_configGroup;
    bool m_startupCompleted : 1;

private Q_SLOTS:
    void populateModel();
};