Commit b0b105d5 authored by hjk's avatar hjk Committed by hjk
Browse files

ProjectExplorer: make currentProject static



This saves one function call compared to the instance()->currentProject()
pattern and is typically less to type on the caller site.

Change-Id: I65568f30205fc90e2aaca7e8e7f0192241df8c85
Reviewed-by: default avatarDaniel Teske <daniel.teske@nokia.com>
parent ecd9f3c4
......@@ -101,7 +101,7 @@ void CMakeManager::updateContextMenu(ProjectExplorer::Project *project, ProjectE
void CMakeManager::runCMake()
{
runCMake(ProjectExplorer::ProjectExplorerPlugin::instance()->currentProject());
runCMake(ProjectExplorer::ProjectExplorerPlugin::currentProject());
}
void CMakeManager::runCMakeContextMenu()
......
......@@ -2157,7 +2157,7 @@ TextEditor::IAssistInterface *CPPEditorWidget::createAssistInterface(
QStringList includePaths;
QStringList frameworkPaths;
if (ProjectExplorer::Project *project =
ProjectExplorer::ProjectExplorerPlugin::instance()->currentProject()) {
ProjectExplorer::ProjectExplorerPlugin::currentProject()) {
includePaths = m_modelManager->projectInfo(project).includePaths;
frameworkPaths = m_modelManager->projectInfo(project).frameworkPaths;
}
......
......@@ -266,9 +266,7 @@ QString CppToolsPlugin::correspondingHeaderOrSourceI(const QString &fileName) co
return m_headerSourceMapping.value(fi.absoluteFilePath());
const Core::MimeDatabase *mimeDatase = Core::ICore::mimeDatabase();
ProjectExplorer::ProjectExplorerPlugin *explorer =
ProjectExplorer::ProjectExplorerPlugin::instance();
ProjectExplorer::Project *project = (explorer ? explorer->currentProject() : 0);
ProjectExplorer::Project *project = ProjectExplorer::ProjectExplorerPlugin::currentProject();
const FileType type = fileType(mimeDatase, fi);
......
......@@ -499,7 +499,7 @@ public:
bool DummyEngine::hasCapability(unsigned cap) const
{
// This can only be a first approximation of what to expect when running.
Project *project = ProjectExplorerPlugin::instance()->currentProject();
Project *project = ProjectExplorerPlugin::currentProject();
if (!project)
return 0;
Target *target = project->activeTarget();
......
......@@ -69,13 +69,14 @@ QString CurrentProjectFind::displayName() const
bool CurrentProjectFind::isEnabled() const
{
return m_plugin->currentProject() != 0 && BaseFileFind::isEnabled();
return ProjectExplorerPlugin::currentProject() != 0 && BaseFileFind::isEnabled();
}
QVariant CurrentProjectFind::additionalParameters() const
{
if (m_plugin->currentProject() && m_plugin->currentProject()->file())
return qVariantFromValue(m_plugin->currentProject()->file()->fileName());
Project *project = ProjectExplorerPlugin::currentProject();
if (project && project->file())
return qVariantFromValue(project->file()->fileName());
return QVariant();
}
......@@ -95,8 +96,8 @@ Utils::FileIterator *CurrentProjectFind::files(const QStringList &nameFilters,
QString CurrentProjectFind::label() const
{
QTC_ASSERT(m_plugin->currentProject(), return QString());
return tr("Project '%1':").arg(m_plugin->currentProject()->displayName());
QTC_ASSERT(ProjectExplorerPlugin::currentProject(), return QString());
return tr("Project '%1':").arg(ProjectExplorerPlugin::currentProject()->displayName());
}
void CurrentProjectFind::handleProjectChanged()
......
......@@ -1347,15 +1347,16 @@ QList<Project *> ProjectExplorerPlugin::openProjects(const QStringList &fileName
return openedPro;
}
Project *ProjectExplorerPlugin::currentProject() const
Project *ProjectExplorerPlugin::currentProject()
{
Project *project = m_instance->d->m_currentProject;
if (debug) {
if (d->m_currentProject)
qDebug() << "ProjectExplorerPlugin::currentProject returns " << d->m_currentProject->displayName();
if (project)
qDebug() << "ProjectExplorerPlugin::currentProject returns " << project->displayName();
else
qDebug() << "ProjectExplorerPlugin::currentProject returns 0";
}
return d->m_currentProject;
return project;
}
Node *ProjectExplorerPlugin::currentNode() const
......
......@@ -84,7 +84,7 @@ public:
SessionManager *session() const;
Project *currentProject() const;
static Project *currentProject();
Node *currentNode() const;
void setCurrentFile(Project *project, const QString &file);
......
......@@ -263,7 +263,7 @@ void ProjectTreeWidget::setAutoSynchronization(bool sync, bool syncNow)
connect(m_explorer, SIGNAL(currentNodeChanged(ProjectExplorer::Node*, ProjectExplorer::Project*)),
this, SLOT(setCurrentItem(ProjectExplorer::Node*, ProjectExplorer::Project*)));
if (syncNow)
setCurrentItem(m_explorer->currentNode(), m_explorer->currentProject());
setCurrentItem(m_explorer->currentNode(), ProjectExplorerPlugin::currentProject());
} else {
disconnect(m_explorer, SIGNAL(currentNodeChanged(ProjectExplorer::Node*, ProjectExplorer::Project*)),
this, SLOT(setCurrentItem(ProjectExplorer::Node*, ProjectExplorer::Project*)));
......@@ -354,7 +354,7 @@ void ProjectTreeWidget::initView()
for (int i = 0; i < m_model->rowCount(sessionIndex); ++i)
m_view->expand(m_model->index(i, 0, sessionIndex));
setCurrentItem(m_explorer->currentNode(), m_explorer->currentProject());
setCurrentItem(m_explorer->currentNode(), ProjectExplorerPlugin::currentProject());
}
void ProjectTreeWidget::openItem(const QModelIndex &mainIndex)
......
......@@ -820,7 +820,7 @@ Project *SessionManager::projectForFile(const QString &fileName) const
const QList<Project *> &projectList = projects();
// Check current project first
Project *currentProject = ProjectExplorerPlugin::instance()->currentProject();
Project *currentProject = ProjectExplorerPlugin::currentProject();
if (currentProject && projectContainsFile(currentProject, fileName))
return currentProject;
......@@ -856,7 +856,7 @@ QString SessionManager::currentSession() const
void SessionManager::updateWindowTitle()
{
if (isDefaultSession(m_sessionName)) {
if (Project *currentProject = ProjectExplorerPlugin::instance()->currentProject())
if (Project *currentProject = ProjectExplorerPlugin::currentProject())
ICore::editorManager()->setWindowTitleAddition(currentProject->displayName());
else
ICore::editorManager()->setWindowTitleAddition(QString());
......
......@@ -185,7 +185,7 @@ void Qt4Manager::editorAboutToClose(Core::IEditor *editor)
void Qt4Manager::updateVariable(const QByteArray &variable)
{
if (variable == kInstallBins) {
Qt4Project *qt4pro = qobject_cast<Qt4Project *>(projectExplorer()->currentProject());
Qt4Project *qt4pro = qobject_cast<Qt4Project *>(ProjectExplorer::ProjectExplorerPlugin::currentProject());
if (!qt4pro) {
Core::VariableManager::instance()->remove(kInstallBins);
return;
......
......@@ -73,8 +73,7 @@ QString TaskFileFactory::displayName() const
Core::IFile *TaskFileFactory::open(const QString &fileName)
{
ProjectExplorer::Project * context =
ProjectExplorer::ProjectExplorerPlugin::instance()->currentProject();
ProjectExplorer::Project *context = ProjectExplorer::ProjectExplorerPlugin::currentProject();
return open(context, fileName);
}
......
......@@ -398,8 +398,7 @@ void CallgrindToolPrivate::updateCostFormat()
void CallgrindToolPrivate::handleFilterProjectCosts()
{
ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin::instance();
ProjectExplorer::Project *pro = pe->currentProject();
ProjectExplorer::Project *pro = ProjectExplorer::ProjectExplorerPlugin::currentProject();
QTC_ASSERT(pro, return)
if (m_filterProjectCosts->isChecked()) {
......
......@@ -231,7 +231,6 @@ static inline QString displayNameOfEditor(const QString &fileName)
void StateListener::slotStateChanged()
{
const ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin::instance();
Core::VcsManager *vcsManager = Core::ICore::vcsManager();
// Get the current file. Are we on a temporary submit editor indicated by
......@@ -280,7 +279,7 @@ void StateListener::slotStateChanged()
}
// Check for project, find the control
Core::IVersionControl *projectControl = 0;
if (const ProjectExplorer::Project *currentProject = pe->currentProject()) {
if (const ProjectExplorer::Project *currentProject = ProjectExplorer::ProjectExplorerPlugin::currentProject()) {
state.currentProjectPath = currentProject->projectDirectory();
state.currentProjectName = currentProject->displayName();
projectControl = vcsManager->findVersionControlForDirectory(state.currentProjectPath,
......@@ -643,7 +642,7 @@ void VcsBasePlugin::createRepository()
QTC_ASSERT(d->m_versionControl->supportsOperation(Core::IVersionControl::CreateRepositoryOperation), return);
// Find current starting directory
QString directory;
if (const ProjectExplorer::Project *currentProject = ProjectExplorer::ProjectExplorerPlugin::instance()->currentProject())
if (const ProjectExplorer::Project *currentProject = ProjectExplorer::ProjectExplorerPlugin::currentProject())
directory = QFileInfo(currentProject->file()->fileName()).absolutePath();
// Prompt for a directory that is not under version control yet
QMainWindow *mw = Core::ICore::mainWindow();
......
......@@ -770,18 +770,16 @@ QStringList VcsBaseSubmitEditor::currentProjectFiles(bool nativeSeparators, QStr
if (name)
name->clear();
if (ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin::instance()) {
if (const ProjectExplorer::Project *currentProject = pe->currentProject()) {
QStringList files = currentProject->files(ProjectExplorer::Project::ExcludeGeneratedFiles);
if (name)
*name = currentProject->displayName();
if (nativeSeparators && !files.empty()) {
const QStringList::iterator end = files.end();
for (QStringList::iterator it = files.begin(); it != end; ++it)
*it = QDir::toNativeSeparators(*it);
}
return files;
if (const ProjectExplorer::Project *currentProject = ProjectExplorer::ProjectExplorerPlugin::currentProject()) {
QStringList files = currentProject->files(ProjectExplorer::Project::ExcludeGeneratedFiles);
if (name)
*name = currentProject->displayName();
if (nativeSeparators && !files.empty()) {
const QStringList::iterator end = files.end();
for (QStringList::iterator it = files.begin(); it != end; ++it)
*it = QDir::toNativeSeparators(*it);
}
return files;
}
return QStringList();
}
......
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