Commit 7ca9f1f2 authored by Benjamin Zeller's avatar Benjamin Zeller

CMakeProjectManager: Split up cmakeproject source files

Preparing for exporting the CMakeProject symbol. Removing all APIs
from the header file that will continue to be interal API.

Change-Id: I820ea0efb909e6a75be70ccb3b419f841a15cfb3
Reviewed-by: default avatarDaniel Teske <daniel.teske@theqtcompany.com>
parent bebcf69c
......@@ -34,6 +34,7 @@
#include "cmakeopenprojectwizard.h"
#include "cmakeproject.h"
#include "cmakeprojectconstants.h"
#include "cmakebuildsettingswidget.h"
#include <coreplugin/documentmanager.h>
#include <coreplugin/icore.h>
......
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "cmakebuildsettingswidget.h"
#include "cmakeproject.h"
#include "cmakebuildconfiguration.h"
#include "cmakebuildinfo.h"
#include "cmakeopenprojectwizard.h"
#include "cmakeprojectmanager.h"
#include <coreplugin/icore.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/target.h>
#include <QFormLayout>
namespace CMakeProjectManager {
namespace Internal {
CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc) : m_buildConfiguration(0)
{
QFormLayout *fl = new QFormLayout(this);
fl->setContentsMargins(20, -1, 0, -1);
fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
setLayout(fl);
QPushButton *runCmakeButton = new QPushButton(tr("Run CMake..."));
connect(runCmakeButton, SIGNAL(clicked()),
this, SLOT(runCMake()));
fl->addRow(tr("Reconfigure project:"), runCmakeButton);
m_pathLineEdit = new QLineEdit(this);
m_pathLineEdit->setReadOnly(true);
QHBoxLayout *hbox = new QHBoxLayout();
hbox->addWidget(m_pathLineEdit);
m_changeButton = new QPushButton(this);
m_changeButton->setText(tr("&Change"));
connect(m_changeButton, SIGNAL(clicked()), this, SLOT(openChangeBuildDirectoryDialog()));
hbox->addWidget(m_changeButton);
fl->addRow(tr("Build directory:"), hbox);
m_buildConfiguration = bc;
m_pathLineEdit->setText(m_buildConfiguration->rawBuildDirectory().toString());
if (m_buildConfiguration->buildDirectory() == bc->target()->project()->projectDirectory())
m_changeButton->setEnabled(false);
else
m_changeButton->setEnabled(true);
setDisplayName(tr("CMake"));
}
void CMakeBuildSettingsWidget::openChangeBuildDirectoryDialog()
{
CMakeProject *project = static_cast<CMakeProject *>(m_buildConfiguration->target()->project());
CMakeBuildInfo info(m_buildConfiguration);
CMakeOpenProjectWizard copw(Core::ICore::mainWindow(),
project->projectManager(), CMakeOpenProjectWizard::ChangeDirectory,
&info);
if (copw.exec() == QDialog::Accepted) {
project->changeBuildDirectory(m_buildConfiguration, copw.buildDirectory());
m_buildConfiguration->setUseNinja(copw.useNinja());
m_pathLineEdit->setText(m_buildConfiguration->rawBuildDirectory().toString());
}
}
void CMakeBuildSettingsWidget::runCMake()
{
if (!ProjectExplorer::ProjectExplorerPlugin::saveModifiedFiles())
return;
CMakeProject *project = static_cast<CMakeProject *>(m_buildConfiguration->target()->project());
CMakeBuildInfo info(m_buildConfiguration);
CMakeOpenProjectWizard copw(Core::ICore::mainWindow(),
project->projectManager(),
CMakeOpenProjectWizard::WantToUpdate, &info);
if (copw.exec() == QDialog::Accepted)
project->parseCMakeLists();
}
} // namespace Internal
} // namespace CMakeProjectManager
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef CMAKEPROJECTMANAGER_INTERNAL_CMAKEBUILDSETTINGSWIDGET_H
#define CMAKEPROJECTMANAGER_INTERNAL_CMAKEBUILDSETTINGSWIDGET_H
#include <projectexplorer/namedwidget.h>
QT_FORWARD_DECLARE_CLASS(QLineEdit)
QT_FORWARD_DECLARE_CLASS(QPushButton)
namespace CMakeProjectManager {
namespace Internal {
class CMakeBuildConfiguration;
class CMakeBuildSettingsWidget : public ProjectExplorer::NamedWidget
{
Q_OBJECT
public:
CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc);
private slots:
void openChangeBuildDirectoryDialog();
void runCMake();
private:
QLineEdit *m_pathLineEdit;
QPushButton *m_changeButton;
CMakeBuildConfiguration *m_buildConfiguration;
};
} // namespace Internal
} // namespace CMakeProjectManager
#endif // CMAKEPROJECTMANAGER_INTERNAL_CMAKEBUILDSETTINGSWIDGET_H
This diff is collapsed.
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef CMAKEPROJECTMANAGER_INTERNAL_CMAKECBPPARSER_H
#define CMAKEPROJECTMANAGER_INTERNAL_CMAKECBPPARSER_H
#include "cmakeproject.h"
#include <QXmlStreamReader>
namespace ProjectExplorer { class FileNode; }
namespace CMakeProjectManager {
namespace Internal {
class CMakeCbpParser : public QXmlStreamReader
{
public:
bool parseCbpFile(const QString &fileName, const QString &sourceDirectory);
QList<ProjectExplorer::FileNode *> fileList();
QList<ProjectExplorer::FileNode *> cmakeFileList();
QList<CMakeBuildTarget> buildTargets();
QString projectName() const;
QString compilerName() const;
bool hasCMakeFiles();
private:
void parseCodeBlocks_project_file();
void parseProject();
void parseBuild();
void parseOption();
void parseBuildTarget();
void parseBuildTargetOption();
void parseMakeCommands();
void parseBuildTargetBuild();
void parseBuildTargetClean();
void parseCompiler();
void parseAdd();
void parseUnit();
void parseUnitOption();
void parseUnknownElement();
void sortFiles();
QList<ProjectExplorer::FileNode *> m_fileList;
QList<ProjectExplorer::FileNode *> m_cmakeFileList;
QSet<Utils::FileName> m_processedUnits;
bool m_parsingCmakeUnit;
CMakeBuildTarget m_buildTarget;
QList<CMakeBuildTarget> m_buildTargets;
QString m_projectName;
QString m_compiler;
QString m_sourceDirectory;
QString m_buildDirectory;
};
} // namespace Internal
} // namespace CMakeProjectManager
#endif // CMAKEPROJECTMANAGER_INTERNAL_CMAKECBPPARSER_H
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "cmakefile.h"
#include "cmakeproject.h"
#include "cmakeprojectconstants.h"
#include <utils/fileutils.h>
using namespace Utils;
namespace CMakeProjectManager {
namespace Internal {
CMakeFile::CMakeFile(CMakeProject *parent, const FileName &fileName)
: Core::IDocument(parent), m_project(parent)
{
setId("Cmake.ProjectFile");
setMimeType(QLatin1String(Constants::CMAKEPROJECTMIMETYPE));
setFilePath(fileName);
}
bool CMakeFile::save(QString *errorString, const QString &fileName, bool autoSave)
{
// Once we have an texteditor open for this file, we probably do
// need to implement this, don't we.
Q_UNUSED(errorString)
Q_UNUSED(fileName)
Q_UNUSED(autoSave)
return false;
}
QString CMakeFile::defaultPath() const
{
return QString();
}
QString CMakeFile::suggestedFileName() const
{
return QString();
}
bool CMakeFile::isModified() const
{
return false;
}
bool CMakeFile::isSaveAsAllowed() const
{
return false;
}
Core::IDocument::ReloadBehavior CMakeFile::reloadBehavior(ChangeTrigger state, ChangeType type) const
{
Q_UNUSED(state)
Q_UNUSED(type)
return BehaviorSilent;
}
bool CMakeFile::reload(QString *errorString, ReloadFlag flag, ChangeType type)
{
Q_UNUSED(errorString)
Q_UNUSED(flag)
Q_UNUSED(type)
return true;
}
} // namespace Internal
} // namespace CMakeProjectManager
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef CMAKEPROJECTMANAGER_INTERNAL_CMAKEFILE_H
#define CMAKEPROJECTMANAGER_INTERNAL_CMAKEFILE_H
#include <coreplugin/idocument.h>
namespace CMakeProjectManager {
namespace Internal {
class CMakeProject;
class CMakeFile : public Core::IDocument
{
Q_OBJECT
public:
CMakeFile(CMakeProject *parent, const Utils::FileName &fileName);
bool save(QString *errorString, const QString &fileName, bool autoSave);
QString defaultPath() const;
QString suggestedFileName() const;
bool isModified() const;
bool isSaveAsAllowed() const;
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
private:
CMakeProject *m_project;
};
} // namespace Internal
} // namespace CMakeProjectManager
#endif // CMAKEPROJECTMANAGER_INTERNAL_CMAKEFILE_H
......@@ -37,7 +37,6 @@
#include "makestep.h"
#include <projectexplorer/project.h>
#include <projectexplorer/projectnodes.h>
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/namedwidget.h>
#include <coreplugin/idocument.h>
......@@ -55,11 +54,9 @@ QT_BEGIN_NAMESPACE
class QFileSystemWatcher;
QT_END_NAMESPACE
namespace ProjectExplorer { class Target; }
namespace CMakeProjectManager {
namespace Internal {
namespace Internal {
class CMakeFile;
class CMakeBuildSettingsWidget;
......@@ -157,83 +154,6 @@ private:
QFuture<void> m_codeModelFuture;
};
class CMakeCbpParser : public QXmlStreamReader
{
public:
bool parseCbpFile(const QString &fileName, const QString &sourceDirectory);
QList<ProjectExplorer::FileNode *> fileList();
QList<ProjectExplorer::FileNode *> cmakeFileList();
QList<CMakeBuildTarget> buildTargets();
QString projectName() const;
QString compilerName() const;
bool hasCMakeFiles();
private:
void parseCodeBlocks_project_file();
void parseProject();
void parseBuild();
void parseOption();
void parseBuildTarget();
void parseBuildTargetOption();
void parseMakeCommands();
void parseBuildTargetBuild();
void parseBuildTargetClean();
void parseCompiler();
void parseAdd();
void parseUnit();
void parseUnitOption();
void parseUnknownElement();
void sortFiles();
QList<ProjectExplorer::FileNode *> m_fileList;
QList<ProjectExplorer::FileNode *> m_cmakeFileList;
QSet<Utils::FileName> m_processedUnits;
bool m_parsingCmakeUnit;
CMakeBuildTarget m_buildTarget;
QList<CMakeBuildTarget> m_buildTargets;
QString m_projectName;
QString m_compiler;
QString m_sourceDirectory;
QString m_buildDirectory;
};
class CMakeFile : public Core::IDocument
{
Q_OBJECT
public:
CMakeFile(CMakeProject *parent, const Utils::FileName &fileName);
bool save(QString *errorString, const QString &fileName, bool autoSave);
QString defaultPath() const;
QString suggestedFileName() const;
bool isModified() const;
bool isSaveAsAllowed() const;
ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const;
bool reload(QString *errorString, ReloadFlag flag, ChangeType type);
private:
CMakeProject *m_project;
};
class CMakeBuildSettingsWidget : public ProjectExplorer::NamedWidget
{
Q_OBJECT
public:
CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc);
private slots:
void openChangeBuildDirectoryDialog();
void runCMake();
private:
QLineEdit *m_pathLineEdit;
QPushButton *m_changeButton;
CMakeBuildConfiguration *m_buildConfiguration;
};
} // namespace Internal
} // namespace CMakeProjectManager
......
......@@ -21,7 +21,10 @@ HEADERS = cmakebuildinfo.h \
cmaketoolmanager.h \
cmake_global.h \
cmakekitinformation.h \
cmakekitconfigwidget.h
cmakekitconfigwidget.h \
cmakecbpparser.h \
cmakefile.h \
cmakebuildsettingswidget.h
SOURCES = cmakeproject.cpp \
cmakeprojectplugin.cpp \
......@@ -40,7 +43,10 @@ SOURCES = cmakeproject.cpp \
cmakesettingspage.cpp \
cmaketoolmanager.cpp \
cmakekitinformation.cpp \
cmakekitconfigwidget.cpp
cmakekitconfigwidget.cpp \
cmakecbpparser.cpp \
cmakefile.cpp \
cmakebuildsettingswidget.cpp
RESOURCES += cmakeproject.qrc
......@@ -21,8 +21,14 @@ QtcPlugin {
"cmakebuildconfiguration.cpp",
"cmakebuildconfiguration.h",
"cmakebuildinfo.h",
"cmakebuildsettingswidget.cpp",
"cmakebuildsettingswidget.h",
"cmakecbpparser.cpp",
"cmakecbpparser.h",
"cmakeeditor.cpp",
"cmakeeditor.h",
"cmakefile.cpp",
"cmakefile.h",
"cmakefilecompletionassist.cpp",
"cmakefilecompletionassist.h",
"cmakekitconfigwidget.h",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment