ProjectExplorer: Rename ProjectTree::findCurrentNode to currentNode

For consistency, it's straight forwards access, similar to
currentProject, not much to search and find.

Change-Id: I7ce696bdc24b6a8713d6f11e02443a6f94c605f6
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2019-04-30 12:58:33 +02:00
parent 28de30df18
commit a5148b5363
13 changed files with 47 additions and 47 deletions

View File

@@ -147,7 +147,7 @@ void CMakeProjectPlugin::extensionsInitialized()
void CMakeProjectPlugin::updateContextActions()
{
Project *project = ProjectTree::currentProject();
const Node *node = ProjectTree::findCurrentNode();
const Node *node = ProjectTree::currentNode();
auto targetNode = dynamic_cast<const CMakeTargetNode *>(node);
// as targetNode can be deleted while the menu is open, we keep only the
const QString targetDisplayName = targetNode ? targetNode->displayName() : QString();

View File

@@ -250,7 +250,7 @@ void ModelsManager::onAboutToShowContextMenu(ProjectExplorer::Project *project,
void ModelsManager::onOpenDiagramFromProjectExplorer()
{
if (ProjectExplorer::ProjectTree::findCurrentNode() == d->contextMenuOwnerNode) {
if (ProjectExplorer::ProjectTree::currentNode() == d->contextMenuOwnerNode) {
qmt::MDiagram *diagram = nullptr;
foreach (const ManagedModel &managedModel, d->managedModels) {
if ((diagram = managedModel.m_documentController->pxNodeController()->findDiagramForExplorerNode(d->contextMenuOwnerNode))) {

View File

@@ -1460,7 +1460,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
connect(dd->m_openTerminalHereRunEnv, &QAction::triggered, dd, []() { dd->openTerminalHere(runEnv); });
connect(dd->m_filePropertiesAction, &QAction::triggered, this, []() {
const Node *currentNode = ProjectTree::findCurrentNode();
const Node *currentNode = ProjectTree::currentNode();
QTC_ASSERT(currentNode && currentNode->asFileNode(), return);
DocumentManager::showFilePropertiesDialog(currentNode->filePath());
});
@@ -2628,7 +2628,7 @@ void ProjectExplorerPlugin::buildProject(Project *p)
void ProjectExplorerPluginPrivate::runProjectContextMenu()
{
const Node *node = ProjectTree::findCurrentNode();
const Node *node = ProjectTree::currentNode();
const ProjectNode *projectNode = node ? node->asProjectNode() : nullptr;
if (projectNode == ProjectTree::currentProject()->rootProjectNode() || !projectNode) {
m_instance->runProject(ProjectTree::currentProject(), Constants::NORMAL_RUN_MODE);
@@ -3160,7 +3160,7 @@ void ProjectExplorerPluginPrivate::updateContextMenuActions()
runMenu->menu()->clear();
runMenu->menu()->menuAction()->setVisible(false);
const Node *currentNode = ProjectTree::findCurrentNode();
const Node *currentNode = ProjectTree::currentNode();
if (currentNode && currentNode->managingProject()) {
ProjectNode *pn;
@@ -3285,7 +3285,7 @@ void ProjectExplorerPluginPrivate::updateLocationSubMenus()
QTC_CHECK(folderMenu->actions().isEmpty());
const FolderNode *const fn
= ProjectTree::findCurrentNode() ? ProjectTree::findCurrentNode()->asFolderNode() : nullptr;
= ProjectTree::currentNode() ? ProjectTree::currentNode()->asFolderNode() : nullptr;
const QList<FolderNode::LocationInfo> locations
= fn ? fn->locationInfo() : QList<FolderNode::LocationInfo>();
@@ -3313,7 +3313,7 @@ void ProjectExplorerPluginPrivate::updateLocationSubMenus()
void ProjectExplorerPluginPrivate::addNewFile()
{
Node* currentNode = ProjectTree::findCurrentNode();
Node *currentNode = ProjectTree::currentNode();
QTC_ASSERT(currentNode, return);
QString location = directoryFor(currentNode);
@@ -3337,7 +3337,7 @@ void ProjectExplorerPluginPrivate::addNewFile()
void ProjectExplorerPluginPrivate::addNewSubproject()
{
Node* currentNode = ProjectTree::findCurrentNode();
Node* currentNode = ProjectTree::currentNode();
QTC_ASSERT(currentNode, return);
QString location = directoryFor(currentNode);
@@ -3364,7 +3364,7 @@ void ProjectExplorerPluginPrivate::addNewSubproject()
void ProjectExplorerPluginPrivate::addExistingProjects()
{
Node * const currentNode = ProjectTree::findCurrentNode();
Node * const currentNode = ProjectTree::currentNode();
if (!currentNode)
return;
ProjectNode *projectNode = currentNode->asProjectNode();
@@ -3405,7 +3405,7 @@ void ProjectExplorerPluginPrivate::addExistingProjects()
void ProjectExplorerPluginPrivate::handleAddExistingFiles()
{
Node *node = ProjectTree::findCurrentNode();
Node *node = ProjectTree::currentNode();
FolderNode *folderNode = node ? node->asFolderNode() : nullptr;
QTC_ASSERT(folderNode, return);
@@ -3420,7 +3420,7 @@ void ProjectExplorerPluginPrivate::handleAddExistingFiles()
void ProjectExplorerPluginPrivate::addExistingDirectory()
{
Node *node = ProjectTree::findCurrentNode();
Node *node = ProjectTree::currentNode();
FolderNode *folderNode = node ? node->asFolderNode() : nullptr;
QTC_ASSERT(folderNode, return);
@@ -3462,7 +3462,7 @@ void ProjectExplorerPlugin::addExistingFiles(FolderNode *folderNode, const QStri
void ProjectExplorerPluginPrivate::removeProject()
{
Node *node = ProjectTree::findCurrentNode();
Node *node = ProjectTree::currentNode();
if (!node)
return;
ProjectNode *projectNode = node->managingProject();
@@ -3476,28 +3476,28 @@ void ProjectExplorerPluginPrivate::removeProject()
void ProjectExplorerPluginPrivate::openFile()
{
const Node *currentNode = ProjectTree::findCurrentNode();
const Node *currentNode = ProjectTree::currentNode();
QTC_ASSERT(currentNode, return);
EditorManager::openEditor(currentNode->filePath().toString());
}
void ProjectExplorerPluginPrivate::searchOnFileSystem()
{
const Node *currentNode = ProjectTree::findCurrentNode();
const Node *currentNode = ProjectTree::currentNode();
QTC_ASSERT(currentNode, return);
TextEditor::FindInFiles::findOnFileSystem(pathFor(currentNode));
}
void ProjectExplorerPluginPrivate::showInGraphicalShell()
{
Node *currentNode = ProjectTree::findCurrentNode();
Node *currentNode = ProjectTree::currentNode();
QTC_ASSERT(currentNode, return);
FileUtils::showInGraphicalShell(ICore::mainWindow(), pathFor(currentNode));
}
void ProjectExplorerPluginPrivate::openTerminalHere(const EnvironmentGetter &env)
{
const Node *currentNode = ProjectTree::findCurrentNode();
const Node *currentNode = ProjectTree::currentNode();
QTC_ASSERT(currentNode, return);
const auto environment = env(ProjectTree::projectForNode(currentNode));
@@ -3509,7 +3509,7 @@ void ProjectExplorerPluginPrivate::openTerminalHere(const EnvironmentGetter &env
void ProjectExplorerPluginPrivate::removeFile()
{
const Node *currentNode = ProjectTree::findCurrentNode();
const Node *currentNode = ProjectTree::currentNode();
QTC_ASSERT(currentNode && currentNode->asFileNode(), return);
const Utils::FileName filePath = currentNode->filePath();
@@ -3519,7 +3519,7 @@ void ProjectExplorerPluginPrivate::removeFile()
const bool deleteFile = removeFileDialog.isDeleteFileChecked();
// Re-read the current node, in case the project is re-parsed while the dialog is open
if (currentNode != ProjectTree::findCurrentNode()) {
if (currentNode != ProjectTree::currentNode()) {
currentNode = ProjectTreeWidget::nodeForFile(filePath);
QTC_ASSERT(currentNode && currentNode->asFileNode(), return);
}
@@ -3544,7 +3544,7 @@ void ProjectExplorerPluginPrivate::removeFile()
void ProjectExplorerPluginPrivate::duplicateFile()
{
Node *currentNode = ProjectTree::findCurrentNode();
Node *currentNode = ProjectTree::currentNode();
QTC_ASSERT(currentNode && currentNode->asFileNode(), return);
FileNode *fileNode = currentNode->asFileNode();
@@ -3575,7 +3575,7 @@ void ProjectExplorerPluginPrivate::duplicateFile()
void ProjectExplorerPluginPrivate::deleteFile()
{
Node *currentNode = ProjectTree::findCurrentNode();
Node *currentNode = ProjectTree::currentNode();
QTC_ASSERT(currentNode && currentNode->asFileNode(), return);
FileNode *fileNode = currentNode->asFileNode();

View File

@@ -104,7 +104,7 @@ Project *ProjectTree::currentProject()
return s_instance->m_currentProject;
}
Node *ProjectTree::findCurrentNode()
Node *ProjectTree::currentNode()
{
s_instance->update();
return s_instance->m_currentNode;
@@ -112,8 +112,8 @@ Node *ProjectTree::findCurrentNode()
FileName ProjectTree::currentFilePath()
{
Node *currentNode = findCurrentNode();
return currentNode ? currentNode->filePath() : FileName();
Node *node = currentNode();
return node ? node->filePath() : FileName();
}
void ProjectTree::registerWidget(ProjectTreeWidget *widget)

View File

@@ -53,7 +53,7 @@ public:
static ProjectTree *instance();
static Project *currentProject();
static Node *findCurrentNode();
static Node *currentNode();
static Utils::FileName currentFilePath();
// Integration with ProjectTreeWidget

View File

@@ -298,7 +298,7 @@ ProjectTreeWidget::ProjectTreeWidget(QWidget *parent) : QWidget(parent)
connect(m_toggleSync, &QAbstractButton::clicked,
this, &ProjectTreeWidget::toggleAutoSynchronization);
setCurrentItem(ProjectTree::findCurrentNode());
setCurrentItem(ProjectTree::currentNode());
setAutoSynchronization(true);
m_projectTreeWidgets << this;

View File

@@ -283,7 +283,7 @@ void QbsProjectManagerPlugin::projectWasAdded(Project *project)
void QbsProjectManagerPlugin::updateContextActions()
{
auto project = qobject_cast<Internal::QbsProject *>(ProjectTree::currentProject());
const Node *node = ProjectTree::findCurrentNode();
const Node *node = ProjectTree::currentNode();
bool isEnabled = !BuildManager::isBuilding(project)
&& project && !project->isParsing()
&& node && node->isEnabled();
@@ -375,7 +375,7 @@ void QbsProjectManagerPlugin::projectChanged()
void QbsProjectManagerPlugin::buildFileContextMenu()
{
const Node *node = ProjectTree::findCurrentNode();
const Node *node = ProjectTree::currentNode();
QTC_ASSERT(node, return);
auto project = dynamic_cast<QbsProject *>(ProjectTree::currentProject());
QTC_ASSERT(project, return);
@@ -412,7 +412,7 @@ void QbsProjectManagerPlugin::rebuildProductContextMenu()
void QbsProjectManagerPlugin::runStepsForProductContextMenu(const QList<Core::Id> &stepTypes)
{
const Node *node = ProjectTree::findCurrentNode();
const Node *node = ProjectTree::currentNode();
QTC_ASSERT(node, return);
auto project = dynamic_cast<QbsProject *>(ProjectTree::currentProject());
QTC_ASSERT(project, return);
@@ -477,7 +477,7 @@ void QbsProjectManagerPlugin::rebuildSubprojectContextMenu()
void QbsProjectManagerPlugin::runStepsForSubprojectContextMenu(const QList<Core::Id> &stepTypes)
{
const Node *node = ProjectTree::findCurrentNode();
const Node *node = ProjectTree::currentNode();
QTC_ASSERT(node, return);
auto project = dynamic_cast<QbsProject *>(ProjectTree::currentProject());
QTC_ASSERT(project, return);

View File

@@ -67,7 +67,7 @@ static QmakeProFileNode *buildableFileProFile(Node *node)
FileNode *QmakeManager::contextBuildableFileNode()
{
Node *node = ProjectTree::findCurrentNode();
Node *node = ProjectTree::currentNode();
QmakeProFileNode *subProjectNode = buildableFileProFile(node);
FileNode *fileNode = node ? node->asFileNode() : nullptr;
@@ -87,7 +87,7 @@ void QmakeManager::addLibraryContextMenu()
{
QString projectPath;
Node *node = ProjectTree::findCurrentNode();
Node *node = ProjectTree::currentNode();
if (ContainerNode *cn = node->asContainerNode())
projectPath = cn->project()->projectFilePath().toString();
else if (dynamic_cast<QmakeProFileNode *>(node))
@@ -132,7 +132,7 @@ void QmakeManager::runQMake()
void QmakeManager::runQMakeContextMenu()
{
runQMakeImpl(ProjectTree::currentProject(), ProjectTree::findCurrentNode());
runQMakeImpl(ProjectTree::currentProject(), ProjectTree::currentNode());
}
void QmakeManager::runQMakeImpl(ProjectExplorer::Project *p, ProjectExplorer::Node *node)
@@ -199,7 +199,7 @@ void QmakeManager::handleSubDirContextMenu(QmakeManager::Action action, bool isF
handleSubDirContextMenu(action,
isFileBuild,
ProjectTree::currentProject(),
buildableFileProFile(ProjectTree::findCurrentNode()),
buildableFileProFile(ProjectTree::currentNode()),
contextBuildableFileNode());
}

View File

@@ -369,7 +369,7 @@ void QmakeProjectManagerPluginPrivate::updateRunQMakeAction()
void QmakeProjectManagerPluginPrivate::updateContextActions()
{
const Node *node = ProjectTree::findCurrentNode();
const Node *node = ProjectTree::currentNode();
Project *project = ProjectTree::currentProject();
const ContainerNode *containerNode = node ? node->asContainerNode() : nullptr;

View File

@@ -72,7 +72,7 @@ QString QmlPreviewFileOnTargetFinder::findPath(const QString &filePath, bool *su
// Try the current node first. It's likely that this is the one we're looking for and if there
// is any ambiguity (same file mapped to multiple qrc paths) it should take precedence.
ProjectExplorer::Node *currentNode = ProjectExplorer::ProjectTree::findCurrentNode();
ProjectExplorer::Node *currentNode = ProjectExplorer::ProjectTree::currentNode();
if (currentNode && currentNode->filePath().toString() == filePath) {
const QString path = resourceNodePath(currentNode);
if (!path.isEmpty())

View File

@@ -143,7 +143,7 @@ bool QmlPreviewPlugin::initialize(const QStringList &arguments, QString *errorSt
Constants::G_FILE_OTHER);
action->setVisible(false);
connect(ProjectTree::instance(), &ProjectTree::currentNodeChanged, action, [action]() {
const Node *node = ProjectTree::findCurrentNode();
const Node *node = ProjectTree::currentNode();
const FileNode *fileNode = node ? node->asFileNode() : nullptr;
action->setVisible(fileNode ? fileNode->fileType() == FileType::QML : false);
});
@@ -297,7 +297,7 @@ void QmlPreviewPlugin::setFileLoader(QmlPreviewFileLoader fileLoader)
void QmlPreviewPlugin::previewCurrentFile()
{
const Node *currentNode = ProjectTree::findCurrentNode();
const Node *currentNode = ProjectTree::currentNode();
if (!currentNode || !currentNode->asFileNode()
|| currentNode->asFileNode()->fileType() != FileType::QML)
return;

View File

@@ -241,7 +241,7 @@ void ResourceEditorPlugin::onRefresh()
void ResourceEditorPlugin::addPrefixContextMenu()
{
auto topLevel = dynamic_cast<ResourceTopLevelNode *>(ProjectTree::findCurrentNode());
auto topLevel = dynamic_cast<ResourceTopLevelNode *>(ProjectTree::currentNode());
QTC_ASSERT(topLevel, return);
PrefixLangDialog dialog(tr("Add Prefix"), QString(), QString(), Core::ICore::mainWindow());
if (dialog.exec() != QDialog::Accepted)
@@ -254,7 +254,7 @@ void ResourceEditorPlugin::addPrefixContextMenu()
void ResourceEditorPlugin::removePrefixContextMenu()
{
auto rfn = dynamic_cast<ResourceFolderNode *>(ProjectTree::findCurrentNode());
auto rfn = dynamic_cast<ResourceFolderNode *>(ProjectTree::currentNode());
QTC_ASSERT(rfn, return);
if (QMessageBox::question(Core::ICore::mainWindow(),
tr("Remove Prefix"),
@@ -267,7 +267,7 @@ void ResourceEditorPlugin::removePrefixContextMenu()
void ResourceEditorPlugin::removeNonExisting()
{
auto topLevel = dynamic_cast<ResourceTopLevelNode *>(ProjectTree::findCurrentNode());
auto topLevel = dynamic_cast<ResourceTopLevelNode *>(ProjectTree::currentNode());
QTC_ASSERT(topLevel, return);
topLevel->removeNonExistingFiles();
}
@@ -279,7 +279,7 @@ void ResourceEditorPlugin::renameFileContextMenu()
void ResourceEditorPlugin::removeFileContextMenu()
{
auto rfn = dynamic_cast<ResourceTopLevelNode *>(ProjectTree::findCurrentNode());
auto rfn = dynamic_cast<ResourceTopLevelNode *>(ProjectTree::currentNode());
QTC_ASSERT(rfn, return);
QString path = rfn->filePath().toString();
FolderNode *parent = rfn->parentFolderNode();
@@ -292,26 +292,26 @@ void ResourceEditorPlugin::removeFileContextMenu()
void ResourceEditorPlugin::openEditorContextMenu()
{
Core::EditorManager::openEditor(ProjectTree::findCurrentNode()->filePath().toString());
Core::EditorManager::openEditor(ProjectTree::currentNode()->filePath().toString());
}
void ResourceEditorPlugin::copyPathContextMenu()
{
auto node = dynamic_cast<ResourceFileNode *>(ProjectTree::findCurrentNode());
auto node = dynamic_cast<ResourceFileNode *>(ProjectTree::currentNode());
QTC_ASSERT(node, return);
QApplication::clipboard()->setText(QLatin1String(resourcePrefix) + node->qrcPath());
}
void ResourceEditorPlugin::copyUrlContextMenu()
{
auto node = dynamic_cast<ResourceFileNode *>(ProjectTree::findCurrentNode());
auto node = dynamic_cast<ResourceFileNode *>(ProjectTree::currentNode());
QTC_ASSERT(node, return);
QApplication::clipboard()->setText(QLatin1String(urlPrefix) + node->qrcPath());
}
void ResourceEditorPlugin::renamePrefixContextMenu()
{
auto node = dynamic_cast<ResourceFolderNode *>(ProjectTree::findCurrentNode());
auto node = dynamic_cast<ResourceFolderNode *>(ProjectTree::currentNode());
QTC_ASSERT(node, return);
PrefixLangDialog dialog(tr("Rename Prefix"), node->prefix(), node->lang(), Core::ICore::mainWindow());
@@ -326,7 +326,7 @@ void ResourceEditorPlugin::renamePrefixContextMenu()
void ResourceEditorPlugin::updateContextActions()
{
const Node *node = ProjectTree::findCurrentNode();
const Node *node = ProjectTree::currentNode();
const bool isResourceNode = dynamic_cast<const ResourceTopLevelNode *>(node);
m_addPrefix->setEnabled(isResourceNode);
m_addPrefix->setVisible(isResourceNode);

View File

@@ -149,7 +149,7 @@ void TodoItemsProvider::setItemsListWithinStartupProject()
void TodoItemsProvider::setItemsListWithinSubproject()
{
// TODO prefer current editor as source of sub-project
const Node *node = ProjectTree::findCurrentNode();
const Node *node = ProjectTree::currentNode();
if (node) {
ProjectNode *projectNode = node->parentProjectNode();
if (projectNode) {