Commit ee85384c authored by Christian Kandeler's avatar Christian Kandeler

QML/Mobile wizard: Factor out common parts.

Reviewed-by: Alessandro Portale
parent 1b0487d5
......@@ -36,6 +36,7 @@ HEADERS += qt4deployconfiguration.h \
wizards/targetsetuppage.h \
wizards/qmlstandaloneappwizard.h \
wizards/qmlstandaloneappwizardpages.h \
wizards/abstractmobileapp.h \
wizards/qmlstandaloneapp.h \
qt4projectmanagerconstants.h \
makestep.h \
......@@ -90,6 +91,7 @@ SOURCES += qt4projectmanagerplugin.cpp \
wizards/targetsetuppage.cpp \
wizards/qmlstandaloneappwizard.cpp \
wizards/qmlstandaloneappwizardpages.cpp \
wizards/abstractmobileapp.cpp \
wizards/qmlstandaloneapp.cpp \
makestep.cpp \
qmakestep.cpp \
......
This diff is collapsed.
/**************************************************************************
**
** 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 ABSTRACTMOBILEAPP_H
#define ABSTRACTMOBILEAPP_H
#include <QtCore/QFileInfo>
#ifndef CREATORLESSTEST
#include <coreplugin/basefilewizard.h>
#endif // CREATORLESSTEST
QT_FORWARD_DECLARE_CLASS(QTextStream);
namespace Qt4ProjectManager {
namespace Internal {
struct AbstractGeneratedFileInfo
{
enum FileType {
MainQmlFile,
MainCppFile,
AppProFile,
DeploymentPriFile,
SymbianSvgIconFile,
MaemoPngIconFile,
DesktopFile,
ExtendedFile
};
AbstractGeneratedFileInfo();
bool isUpToDate() const;
bool wasModified() const;
virtual bool isOutdated() const=0;
int fileType;
QFileInfo fileInfo;
int version;
quint16 dataChecksum;
quint16 statedChecksum;
};
class AbstractMobileApp : public QObject
{
public:
enum Orientation {
LockLandscape,
LockPortrait,
Auto
};
enum FileType {
MainCpp,
MainCppOrigin,
AppPro,
AppProOrigin,
AppProPath,
Desktop,
DesktopOrigin,
DeploymentPri,
DeploymentPriOrigin,
SymbianSvgIcon,
SymbianSvgIconOrigin,
MaemoPngIcon,
MaemoPngIconOrigin,
ExtendedFile
};
virtual ~AbstractMobileApp();
void setOrientation(Orientation orientation);
Orientation orientation() const;
void setProjectName(const QString &name);
QString projectName() const;
void setProjectPath(const QString &path);
void setSymbianSvgIcon(const QString &icon);
QString symbianSvgIcon() const;
void setMaemoPngIcon(const QString &icon);
QString maemoPngIcon() const;
void setSymbianTargetUid(const QString &uid);
QString symbianTargetUid() const;
void setNetworkEnabled(bool enabled);
bool networkEnabled() const;
static QString symbianUidForPath(const QString &path);
static int makeStubVersion(int minor);
QString path(int fileType) const;
QString error() const;
static const QString DeploymentPriFileName;
protected:
AbstractMobileApp();
static QString templatesRoot();
static void insertParameter(QString &line, const QString &parameter);
QByteArray readBlob(const QString &filePath, QString *errorMsg) const;
#ifndef CREATORLESSTEST
virtual Core::GeneratedFiles generateFiles(QString *errorMessage) const;
static Core::GeneratedFile file(const QByteArray &data,
const QString &targetFile);
#else
bool generateFiles(QString *errorMessage) const;
#endif // CREATORLESSTEST
QByteArray generateFile(int fileType, QString *errorMessage) const;
QString outputPathBase() const;
static const QString CFileComment;
static const QString ProFileComment;
static const QString FileChecksum;
static const QString FileStubVersion;
static const int StubVersion;
QString m_error;
private:
QByteArray generateDesktopFile(QString *errorMessage) const;
QByteArray generateMainCpp(QString *errorMessage) const;
QByteArray generateProFile(QString *errorMessage) const;
virtual QByteArray generateFileExtended(int fileType,
bool *versionAndCheckSum, QString *comment, QString *errorMessage) const=0;
virtual QString pathExtended(int fileType) const=0;
virtual QString originsRoot() const=0;
virtual QString mainWindowClassName() const=0;
virtual int stubVersionMinor() const=0;
virtual bool adaptCurrentMainCppTemplateLine(QString &line) const=0;
virtual void handleCurrentProFileTemplateLine(const QString &line,
QTextStream &proFileTemplate, QTextStream &proFile,
bool &uncommentNextLine) const=0;
QString m_projectName;
QFileInfo m_projectPath;
QString m_symbianSvgIcon;
QString m_maemoPngIcon;
QString m_symbianTargetUid;
Orientation m_orientation;
bool m_networkEnabled;
};
} // end of namespace Internal
} // end of namespace Qt4ProjectManager
#endif // ABSTRACTMOBILEAPP_H
......@@ -30,111 +30,52 @@
#ifndef MOBILEAPP_H
#define MOBILEAPP_H
#include <coreplugin/basefilewizard.h>
#include <QtCore/QStringList>
#include <QtCore/QFileInfo>
#include <QtCore/QHash>
#include "abstractmobileapp.h"
namespace Qt4ProjectManager {
namespace Internal {
struct MobileAppGeneratedFileInfo
struct MobileAppGeneratedFileInfo : AbstractGeneratedFileInfo
{
enum File {
MainCppFile,
AppProFile,
DeploymentPriFile,
MainWindowCppFile,
enum ExtendedFileType {
MainWindowCppFile = ExtendedFile,
MainWindowHFile,
MainWindowUiFile,
SymbianSvgIconFile,
MaemoPngIconFile,
DesktopFile
};
MobileAppGeneratedFileInfo();
bool isUpToDate() const;
bool isOutdated() const;
bool wasModified() const;
File file;
QFileInfo fileInfo;
int version;
quint16 dataChecksum;
quint16 statedChecksum;
MobileAppGeneratedFileInfo() : AbstractGeneratedFileInfo() {}
virtual bool isOutdated() const;
};
class MobileApp: public QObject
class MobileApp : public AbstractMobileApp
{
public:
enum Orientation {
LockLandscape,
LockPortrait,
Auto
};
enum Path {
MainCpp,
MainCppOrigin,
AppPro,
AppProOrigin,
AppProPath,
Desktop,
DesktopOrigin,
DeploymentPri,
DeploymentPriOrigin,
MainWindowCpp,
enum ExtendedFileType {
MainWindowCpp = ExtendedFile,
MainWindowCppOrigin,
MainWindowH,
MainWindowHOrigin,
MainWindowUi,
MainWindowUiOrigin,
SymbianSvgIcon,
SymbianSvgIconOrigin,
MaemoPngIcon,
MaemoPngIconOrigin,
};
MobileApp();
~MobileApp();
virtual ~MobileApp();
void setOrientation(Orientation orientation);
Orientation orientation() const;
void setProjectName(const QString &name);
QString projectName() const;
void setProjectPath(const QString &path);
void setSymbianSvgIcon(const QString &icon);
QString symbianSvgIcon() const;
void setMaemoPngIcon(const QString &icon);
QString maemoPngIcon() const;
void setSymbianTargetUid(const QString &uid);
QString symbianTargetUid() const;
void setNetworkEnabled(bool enabled);
bool networkEnabled() const;
virtual Core::GeneratedFiles generateFiles(QString *errorMessage) const;
static QString symbianUidForPath(const QString &path);
Core::GeneratedFiles generateFiles(QString *errorMessage) const;
QString path(Path path) const;
QString error() const;
QByteArray generateFile(MobileAppGeneratedFileInfo::File file,
const QString *errorMessage) const;
static int stubVersion();
static const int StubVersion;
private:
QByteArray generateMainCpp(const QString *errorMessage) const;
QByteArray generateProFile(const QString *errorMessage) const;
QByteArray generateDesktopFile(const QString *errorMessage) const;
static QString templatesRoot(const QString &dirName);
QString m_projectName;
QFileInfo m_projectPath;
QString m_symbianSvgIcon;
QString m_maemoPngIcon;
QString m_symbianTargetUid;
Orientation m_orientation;
bool m_networkEnabled;
QString m_error;
virtual QByteArray generateFileExtended(int fileType,
bool *versionAndCheckSum, QString *comment, QString *errorMessage) const;
virtual QString pathExtended(int fileType) const;
virtual QString originsRoot() const;
virtual QString mainWindowClassName() const;
virtual int stubVersionMinor() const;
virtual bool adaptCurrentMainCppTemplateLine(QString &line) const;
virtual void handleCurrentProFileTemplateLine(const QString &line,
QTextStream &proFileTemplate, QTextStream &proFile,
bool &uncommentNextLine) const;
};
} // end of namespace Internal
......
......@@ -30,13 +30,10 @@
#ifndef QMLSTANDALONEAPP_H
#define QMLSTANDALONEAPP_H
#include <QtCore/QStringList>
#include <QtCore/QFileInfo>
#include <QtCore/QHash>
#include "abstractmobileapp.h"
#ifndef CREATORLESSTEST
#include <coreplugin/basefilewizard.h>
#endif // CREATORLESSTEST
#include <QtCore/QHash>
#include <QtCore/QStringList>
namespace Qt4ProjectManager {
namespace Internal {
......@@ -76,132 +73,81 @@ struct QmlCppPlugin
const QFileInfo proFile; // .pro file for the plugin
};
struct QmlAppGeneratedFileInfo
struct QmlAppGeneratedFileInfo : public AbstractGeneratedFileInfo
{
enum File {
MainQmlFile,
MainCppFile,
AppProFile,
enum ExtendedFileType {
MainQmlFile = ExtendedFile,
AppViewerPriFile,
DeploymentPriFile,
AppViewerCppFile,
AppViewerHFile,
SymbianSvgIconFile,
MaemoPngIconFile,
DesktopFile
};
QmlAppGeneratedFileInfo();
bool isUpToDate() const;
bool isOutdated() const;
bool wasModified() const;
File file;
QFileInfo fileInfo;
int version;
quint16 dataChecksum;
quint16 statedChecksum;
QmlAppGeneratedFileInfo() : AbstractGeneratedFileInfo() {}
virtual bool isOutdated() const;
};
class QmlStandaloneApp: public QObject
class QmlStandaloneApp : public AbstractMobileApp
{
public:
enum Orientation {
LockLandscape,
LockPortrait,
Auto
};
enum Path {
MainQml,
enum ExtendedFileType {
MainQml = ExtendedFile,
MainQmlDeployed,
MainQmlOrigin,
MainCpp,
MainCppOrigin,
AppPro,
AppProOrigin,
AppProPath,
Desktop,
DesktopOrigin,
AppViewerPri,
AppViewerPriOrigin,
DeploymentPri,
DeploymentPriOrigin,
AppViewerCpp,
AppViewerCppOrigin,
AppViewerH,
AppViewerHOrigin,
SymbianSvgIcon,
SymbianSvgIconOrigin,
MaemoPngIcon,
MaemoPngIconOrigin,
QmlDir,
QmlDirProFileRelative,
ModulesDir
};
QmlStandaloneApp();
~QmlStandaloneApp();
virtual ~QmlStandaloneApp();
void setMainQmlFile(const QString &qmlFile);
QString mainQmlFile() const;
void setOrientation(Orientation orientation);
Orientation orientation() const;
void setProjectName(const QString &name);
QString projectName() const;
void setProjectPath(const QString &path);
void setSymbianSvgIcon(const QString &icon);
QString symbianSvgIcon() const;
void setMaemoPngIcon(const QString &icon);
QString maemoPngIcon() const;
void setSymbianTargetUid(const QString &uid);
QString symbianTargetUid() const;
void setLoadDummyData(bool loadIt);
bool loadDummyData() const;
void setNetworkEnabled(bool enabled);
bool networkEnabled() const;
bool setExternalModules(const QStringList &uris, const QStringList &importPaths);
static QString symbianUidForPath(const QString &path);
#ifndef CREATORLESSTEST
Core::GeneratedFiles generateFiles(QString *errorMessage) const;
virtual Core::GeneratedFiles generateFiles(QString *errorMessage) const;
#else
bool generateFiles(QString *errorMessage) const;
#endif // CREATORLESSTEST
QString path(Path path) const;
bool useExistingMainQml() const;
QString error() const;
const QList<QmlModule*> modules() const;
QByteArray generateFile(QmlAppGeneratedFileInfo::File file, const QString *errorMessage) const;
static int stubVersion();
static QList<QmlAppGeneratedFileInfo> fileUpdates(const QString &mainProFile);
static bool updateFiles(const QList<QmlAppGeneratedFileInfo> &list, QString &error);
static const int StubVersion;
private:
QByteArray generateMainCpp(const QString *errorMessage) const;
QByteArray generateProFile(const QString *errorMessage) const;
QByteArray generateDesktopFile(const QString *errorMessage) const;
static QString templatesRoot();
virtual QByteArray generateFileExtended(int fileType,
bool *versionAndCheckSum, QString *comment, QString *errorMessage) const;
virtual QString pathExtended(int fileType) const;
virtual QString originsRoot() const;
virtual QString mainWindowClassName() const;
virtual int stubVersionMinor() const;
virtual bool adaptCurrentMainCppTemplateLine(QString &line) const;
virtual void handleCurrentProFileTemplateLine(const QString &line,
QTextStream &proFileTemplate, QTextStream &proFile,
bool &uncommentNextLine) const;
bool addExternalModule(const QString &uri, const QFileInfo &dir,
const QFileInfo &contentDir);
bool addCppPlugins(QmlModule *module);
bool addCppPlugin(const QString &qmldirLine, QmlModule *module);
void clearModulesAndPlugins();
QString m_projectName;
QFileInfo m_projectPath;
QString m_symbianSvgIcon;
QString m_maemoPngIcon;
QString m_symbianTargetUid;
bool m_loadDummyData;
Orientation m_orientation;
bool m_networkEnabled;
QFileInfo m_mainQmlFile;
QStringList m_importPaths;
QList <QmlModule*> m_modules;
QList <QmlCppPlugin*> m_cppPlugins;
QString m_error;
};
} // end of namespace Internal
......
......@@ -51,10 +51,12 @@ bool QmlStandaloneApp::generateFiles(QString *errorMessage) const
&& writeFile(generateFile(QmlAppGeneratedFileInfo::AppViewerCppFile, errorMessage), path(AppViewerCpp))
&& writeFile(generateFile(QmlAppGeneratedFileInfo::AppViewerHFile, errorMessage), path(AppViewerH))
&& writeFile(generateFile(QmlAppGeneratedFileInfo::SymbianSvgIconFile, errorMessage), path(SymbianSvgIcon))
&& writeFile(generateFile(QmlAppGeneratedFileInfo::MaemoPngIconFile, errorMessage), path(MaemoPngIcon));
&& writeFile(generateFile(QmlAppGeneratedFileInfo::MaemoPngIconFile, errorMessage), path(MaemoPngIcon))
&& writeFile(generateFile(QmlAppGeneratedFileInfo::DesktopFile, errorMessage), path(Desktop))
&& writeFile(generateFile(QmlAppGeneratedFileInfo::DeploymentPriFile, errorMessage), path(DeploymentPri));
}
QString QmlStandaloneApp::templatesRoot()
QString AbstractMobileApp::templatesRoot()
{
return QLatin1String("../../../share/qtcreator/templates/");
}
......
......@@ -4,8 +4,10 @@ DEFINES += \
CREATORLESSTEST
APPSOURCEDIR = $$CREATORSOURCEDIR/src/plugins/qt4projectmanager/wizards
HEADERS += \
$$APPSOURCEDIR/qmlstandaloneapp.h
$$APPSOURCEDIR/qmlstandaloneapp.h \
$$APPSOURCEDIR/abstractmobileapp.h
SOURCES += \
$$APPSOURCEDIR/qmlstandaloneapp.cpp \
$$APPSOURCEDIR/abstractmobileapp.cpp \
main.cpp
INCLUDEPATH += $$APPSOURCEDIR
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment