2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
|
** Contact: http://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
|
2015-01-14 18:07:15 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms and
|
|
|
|
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
2014-10-01 13:21:18 +02:00
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
2015-01-14 18:07:15 +01:00
|
|
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
|
|
|
|
** rights. These rights are described in The Qt Company LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2014-05-26 16:58:50 +02:00
|
|
|
#ifndef BASEFILEWIZARDFACTORY_H
|
|
|
|
|
#define BASEFILEWIZARDFACTORY_H
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#include "core_global.h"
|
2011-09-12 16:52:54 +02:00
|
|
|
#include "generatedfile.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-05-02 17:38:42 +02:00
|
|
|
#include <coreplugin/iwizardfactory.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QList>
|
2015-02-26 13:38:54 +01:00
|
|
|
#include <QVariantMap>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
2010-03-18 10:59:06 +01:00
|
|
|
class QIcon;
|
2008-12-02 12:01:29 +01:00
|
|
|
class QWizard;
|
|
|
|
|
class QWizardPage;
|
2010-03-12 11:20:32 +01:00
|
|
|
class QDebug;
|
2008-12-02 12:01:29 +01:00
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
2013-09-20 15:12:44 +02:00
|
|
|
namespace Utils { class Wizard; }
|
2010-03-31 14:48:08 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
namespace Core {
|
|
|
|
|
|
2014-05-27 13:18:05 +02:00
|
|
|
class BaseFileWizard;
|
2013-10-02 10:49:01 +02:00
|
|
|
|
2012-02-03 18:00:08 +01:00
|
|
|
class CORE_EXPORT WizardDialogParameters
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
typedef QList<QWizardPage *> WizardPageList;
|
|
|
|
|
|
2012-03-19 16:12:51 +01:00
|
|
|
enum DialogParameterEnum {
|
|
|
|
|
ForceCapitalLetterForFileName = 0x01
|
|
|
|
|
};
|
|
|
|
|
Q_DECLARE_FLAGS(DialogParameterFlags, DialogParameterEnum)
|
|
|
|
|
|
2015-05-29 17:25:40 +02:00
|
|
|
explicit WizardDialogParameters(const QString &defaultPath, const QString &platform,
|
|
|
|
|
const FeatureSet &requiredFeatures, DialogParameterFlags flags,
|
2012-05-14 18:55:30 +02:00
|
|
|
QVariantMap extraValues)
|
2012-02-03 18:00:08 +01:00
|
|
|
: m_defaultPath(defaultPath),
|
|
|
|
|
m_selectedPlatform(platform),
|
2012-03-19 16:12:51 +01:00
|
|
|
m_requiredFeatures(requiredFeatures),
|
2012-05-14 18:55:30 +02:00
|
|
|
m_parameterFlags(flags),
|
|
|
|
|
m_extraValues(extraValues)
|
|
|
|
|
{}
|
2012-02-03 18:00:08 +01:00
|
|
|
|
|
|
|
|
QString defaultPath() const
|
|
|
|
|
{ return m_defaultPath; }
|
|
|
|
|
|
|
|
|
|
QString selectedPlatform() const
|
|
|
|
|
{ return m_selectedPlatform; }
|
|
|
|
|
|
2014-11-16 10:52:41 +02:00
|
|
|
FeatureSet requiredFeatures() const
|
2012-02-03 18:00:08 +01:00
|
|
|
{ return m_requiredFeatures; }
|
|
|
|
|
|
2012-03-19 16:12:51 +01:00
|
|
|
DialogParameterFlags flags() const
|
|
|
|
|
{ return m_parameterFlags; }
|
|
|
|
|
|
2012-05-14 18:55:30 +02:00
|
|
|
QVariantMap extraValues() const
|
|
|
|
|
{ return m_extraValues; }
|
|
|
|
|
|
2012-02-03 18:00:08 +01:00
|
|
|
private:
|
|
|
|
|
QString m_defaultPath;
|
|
|
|
|
QString m_selectedPlatform;
|
2014-11-16 10:52:41 +02:00
|
|
|
FeatureSet m_requiredFeatures;
|
2012-03-19 16:12:51 +01:00
|
|
|
DialogParameterFlags m_parameterFlags;
|
2012-05-14 18:55:30 +02:00
|
|
|
QVariantMap m_extraValues;
|
2012-02-03 18:00:08 +01:00
|
|
|
};
|
|
|
|
|
|
2014-05-26 16:58:50 +02:00
|
|
|
class CORE_EXPORT BaseFileWizardFactory : public IWizardFactory
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
2015-05-29 17:25:40 +02:00
|
|
|
friend class BaseFileWizard;
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
public:
|
|
|
|
|
static QString buildFileName(const QString &path, const QString &baseName, const QString &extension);
|
2010-03-31 14:48:08 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
protected:
|
2014-05-27 13:18:05 +02:00
|
|
|
virtual BaseFileWizard *create(QWidget *parent, const WizardDialogParameters ¶meters) const = 0;
|
2012-02-03 18:00:08 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
virtual GeneratedFiles generateFiles(const QWizard *w,
|
|
|
|
|
QString *errorMessage) const = 0;
|
|
|
|
|
|
2015-05-29 17:25:40 +02:00
|
|
|
virtual bool writeFiles(const GeneratedFiles &files, QString *errorMessage) const;
|
2010-09-01 13:27:24 +02:00
|
|
|
|
2015-05-29 17:25:40 +02:00
|
|
|
virtual bool postGenerateFiles(const QWizard *w, const GeneratedFiles &l, QString *errorMessage) const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-12-16 14:19:34 +01:00
|
|
|
static QString preferredSuffix(const QString &mimeType);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
enum OverwriteResult { OverwriteOk, OverwriteError, OverwriteCanceled };
|
2011-04-15 11:27:15 +02:00
|
|
|
OverwriteResult promptOverwrite(GeneratedFiles *files,
|
2008-12-02 12:01:29 +01:00
|
|
|
QString *errorMessage) const;
|
2010-04-16 15:55:32 +02:00
|
|
|
static bool postGenerateOpenEditors(const GeneratedFiles &l, QString *errorMessage = 0);
|
2015-05-29 15:55:49 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// IWizard
|
2015-05-29 16:17:51 +02:00
|
|
|
Utils::Wizard *runWizardImpl(const QString &path, QWidget *parent, const QString &platform,
|
|
|
|
|
const QVariantMap &extraValues) override;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Core
|
|
|
|
|
|
2010-04-16 15:55:32 +02:00
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(Core::GeneratedFile::Attributes)
|
2012-03-19 16:12:51 +01:00
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(Core::WizardDialogParameters::DialogParameterFlags)
|
2010-04-16 15:55:32 +02:00
|
|
|
|
2014-05-26 16:58:50 +02:00
|
|
|
#endif // BASEFILEWIZARDFACTORY_H
|