cppclasswizard.h 3.15 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
con's avatar
con committed
2
**
3
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
con's avatar
con committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
con's avatar
con committed
7
**
hjk's avatar
hjk committed
8 9 10 11 12 13 14
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
15
**
16
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17 18 19 20 21 22 23 24 25
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
con's avatar
con committed
26 27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
hjk's avatar
hjk committed
29

con's avatar
con committed
30 31 32 33
#ifndef CPPCLASSWIZARD_H
#define CPPCLASSWIZARD_H

#include <coreplugin/basefilewizard.h>
34

35
#include <utils/wizard.h>
con's avatar
con committed
36

37
#include <QWizardPage>
con's avatar
con committed
38

39
namespace Utils { class NewClassWidget; }
con's avatar
con committed
40 41 42 43 44 45 46 47 48

namespace CppEditor {
namespace Internal {

class ClassNamePage : public QWizardPage
{
    Q_OBJECT

public:
49
    explicit ClassNamePage(QWidget *parent = 0);
con's avatar
con committed
50 51

    bool isComplete() const { return m_isValid; }
52
    Utils::NewClassWidget *newClassWidget() const { return m_newClassWidget; }
con's avatar
con committed
53 54 55 56 57

private slots:
    void slotValidChanged();

private:
58 59
    void initParameters();

60
    Utils::NewClassWidget *m_newClassWidget;
con's avatar
con committed
61 62 63 64
    bool m_isValid;
};


65 66
struct CppClassWizardParameters
{
con's avatar
con committed
67 68 69 70 71
    QString className;
    QString headerFile;
    QString sourceFile;
    QString baseClass;
    QString path;
72
    int classType;
con's avatar
con committed
73 74
};

75
class CppClassWizardDialog : public Utils::Wizard
76
{
con's avatar
con committed
77
    Q_OBJECT
hjk's avatar
hjk committed
78

con's avatar
con committed
79
public:
80
    explicit CppClassWizardDialog(QWidget *parent = 0);
con's avatar
con committed
81 82 83 84 85 86 87 88 89 90 91 92

    void setPath(const QString &path);
    CppClassWizardParameters parameters() const;

private:
    ClassNamePage *m_classNamePage;
};


class CppClassWizard : public Core::BaseFileWizard
{
    Q_OBJECT
hjk's avatar
hjk committed
93

con's avatar
con committed
94
public:
hjk's avatar
hjk committed
95
    CppClassWizard();
con's avatar
con committed
96

hjk's avatar
hjk committed
97 98
private:
    QWizard *createWizardDialog(QWidget *parent,
99
                                        const Core::WizardDialogParameters &wizardDialogParameters) const;
con's avatar
con committed
100 101


hjk's avatar
hjk committed
102
    Core::GeneratedFiles generateFiles(const QWizard *w,
con's avatar
con committed
103 104 105 106 107 108 109 110 111 112 113 114
                                               QString *errorMessage) const;
    QString sourceSuffix() const;
    QString headerSuffix() const;

    static bool generateHeaderAndSource(const CppClassWizardParameters &params,
                                        QString *header, QString *source);
};

} // namespace Internal
} // namespace CppEditor

#endif // CPPCLASSWIZARD_H