OSDN Git Service

d4117dcae898030f7196bf52d34108ea6e214820
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qt4projectmanager / wizards / qtquickapp.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (qt-info@nokia.com)
8 **
9 ** No Commercial Usage
10 **
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
14 ** this package.
15 **
16 ** GNU Lesser General Public License Usage
17 **
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file.  Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Nokia gives you certain additional
26 ** rights.  These rights are described in the Nokia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** If you have questions regarding the use of this file, please contact
30 ** Nokia at qt-info@nokia.com.
31 **
32 **************************************************************************/
33
34 #ifndef QTQUICKAPP_H
35 #define QTQUICKAPP_H
36
37 #include "abstractmobileapp.h"
38
39 #include <QtCore/QHash>
40 #include <QtCore/QStringList>
41
42 namespace Qt4ProjectManager {
43 namespace Internal {
44
45 class QtQuickApp;
46
47 struct QmlModule
48 {
49     enum Path {
50         // Example: Module "com.foo.bar" in "c:/modules/".
51         // "qmldir" file is in "c:/modules/com/foo/bar/".
52         // Application .pro file is "c:/app/app.pro".
53         Root,                   // "c:/modules/" (absolute)
54         ContentDir,             // "../modules/com/foo/bar" (relative form .pro file)
55         ContentBase,            // "com/foo/"
56         DeployedContentBase     // "<qmlmodules>/com/foo" (on deploy target)
57     };
58
59     QmlModule(const QString &name, const QFileInfo &rootDir, const QFileInfo &qmldir,
60               bool isExternal, QtQuickApp *qtQuickApp);
61     QString path(Path path) const;
62     const QString uri;              // "com.foo.bar"
63     const QFileInfo rootDir;        // Location of "com/"
64     const QFileInfo qmldir;         // 'qmldir' file.
65     const bool isExternal;          // Either external or inside a source paths
66     const QtQuickApp *qtQuickApp;
67     QHash<QString, struct QmlCppPlugin*> cppPlugins;   // Just as info. No ownership.
68 };
69
70 struct QmlCppPlugin
71 {
72     QmlCppPlugin(const QString &name, const QFileInfo &path,
73                  const QmlModule *module, const QFileInfo &proFile);
74     const QString name;             // Original name
75     const QFileInfo path;           // Plugin path where qmldir points to
76     const QmlModule *module;
77     const QFileInfo proFile;        // .pro file for the plugin
78 };
79
80 struct QtQuickAppGeneratedFileInfo : public AbstractGeneratedFileInfo
81 {
82     enum ExtendedFileType {
83         MainQmlFile = ExtendedFile,
84         AppViewerPriFile,
85         AppViewerCppFile,
86         AppViewerHFile
87     };
88
89     QtQuickAppGeneratedFileInfo() : AbstractGeneratedFileInfo() {}
90 };
91
92 class QtQuickApp : public AbstractMobileApp
93 {
94 public:
95     enum ExtendedFileType {
96         MainQml = ExtendedFile,
97         MainQmlDeployed,
98         MainQmlOrigin,
99         AppViewerPri,
100         AppViewerPriOrigin,
101         AppViewerCpp,
102         AppViewerCppOrigin,
103         AppViewerH,
104         AppViewerHOrigin,
105         QmlDir,
106         QmlDirProFileRelative,
107         ModulesDir
108     };
109
110     enum Mode {
111         ModeGenerate,
112         ModeImport
113     };
114
115     QtQuickApp();
116     virtual ~QtQuickApp();
117
118     void setMainQml(Mode mode, const QString &file = QString());
119     Mode mainQmlMode() const;
120     bool setExternalModules(const QStringList &uris, const QStringList &importPaths);
121
122 #ifndef CREATORLESSTEST
123     virtual Core::GeneratedFiles generateFiles(QString *errorMessage) const;
124 #else
125     bool generateFiles(QString *errorMessage) const;
126 #endif // CREATORLESSTEST
127     bool useExistingMainQml() const;
128     const QList<QmlModule*> modules() const;
129
130     static const int StubVersion;
131
132 private:
133     virtual QByteArray generateFileExtended(int fileType,
134         bool *versionAndCheckSum, QString *comment, QString *errorMessage) const;
135     virtual QString pathExtended(int fileType) const;
136     virtual QString originsRoot() const;
137     virtual QString mainWindowClassName() const;
138     virtual int stubVersionMinor() const;
139     virtual bool adaptCurrentMainCppTemplateLine(QString &line) const;
140     virtual void handleCurrentProFileTemplateLine(const QString &line,
141         QTextStream &proFileTemplate, QTextStream &proFile,
142         bool &commentOutNextLine) const;
143     QList<AbstractGeneratedFileInfo> updateableFiles(const QString &mainProFile) const;
144     QList<DeploymentFolder> deploymentFolders() const;
145
146     bool addExternalModule(const QString &uri, const QFileInfo &dir,
147                            const QFileInfo &contentDir);
148     bool addCppPlugins(QmlModule *module);
149     bool addCppPlugin(const QString &qmldirLine, QmlModule *module);
150     void clearModulesAndPlugins();
151
152     QFileInfo m_mainQmlFile;
153     Mode m_mainQmlMode;
154     QStringList m_importPaths;
155     QList <QmlModule*> m_modules;
156     QList <QmlCppPlugin*> m_cppPlugins;
157 };
158
159 } // namespace Internal
160 } // namespace Qt4ProjectManager
161
162 #endif // QTQUICKAPP_H