qtquickapp.h 5.63 KB
Newer Older
1 2 3 4
/**************************************************************************
**
** This file is part of Qt Creator
**
con's avatar
con committed
5
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6
**
hjk's avatar
hjk committed
7
** Contact: Nokia Corporation (info@qt.nokia.com)
8 9 10 11
**
**
** GNU Lesser General Public License Usage
**
hjk's avatar
hjk committed
12 13 14 15 16 17
** 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.
18
**
con's avatar
con committed
19
** In addition, as a special exception, Nokia gives you certain additional
hjk's avatar
hjk committed
20
** rights. These rights are described in the Nokia Qt LGPL Exception
con's avatar
con committed
21 22
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
23 24 25 26 27
** 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.
**
con's avatar
con committed
28
** If you have questions regarding the use of this file, please contact
Tobias Hunger's avatar
Tobias Hunger committed
29
** Nokia at info@qt.nokia.com.
30 31 32
**
**************************************************************************/

33 34
#ifndef QTQUICKAPP_H
#define QTQUICKAPP_H
35

36
#include "abstractmobileapp.h"
37

38 39
#include <QtCore/QHash>
#include <QtCore/QStringList>
40

41
namespace Qt4ProjectManager {
42 43
namespace Internal {

44
class QtQuickApp;
hjk's avatar
hjk committed
45
struct QmlCppPlugin;
46 47 48

struct QmlModule
{
49
    enum Path {
50 51 52 53 54 55 56 57 58 59
        // Example: Module "com.foo.bar" in "c:/modules/".
        // "qmldir" file is in "c:/modules/com/foo/bar/".
        // Application .pro file is "c:/app/app.pro".
        Root,                   // "c:/modules/" (absolute)
        ContentDir,             // "../modules/com/foo/bar" (relative form .pro file)
        ContentBase,            // "com/foo/"
        DeployedContentBase     // "<qmlmodules>/com/foo" (on deploy target)
    };

    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 64 65
    const QFileInfo rootDir;        // Location of "com/"
    const QFileInfo qmldir;         // 'qmldir' file.
    const bool isExternal;          // Either external or inside a source paths
66
    const QtQuickApp *qtQuickApp;
hjk's avatar
hjk committed
67
    QHash<QString, QmlCppPlugin *> cppPlugins;   // Just as info. No ownership.
68 69 70 71 72 73 74 75 76 77 78 79
};

struct QmlCppPlugin
{
    QmlCppPlugin(const QString &name, const QFileInfo &path,
                 const QmlModule *module, const QFileInfo &proFile);
    const QString name;             // Original name
    const QFileInfo path;           // Plugin path where qmldir points to
    const QmlModule *module;
    const QFileInfo proFile;        // .pro file for the plugin
};

80
struct QtQuickAppGeneratedFileInfo : public AbstractGeneratedFileInfo
81
{
82 83
    enum ExtendedFileType {
        MainQmlFile = ExtendedFile,
Feetu Nyrhinen's avatar
Feetu Nyrhinen committed
84
        MainPageQmlFile,
85
        AppViewerPriFile,
86
        AppViewerCppFile,
87
        AppViewerHFile
88 89
    };

90
    QtQuickAppGeneratedFileInfo() : AbstractGeneratedFileInfo() {}
91 92
};

93
class QtQuickApp : public AbstractMobileApp
94 95
{
public:
96 97
    enum ExtendedFileType {
        MainQml = ExtendedFile,
98 99
        MainQmlDeployed,
        MainQmlOrigin,
100 101
        AppViewerPri,
        AppViewerPriOrigin,
102
        AppViewerCpp,
103
        AppViewerCppOrigin,
104
        AppViewerH,
105 106
        AppViewerHOrigin,
        QmlDir,
107
        QmlDirProFileRelative,
Feetu Nyrhinen's avatar
Feetu Nyrhinen committed
108 109 110
        ModulesDir,
        MainPageQml,
        MainPageQmlOrigin
111 112
    };

113 114 115 116 117
    enum Mode {
        ModeGenerate,
        ModeImport
    };

Feetu Nyrhinen's avatar
Feetu Nyrhinen committed
118 119 120 121 122
    enum ComponentSet {
        QtQuick10Components,
        Symbian10Components
    };

123 124
    QtQuickApp();
    virtual ~QtQuickApp();
125

Feetu Nyrhinen's avatar
Feetu Nyrhinen committed
126 127 128
    void setComponentSet(ComponentSet componentSet);
    ComponentSet componentSet() const;

129 130
    void setMainQml(Mode mode, const QString &file = QString());
    Mode mainQmlMode() const;
131
    bool setExternalModules(const QStringList &uris, const QStringList &importPaths);
132

133
#ifndef CREATORLESSTEST
134
    virtual Core::GeneratedFiles generateFiles(QString *errorMessage) const;
135 136 137
#else
    bool generateFiles(QString *errorMessage) const;
#endif // CREATORLESSTEST
138
    bool useExistingMainQml() const;
139
    const QList<QmlModule*> modules() const;
140

141 142
    static const int StubVersion;

143
private:
144 145 146 147 148 149 150 151 152
    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,
153
        bool &commentOutNextLine) const;
154
    QList<AbstractGeneratedFileInfo> updateableFiles(const QString &mainProFile) const;
155
    QList<DeploymentFolder> deploymentFolders() const;
156

157
    bool addExternalModule(const QString &uri, const QFileInfo &dir,
158 159 160 161
                           const QFileInfo &contentDir);
    bool addCppPlugins(QmlModule *module);
    bool addCppPlugin(const QString &qmldirLine, QmlModule *module);
    void clearModulesAndPlugins();
Feetu Nyrhinen's avatar
Feetu Nyrhinen committed
162
    QString componentSetDir(ComponentSet componentSet) const;
163

164
    QFileInfo m_mainQmlFile;
165
    Mode m_mainQmlMode;
166
    QStringList m_importPaths;
hjk's avatar
hjk committed
167 168
    QList<QmlModule *> m_modules;
    QList<QmlCppPlugin *> m_cppPlugins;
Feetu Nyrhinen's avatar
Feetu Nyrhinen committed
169
    ComponentSet m_componentSet;
170 171
};

172 173
} // namespace Internal
} // namespace Qt4ProjectManager
174

175
#endif // QTQUICKAPP_H