2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
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
|
|
|
|
|
** 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.
|
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
|
|
|
|
|
** 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
|
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
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#ifndef BASEFILEWIZARD_H
|
|
|
|
|
#define BASEFILEWIZARD_H
|
|
|
|
|
|
|
|
|
|
#include "core_global.h"
|
2011-09-12 16:52:54 +02:00
|
|
|
#include "generatedfile.h"
|
2013-03-27 08:29:38 +01:00
|
|
|
#include "featureprovider.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#include <coreplugin/dialogs/iwizard.h>
|
|
|
|
|
|
2012-02-14 14:02:47 +01:00
|
|
|
#include <extensionsystem/iplugin.h>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QSharedDataPointer>
|
|
|
|
|
#include <QList>
|
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 {
|
|
|
|
|
|
2013-10-02 10:49:01 +02:00
|
|
|
class IFileWizardExtension;
|
|
|
|
|
|
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)
|
|
|
|
|
|
2012-02-03 18:00:08 +01:00
|
|
|
explicit WizardDialogParameters(const QString &defaultPath, const WizardPageList &extensionPages,
|
2012-03-19 16:12:51 +01:00
|
|
|
const QString &platform, const Core::FeatureSet &requiredFeatures,
|
2012-05-14 18:55:30 +02:00
|
|
|
DialogParameterFlags flags,
|
|
|
|
|
QVariantMap extraValues)
|
2012-02-03 18:00:08 +01:00
|
|
|
: m_defaultPath(defaultPath),
|
|
|
|
|
m_extensionPages(extensionPages),
|
|
|
|
|
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; }
|
|
|
|
|
|
|
|
|
|
WizardPageList extensionPages() const
|
|
|
|
|
{ return m_extensionPages; }
|
|
|
|
|
|
|
|
|
|
QString selectedPlatform() const
|
|
|
|
|
{ return m_selectedPlatform; }
|
|
|
|
|
|
|
|
|
|
Core::FeatureSet requiredFeatures() const
|
|
|
|
|
{ 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;
|
|
|
|
|
WizardPageList m_extensionPages;
|
|
|
|
|
QString m_selectedPlatform;
|
|
|
|
|
Core::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
|
|
|
};
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
class CORE_EXPORT BaseFileWizard : public IWizard
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
virtual ~BaseFileWizard();
|
|
|
|
|
|
|
|
|
|
// IWizard
|
2012-04-02 14:55:56 +02:00
|
|
|
virtual void runWizard(const QString &path, QWidget *parent, const QString &platform, const QVariantMap &extraValues);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
static QString buildFileName(const QString &path, const QString &baseName, const QString &extension);
|
|
|
|
|
static void setupWizard(QWizard *);
|
2010-03-31 14:48:08 +02:00
|
|
|
static void applyExtensionPageShortTitle(Utils::Wizard *wizard, int pageId);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
protected:
|
|
|
|
|
typedef QList<QWizardPage *> WizardPageList;
|
2013-10-02 10:49:01 +02:00
|
|
|
typedef QList<Core::IFileWizardExtension*> ExtensionList;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-09-20 15:12:44 +02:00
|
|
|
explicit BaseFileWizard(QObject *parent = 0);
|
2012-01-18 13:50:14 +01:00
|
|
|
|
2013-10-02 10:49:01 +02:00
|
|
|
virtual ExtensionList selectExtensions();
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
virtual QWizard *createWizardDialog(QWidget *parent,
|
2012-02-03 18:00:08 +01:00
|
|
|
const WizardDialogParameters &wizardDialogParameters) const = 0;
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
virtual GeneratedFiles generateFiles(const QWizard *w,
|
|
|
|
|
QString *errorMessage) const = 0;
|
|
|
|
|
|
2010-09-01 13:27:24 +02:00
|
|
|
virtual bool writeFiles(const GeneratedFiles &files, QString *errorMessage);
|
|
|
|
|
|
2010-02-17 16:18:21 +01:00
|
|
|
virtual bool postGenerateFiles(const QWizard *w, const GeneratedFiles &l, QString *errorMessage);
|
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);
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
2008-12-02 14:09:21 +01:00
|
|
|
class CORE_EXPORT StandardFileWizard : public BaseFileWizard
|
|
|
|
|
{
|
2008-12-02 12:01:29 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
protected:
|
2013-09-20 15:12:44 +02:00
|
|
|
explicit StandardFileWizard(QObject *parent = 0);
|
2012-02-03 18:00:08 +01:00
|
|
|
virtual QWizard *createWizardDialog(QWidget *parent, const WizardDialogParameters &wizardDialogParameters) const;
|
2011-04-01 12:18:25 +02:00
|
|
|
virtual GeneratedFiles generateFiles(const QWizard *w, QString *errorMessage) const;
|
|
|
|
|
virtual GeneratedFiles generateFilesFromPath(const QString &path, const QString &name,
|
2008-12-02 12:01:29 +01:00
|
|
|
QString *errorMessage) const = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // 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
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#endif // BASEFILEWIZARD_H
|