2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2011-01-11 16:28:15 +01:00
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Contact: Nokia Corporation (info@qt.nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-05-06 15:05:37 +02:00
|
|
|
** Nokia at info@qt.nokia.com.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01: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>
|
|
|
|
|
|
|
|
|
|
#include <QtCore/QSharedDataPointer>
|
|
|
|
|
#include <QtCore/QList>
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QSharedDataPointer<BaseFileWizardParameterData> m_d;
|
|
|
|
|
};
|
|
|
|
|
|
2010-03-12 11:20:32 +01:00
|
|
|
CORE_EXPORT QDebug operator<<(QDebug d, const BaseFileWizardParameters &);
|
|
|
|
|
|
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
|
|
|
|
2010-09-16 17:09:36 +02:00
|
|
|
virtual void runWizard(const QString &path, QWidget *parent);
|
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
|
|
|
|
|
|
|
|
virtual QWizard *createWizardDialog(QWidget *parent,
|
|
|
|
|
const QString &defaultPath,
|
|
|
|
|
const WizardPageList &extensionPages) const = 0;
|
|
|
|
|
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:
|
|
|
|
|
BaseFileWizardPrivate *m_d;
|
|
|
|
|
};
|
|
|
|
|
|
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);
|
2008-12-02 12:01:29 +01:00
|
|
|
virtual QWizard *createWizardDialog(QWidget *parent,
|
|
|
|
|
const QString &defaultPath,
|
|
|
|
|
const WizardPageList &extensionPages) 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)
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#endif // BASEFILEWIZARD_H
|