1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
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.
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.
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.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 #ifndef NEWCLASSWIDGET_H
34 #define NEWCLASSWIDGET_H
36 #include "utils_global.h"
38 #include <QtGui/QWidget>
46 struct NewClassWidgetPrivate;
48 class QTCREATOR_UTILS_EXPORT NewClassWidget : public QWidget
50 Q_DISABLE_COPY(NewClassWidget)
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)
77 enum ClassType { NoClassType, ClassInheritsQObject, ClassInheritsQWidget,
78 ClassInheritsQDeclarativeItem,
81 explicit NewClassWidget(QWidget *parent = 0);
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;
92 QString className() const;
93 QString baseClassName() const;
94 QString sourceFileName() const;
95 QString headerFileName() const;
96 QString formFileName() 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;
107 bool isValid(QString *error = 0) const;
109 QStringList files() const;
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);
125 * The name passed into the new class widget will be reformatted to be a
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);
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.
145 void suggestClassNameFromBase();
148 /** Trigger an update (after changing settings) */
149 void triggerUpdateFileNames();
152 void slotUpdateFileNames(const QString &t);
153 void slotValidChanged();
154 void slotActivated();
155 void classNameEdited();
156 void slotFormInputChecked();
157 void slotBaseClassEdited(const QString &);
160 void setFormInputCheckable(bool checkable, bool force);
162 QString fixSuffix(const QString &suffix);
163 NewClassWidgetPrivate *m_d;
168 #endif // NEWCLASSWIDGET_H