Commit 4b4dc9d0 authored by Tobias Hunger's avatar Tobias Hunger

CMake: Project tree for server mode data

Change-Id: Ief884a76c1b4211501dd6515b17b6e88a8e881e5
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent 38f30e73
......@@ -298,9 +298,10 @@ void BuildDirManager::resetData()
m_reader->resetData();
m_cmakeCache.clear();
QTC_ASSERT(!m_futureInterface || m_futureInterface->isFinished(), return);
m_futureInterface.reset();
m_reader.reset(nullptr);
m_reader.reset();
}
bool BuildDirManager::updateCMakeStateBeforeBuild()
......@@ -323,7 +324,7 @@ bool BuildDirManager::persistCMakeState()
return true;
}
void BuildDirManager::generateProjectTree(CMakeProjectNode *root)
void BuildDirManager::generateProjectTree(CMakeListsNode *root)
{
QTC_ASSERT(m_reader, return);
QTC_ASSERT(m_futureInterface, return);
......
......@@ -72,7 +72,7 @@ public:
bool updateCMakeStateBeforeBuild();
bool persistCMakeState();
void generateProjectTree(CMakeProjectNode *root);
void generateProjectTree(CMakeListsNode *root);
QSet<Core::Id> updateCodeModel(CppTools::ProjectPartBuilder &ppBuilder);
QList<CMakeBuildTarget> buildTargets() const;
......
......@@ -49,6 +49,7 @@ namespace CMakeProjectManager {
namespace Internal {
class CMakeBuildConfiguration;
class CMakeListsNode;
class BuildDirReader : public QObject
{
......@@ -100,7 +101,7 @@ public:
virtual CMakeConfig parsedConfiguration() const = 0;
virtual QList<CMakeBuildTarget> buildTargets() const = 0;
virtual void generateProjectTree(CMakeProjectNode *root,
virtual void generateProjectTree(CMakeListsNode *root,
const QList<ProjectExplorer::FileNode *> &allFiles) = 0;
virtual QSet<Core::Id> updateCodeModel(CppTools::ProjectPartBuilder &ppBuilder) = 0;
......
......@@ -202,7 +202,7 @@ QList<CMakeBuildTarget> CMakeBuildConfiguration::buildTargets() const
return m_buildDirManager->buildTargets();
}
void CMakeBuildConfiguration::generateProjectTree(CMakeProjectNode *root) const
void CMakeBuildConfiguration::generateProjectTree(CMakeListsNode *root) const
{
if (!m_buildDirManager || m_buildDirManager->isParsing())
return;
......
......@@ -46,6 +46,7 @@ namespace Internal {
class BuildDirManager;
class CMakeBuildConfigurationFactory;
class CMakeBuildSettingsWidget;
class CMakeListsNode;
class CMakeBuildConfiguration : public ProjectExplorer::BuildConfiguration
{
......@@ -84,7 +85,7 @@ public:
void clearCache();
QList<CMakeBuildTarget> buildTargets() const;
void generateProjectTree(CMakeProjectNode *root) const;
void generateProjectTree(CMakeListsNode *root) const;
QSet<Core::Id> updateCodeModel(CppTools::ProjectPartBuilder &ppBuilder);
static Utils::FileName
......
......@@ -78,7 +78,7 @@ CMakeProject::CMakeProject(CMakeManager *manager, const FileName &fileName)
setDocument(new TextEditor::TextDocument);
document()->setFilePath(fileName);
setRootProjectNode(new CMakeProjectNode(FileName::fromString(fileName.toFileInfo().absolutePath())));
setRootProjectNode(new CMakeListsNode(fileName));
setProjectContext(Core::Context(CMakeProjectManager::Constants::PROJECTCONTEXT));
setProjectLanguages(Core::Context(ProjectExplorer::Constants::LANG_CXX));
......@@ -104,7 +104,7 @@ void CMakeProject::updateProjectData()
return;
Kit *k = t->kit();
cmakeBc->generateProjectTree(static_cast<CMakeProjectNode *>(rootProjectNode()));
cmakeBc->generateProjectTree(static_cast<CMakeListsNode *>(rootProjectNode()));
updateApplicationAndDeploymentTargets();
updateTargetRunConfigurations(t);
......
......@@ -41,9 +41,8 @@ QT_END_NAMESPACE
namespace CMakeProjectManager {
namespace Internal {
class CMakeBuildSettingsWidget;
class CMakeBuildConfiguration;
class CMakeProjectNode;
class CMakeBuildSettingsWidget;
class CMakeManager;
} // namespace Internal
......@@ -76,8 +75,7 @@ public:
class CMAKE_EXPORT CMakeProject : public ProjectExplorer::Project
{
Q_OBJECT
// for changeBuildDirectory
friend class Internal::CMakeBuildSettingsWidget;
public:
CMakeProject(Internal::CMakeManager *manager, const Utils::FileName &filename);
~CMakeProject() final;
......@@ -128,6 +126,7 @@ private:
QList<ProjectExplorer::ExtraCompiler *> m_extraCompilers;
friend class Internal::CMakeBuildConfiguration;
friend class Internal::CMakeBuildSettingsWidget;
};
} // namespace CMakeProjectManager
......@@ -25,22 +25,122 @@
#include "cmakeprojectnodes.h"
#include "cmakeprojectconstants.h"
#include <coreplugin/fileiconprovider.h>
#include <utils/algorithm.h>
#include <QApplication>
using namespace CMakeProjectManager;
using namespace CMakeProjectManager::Internal;
CMakeProjectNode::CMakeProjectNode(const Utils::FileName &dirName)
: ProjectExplorer::ProjectNode(dirName)
CMakeInputsNode::CMakeInputsNode(const Utils::FileName &cmakeLists) :
ProjectExplorer::ProjectNode(CMakeInputsNode::inputsPathFromCMakeListsPath(cmakeLists))
{
setPriority(Node::DefaultPriority - 10); // Bottom most!
setDisplayName(QCoreApplication::translate("CMakeFilesProjectNode", "CMake Modules"));
setIcon(QIcon(":/projectexplorer/images/session.png")); // TODO: Use a better icon!
}
Utils::FileName CMakeInputsNode::inputsPathFromCMakeListsPath(const Utils::FileName &cmakeLists)
{
Utils::FileName result = cmakeLists;
result.appendPath("cmakeInputs"); // cmakeLists is a file, so this can not exist on disk
return result;
}
bool CMakeInputsNode::showInSimpleTree() const
{
return false;
}
QList<ProjectExplorer::ProjectAction> CMakeInputsNode::supportedActions(ProjectExplorer::Node *node) const
{
Q_UNUSED(node);
return QList<ProjectExplorer::ProjectAction>();
}
CMakeListsNode::CMakeListsNode(const Utils::FileName &cmakeListPath) :
ProjectExplorer::ProjectNode(cmakeListPath)
{
static QIcon folderIcon;
if (folderIcon.isNull()) {
const QIcon overlayIcon(Constants::FILEOVERLAY_CMAKE);
QPixmap dirPixmap = qApp->style()->standardIcon(QStyle::SP_DirIcon).pixmap(QSize(16, 16));
folderIcon.addPixmap(Core::FileIconProvider::overlayIcon(dirPixmap, overlayIcon));
}
setIcon(folderIcon);
}
bool CMakeListsNode::showInSimpleTree() const
{
return false;
}
QList<ProjectExplorer::ProjectAction> CMakeListsNode::supportedActions(ProjectExplorer::Node *node) const
{
Q_UNUSED(node);
return QList<ProjectExplorer::ProjectAction>();
}
CMakeProjectNode::CMakeProjectNode(const Utils::FileName &directory) :
ProjectExplorer::ProjectNode(directory)
{
setPriority(Node::DefaultProjectPriority + 1000);
setIcon(QIcon(":/projectexplorer/images/projectexplorer.png")); // TODO: Use proper icon!
}
bool CMakeProjectNode::showInSimpleTree() const
{
// TODO
return true;
}
QList<ProjectExplorer::ProjectAction> CMakeProjectNode::supportedActions(Node *node) const
QString CMakeProjectNode::tooltip() const
{
return QString();
}
QList<ProjectExplorer::ProjectAction> CMakeProjectNode::supportedActions(ProjectExplorer::Node *node) const
{
Q_UNUSED(node);
return QList<ProjectExplorer::ProjectAction>();
}
CMakeTargetNode::CMakeTargetNode(const Utils::FileName &directory) :
ProjectExplorer::ProjectNode(directory)
{
setPriority(Node::DefaultProjectPriority + 900);
setIcon(QIcon(":/projectexplorer/images/build.png")); // TODO: Use proper icon!
}
bool CMakeTargetNode::showInSimpleTree() const
{
return true;
}
QString CMakeTargetNode::tooltip() const
{
return m_tooltip;
}
QList<ProjectExplorer::ProjectAction> CMakeTargetNode::supportedActions(ProjectExplorer::Node *node) const
{
Q_UNUSED(node);
return QList<ProjectExplorer::ProjectAction>();
}
void CMakeTargetNode::setTargetInformation(const QList<Utils::FileName> &artifacts,
const QString &type)
{
m_tooltip = QCoreApplication::translate("CMakeTargetNode", "Target type: ") + type + "<br>";
if (artifacts.count() == 0) {
m_tooltip += QCoreApplication::translate("CMakeTargetNode", "No build artifacts");
} else {
const QStringList tmp = Utils::transform(artifacts, &Utils::FileName::toUserOutput);
m_tooltip += QCoreApplication::translate("CMakeTargetNode", "Build artifacts:<br>")
+ tmp.join("<br>");
}
}
......@@ -32,12 +32,49 @@ class CMakeProject;
namespace Internal {
class CMakeInputsNode : public ProjectExplorer::ProjectNode
{
public:
CMakeInputsNode(const Utils::FileName &cmakeLists);
static Utils::FileName inputsPathFromCMakeListsPath(const Utils::FileName &cmakeLists);
bool showInSimpleTree() const final;
QList<ProjectExplorer::ProjectAction> supportedActions(Node *node) const final;
};
class CMakeListsNode : public ProjectExplorer::ProjectNode
{
public:
CMakeListsNode(const Utils::FileName &cmakeListPath);
bool showInSimpleTree() const final;
QList<ProjectExplorer::ProjectAction> supportedActions(Node *node) const final;
};
class CMakeProjectNode : public ProjectExplorer::ProjectNode
{
public:
CMakeProjectNode(const Utils::FileName &dirName);
bool showInSimpleTree() const override;
QList<ProjectExplorer::ProjectAction> supportedActions(Node *node) const override;
CMakeProjectNode(const Utils::FileName &directory);
bool showInSimpleTree() const final;
QString tooltip() const final;
QList<ProjectExplorer::ProjectAction> supportedActions(Node *node) const final;
};
class CMakeTargetNode : public ProjectExplorer::ProjectNode
{
public:
CMakeTargetNode(const Utils::FileName &directory);
void setTargetInformation(const QList<Utils::FileName> &artifacts, const QString &type);
bool showInSimpleTree() const final;
QString tooltip() const final;
QList<ProjectExplorer::ProjectAction> supportedActions(Node *node) const final;
private:
QString m_tooltip;
};
} // namespace Internal
......
......@@ -64,7 +64,7 @@ public:
QList<CMakeBuildTarget> buildTargets() const final;
CMakeConfig parsedConfiguration() const final;
void generateProjectTree(CMakeProjectNode *root, const QList<ProjectExplorer::FileNode *> &allFiles) final;
void generateProjectTree(CMakeListsNode *root, const QList<ProjectExplorer::FileNode *> &allFiles) final;
QSet<Core::Id> updateCodeModel(CppTools::ProjectPartBuilder &ppBuilder) final;
private:
......@@ -119,6 +119,20 @@ private:
void extractCMakeInputsData(const QVariantMap &data);
void extractCacheData(const QVariantMap &data);
QSet<ProjectExplorer::Node *> updateCMakeLists(CMakeListsNode *root,
const QList<ProjectExplorer::FileNode *> &cmakeLists);
QSet<ProjectExplorer::Node *> updateProjects(CMakeListsNode *root,
const QList<Project *> &projects,
const QList<ProjectExplorer::FileNode *> &allFiles);
QSet<ProjectExplorer::Node *> updateTargets(CMakeListsNode *root,
const QList<Target *> &targets,
const QHash<Utils::FileName, QList<ProjectExplorer::FileNode *>> &headers);
QSet<ProjectExplorer::Node *> updateFileGroups(ProjectExplorer::ProjectNode *targetRoot,
const Utils::FileName &sourceDirectory,
const Utils::FileName &buildDirectory,
const QList<FileGroup *> &fileGroups,
const QHash<Utils::FileName, QList<ProjectExplorer::FileNode *>> &headers);
bool m_hasData = false;
std::unique_ptr<ServerMode> m_cmakeServer;
......
......@@ -318,7 +318,7 @@ CMakeConfig TeaLeafReader::parseConfiguration(const FileName &cacheFile, QString
return result;
}
void TeaLeafReader::generateProjectTree(CMakeProjectNode *root, const QList<FileNode *> &allFiles)
void TeaLeafReader::generateProjectTree(CMakeListsNode *root, const QList<FileNode *> &allFiles)
{
root->setDisplayName(m_projectName);
......
......@@ -52,7 +52,7 @@ public:
QList<CMakeBuildTarget> buildTargets() const final;
CMakeConfig parsedConfiguration() const final;
void generateProjectTree(CMakeProjectNode *root,
void generateProjectTree(CMakeListsNode *root,
const QList<ProjectExplorer::FileNode *> &allFiles) final;
QSet<Core::Id> updateCodeModel(CppTools::ProjectPartBuilder &ppBuilder) final;
......
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