aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/studiowelcome/fieldhelper.h
blob: 39cd5443aa13a4ec71e3c6e338708f3ca2892aa9 (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
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include <QStringList>

QT_FORWARD_DECLARE_CLASS(QStandardItemModel)

namespace ProjectExplorer {
class JsonFieldPage;
class CheckBoxField;
class ComboBoxField;
}

namespace StudioWelcome::FieldHelper {

class CheckBoxHelper
{
public:
    CheckBoxHelper(ProjectExplorer::JsonFieldPage *detailsPage, const QString &fieldName);

    void setChecked(bool value);
    bool isChecked() const;

private:
    ProjectExplorer::CheckBoxField *m_field = nullptr;
};

class ComboBoxHelper
{
public:
    ComboBoxHelper(ProjectExplorer::JsonFieldPage *detailsPage, const QString &fieldName);

    void selectIndex(int index);

    QString text(int index) const;
    int indexOf(const QString &text) const;
    int selectedIndex() const;
    QStandardItemModel *model() const;
    QStringList allTexts() const;

private:
    ProjectExplorer::ComboBoxField *m_field = nullptr;
};

} // namespace StudioWelcome::FieldHelper