summaryrefslogtreecommitdiff
path: root/src/plugins/studiowelcome/wizardfactories.h
blob: 7ce4cdf2be3ea6a2a3e887f7b00b692c4b50c489 (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
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0

#pragma once

#include "presetmodel.h"

#include <utils/id.h>

namespace Core {
class IWizardFactory;
}

namespace ProjectExplorer {
class JsonWizardFactory;
}

using ProjectExplorer::JsonWizardFactory;

namespace StudioWelcome {

class WizardFactories
{
public:
    using GetIconUnicodeFunc = QString (*)(const QString &);

public:
    WizardFactories(const QList<Core::IWizardFactory *> &factories, QWidget *wizardParent,
                    const Utils::Id &platform);

    const Core::IWizardFactory *front() const;
    const std::map<QString, WizardCategory> &presetsGroupedByCategory() const
    { return m_presetItems; }

    bool empty() const { return m_factories.empty(); }
    static GetIconUnicodeFunc setIconUnicodeCallback(GetIconUnicodeFunc cb)
    {
        return std::exchange(m_getIconUnicode, cb);
    }

private:
    void sortByCategoryAndId();
    void filter();

    std::shared_ptr<PresetItem> makePresetItem(JsonWizardFactory *f, QWidget *parent, const Utils::Id &platform);
    std::map<QString, WizardCategory> makePresetItemsGroupedByCategory();

private:
    QWidget *m_wizardParent;
    Utils::Id m_platform; // filter wizards to only those supported by this platform.

    QList<JsonWizardFactory *> m_factories;
    std::map<QString, WizardCategory> m_presetItems;

    static GetIconUnicodeFunc m_getIconUnicode;
};

} // namespace StudioWelcome