Commit ad003363 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

ProjectExplorer: Rename Node::projectNode to Node::parentProjectNode



Change-Id: I47fa794a0bd8456ae23271934a957d9667d2d7bb
Reviewed-by: Tim Jenssen's avatarTim Jenssen <tim.jenssen@qt.io>
parent c7b0163f
......@@ -2914,7 +2914,7 @@ void ProjectExplorerPluginPrivate::updateContextMenuActions()
Node *currentNode = ProjectTree::currentNode();
if (currentNode && currentNode->projectNode()) {
if (currentNode && currentNode->parentProjectNode()) {
QList<ProjectAction> actions = currentNode->supportedActions(currentNode);
if (ProjectNode *pn = currentNode->asProjectNode()) {
......@@ -3082,7 +3082,7 @@ void ProjectExplorerPlugin::addExistingFiles(FolderNode *folderNode, const QStri
if (!notAdded.isEmpty()) {
const QString message = tr("Could not add following files to project %1:")
.arg(folderNode->projectNode()->displayName()) + QLatin1Char('\n');
.arg(folderNode->parentProjectNode()->displayName()) + QLatin1Char('\n');
const QStringList nativeFiles
= Utils::transform(notAdded,
[](const QString &f) { return QDir::toNativeSeparators(f); });
......@@ -3100,7 +3100,7 @@ void ProjectExplorerPluginPrivate::removeProject()
Node *node = ProjectTree::currentNode();
if (!node)
return;
ProjectNode *subProjectNode = node->projectNode();
ProjectNode *subProjectNode = node->parentProjectNode();
if (!subProjectNode)
return;
ProjectNode *projectNode = subProjectNode->parentFolderNode()->asProjectNode();
......@@ -3157,7 +3157,7 @@ void ProjectExplorerPluginPrivate::removeFile()
QMessageBox::warning(ICore::mainWindow(), tr("Removing File Failed"),
tr("Could not remove file %1 from project %2.")
.arg(QDir::toNativeSeparators(filePath))
.arg(folderNode->projectNode()->displayName()));
.arg(folderNode->parentProjectNode()->displayName()));
if (!deleteFile)
return;
}
......@@ -3251,7 +3251,7 @@ void ProjectExplorerPlugin::renameFile(Node *node, const QString &newFilePath)
{
const QString oldFilePath = node->filePath().toFileInfo().absoluteFilePath();
FolderNode *folderNode = node->parentFolderNode();
const QString projectFileName = folderNode->projectNode()->filePath().fileName();
const QString projectFileName = folderNode->parentProjectNode()->filePath().fileName();
if (oldFilePath == newFilePath)
return;
......
......@@ -96,7 +96,7 @@ NodeType Node::nodeType() const
The project that owns and manages the node. It is the first project in the list
of ancestors.
*/
ProjectNode *Node::projectNode() const
ProjectNode *Node::parentProjectNode() const
{
return m_projectNode;
}
......@@ -485,36 +485,36 @@ QString FolderNode::addFileFilter() const
bool FolderNode::addFiles(const QStringList &filePaths, QStringList *notAdded)
{
if (projectNode())
return projectNode()->addFiles(filePaths, notAdded);
if (parentProjectNode())
return parentProjectNode()->addFiles(filePaths, notAdded);
return false;
}
bool FolderNode::removeFiles(const QStringList &filePaths, QStringList *notRemoved)
{
if (projectNode())
return projectNode()->removeFiles(filePaths, notRemoved);
if (parentProjectNode())
return parentProjectNode()->removeFiles(filePaths, notRemoved);
return false;
}
bool FolderNode::deleteFiles(const QStringList &filePaths)
{
if (projectNode())
return projectNode()->deleteFiles(filePaths);
if (parentProjectNode())
return parentProjectNode()->deleteFiles(filePaths);
return false;
}
bool FolderNode::canRenameFile(const QString &filePath, const QString &newFilePath)
{
if (projectNode())
return projectNode()->canRenameFile(filePath, newFilePath);
if (parentProjectNode())
return parentProjectNode()->canRenameFile(filePath, newFilePath);
return false;
}
bool FolderNode::renameFile(const QString &filePath, const QString &newFilePath)
{
if (projectNode())
return projectNode()->renameFile(filePath, newFilePath);
if (parentProjectNode())
return parentProjectNode()->renameFile(filePath, newFilePath);
return false;
}
......@@ -534,7 +534,7 @@ FolderNode::AddNewInformation FolderNode::addNewInformation(const QStringList &f
void FolderNode::addFileNodes(const QList<FileNode *> &files)
{
Q_ASSERT(projectNode());
Q_ASSERT(parentProjectNode());
if (files.isEmpty())
return;
......@@ -545,7 +545,7 @@ void FolderNode::addFileNodes(const QList<FileNode *> &files)
qDebug("File node has already a parent folder"));
file->setParentFolderNode(this);
file->setProjectNode(projectNode());
file->setProjectNode(parentProjectNode());
// Now find the correct place to insert file
if (m_fileNodes.count() == 0
|| m_fileNodes.last() < file) {
......@@ -570,7 +570,7 @@ void FolderNode::addFileNodes(const QList<FileNode *> &files)
void FolderNode::removeFileNodes(const QList<FileNode *> &files)
{
Q_ASSERT(projectNode());
Q_ASSERT(parentProjectNode());
if (files.isEmpty())
return;
......@@ -601,7 +601,7 @@ void FolderNode::removeFileNodes(const QList<FileNode *> &files)
*/
void FolderNode::addFolderNodes(const QList<FolderNode*> &subFolders)
{
Q_ASSERT(projectNode());
Q_ASSERT(parentProjectNode());
if (subFolders.isEmpty())
return;
......@@ -611,7 +611,7 @@ void FolderNode::addFolderNodes(const QList<FolderNode*> &subFolders)
QTC_ASSERT(!folder->parentFolderNode(),
qDebug("Project node has already a parent folder"));
folder->setParentFolderNode(this);
folder->setProjectNode(projectNode());
folder->setProjectNode(parentProjectNode());
// Find the correct place to insert
if (m_folderNodes.count() == 0
......@@ -640,7 +640,7 @@ void FolderNode::addFolderNodes(const QList<FolderNode*> &subFolders)
*/
void FolderNode::removeFolderNodes(const QList<FolderNode*> &subFolders)
{
Q_ASSERT(projectNode());
Q_ASSERT(parentProjectNode());
if (subFolders.isEmpty())
return;
......
......@@ -109,7 +109,7 @@ class PROJECTEXPLORER_EXPORT Node
public:
virtual ~Node() = default;
NodeType nodeType() const;
ProjectNode *projectNode() const; // managing project
ProjectNode *parentProjectNode() const; // managing project
FolderNode *parentFolderNode() const; // parent folder or project
const Utils::FileName &filePath() const; // file system path
int line() const;
......
......@@ -341,10 +341,10 @@ void ProjectTree::emitFoldersAboutToBeRemoved(FolderNode *parentFolder, const QL
while (n) {
if (FolderNode *fn = n->asFolderNode()) {
if (staleFolders.contains(fn)) {
ProjectNode *pn = n->projectNode();
ProjectNode *pn = n->parentProjectNode();
// Make sure the node we are switching too isn't going to be removed also
while (staleFolders.contains(pn))
pn = pn->parentFolderNode()->projectNode();
pn = pn->parentFolderNode()->parentProjectNode();
m_resetCurrentNodeFolder = true;
break;
}
......
......@@ -87,7 +87,7 @@ QIcon QbsProductNode::m_productIcon;
static QbsProjectNode *parentQbsProjectNode(ProjectExplorer::Node *node)
{
for (ProjectExplorer::FolderNode *pn = node->projectNode(); pn; pn = pn->parentFolderNode()) {
for (ProjectExplorer::FolderNode *pn = node->parentProjectNode(); pn; pn = pn->parentFolderNode()) {
QbsProjectNode *prjNode = dynamic_cast<QbsProjectNode *>(pn);
if (prjNode)
return prjNode;
......@@ -719,7 +719,7 @@ void QbsProductNode::setQbsProductData(const qbs::Project &project, const qbs::P
QList<ProjectExplorer::RunConfiguration *> QbsProductNode::runConfigurations() const
{
QList<ProjectExplorer::RunConfiguration *> result;
QbsProjectNode *pn = dynamic_cast<QbsProjectNode *>(projectNode());
QbsProjectNode *pn = dynamic_cast<QbsProjectNode *>(parentProjectNode());
if (!isEnabled() || !pn || m_qbsProductData.targetExecutable().isEmpty())
return result;
......
......@@ -259,7 +259,9 @@ void QbsProjectManagerPlugin::updateContextActions()
&& m_selectedNode && m_selectedNode->isEnabled();
bool isFile = m_selectedProject && m_selectedNode && (m_selectedNode->nodeType() == NodeType::File);
bool isProduct = m_selectedProject && m_selectedNode && dynamic_cast<QbsProductNode *>(m_selectedNode->projectNode());
bool isProduct = m_selectedProject
&& m_selectedNode
&& dynamic_cast<QbsProductNode *>(m_selectedNode->parentProjectNode());
QbsProjectNode *subproject = dynamic_cast<QbsProjectNode *>(m_selectedNode);
bool isSubproject = m_selectedProject && subproject && subproject != m_selectedProject->rootProjectNode();
......@@ -293,10 +295,10 @@ void QbsProjectManagerPlugin::updateBuildActions()
&& !m_editorProject->isParsing();
fileName = m_editorNode->filePath().fileName();
fileVisible = m_editorProject && m_editorNode && dynamic_cast<QbsBaseProjectNode *>(m_editorNode->projectNode());
fileVisible = m_editorProject && m_editorNode && dynamic_cast<QbsBaseProjectNode *>(m_editorNode->parentProjectNode());
QbsProductNode *productNode
= dynamic_cast<QbsProductNode *>(m_editorNode ? m_editorNode->projectNode() : 0);
= dynamic_cast<QbsProductNode *>(m_editorNode ? m_editorNode->parentProjectNode() : 0);
if (productNode) {
productVisible = true;
productName = productNode->displayName();
......@@ -393,7 +395,7 @@ void QbsProjectManagerPlugin::buildProduct()
if (!m_editorProject || !m_editorNode)
return;
QbsProductNode *product = dynamic_cast<QbsProductNode *>(m_editorNode->projectNode());
QbsProductNode *product = dynamic_cast<QbsProductNode *>(m_editorNode->parentProjectNode());
if (!product)
return;
......@@ -423,7 +425,7 @@ void QbsProjectManagerPlugin::buildSubproject()
return;
QbsProjectNode *subproject = 0;
QbsBaseProjectNode *start = dynamic_cast<QbsBaseProjectNode *>(m_editorNode->projectNode());
QbsBaseProjectNode *start = dynamic_cast<QbsBaseProjectNode *>(m_editorNode->parentProjectNode());
while (start && start != m_editorProject->rootProjectNode()) {
QbsProjectNode *tmp = dynamic_cast<QbsProjectNode *>(start);
if (tmp) {
......
......@@ -578,7 +578,7 @@ struct InternalNode
nodesToAdd.reserve(resourcesToAdd.size());
foreach (const FileName &file, resourcesToAdd) {
auto vfs = static_cast<QmakePriFileNode *>(folder->projectNode())->m_project->qmakeVfs();
auto vfs = static_cast<QmakePriFileNode *>(folder->parentProjectNode())->m_project->qmakeVfs();
QString contents;
// Prefer the cumulative file if it's non-empty, based on the assumption
// that it contains more "stuff".
......@@ -1110,7 +1110,7 @@ bool QmakePriFileNode::renameFile(const QString &filePath, const QString &newFil
FolderNode::AddNewInformation QmakePriFileNode::addNewInformation(const QStringList &files, Node *context) const
{
Q_UNUSED(files)
return FolderNode::AddNewInformation(filePath().fileName(), context && context->projectNode() == this ? 120 : 90);
return FolderNode::AddNewInformation(filePath().fileName(), context && context->parentProjectNode() == this ? 120 : 90);
}
bool QmakePriFileNode::priFileWritable(const QString &path)
......@@ -1637,7 +1637,7 @@ bool QmakeProFileNode::showInSimpleTree() const
FolderNode::AddNewInformation QmakeProFileNode::addNewInformation(const QStringList &files, Node *context) const
{
Q_UNUSED(files)
return AddNewInformation(filePath().fileName(), context && context->projectNode() == this ? 120 : 100);
return AddNewInformation(filePath().fileName(), context && context->parentProjectNode() == this ? 120 : 100);
}
bool QmakeProFileNode::showInSimpleTree(QmakeProjectType projectType) const
......
......@@ -221,7 +221,7 @@ void QmakeManager::buildFile()
Project *project = SessionManager::projectForFile(file);
if (project && node)
handleSubDirContextMenu(BUILD, true, project, node->projectNode(), node);
handleSubDirContextMenu(BUILD, true, project, node->parentProjectNode(), node);
}
}
......
......@@ -323,7 +323,7 @@ void QmakeProjectManagerPlugin::updateContextActions(ProjectExplorer::Node *node
auto qmakeProject = qobject_cast<QmakeProject *>(project);
QmakeProFileNode *subProjectNode = nullptr;
if (node) {
if (auto subPriFileNode = dynamic_cast<QmakePriFileNode *>(node->projectNode()))
if (auto subPriFileNode = dynamic_cast<QmakePriFileNode *>(node->parentProjectNode()))
subProjectNode = subPriFileNode->proFileNode();
}
ProjectExplorer::FileNode *fileNode = node ? node->asFileNode() : nullptr;
......@@ -397,7 +397,7 @@ void QmakeProjectManagerPlugin::updateBuildFileAction()
m_buildFileAction->setParameter(file.fileName());
visible = qobject_cast<QmakeProject *>(project)
&& node
&& dynamic_cast<QmakePriFileNode *>(node->projectNode());
&& dynamic_cast<QmakePriFileNode *>(node->parentProjectNode());
enabled = !BuildManager::isBuilding(project);
}
......
......@@ -399,7 +399,7 @@ void DocumentManager::findPathToIsoProFile(bool *iconResourceFileAlreadyExists,
qCDebug(documentManagerLog) << "Found" << isoIconsQrcFile << "in" << virtualFolderNode->filePath();
iconQrcFileNode = subFolderNode;
*resourceFileProPath = iconQrcFileNode->projectNode()->filePath().toString();
*resourceFileProPath = iconQrcFileNode->parentProjectNode()->filePath().toString();
}
}
}
......@@ -416,7 +416,7 @@ void DocumentManager::findPathToIsoProFile(bool *iconResourceFileAlreadyExists,
*resourceFilePath = project->projectDirectory().toString() + "/" + isoIconsQrcFile;
// We assume that the .pro containing the QML file is an acceptable place to add the .qrc file.
ProjectExplorer::ProjectNode *projectNode = ProjectExplorer::SessionManager::nodeForFile(qmlFileName)->projectNode();
ProjectExplorer::ProjectNode *projectNode = ProjectExplorer::SessionManager::nodeForFile(qmlFileName)->parentProjectNode();
*resourceFileProPath = projectNode->filePath().toString();
} else {
// We found the QRC file that we want.
......
......@@ -345,7 +345,7 @@ ProjectExplorer::FolderNode::AddNewInformation ResourceTopLevelNode::addNewInfor
p = 110;
if (context == this)
p = 120;
else if (projectNode() == context)
else if (parentProjectNode() == context)
p = 150; // steal from our project node
// The ResourceFolderNode '/' defers to us, as otherwise
// two nodes would be responsible for '/'
......
......@@ -146,7 +146,7 @@ void TodoItemsProvider::setItemsListWithinSubproject()
// TODO prefer current editor as source of sub-project
Node *node = ProjectTree::currentNode();
if (node) {
ProjectNode *projectNode = node->projectNode();
ProjectNode *projectNode = node->parentProjectNode();
if (projectNode) {
FindAllFilesVisitor filesVisitor;
......
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