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"
|
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
|
|
|
|
|
|
2010-03-31 14:48:08 +02:00
|
|
|
namespace Utils {
|
|
|
|
|
class Wizard;
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
namespace Core {
|
|
|
|
|
|
|
|
|
|
class IEditor;
|
|
|
|
|
class IFileWizardExtension;
|
|
|
|
|
|
|
|
|
|
class BaseFileWizardParameterData;
|
|
|
|
|
struct BaseFileWizardPrivate;
|
|
|
|
|
|
2008-12-02 14:09:21 +01:00
|
|
|
class CORE_EXPORT BaseFileWizardParameters
|
|
|
|
|
{
|
2008-12-02 12:01:29 +01:00
|
|
|
public:
|
2010-01-14 14:14:39 +01:00
|
|
|
explicit BaseFileWizardParameters(IWizard::WizardKind kind = IWizard::FileWizard);
|
2008-12-02 12:01:29 +01:00
|
|
|
BaseFileWizardParameters(const BaseFileWizardParameters &);
|
|
|
|
|
BaseFileWizardParameters &operator=(const BaseFileWizardParameters&);
|
|
|
|
|
~BaseFileWizardParameters();
|
|
|
|
|
|
2010-03-12 11:20:32 +01:00
|
|
|
void clear();
|
|
|
|
|
|
2010-01-14 14:14:39 +01:00
|
|
|
IWizard::WizardKind kind() const;
|
|
|
|
|
void setKind(IWizard::WizardKind k);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
QIcon icon() const;
|
2009-01-20 15:31:33 +01:00
|
|
|
void setIcon(const QIcon &icon);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
QString description() const;
|
2009-01-20 15:31:33 +01:00
|
|
|
void setDescription(const QString &description);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-01-07 18:17:24 +01:00
|
|
|
QString displayName() const;
|
|
|
|
|
void setDisplayName(const QString &name);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-11-27 10:33:24 +01:00
|
|
|
QString id() const;
|
|
|
|
|
void setId(const QString &id);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
QString category() const;
|
2009-01-20 15:31:33 +01:00
|
|
|
void setCategory(const QString &category);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-01-07 18:17:24 +01:00
|
|
|
QString displayCategory() const;
|
|
|
|
|
void setDisplayCategory(const QString &trCategory);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-01-18 13:50:14 +01:00
|
|
|
Core::FeatureSet requiredFeatures() const;
|
|
|
|
|
void setRequiredFeatures(Core::FeatureSet features);
|
|
|
|
|
|
2012-02-08 17:25:35 +01:00
|
|
|
Core::IWizard::WizardFlags flags() const;
|
|
|
|
|
void setFlags(Core::IWizard::WizardFlags flags);
|
2012-02-10 15:40:53 +01:00
|
|
|
|
|
|
|
|
QString descriptionImage() const;
|
|
|
|
|
void setDescriptionImage(const QString &path);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
private:
|
|
|
|
|
QSharedDataPointer<BaseFileWizardParameterData> m_d;
|
|
|
|
|
};
|
|
|
|
|
|
2010-03-12 11:20:32 +01:00
|
|
|
CORE_EXPORT QDebug operator<<(QDebug d, const BaseFileWizardParameters &);
|
|
|
|
|
|
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
|
2010-01-14 14:14:39 +01:00
|
|
|
virtual WizardKind kind() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
virtual QIcon icon() const;
|
|
|
|
|
virtual QString description() const;
|
2010-01-07 18:17:24 +01:00
|
|
|
virtual QString displayName() const;
|
2009-11-27 10:33:24 +01:00
|
|
|
virtual QString id() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
virtual QString category() const;
|
2010-01-07 18:17:24 +01:00
|
|
|
virtual QString displayCategory() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-02-10 15:40:53 +01:00
|
|
|
virtual QString descriptionImage() const;
|
|
|
|
|
|
2012-04-02 14:55:56 +02:00
|
|
|
virtual void runWizard(const QString &path, QWidget *parent, const QString &platform, const QVariantMap &extraValues);
|
2012-01-18 13:50:14 +01:00
|
|
|
virtual Core::FeatureSet requiredFeatures() const;
|
2012-02-08 17:25:35 +01:00
|
|
|
virtual WizardFlags flags() const;
|
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;
|
|
|
|
|
|
2009-01-20 15:31:33 +01:00
|
|
|
explicit BaseFileWizard(const BaseFileWizardParameters ¶meters, QObject *parent = 0);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-01-18 13:50:14 +01:00
|
|
|
BaseFileWizardParameters baseFileWizardParameters() const;
|
|
|
|
|
|
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
|
|
|
private:
|
2011-09-15 13:42:38 +02:00
|
|
|
BaseFileWizardPrivate *d;
|
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:
|
2009-01-20 15:31:33 +01:00
|
|
|
explicit StandardFileWizard(const BaseFileWizardParameters ¶meters, 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;
|
|
|
|
|
};
|
|
|
|
|
|
2012-02-14 14:02:47 +01:00
|
|
|
template <class WizardClass>
|
|
|
|
|
QList<WizardClass*> createMultipleBaseFileWizardInstances(const QList<BaseFileWizardParameters> ¶metersList, ExtensionSystem::IPlugin *plugin)
|
|
|
|
|
{
|
|
|
|
|
QList<WizardClass*> list;
|
|
|
|
|
foreach (const BaseFileWizardParameters ¶meters, parametersList) {
|
|
|
|
|
WizardClass *wc = new WizardClass(parameters, 0);
|
|
|
|
|
plugin->addAutoReleasedObject(wc);
|
|
|
|
|
list << wc;
|
|
|
|
|
}
|
|
|
|
|
return list;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#endif // BASEFILEWIZARD_H
|