OSDN Git Service

0b13dcadf1c62df107f23ba867ad143c8c8ac964
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qmlprojectmanager / qmlproject.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 QMLPROJECT_H
35 #define QMLPROJECT_H
36
37 #include "qmlprojectmanager_global.h"
38 #include "qmlprojectnodes.h"
39 #include "qmlprojectmanager.h"
40
41 #include <projectexplorer/project.h>
42
43 #include <QtDeclarative/QDeclarativeEngine>
44
45 namespace QmlJS {
46 class ModelManagerInterface;
47 }
48
49 namespace ProjectExplorer {
50 class FileWatcher;
51 }
52
53 namespace QmlProjectManager {
54
55 class QmlProjectItem;
56
57 namespace Internal {
58
59 class QmlProjectFile;
60 class QmlProjectTarget;
61 } // namespace Internal
62
63 class QMLPROJECTMANAGER_EXPORT QmlProject : public ProjectExplorer::Project
64 {
65     Q_OBJECT
66
67 public:
68     QmlProject(Internal::Manager *manager, const QString &filename);
69     virtual ~QmlProject();
70
71     QString filesFileName() const;
72
73     QString displayName() const;
74     QString id() const;
75     Core::IFile *file() const;
76     Internal::Manager *projectManager() const;
77     Internal::QmlProjectTarget *activeTarget() const;
78
79     QList<ProjectExplorer::Project *> dependsOn();
80
81     QList<ProjectExplorer::BuildConfigWidget*> subConfigWidgets();
82
83     Internal::QmlProjectNode *rootProjectNode() const;
84     QStringList files(FilesMode fileMode) const;
85
86     bool validProjectFile() const;
87
88     enum RefreshOption {
89         ProjectFile   = 0x01,
90         Files         = 0x02,
91         Configuration = 0x04,
92         Everything    = ProjectFile | Files | Configuration
93     };
94     Q_DECLARE_FLAGS(RefreshOptions,RefreshOption)
95
96     void refresh(RefreshOptions options);
97
98     QDir projectDir() const;
99     QStringList files() const;
100     QString mainFile() const;
101     QStringList importPaths() const;
102
103     bool addFiles(const QStringList &filePaths);
104
105 private slots:
106     void refreshProjectFile();
107     void refreshFiles(const QSet<QString> &added, const QSet<QString> &removed);
108
109 protected:
110     bool fromMap(const QVariantMap &map);
111
112 private:
113     // plain format
114     void parseProject(RefreshOptions options);
115     QStringList convertToAbsoluteFiles(const QStringList &paths) const;
116
117     Internal::Manager *m_manager;
118     QString m_fileName;
119     Internal::QmlProjectFile *m_file;
120     QString m_projectName;
121     QmlJS::ModelManagerInterface *m_modelManager;
122
123     // plain format
124     QStringList m_files;
125
126     // qml based, new format
127     QDeclarativeEngine m_engine;
128     QWeakPointer<QmlProjectItem> m_projectItem;
129     ProjectExplorer::FileWatcher *m_fileWatcher;
130
131     Internal::QmlProjectNode *m_rootNode;
132 };
133
134 } // namespace QmlProjectManager
135
136 Q_DECLARE_OPERATORS_FOR_FLAGS(QmlProjectManager::QmlProject::RefreshOptions)
137
138 #endif // QMLPROJECT_H