cmakeprojectmanager.h 3.37 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2 3 4
**
** This file is part of Qt Creator
**
5
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6 7 8
**
** Contact:  Qt Software Information (qt-info@nokia.com)
**
9
** Commercial Usage
10
**
11 12 13 14
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
15
**
16
** GNU Lesser General Public License Usage
17
**
18 19 20 21 22 23
** Alternatively, 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.
24
**
25 26
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
con's avatar
con committed
27
**
28
**************************************************************************/
hjk's avatar
hjk committed
29

con's avatar
con committed
30 31 32
#ifndef CMAKEPROJECTMANAGER_H
#define CMAKEPROJECTMANAGER_H

33
#include <coreplugin/dialogs/ioptionspage.h>
con's avatar
con committed
34
#include <projectexplorer/iprojectmanager.h>
35
#include <utils/pathchooser.h>
dt's avatar
dt committed
36 37 38
#include <QtCore/QFuture>
#include <QtCore/QStringList>
#include <QtCore/QDir>
con's avatar
con committed
39

40 41
QT_FORWARD_DECLARE_CLASS(QProcess)

con's avatar
con committed
42 43 44
namespace CMakeProjectManager {
namespace Internal {

45
class CMakeSettingsPage;
dt's avatar
dt committed
46
class CMakeRunner;
47

con's avatar
con committed
48 49 50 51
class CMakeManager : public ProjectExplorer::IProjectManager
{
    Q_OBJECT
public:
52
    CMakeManager(CMakeSettingsPage *cmakeSettingsPage);
con's avatar
con committed
53 54 55 56 57 58

    virtual int projectContext() const;
    virtual int projectLanguage() const;

    virtual ProjectExplorer::Project *openProject(const QString &fileName);
    virtual QString mimeType() const;
dt's avatar
dt committed
59 60
    QString cmakeExecutable() const;

61 62
    QProcess* createXmlFile(const QStringList &arguments, const QString &sourceDirectory, const QDir &buildDirectory);
    static QString findCbpFile(const QDir &);
con's avatar
con committed
63 64 65
private:
    int m_projectContext;
    int m_projectLanguage;
66 67 68
    CMakeSettingsPage *m_settingsPage;
};

dt's avatar
dt committed
69 70 71 72 73 74 75 76 77 78
class CMakeRunner
{
public:
    CMakeRunner();
    void setExecutable(const QString &executable);
    QString executable() const;
    QString version() const;
    bool supportsQtCreator() const;

private:
79 80
    void run(QFutureInterface<void> &fi);
    void waitForUpToDate() const;
dt's avatar
dt committed
81 82 83 84 85 86 87 88
    QString m_executable;
    QString m_version;
    bool m_supportsQtCreator;
    bool m_cacheUpToDate;
    mutable QFuture<void> m_future;
    mutable QMutex m_mutex;
};

89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
class CMakeSettingsPage : public Core::IOptionsPage
{
    Q_OBJECT
public:
    CMakeSettingsPage();
    virtual ~CMakeSettingsPage();
    virtual QString name() const;
    virtual QString category() const;
    virtual QString trCategory() const;

    virtual QWidget *createPage(QWidget *parent);
    virtual void apply();
    virtual void finish();

    QString cmakeExecutable() const;
    void askUserForCMakeExecutable();
private:
106
    void updateCachedInformation() const;
107 108
    void saveSettings() const;
    QString findCmakeExecutable() const;
dt's avatar
dt committed
109 110

    mutable CMakeRunner m_cmakeRunner;
111
    Core::Utils::PathChooser *m_pathchooser;
con's avatar
con committed
112
};
hjk's avatar
hjk committed
113 114 115 116

} // namespace Internal
} // namespace CMakeProjectManager

con's avatar
con committed
117
#endif // CMAKEPROJECTMANAGER_H