summaryrefslogtreecommitdiff
path: root/src/lib/xdgdesktopentries.h
blob: 305b928a78a64bb156449bee6a708936427edf3b (plain)
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
#ifndef XDGDESKTOPENTRIES_H
#define XDGDESKTOPENTRIES_H

#include <QAbstractListModel>
#include <QObject>
#include "xdgentries.h"

namespace KaZoe {
    class DesktopEntries : public QAbstractListModel
    {
        Q_OBJECT
        Q_PROPERTY(QStringList categories READ categories NOTIFY categoriesChanged)
        KaZoe::Entries m_entries;

    private slots:
        bool _contains(QString path);
        //void _reload(QString path);
        QStringList _getEntriesFrom(QString path = "");
        void _dataChanged(const QString appid, const QString item, const QString value);

    public:
        explicit DesktopEntries(QObject *parent = nullptr);

        enum XdgDesktopEntriesRoles {
            PathRole = Qt::UserRole + 1,
            NameRole,
            IconRole,
            CategoryRole,
            NoDisplayRole,
            KeywordsRole,
            ExecRole,
            DesktopFileRole,
            AppIdRole,
            AppNameRole,
            EntryRole
        };

        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;

        QStringList categories();

    public slots:
        void start(QString path, const QStringList &args = QStringList());
        void stop(QString path, const QStringList &args = QStringList());
        QString appIdData(QString appid, QString key);

    signals:
        void raiseProcess(int pid);
        void categoriesChanged(QStringList categories);

    private:
        QString m_sources;
    };
}

#endif // XDGDESKTOPENTRIES_H