aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/coreplugin/dialogs/newdialogwidget.h
blob: 1733cae83dadc437a61eab3678662de8e3731fcb (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
81
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include "../iwizardfactory.h"
#include "newdialog.h"

#include <QCoreApplication>
#include <QDialog>
#include <QIcon>
#include <QList>
#include <QVariantMap>

QT_BEGIN_NAMESPACE
class QComboBox;
class QLabel;
class QListView;
class QModelIndex;
class QPushButton;
class QSortFilterProxyModel;
class QStandardItem;
class QStandardItemModel;
class QTextBrowser;
class QTreeView;
QT_END_NAMESPACE

namespace Core {

namespace Internal {

class NewDialogWidget : public QDialog, public NewDialog
{
    Q_DECLARE_TR_FUNCTIONS(Core::Internal::NewDialog)

public:
    explicit NewDialogWidget(QWidget *parent);
    ~NewDialogWidget() override;

    void setWizardFactories(QList<IWizardFactory *> factories,
                            const Utils::FilePath &defaultLocation,
                            const QVariantMap &extraVariables) override;

    void showDialog() override;
    Utils::Id selectedPlatform() const;
    QWidget *widget() override { return this; }

    void setWindowTitle(const QString &title) override {
        QDialog::setWindowTitle(title);
    }

protected:
    bool event(QEvent *) override;

private:
    void currentCategoryChanged(const QModelIndex &);
    void currentItemChanged(const QModelIndex &);
    void accept() override;
    void reject() override;
    void updateOkButton();
    void setSelectedPlatform(int index);

    Core::IWizardFactory *currentWizardFactory() const;
    void addItem(QStandardItem *topLevelCategoryItem, IWizardFactory *factory);
    void saveState();

    QStandardItemModel *m_model;
    QSortFilterProxyModel *m_filterProxyModel;
    QComboBox *m_comboBox;
    QTreeView *m_templateCategoryView;
    QListView *m_templatesView;
    QLabel *m_imageLabel;
    QTextBrowser *m_templateDescription;
    QPushButton *m_okButton = nullptr;
    QList<QStandardItem *> m_categoryItems;
    Utils::FilePath m_defaultLocation;
    QVariantMap m_extraVariables;
};

} // namespace Internal
} // namespace Core