2010-03-12 11:20:32 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
|
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
|
|
**
|
|
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
|
|
|
**
|
|
|
|
|
** Commercial Usage
|
|
|
|
|
**
|
|
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
** If you are unsure which license is appropriate for your use, please
|
|
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
|
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef CUSTOMPROJECTWIZARDPARAMETERS_H
|
|
|
|
|
#define CUSTOMPROJECTWIZARDPARAMETERS_H
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/basefilewizard.h>
|
|
|
|
|
|
2010-09-03 14:27:13 +02:00
|
|
|
#include <QtCore/QStringList>
|
2010-03-12 11:20:32 +01:00
|
|
|
#include <QtCore/QMap>
|
2010-09-03 14:27:13 +02:00
|
|
|
#include <QtCore/QSharedPointer>
|
2010-03-12 11:20:32 +01:00
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QIODevice;
|
|
|
|
|
class QDebug;
|
2010-09-03 14:27:13 +02:00
|
|
|
class QTemporaryFile;
|
2010-03-12 11:20:32 +01:00
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
struct CustomWizardField {
|
|
|
|
|
// Parameters of the widget control are stored as map
|
|
|
|
|
typedef QMap<QString, QString> ControlAttributeMap;
|
|
|
|
|
CustomWizardField();
|
|
|
|
|
void clear();
|
|
|
|
|
|
2010-07-08 11:46:05 +02:00
|
|
|
// Attribute map keys for combo entries
|
|
|
|
|
static QString comboEntryValueKey(int i);
|
|
|
|
|
static QString comboEntryTextKey(int i);
|
|
|
|
|
|
2010-03-12 11:20:32 +01:00
|
|
|
QString description;
|
|
|
|
|
QString name;
|
|
|
|
|
ControlAttributeMap controlAttributes;
|
|
|
|
|
bool mandatory;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct CustomWizardFile {
|
2010-04-16 15:55:32 +02:00
|
|
|
CustomWizardFile();
|
|
|
|
|
|
2010-03-12 11:20:32 +01:00
|
|
|
QString source;
|
|
|
|
|
QString target;
|
2010-04-16 15:55:32 +02:00
|
|
|
bool openEditor;
|
|
|
|
|
bool openProject;
|
2010-03-12 11:20:32 +01:00
|
|
|
};
|
|
|
|
|
|
2010-09-03 14:27:13 +02:00
|
|
|
// Argument to the generator script containing placeholders to
|
|
|
|
|
// be replaced by field values or file names
|
|
|
|
|
// as in '--class-name=%ClassName%' or '--description=%Description%'.
|
|
|
|
|
struct GeneratorScriptArgument {
|
|
|
|
|
enum Flags {
|
|
|
|
|
// Omit this arguments if all field placeholders expanded to empty strings.
|
|
|
|
|
OmitEmpty = 0x1,
|
|
|
|
|
// Do use the actual field value, but write it to a temporary
|
|
|
|
|
// text file and inserts its file name (suitable for multiline texts).
|
|
|
|
|
WriteFile = 0x2 };
|
|
|
|
|
|
|
|
|
|
explicit GeneratorScriptArgument(const QString &value = QString());
|
|
|
|
|
|
|
|
|
|
QString value;
|
|
|
|
|
unsigned flags;
|
|
|
|
|
};
|
|
|
|
|
|
2010-03-12 11:20:32 +01:00
|
|
|
struct CustomWizardParameters
|
|
|
|
|
{
|
|
|
|
|
public:
|
2010-08-13 11:10:11 +02:00
|
|
|
enum ParseResult { ParseOk, ParseDisabled, ParseFailed };
|
|
|
|
|
|
2010-03-12 11:20:32 +01:00
|
|
|
CustomWizardParameters();
|
|
|
|
|
void clear();
|
2010-08-13 11:10:11 +02:00
|
|
|
ParseResult parse(QIODevice &device, const QString &configFileFullPath,
|
|
|
|
|
Core::BaseFileWizardParameters *bp, QString *errorMessage);
|
|
|
|
|
ParseResult parse(const QString &configFileFullPath,
|
|
|
|
|
Core::BaseFileWizardParameters *bp, QString *errorMessage);
|
2010-03-17 15:17:03 +01:00
|
|
|
QString toString() const;
|
2010-03-12 11:20:32 +01:00
|
|
|
|
|
|
|
|
QString directory;
|
|
|
|
|
QString klass;
|
|
|
|
|
QList<CustomWizardFile> files;
|
2010-09-03 14:27:13 +02:00
|
|
|
QStringList filesGeneratorScript; // Complete binary, such as 'cmd /c myscript.pl'.
|
|
|
|
|
QList<GeneratorScriptArgument> filesGeneratorScriptArguments;
|
|
|
|
|
|
2010-03-12 11:20:32 +01:00
|
|
|
QString fieldPageTitle;
|
|
|
|
|
QList<CustomWizardField> fields;
|
|
|
|
|
int firstPageId;
|
|
|
|
|
};
|
|
|
|
|
|
2010-03-22 15:33:33 +01:00
|
|
|
// Context used for one wizard run, shared between CustomWizard
|
|
|
|
|
// and the CustomWizardPage as it is used for the QLineEdit-type fields'
|
|
|
|
|
// default texts as well. Contains basic replacement fields
|
|
|
|
|
// like '%CppSourceSuffix%', '%CppHeaderSuffix%' (settings-dependent)
|
|
|
|
|
// reset() should be called before each wizard run to refresh them.
|
|
|
|
|
// CustomProjectWizard additionally inserts '%ProjectName%' from
|
|
|
|
|
// the intro page to have it available for default texts.
|
|
|
|
|
|
|
|
|
|
struct CustomWizardContext {
|
|
|
|
|
typedef QMap<QString, QString> FieldReplacementMap;
|
2010-09-03 14:27:13 +02:00
|
|
|
typedef QSharedPointer<QTemporaryFile> TemporaryFilePtr;
|
|
|
|
|
typedef QList<TemporaryFilePtr> TemporaryFilePtrList;
|
2010-03-22 15:33:33 +01:00
|
|
|
|
|
|
|
|
void reset();
|
|
|
|
|
|
|
|
|
|
// Replace field values delimited by '%' with special modifiers:
|
|
|
|
|
// %Field% -> simple replacement
|
|
|
|
|
// %Field:l% -> lower case replacement, 'u' upper case,
|
2010-09-03 14:27:13 +02:00
|
|
|
// 'c' capitalize first letter. Return value indicates whether non-empty
|
|
|
|
|
// replacements where encountered
|
|
|
|
|
static bool replaceFields(const FieldReplacementMap &fm, QString *s);
|
|
|
|
|
|
|
|
|
|
// Special replaceFields() overload used for the arguments of a generator
|
|
|
|
|
// script: Write the expanded field values out to temporary files and
|
|
|
|
|
// inserts file names instead of the expanded fields in string 's'.
|
|
|
|
|
static bool replaceFields(const FieldReplacementMap &fm, QString *s,
|
|
|
|
|
TemporaryFilePtrList *files);
|
|
|
|
|
|
2010-07-09 08:31:46 +02:00
|
|
|
static QString processFile(const FieldReplacementMap &fm, QString in);
|
2010-03-22 15:33:33 +01:00
|
|
|
|
|
|
|
|
FieldReplacementMap baseReplacements;
|
2010-09-01 13:27:24 +02:00
|
|
|
FieldReplacementMap replacements;
|
2010-09-06 16:33:44 +02:00
|
|
|
|
|
|
|
|
QString path;
|
|
|
|
|
// Where files should be created, that is, 'path' for simple wizards
|
|
|
|
|
// or "path + project" for project wizards.
|
2010-09-01 13:27:24 +02:00
|
|
|
QString targetPath;
|
2010-03-22 15:33:33 +01:00
|
|
|
};
|
|
|
|
|
|
2010-09-01 13:27:24 +02:00
|
|
|
extern const char customWizardFileOpenEditorAttributeC[];
|
|
|
|
|
extern const char customWizardFileOpenProjectAttributeC[];
|
|
|
|
|
|
2010-03-12 11:20:32 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace ProjectExplorer
|
|
|
|
|
|
|
|
|
|
#endif // CUSTOMPROJECTWIZARDPARAMETERS_H
|