OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / cmakeprojectmanager / cmakeprojectmanager.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 CMAKEPROJECTMANAGER_H
34 #define CMAKEPROJECTMANAGER_H
35
36 #include <projectexplorer/iprojectmanager.h>
37 #include <coreplugin/dialogs/ioptionspage.h>
38 #include <projectexplorer/project.h>
39 #include <projectexplorer/projectnodes.h>
40 #include <coreplugin/icontext.h>
41
42 #include <utils/environment.h>
43 #include <utils/pathchooser.h>
44
45 #include <QtCore/QFuture>
46 #include <QtCore/QStringList>
47 #include <QtCore/QDir>
48 #include <QtGui/QAction>
49
50 QT_FORWARD_DECLARE_CLASS(QProcess)
51 QT_FORWARD_DECLARE_CLASS(QLabel)
52
53 namespace Utils {
54 class QtcProcess;
55 }
56
57 namespace CMakeProjectManager {
58 namespace Internal {
59
60 class CMakeSettingsPage;
61
62 class CMakeManager : public ProjectExplorer::IProjectManager
63 {
64     Q_OBJECT
65 public:
66     CMakeManager(CMakeSettingsPage *cmakeSettingsPage);
67
68     virtual Core::Context projectContext() const;
69     virtual Core::Context projectLanguage() const;
70
71     virtual ProjectExplorer::Project *openProject(const QString &fileName);
72     virtual QString mimeType() const;
73
74     QString cmakeExecutable() const;
75     bool isCMakeExecutableValid() const;
76
77     void setCMakeExecutable(const QString &executable);
78
79     void createXmlFile(Utils::QtcProcess *process,
80                        const QString &arguments,
81                        const QString &sourceDirectory,
82                        const QDir &buildDirectory,
83                        const Utils::Environment &env,
84                        const QString &generator);
85     bool hasCodeBlocksMsvcGenerator() const;
86     static QString findCbpFile(const QDir &);
87
88     static QString findDumperLibrary(const Utils::Environment &env);
89 private slots:
90     void updateContextMenu(ProjectExplorer::Project *project, ProjectExplorer::Node *node);
91     void runCMake();
92     void runCMakeContextMenu();
93 private:
94     void runCMake(ProjectExplorer::Project *project);
95     static QString qtVersionForQMake(const QString &qmakePath);
96     static QPair<QString, QString> findQtDir(const Utils::Environment &env);
97     Core::Context m_projectContext;
98     Core::Context m_projectLanguage;
99     CMakeSettingsPage *m_settingsPage;
100     QAction *m_runCMakeAction;
101     QAction *m_runCMakeActionContextMenu;
102     ProjectExplorer::Project *m_contextProject;
103 };
104
105 struct CMakeValidator
106 {
107     enum STATE { VALID, INVALID, RUNNING };
108     STATE state;
109     QProcess *process;
110     bool hasCodeBlocksMsvcGenerator;
111     QString version;
112     QString executable;
113 };
114
115 class CMakeSettingsPage : public Core::IOptionsPage
116 {
117     Q_OBJECT
118 public:
119     CMakeSettingsPage();
120     virtual ~CMakeSettingsPage();
121     virtual QString id() const;
122     virtual QString displayName() const;
123     virtual QString category() const;
124     virtual QString displayCategory() const;
125     virtual QIcon categoryIcon() const;
126
127     virtual QWidget *createPage(QWidget *parent);
128     virtual void apply();
129     virtual void finish();
130
131     QString cmakeExecutable() const;
132     void setCMakeExecutable(const QString &executable);
133     bool isCMakeExecutableValid() const;
134     bool hasCodeBlocksMsvcGenerator() const;
135 private slots:
136     void userCmakeFinished();
137     void pathCmakeFinished();
138 private:
139     void cmakeFinished(CMakeValidator *cmakeValidator) const;
140     void saveSettings() const;
141     QString findCmakeExecutable() const;
142     void startProcess(CMakeValidator *cmakeValidator);
143     void updateInfo(CMakeValidator *cmakeValidator);
144
145     Utils::PathChooser *m_pathchooser;
146     mutable CMakeValidator m_userCmake;
147     mutable CMakeValidator m_pathCmake;
148 };
149
150 } // namespace Internal
151 } // namespace CMakeProjectManager
152
153 #endif // CMAKEPROJECTMANAGER_H