OSDN Git Service

Update license.
[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 (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 **
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 **
23 ** Other Usage
24 **
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #ifndef QMLPROJECT_H
34 #define QMLPROJECT_H
35
36 #include "qmlprojectmanager_global.h"
37 #include "qmlprojectnodes.h"
38 #include "qmlprojectmanager.h"
39
40 #include <projectexplorer/project.h>
41
42 #include <QtDeclarative/QDeclarativeEngine>
43
44 namespace QmlJS {
45 class ModelManagerInterface;
46 }
47
48 namespace ProjectExplorer {
49 class FileWatcher;
50 }
51
52 namespace QmlProjectManager {
53
54 class QmlProjectItem;
55
56 namespace Internal {
57
58 class QmlProjectFile;
59 class QmlProjectTarget;
60 } // namespace Internal
61
62 class QMLPROJECTMANAGER_EXPORT QmlProject : public ProjectExplorer::Project
63 {
64     Q_OBJECT
65
66 public:
67     QmlProject(Internal::Manager *manager, const QString &filename);
68     virtual ~QmlProject();
69
70     QString filesFileName() const;
71
72     QString displayName() const;
73     QString id() const;
74     Core::IFile *file() const;
75     Internal::Manager *projectManager() const;
76     Internal::QmlProjectTarget *activeTarget() const;
77
78     QList<ProjectExplorer::Project *> dependsOn();
79
80     QList<ProjectExplorer::BuildConfigWidget*> subConfigWidgets();
81
82     Internal::QmlProjectNode *rootProjectNode() const;
83     QStringList files(FilesMode fileMode) const;
84
85     bool validProjectFile() const;
86
87     enum RefreshOption {
88         ProjectFile   = 0x01,
89         Files         = 0x02,
90         Configuration = 0x04,
91         Everything    = ProjectFile | Files | Configuration
92     };
93     Q_DECLARE_FLAGS(RefreshOptions,RefreshOption)
94
95     void refresh(RefreshOptions options);
96
97     QDir projectDir() const;
98     QStringList files() const;
99     QString mainFile() const;
100     QStringList importPaths() const;
101
102     bool addFiles(const QStringList &filePaths);
103
104 private slots:
105     void refreshProjectFile();
106     void refreshFiles(const QSet<QString> &added, const QSet<QString> &removed);
107
108 protected:
109     bool fromMap(const QVariantMap &map);
110
111 private:
112     // plain format
113     void parseProject(RefreshOptions options);
114     QStringList convertToAbsoluteFiles(const QStringList &paths) const;
115
116     Internal::Manager *m_manager;
117     QString m_fileName;
118     Internal::QmlProjectFile *m_file;
119     QString m_projectName;
120     QmlJS::ModelManagerInterface *m_modelManager;
121
122     // plain format
123     QStringList m_files;
124
125     // qml based, new format
126     QDeclarativeEngine m_engine;
127     QWeakPointer<QmlProjectItem> m_projectItem;
128     ProjectExplorer::FileWatcher *m_fileWatcher;
129
130     Internal::QmlProjectNode *m_rootNode;
131 };
132
133 } // namespace QmlProjectManager
134
135 Q_DECLARE_OPERATORS_FOR_FLAGS(QmlProjectManager::QmlProject::RefreshOptions)
136
137 #endif // QMLPROJECT_H