2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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
|
2016-01-15 14:58:39 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2016-01-15 14:58:39 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#include "utils_global.h"
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QWidget>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QStringList;
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
|
|
namespace Utils {
|
|
|
|
|
|
|
|
|
|
struct NewClassWidgetPrivate;
|
|
|
|
|
|
2009-05-08 12:09:21 +02:00
|
|
|
class QTCREATOR_UTILS_EXPORT NewClassWidget : public QWidget
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
Q_PROPERTY(bool namespacesEnabled READ namespacesEnabled WRITE setNamespacesEnabled DESIGNABLE true)
|
|
|
|
|
Q_PROPERTY(bool baseClassInputVisible READ isBaseClassInputVisible WRITE setBaseClassInputVisible DESIGNABLE true)
|
|
|
|
|
Q_PROPERTY(bool baseClassEditable READ isBaseClassEditable WRITE setBaseClassEditable DESIGNABLE false)
|
|
|
|
|
Q_PROPERTY(bool formInputVisible READ isFormInputVisible WRITE setFormInputVisible DESIGNABLE true)
|
2013-03-19 00:25:42 +04:00
|
|
|
Q_PROPERTY(bool headerInputVisible READ isHeaderInputVisible WRITE setHeaderInputVisible DESIGNABLE true)
|
|
|
|
|
Q_PROPERTY(bool sourceInputVisible READ isSourceInputVisible WRITE setSourceInputVisible DESIGNABLE true)
|
2008-12-02 12:01:29 +01:00
|
|
|
Q_PROPERTY(bool pathInputVisible READ isPathInputVisible WRITE setPathInputVisible DESIGNABLE true)
|
2009-11-02 15:46:51 +01:00
|
|
|
Q_PROPERTY(bool classTypeComboVisible READ isClassTypeComboVisible WRITE setClassTypeComboVisible DESIGNABLE true)
|
2008-12-02 12:01:29 +01:00
|
|
|
Q_PROPERTY(QString className READ className WRITE setClassName DESIGNABLE true)
|
|
|
|
|
Q_PROPERTY(QString baseClassName READ baseClassName WRITE setBaseClassName DESIGNABLE true)
|
|
|
|
|
Q_PROPERTY(QString sourceFileName READ sourceFileName DESIGNABLE false)
|
|
|
|
|
Q_PROPERTY(QString headerFileName READ headerFileName DESIGNABLE false)
|
|
|
|
|
Q_PROPERTY(QString formFileName READ formFileName DESIGNABLE false)
|
|
|
|
|
Q_PROPERTY(QString path READ path WRITE setPath DESIGNABLE true)
|
|
|
|
|
Q_PROPERTY(QStringList baseClassChoices READ baseClassChoices WRITE setBaseClassChoices DESIGNABLE true)
|
|
|
|
|
Q_PROPERTY(QString sourceExtension READ sourceExtension WRITE setSourceExtension DESIGNABLE true)
|
|
|
|
|
Q_PROPERTY(QString headerExtension READ headerExtension WRITE setHeaderExtension DESIGNABLE true)
|
|
|
|
|
Q_PROPERTY(QString formExtension READ formExtension WRITE setFormExtension DESIGNABLE true)
|
2013-03-19 00:25:42 +04:00
|
|
|
Q_PROPERTY(QString namesDelimiter READ namesDelimiter WRITE setNamesDelimiter)
|
2008-12-02 12:01:29 +01:00
|
|
|
Q_PROPERTY(bool formInputCheckable READ formInputCheckable WRITE setFormInputCheckable DESIGNABLE true)
|
|
|
|
|
Q_PROPERTY(bool formInputChecked READ formInputChecked WRITE setFormInputChecked DESIGNABLE true)
|
2008-12-05 10:39:08 +01:00
|
|
|
Q_PROPERTY(bool allowDirectories READ allowDirectories WRITE setAllowDirectories)
|
2009-03-18 16:43:01 +01:00
|
|
|
Q_PROPERTY(bool lowerCaseFiles READ lowerCaseFiles WRITE setLowerCaseFiles)
|
2009-11-02 15:46:51 +01:00
|
|
|
Q_PROPERTY(ClassType classType READ classType WRITE setClassType)
|
2008-12-02 12:01:29 +01:00
|
|
|
// Utility "USER" property for wizards containing file names.
|
|
|
|
|
Q_PROPERTY(QStringList files READ files DESIGNABLE false USER true)
|
2009-11-02 15:46:51 +01:00
|
|
|
Q_ENUMS(ClassType)
|
2011-07-13 18:02:35 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
public:
|
2013-01-17 16:18:29 +01:00
|
|
|
enum ClassType { NoClassType,
|
|
|
|
|
ClassInheritsQObject,
|
|
|
|
|
ClassInheritsQWidget,
|
2010-07-05 10:47:24 +02:00
|
|
|
ClassInheritsQDeclarativeItem,
|
2013-01-17 16:18:29 +01:00
|
|
|
ClassInheritsQQuickItem,
|
|
|
|
|
SharedDataClass
|
|
|
|
|
};
|
2009-11-02 15:46:51 +01:00
|
|
|
|
2018-05-07 17:33:02 +02:00
|
|
|
explicit NewClassWidget(QWidget *parent = nullptr);
|
2018-05-07 15:07:21 +02:00
|
|
|
~NewClassWidget() override;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
bool namespacesEnabled() const;
|
|
|
|
|
bool isBaseClassInputVisible() const;
|
|
|
|
|
bool isBaseClassEditable() const;
|
|
|
|
|
bool isFormInputVisible() const;
|
2013-03-19 00:25:42 +04:00
|
|
|
bool isHeaderInputVisible() const;
|
|
|
|
|
bool isSourceInputVisible() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
bool isPathInputVisible() const;
|
|
|
|
|
bool formInputCheckable() const;
|
|
|
|
|
bool formInputChecked() const;
|
|
|
|
|
|
|
|
|
|
QString className() const;
|
|
|
|
|
QString baseClassName() const;
|
|
|
|
|
QString sourceFileName() const;
|
|
|
|
|
QString headerFileName() const;
|
|
|
|
|
QString formFileName() const;
|
|
|
|
|
QString path() const;
|
|
|
|
|
QStringList baseClassChoices() const;
|
|
|
|
|
QString sourceExtension() const;
|
|
|
|
|
QString headerExtension() const;
|
|
|
|
|
QString formExtension() const;
|
2008-12-05 10:39:08 +01:00
|
|
|
bool allowDirectories() const;
|
2009-03-18 16:43:01 +01:00
|
|
|
bool lowerCaseFiles() const;
|
2009-11-02 15:46:51 +01:00
|
|
|
ClassType classType() const;
|
2013-03-19 00:25:42 +04:00
|
|
|
QString namesDelimiter() const;
|
2009-11-02 15:46:51 +01:00
|
|
|
bool isClassTypeComboVisible() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2018-05-07 17:33:02 +02:00
|
|
|
bool isValid(QString *error = nullptr) const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
QStringList files() const;
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void validChanged();
|
|
|
|
|
void activated();
|
|
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
void setNamespacesEnabled(bool b);
|
|
|
|
|
void setBaseClassInputVisible(bool visible);
|
|
|
|
|
void setBaseClassEditable(bool editable);
|
|
|
|
|
void setFormInputVisible(bool visible);
|
2013-03-19 00:25:42 +04:00
|
|
|
void setHeaderInputVisible(bool visible);
|
|
|
|
|
void setSourceInputVisible(bool visible);
|
2008-12-02 12:01:29 +01:00
|
|
|
void setPathInputVisible(bool visible);
|
|
|
|
|
void setFormInputCheckable(bool v);
|
|
|
|
|
void setFormInputChecked(bool v);
|
|
|
|
|
|
2009-03-20 11:06:09 +01:00
|
|
|
/**
|
|
|
|
|
* The name passed into the new class widget will be reformatted to be a
|
|
|
|
|
* valid class name.
|
|
|
|
|
*/
|
2008-12-02 12:01:29 +01:00
|
|
|
void setClassName(const QString &suggestedName);
|
|
|
|
|
void setBaseClassName(const QString &);
|
|
|
|
|
void setPath(const QString &path);
|
|
|
|
|
void setBaseClassChoices(const QStringList &choices);
|
|
|
|
|
void setSourceExtension(const QString &e);
|
|
|
|
|
void setHeaderExtension(const QString &e);
|
|
|
|
|
void setFormExtension(const QString &e);
|
2008-12-05 10:39:08 +01:00
|
|
|
void setAllowDirectories(bool v);
|
2009-03-18 16:43:01 +01:00
|
|
|
void setLowerCaseFiles(bool v);
|
2009-11-02 15:46:51 +01:00
|
|
|
void setClassType(ClassType ct);
|
2013-03-19 00:25:42 +04:00
|
|
|
void setNamesDelimiter(const QString &delimiter);
|
2009-11-02 15:46:51 +01:00
|
|
|
void setClassTypeComboVisible(bool v);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-03-20 11:06:09 +01:00
|
|
|
/**
|
|
|
|
|
* Suggest a class name from the base class by stripping the leading 'Q'
|
2008-12-02 12:01:29 +01:00
|
|
|
* character. This will happen automagically if the base class combo
|
2009-03-20 11:06:09 +01:00
|
|
|
* changes until the class line edited is manually edited.
|
|
|
|
|
*/
|
2008-12-02 12:01:29 +01:00
|
|
|
void suggestClassNameFromBase();
|
|
|
|
|
|
2016-06-28 22:31:02 +03:00
|
|
|
private:
|
2009-03-18 16:43:01 +01:00
|
|
|
void slotUpdateFileNames(const QString &t);
|
2008-12-02 12:01:29 +01:00
|
|
|
void slotValidChanged();
|
|
|
|
|
void slotActivated();
|
|
|
|
|
void classNameEdited();
|
|
|
|
|
void slotFormInputChecked();
|
2010-02-26 16:11:14 +01:00
|
|
|
void slotBaseClassEdited(const QString &);
|
2008-12-02 12:01:29 +01:00
|
|
|
void setFormInputCheckable(bool checkable, bool force);
|
|
|
|
|
|
|
|
|
|
QString fixSuffix(const QString &suffix);
|
2011-09-07 14:26:11 +02:00
|
|
|
NewClassWidgetPrivate *d;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Utils
|