aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/extensionmanager/extensionsmodel.h
blob: 8c83c181c26736c9c30ac70d0e2e981c8f5d0718 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include <utils/osspecificaspects.h>
#include <utils/filepath.h>

#include <QAbstractListModel>

namespace ExtensionSystem {
class PluginSpec;
}

namespace ExtensionManager::Internal {

enum ItemType {
    ItemTypePack,
    ItemTypeExtension,
};

enum ExtensionState {
    None, // Not a plugin
    InstalledEnabled,
    InstalledDisabled,
    NotInstalled,
};

enum Role {
    RoleName = Qt::UserRole,
    RoleBadge,
    RoleCopyright,
    RoleDateUpdated,
    RoleDependencies,
    RoleDescriptionLong,
    RoleDescriptionShort,
    RoleDownloadCount,
    RoleDownloadUrl,
    RoleExtensionState,
    RoleId,
    RoleItemType,
    RoleLicense,
    RolePlatforms,
    RolePlugins,
    RoleSearchText,
    RoleStatus,
    RoleTags,
    RoleVendor,
    RoleVendorId,
    RoleVersion,
    RoleFullId,
    RoleSpec,
};

class ExtensionsModel : public QAbstractListModel
{
public:
    ExtensionsModel(QObject *parent = nullptr);
    ~ExtensionsModel();

    int rowCount(const QModelIndex &parent = {}) const;
    QVariant data(const QModelIndex &index, int role) const;

    QModelIndex indexOfId(const QString &extensionId) const;
    void setRepositoryPaths(const Utils::FilePaths &paths);

private:
    class ExtensionsModelPrivate *d = nullptr;
};

QString customOsTypeToString(Utils::OsType osType);
QString customOsArchToString(Utils::OsArch osArch);
ExtensionSystem::PluginSpec *pluginSpecForId(const QString &pluginId);
QString statusDisplayString(const QModelIndex &index);

#ifdef WITH_TESTS
QObject *createExtensionsModelTest();
#endif

} // ExtensionManager::Internal