Commit 5422b2c4 authored by Tobias Hunger's avatar Tobias Hunger

Introduce Project::projectFilePath()

Use it instead of retrieving this information from the document.

Change-Id: I809fcb2daf59021cf503c371a5d40d75d7448796
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 54886da9
......@@ -45,7 +45,6 @@
#include <projectexplorer/session.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectnodes.h>
#include <coreplugin/idocument.h>
#include <utils/qtcassert.h>
#include <QStandardItem>
......@@ -287,7 +286,7 @@ ParserTreeItem::ConstPtr Parser::parse()
QString prjName(prj->displayName());
QString prjType(prjName);
if (prj->document())
prjType = prj->document()->filePath();
prjType = prj->projectFilePath();
SymbolInformation inf(prjName, prjType);
QStringList projectList = addProjectNode(item, prj->rootProjectNode());
......
......@@ -52,7 +52,7 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(ProjectExplorer::Target *parent
BuildConfiguration(parent, Core::Id(Constants::CMAKE_BC_ID)), m_useNinja(false)
{
CMakeProject *project = static_cast<CMakeProject *>(parent->project());
m_buildDirectory = project->shadowBuildDirectory(project->document()->filePath(),
m_buildDirectory = project->shadowBuildDirectory(project->projectFilePath(),
parent->kit(),
displayName());
}
......@@ -181,7 +181,7 @@ CMakeBuildConfiguration *CMakeBuildConfigurationFactory::create(ProjectExplorer:
info.sourceDirectory = project->projectDirectory();
info.environment = Utils::Environment::systemEnvironment();
parent->kit()->addToEnvironment(info.environment);
info.buildDirectory = project->shadowBuildDirectory(project->document()->filePath(),
info.buildDirectory = project->shadowBuildDirectory(project->projectFilePath(),
parent->kit(),
buildConfigurationName);
info.kit = parent->kit();
......
......@@ -76,9 +76,9 @@ QList<Locator::FilterEntry> CMakeLocatorFilter::matchesFor(QFutureInterface<Loca
if (cmakeProject) {
foreach (const CMakeBuildTarget &ct, cmakeProject->buildTargets()) {
if (ct.title.contains(entry)) {
Locator::FilterEntry entry(this, ct.title, cmakeProject->document()->filePath());
Locator::FilterEntry entry(this, ct.title, cmakeProject->projectFilePath());
entry.extraInfo = FileUtils::shortNativePath(
FileName::fromString(cmakeProject->document()->filePath()));
FileName::fromString(cmakeProject->projectFilePath()));
result.append(entry);
}
}
......@@ -97,7 +97,7 @@ void CMakeLocatorFilter::accept(Locator::FilterEntry selection) const
ProjectExplorer::ProjectExplorerPlugin::instance()->session()->projects();
foreach (ProjectExplorer::Project *p, projects) {
cmakeProject = qobject_cast<CMakeProject *>(p);
if (cmakeProject && cmakeProject->document()->filePath() == selection.internalData.toString())
if (cmakeProject && cmakeProject->projectFilePath() == selection.internalData.toString())
break;
cmakeProject = 0;
}
......
......@@ -379,7 +379,7 @@ void CppModelManager::dumpModelManagerConfiguration()
// Tons of debug output...
qDebug() << "========= CppModelManager::dumpModelManagerConfiguration ======";
foreach (const ProjectInfo &pinfo, m_projectToProjectsInfo) {
qDebug() << " for project:"<< pinfo.project().data()->document()->filePath();
qDebug() << " for project:"<< pinfo.project().data()->projectFilePath();
foreach (const ProjectPart::Ptr &part, pinfo.projectParts()) {
qDebug() << "=== part ===";
const char* cVersion;
......
......@@ -3502,7 +3502,7 @@ void DebuggerPluginPrivate::testProjectLoaded(Project *project)
void DebuggerPluginPrivate::testProjectEvaluated()
{
QString fileName = m_testProject->document()->filePath();
QString fileName = m_testProject->projectFilePath();
QVERIFY(!fileName.isEmpty());
qWarning("Project %s loaded", qPrintable(fileName));
connect(ProjectExplorerPlugin::instance()->buildManager(),
......
......@@ -117,7 +117,7 @@ void GenericProjectPlugin::updateContextMenu(ProjectExplorer::Project *project,
void GenericProjectPlugin::editFiles()
{
GenericProject *genericProject = static_cast<GenericProject *>(m_contextMenuProject);
SelectableFilesDialog sfd(QFileInfo(genericProject->document()->filePath()).path(), genericProject->files(),
SelectableFilesDialog sfd(QFileInfo(genericProject->projectFilePath()).path(), genericProject->files(),
Core::ICore::mainWindow());
if (sfd.exec() == QDialog::Accepted)
genericProject->setFiles(sfd.selectedFiles());
......
......@@ -210,7 +210,7 @@ bool MaemoPublisherFremantleFree::copyRecursively(const QString &srcFilePath,
QByteArray rulesContents = reader.data();
rulesContents.replace("$(MAKE) clean", "# $(MAKE) clean");
rulesContents.replace("# Add here commands to configure the package.",
"qmake " + QFileInfo(m_project->document()->filePath()).fileName().toLocal8Bit());
"qmake " + QFileInfo(m_project->projectFilePath()).fileName().toLocal8Bit());
MaemoDebianPackageCreationStep::ensureShlibdeps(rulesContents);
FileSaver saver(tgtFilePath);
saver.write(rulesContents);
......
......@@ -33,7 +33,6 @@
#include "project.h"
#include "session.h"
#include <coreplugin/idocument.h>
#include <utils/qtcassert.h>
#include <utils/filesearch.h>
......@@ -76,7 +75,7 @@ QVariant CurrentProjectFind::additionalParameters() const
{
Project *project = ProjectExplorerPlugin::currentProject();
if (project && project->document())
return qVariantFromValue(project->document()->filePath());
return qVariantFromValue(project->projectFilePath());
return QVariant();
}
......@@ -87,7 +86,7 @@ Utils::FileIterator *CurrentProjectFind::files(const QStringList &nameFilters,
QList<Project *> allProjects = m_plugin->session()->projects();
QString projectFile = additionalParameters.toString();
foreach (Project *project, allProjects) {
if (project->document() && projectFile == project->document()->filePath())
if (project->document() && projectFile == project->projectFilePath())
return filesForProjects(nameFilters, QList<Project *>() << project);
}
return new Utils::FileIterator();
......@@ -112,7 +111,7 @@ void CurrentProjectFind::recheckEnabled()
QString projectFile = getAdditionalParameters(search).toString();
QList<Project *> allProjects = m_plugin->session()->projects();
foreach (Project *project, allProjects) {
if (project->document() && projectFile == project->document()->filePath()) {
if (projectFile == project->projectFilePath()) {
search->setSearchAgainEnabled(true);
return;
}
......
......@@ -32,7 +32,6 @@
#include "session.h"
#include <coreplugin/fileiconprovider.h>
#include <coreplugin/idocument.h>
#include <utils/detailswidget.h>
#include <QDebug>
......@@ -104,7 +103,7 @@ QVariant DependenciesModel::data(const QModelIndex &index, int role) const
case Qt::CheckStateRole:
return m_session->hasDependency(m_project, p) ? Qt::Checked : Qt::Unchecked;
case Qt::DecorationRole:
return Core::FileIconProvider::instance()->icon(QFileInfo(p->document()->filePath()));
return Core::FileIconProvider::instance()->icon(QFileInfo(p->projectFilePath()));
default:
return QVariant();
}
......
......@@ -33,7 +33,6 @@
#include <utils/styledbar.h>
#include <utils/stylehelper.h>
#include <coreplugin/idocument.h>
#include <coreplugin/icore.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/modemanager.h>
......@@ -237,7 +236,7 @@ QListWidgetItem *ProjectListWidget::itemForProject(Project *project)
QString ProjectListWidget::fullName(ProjectExplorer::Project *project)
{
return tr("%1 (%2)").arg(project->displayName(), project->document()->filePath());
return tr("%1 (%2)").arg(project->displayName(), project->projectFilePath());
}
void ProjectListWidget::addProject(Project *project)
......@@ -1395,7 +1394,7 @@ void MiniProjectTargetSelector::updateActionAndSummary()
projectName = project->displayName();
foreach (Project *p, ProjectExplorerPlugin::instance()->session()->projects()) {
if (p != project && p->displayName() == projectName) {
fileName = project->document()->filePath();
fileName = project->projectFilePath();
break;
}
}
......
......@@ -109,6 +109,11 @@ Project::~Project()
delete d;
}
QString Project::projectFilePath() const
{
return document()->filePath();
}
bool Project::hasActiveBuildSettings() const
{
return activeTarget() && IBuildConfigurationFactory::find(activeTarget());
......
......@@ -74,6 +74,8 @@ public:
virtual Core::IDocument *document() const = 0;
virtual IProjectManager *projectManager() const = 0;
QString projectFilePath() const;
bool hasActiveBuildSettings() const;
// EditorConfiguration:
......
......@@ -1353,7 +1353,7 @@ QList<Project *> ProjectExplorerPlugin::openProjects(const QStringList &fileName
QString canonicalFilePath = fi.canonicalFilePath();
bool found = false;
foreach (ProjectExplorer::Project *pi, session()->projects()) {
if (canonicalFilePath == pi->document()->filePath()) {
if (canonicalFilePath == pi->projectFilePath()) {
found = true;
break;
}
......@@ -1947,7 +1947,7 @@ void ProjectExplorerPlugin::updateActions()
QStringList ProjectExplorerPlugin::allFilesWithDependencies(Project *pro)
{
if (debug)
qDebug() << "ProjectExplorerPlugin::allFilesWithDependencies(" << pro->document()->filePath() << ")";
qDebug() << "ProjectExplorerPlugin::allFilesWithDependencies(" << pro->projectFilePath() << ")";
QStringList filesToSave;
foreach (Project *p, d->m_session->projectOrder(pro)) {
......@@ -2355,7 +2355,7 @@ void ProjectExplorerPlugin::projectRemoved(ProjectExplorer::Project * pro)
void ProjectExplorerPlugin::projectDisplayNameChanged(Project *pro)
{
addToRecentProjects(pro->document()->filePath(), pro->displayName());
addToRecentProjects(pro->projectFilePath(), pro->displayName());
updateActions();
}
......
......@@ -347,7 +347,7 @@ void ProjectWindow::registerProject(ProjectExplorer::Project *project)
}
m_tabIndexToProject.insert(index, project);
m_tabWidget->insertTab(index, project->displayName(), project->document()->filePath(), subtabs);
m_tabWidget->insertTab(index, project->displayName(), project->projectFilePath(), subtabs);
connect(project, SIGNAL(removedTarget(ProjectExplorer::Target*)),
this, SLOT(removedTarget(ProjectExplorer::Target*)));
......
......@@ -156,7 +156,7 @@ bool SessionManager::recursiveDependencyCheck(const QString &newDep, const QStri
QList<Project *> SessionManager::dependencies(const Project *project) const
{
const QString &proName = project->document()->filePath();
const QString &proName = project->projectFilePath();
const QStringList &proDeps = m_depMap.value(proName);
QList<Project *> projects;
......@@ -170,8 +170,8 @@ QList<Project *> SessionManager::dependencies(const Project *project) const
bool SessionManager::hasDependency(const Project *project, const Project *depProject) const
{
const QString &proName = project->document()->filePath();
const QString &depName = depProject->document()->filePath();
const QString &proName = project->projectFilePath();
const QString &depName = depProject->projectFilePath();
const QStringList &proDeps = m_depMap.value(proName);
return proDeps.contains(depName);
......@@ -179,16 +179,16 @@ bool SessionManager::hasDependency(const Project *project, const Project *depPro
bool SessionManager::canAddDependency(const Project *project, const Project *depProject) const
{
const QString &newDep = project->document()->filePath();
const QString &checkDep = depProject->document()->filePath();
const QString &newDep = project->projectFilePath();
const QString &checkDep = depProject->projectFilePath();
return recursiveDependencyCheck(newDep, checkDep);
}
bool SessionManager::addDependency(Project *project, Project *depProject)
{
const QString &proName = project->document()->filePath();
const QString &depName = depProject->document()->filePath();
const QString &proName = project->projectFilePath();
const QString &depName = depProject->projectFilePath();
// check if this dependency is valid
if (!recursiveDependencyCheck(proName, depName))
......@@ -206,8 +206,8 @@ bool SessionManager::addDependency(Project *project, Project *depProject)
void SessionManager::removeDependency(Project *project, Project *depProject)
{
const QString &proName = project->document()->filePath();
const QString &depName = depProject->document()->filePath();
const QString &proName = project->projectFilePath();
const QString &depName = depProject->projectFilePath();
QStringList proDeps = m_depMap.value(proName);
proDeps.removeAll(depName);
......@@ -304,7 +304,7 @@ bool SessionManager::save()
QVariantMap data;
// save the startup project
if (m_startupProject)
data.insert(QLatin1String("StartupProject"), m_startupProject->document()->filePath());
data.insert(QLatin1String("StartupProject"), m_startupProject->projectFilePath());
QColor c = Utils::StyleHelper::requestedBaseColor();
if (c.isValid()) {
......@@ -317,7 +317,7 @@ bool SessionManager::save()
QStringList projectFiles;
foreach (Project *pro, m_projects)
projectFiles << pro->document()->filePath();
projectFiles << pro->projectFilePath();
// Restore infromation on projects that failed to load:
// don't readd projects to the list, which the user loaded
......@@ -402,7 +402,7 @@ QStringList SessionManager::dependenciesOrder() const
// copy the map to a temporary list
foreach (Project *pro, projects()) {
const QString &proName = pro->document()->filePath();
const QString &proName = pro->projectFilePath();
unordered << QPair<QString, QStringList>
(proName, m_depMap.value(proName));
}
......@@ -435,13 +435,13 @@ QList<Project *> SessionManager::projectOrder(Project *project) const
QStringList pros;
if (project)
pros = dependencies(project->document()->filePath());
pros = dependencies(project->projectFilePath());
else
pros = dependenciesOrder();
foreach (const QString &proFile, pros) {
foreach (Project *pro, projects()) {
if (pro->document()->filePath() == proFile) {
if (pro->projectFilePath() == proFile) {
result << pro;
break;
}
......@@ -562,7 +562,7 @@ void SessionManager::removeProjects(QList<Project *> remove)
QSet<QString> projectFiles;
foreach (Project *pro, projects()) {
if (!remove.contains(pro))
projectFiles.insert(pro->document()->filePath());
projectFiles.insert(pro->projectFilePath());
}
QSet<QString>::const_iterator i = projectFiles.begin();
......@@ -765,7 +765,7 @@ void SessionManager::restoreStartupProject(const Utils::PersistentSettingsReader
const QString startupProject = reader.restoreValue(QLatin1String("StartupProject")).toString();
if (!startupProject.isEmpty()) {
foreach (Project *pro, m_projects) {
if (QDir::cleanPath(pro->document()->filePath()) == startupProject) {
if (QDir::cleanPath(pro->projectFilePath()) == startupProject) {
setStartupProject(pro);
break;
}
......@@ -802,7 +802,7 @@ void SessionManager::restoreProjects(const QStringList &fileList)
if (!errors.isEmpty())
QMessageBox::critical(Core::ICore::mainWindow(), tr("Failed to open project"), errors);
foreach (Project *p, projects)
m_failedProjects.removeAll(p->document()->filePath());
m_failedProjects.removeAll(p->projectFilePath());
}
}
......
......@@ -42,7 +42,6 @@
#include "kitmanager.h"
#include <coreplugin/icore.h>
#include <coreplugin/idocument.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/persistentsettings.h>
#include <utils/hostosinfo.h>
......@@ -716,7 +715,7 @@ QByteArray SettingsAccessor::creatorId()
QString SettingsAccessor::defaultFileName(const QString &suffix) const
{
return project()->document()->filePath() + suffix;
return project()->projectFilePath() + suffix;
}
int SettingsAccessor::currentVersion() const
......@@ -819,7 +818,7 @@ SettingsAccessor::SettingsData SettingsAccessor::readUserSettings() const
SettingsAccessor::SettingsData SettingsAccessor::readSharedSettings() const
{
SettingsData sharedSettings;
QString fn = project()->document()->filePath() + m_sharedFileAcessor.suffix();
QString fn = project()->projectFilePath() + m_sharedFileAcessor.suffix();
sharedSettings.m_fileName = Utils::FileName::fromString(fn);
if (!m_sharedFileAcessor.readFile(&sharedSettings))
......
......@@ -566,7 +566,7 @@ QbsGroupNode *QbsProductNode::findGroupNode(const QString &name)
// --------------------------------------------------------------------
QbsProjectNode::QbsProjectNode(QbsProject *project) :
QbsBaseProjectNode(project->document()->filePath()),
QbsBaseProjectNode(project->projectFilePath()),
m_project(project), m_qbsProject(0)
{
ctor();
......
......@@ -157,7 +157,7 @@ void QmlProject::addedRunConfiguration(ProjectExplorer::RunConfiguration *rc)
QDir QmlProject::projectDir() const
{
return QFileInfo(document()->filePath()).dir();
return QFileInfo(projectFilePath()).dir();
}
QString QmlProject::filesFileName() const
......
......@@ -153,7 +153,7 @@ QString QmlProjectRunConfiguration::viewerArguments() const
QString QmlProjectRunConfiguration::workingDirectory() const
{
QFileInfo projectFile(target()->project()->document()->filePath());
QFileInfo projectFile(target()->project()->projectFilePath());
return canonicalCapsPath(projectFile.absolutePath());
}
......
......@@ -122,9 +122,9 @@ QString QMakeStep::allArguments(bool shorted)
if (bc->subNodeBuild())
arguments << QDir::toNativeSeparators(bc->subNodeBuild()->path());
else if (shorted)
arguments << QDir::toNativeSeparators(QFileInfo(project()->document()->filePath()).fileName());
arguments << QDir::toNativeSeparators(QFileInfo(project()->projectFilePath()).fileName());
else
arguments << QDir::toNativeSeparators(project()->document()->filePath());
arguments << QDir::toNativeSeparators(project()->projectFilePath());
arguments << QLatin1String("-r");
bool userProvidedMkspec = false;
......
......@@ -188,7 +188,7 @@ NamedWidget *Qt4BuildConfiguration::createConfigWidget()
QString Qt4BuildConfiguration::defaultShadowBuildDirectory() const
{
// todo displayName isn't ideal
return Qt4Project::shadowBuildDirectory(target()->project()->document()->filePath(),
return Qt4Project::shadowBuildDirectory(target()->project()->projectFilePath(),
target()->kit(), displayName());
}
......
......@@ -901,7 +901,7 @@ bool Qt4Project::supportsKit(Kit *k, QString *errorMessage) const
QString Qt4Project::displayName() const
{
return QFileInfo(document()->filePath()).completeBaseName();
return QFileInfo(projectFilePath()).completeBaseName();
}
Core::Id Qt4Project::id() const
......@@ -1392,7 +1392,7 @@ void Qt4Project::configureAsExampleProject(const QStringList &platforms)
continue;
QList<BuildConfigurationInfo> infoList
= Qt4BuildConfigurationFactory::availableBuildConfigurations(k, document()->filePath());
= Qt4BuildConfigurationFactory::availableBuildConfigurations(k, projectFilePath());
if (infoList.isEmpty())
continue;
addTarget(createTarget(k, infoList));
......
......@@ -171,7 +171,7 @@ void Qt4ProjectConfigWidget::updateProblemLabel()
{
m_ui->shadowBuildDirEdit->triggerChanged();
ProjectExplorer::Kit *k = m_buildConfiguration->target()->kit();
const QString proFileName = m_buildConfiguration->target()->project()->document()->filePath();
const QString proFileName = m_buildConfiguration->target()->project()->projectFilePath();
// Check for Qt version:
QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(k);
......
......@@ -33,7 +33,6 @@
#include "qt4project.h"
#include <coreplugin/idocument.h>
#include <coreplugin/icore.h>
#include <coreplugin/modemanager.h>
#include <coreplugin/coreconstants.h>
......@@ -102,7 +101,7 @@ TargetSetupPageWrapper::TargetSetupPageWrapper(ProjectExplorer::Project *project
m_targetSetupPage->setRequiredKitMatcher(new QtSupport::QtVersionKitMatcher);
m_targetSetupPage->setUseScrollArea(false);
m_targetSetupPage->setImportSearch(true);
m_targetSetupPage->setProFilePath(project->document()->filePath());
m_targetSetupPage->setProFilePath(project->projectFilePath());
m_targetSetupPage->initializePage();
m_targetSetupPage->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
updateNoteText();
......
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