OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / libs / utils / newclasswidget.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 **
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 **
23 ** Other Usage
24 **
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #ifndef NEWCLASSWIDGET_H
34 #define NEWCLASSWIDGET_H
35
36 #include "utils_global.h"
37
38 #include <QtGui/QWidget>
39
40 QT_BEGIN_NAMESPACE
41 class QStringList;
42 QT_END_NAMESPACE
43
44 namespace Utils {
45
46 struct NewClassWidgetPrivate;
47
48 class QTCREATOR_UTILS_EXPORT NewClassWidget : public QWidget
49 {
50     Q_DISABLE_COPY(NewClassWidget)
51     Q_OBJECT
52     Q_PROPERTY(bool namespacesEnabled READ namespacesEnabled WRITE setNamespacesEnabled DESIGNABLE true)
53     Q_PROPERTY(bool baseClassInputVisible READ isBaseClassInputVisible WRITE setBaseClassInputVisible DESIGNABLE true)
54     Q_PROPERTY(bool baseClassEditable READ isBaseClassEditable WRITE setBaseClassEditable DESIGNABLE false)
55     Q_PROPERTY(bool formInputVisible READ isFormInputVisible WRITE setFormInputVisible DESIGNABLE true)
56     Q_PROPERTY(bool pathInputVisible READ isPathInputVisible WRITE setPathInputVisible DESIGNABLE true)
57     Q_PROPERTY(bool classTypeComboVisible READ isClassTypeComboVisible WRITE setClassTypeComboVisible DESIGNABLE true)
58     Q_PROPERTY(QString className READ className WRITE setClassName DESIGNABLE true)
59     Q_PROPERTY(QString baseClassName READ baseClassName WRITE setBaseClassName DESIGNABLE true)
60     Q_PROPERTY(QString sourceFileName READ sourceFileName DESIGNABLE false)
61     Q_PROPERTY(QString headerFileName READ headerFileName DESIGNABLE false)
62     Q_PROPERTY(QString formFileName READ formFileName DESIGNABLE false)
63     Q_PROPERTY(QString path READ path WRITE setPath DESIGNABLE true)
64     Q_PROPERTY(QStringList baseClassChoices READ baseClassChoices WRITE setBaseClassChoices DESIGNABLE true)
65     Q_PROPERTY(QString sourceExtension READ sourceExtension WRITE setSourceExtension DESIGNABLE true)
66     Q_PROPERTY(QString headerExtension READ headerExtension WRITE setHeaderExtension DESIGNABLE true)
67     Q_PROPERTY(QString formExtension READ formExtension WRITE setFormExtension DESIGNABLE true)
68     Q_PROPERTY(bool formInputCheckable READ formInputCheckable WRITE setFormInputCheckable DESIGNABLE true)
69     Q_PROPERTY(bool formInputChecked READ formInputChecked WRITE setFormInputChecked DESIGNABLE true)
70     Q_PROPERTY(bool allowDirectories READ allowDirectories WRITE setAllowDirectories)
71     Q_PROPERTY(bool lowerCaseFiles READ lowerCaseFiles WRITE setLowerCaseFiles)
72     Q_PROPERTY(ClassType classType READ classType WRITE setClassType)
73     // Utility "USER" property for wizards containing file names.
74     Q_PROPERTY(QStringList files READ files DESIGNABLE false USER true)
75     Q_ENUMS(ClassType)
76 public:
77     enum ClassType { NoClassType, ClassInheritsQObject, ClassInheritsQWidget,
78                      ClassInheritsQDeclarativeItem,
79                      SharedDataClass };
80
81     explicit NewClassWidget(QWidget *parent = 0);
82     ~NewClassWidget();
83
84     bool namespacesEnabled() const;
85     bool isBaseClassInputVisible() const;
86     bool isBaseClassEditable() const;
87     bool isFormInputVisible() const;
88     bool isPathInputVisible() const;
89     bool formInputCheckable() const;
90     bool formInputChecked() const;
91
92     QString className() const;
93     QString baseClassName() const;
94     QString sourceFileName() const;
95     QString headerFileName() const;
96     QString formFileName() const;
97     QString path() const;
98     QStringList baseClassChoices() const;
99     QString sourceExtension() const;
100     QString headerExtension() const;
101     QString formExtension() const;
102     bool allowDirectories() const;
103     bool lowerCaseFiles() const;
104     ClassType classType() const;
105     bool isClassTypeComboVisible() const;
106
107     bool isValid(QString *error = 0) const;
108
109     QStringList files() const;
110
111 signals:
112     void validChanged();
113     void activated();
114
115 public slots:
116     void setNamespacesEnabled(bool b);
117     void setBaseClassInputVisible(bool visible);
118     void setBaseClassEditable(bool editable);
119     void setFormInputVisible(bool visible);
120     void setPathInputVisible(bool visible);
121     void setFormInputCheckable(bool v);
122     void setFormInputChecked(bool v);
123
124     /**
125      * The name passed into the new class widget will be reformatted to be a
126      * valid class name.
127      */
128     void setClassName(const QString &suggestedName);
129     void setBaseClassName(const QString &);
130     void setPath(const QString &path);
131     void setBaseClassChoices(const QStringList &choices);
132     void setSourceExtension(const QString &e);
133     void setHeaderExtension(const QString &e);
134     void setFormExtension(const QString &e);
135     void setAllowDirectories(bool v);
136     void setLowerCaseFiles(bool v);
137     void setClassType(ClassType ct);
138     void setClassTypeComboVisible(bool v);
139
140     /**
141      * Suggest a class name from the base class by stripping the leading 'Q'
142      * character. This will happen automagically if the base class combo
143      * changes until the class line edited is manually edited.
144      */
145     void suggestClassNameFromBase();
146
147 public slots:
148     /** Trigger an update (after changing settings) */
149     void triggerUpdateFileNames();
150
151 private slots:
152     void slotUpdateFileNames(const QString &t);
153     void slotValidChanged();
154     void slotActivated();
155     void classNameEdited();
156     void slotFormInputChecked();
157     void slotBaseClassEdited(const QString &);
158
159 private:
160     void setFormInputCheckable(bool checkable, bool force);
161
162     QString fixSuffix(const QString &suffix);
163     NewClassWidgetPrivate *m_d;
164 };
165
166 } // namespace Utils
167
168 #endif // NEWCLASSWIDGET_H