Commit aadb6f16 authored by hjk's avatar hjk

SessionManager: Apply 'static' pattern

Change-Id: I370f72fcf7a24216ee189979ce6b5c8bfc5f4140
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent dab9886e
......@@ -48,6 +48,7 @@
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/project.h>
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/session.h>
#include <projectexplorer/target.h>
#include <utils/fancymainwindow.h>
......@@ -425,7 +426,7 @@ bool AnalyzerManagerPrivate::isActionRunnable(AnalyzerAction *action) const
return true;
ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
return pe->canRun(pe->startupProject(), action->tool()->runMode());
return pe->canRun(SessionManager::startupProject(), action->tool()->runMode());
}
void AnalyzerManagerPrivate::startTool()
......@@ -578,7 +579,7 @@ void AnalyzerManagerPrivate::saveToolSettings(AnalyzerAction *action)
void AnalyzerManagerPrivate::updateRunActions()
{
ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
Project *project = pe->startupProject();
Project *project = SessionManager::startupProject();
QString disabledReason;
if (m_isRunning)
......
......@@ -65,6 +65,7 @@
#include <QFileDialog>
#include <QTimer>
using namespace ProjectExplorer;
using namespace Android;
using namespace Android::Internal;
......@@ -78,15 +79,14 @@ bool checkPackageName(const QString &packageName)
return QRegExp(packageNameRegExp).exactMatch(packageName);
}
ProjectExplorer::Project *androidProject(const QString &file)
Project *androidProject(const QString &file)
{
ProjectExplorer::SessionManager *session = ProjectExplorer::ProjectExplorerPlugin::instance()->session();
Utils::FileName fileName = Utils::FileName::fromString(file);
foreach (ProjectExplorer::Project *project, session->projects()) {
foreach (Project *project, SessionManager::projects()) {
if (!project->activeTarget())
continue;
ProjectExplorer::Kit *kit = project->activeTarget()->kit();
if (ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(kit) == Constants::ANDROID_DEVICE_TYPE
Kit *kit = project->activeTarget()->kit();
if (DeviceTypeKitInformation::deviceTypeId(kit) == Android::Constants::ANDROID_DEVICE_TYPE
&& fileName.isChildOf(Utils::FileName::fromString(project->projectDirectory())))
return project;
}
......
......@@ -355,7 +355,7 @@ BookmarkManager::BookmarkManager() :
connect(Core::ICore::instance(), SIGNAL(contextChanged(QList<Core::IContext*>,Core::Context)),
this, SLOT(updateActionStatus()));
connect(ProjectExplorerPlugin::instance()->session(), SIGNAL(sessionLoaded(QString)),
connect(SessionManager::instance(), SIGNAL(sessionLoaded(QString)),
this, SLOT(loadBookmarks()));
updateActionStatus();
......@@ -645,12 +645,6 @@ TextEditor::ITextEditor *BookmarkManager::currentTextEditor() const
return qobject_cast<TextEditor::ITextEditor *>(currEditor);
}
/* Returns the current session. */
SessionManager *BookmarkManager::sessionManager() const
{
return ProjectExplorerPlugin::instance()->session();
}
BookmarkManager::State BookmarkManager::state() const
{
if (m_bookmarksMap.empty())
......@@ -826,7 +820,7 @@ void BookmarkManager::saveBookmarks()
foreach (const Bookmark *bookmark, m_bookmarksList)
list << bookmarkToString(bookmark);
sessionManager()->setValue(QLatin1String("Bookmarks"), list);
SessionManager::setValue(QLatin1String("Bookmarks"), list);
}
void BookmarkManager::operateTooltip(TextEditor::ITextEditor *textEditor, const QPoint &pos, Bookmark *mark)
......@@ -844,7 +838,7 @@ void BookmarkManager::operateTooltip(TextEditor::ITextEditor *textEditor, const
void BookmarkManager::loadBookmarks()
{
removeAllBookmarks();
const QStringList &list = sessionManager()->value(QLatin1String("Bookmarks")).toStringList();
const QStringList &list = SessionManager::value(QLatin1String("Bookmarks")).toStringList();
foreach (const QString &bookmarkString, list)
addBookmark(bookmarkString);
......
......@@ -42,14 +42,6 @@
#include <QPixmap>
#include <QStyledItemDelegate>
namespace ProjectExplorer {
class SessionManager;
}
namespace Core {
class IEditor;
}
namespace Bookmarks {
namespace Internal {
......@@ -124,7 +116,6 @@ private slots:
private:
TextEditor::ITextEditor *currentTextEditor() const;
ProjectExplorer::SessionManager* sessionManager() const;
void documentPrevNext(bool next);
......
......@@ -227,8 +227,7 @@ void Manager::initialize()
connect(this, SIGNAL(stateChanged(bool)), SLOT(onStateChanged(bool)), Qt::QueuedConnection);
// connections to enable/disable navi widget factory
ProjectExplorer::SessionManager *sessionManager =
ProjectExplorer::ProjectExplorerPlugin::instance()->session();
QObject *sessionManager = ProjectExplorer::SessionManager::instance();
connect(sessionManager, SIGNAL(projectAdded(ProjectExplorer::Project*)),
SLOT(onProjectListChanged()), Qt::QueuedConnection);
connect(sessionManager, SIGNAL(projectRemoved(ProjectExplorer::Project*)),
......
......@@ -58,6 +58,8 @@
enum { debug = false };
using namespace ProjectExplorer;
namespace ClassView {
namespace Internal {
......@@ -274,8 +276,7 @@ ParserTreeItem::ConstPtr Parser::parse()
ParserTreeItem::Ptr rootItem(new ParserTreeItem());
// check all projects
QList<ProjectExplorer::Project *> projects = getProjectList();
foreach (const ProjectExplorer::Project *prj, projects) {
foreach (const Project *prj, SessionManager::projects()) {
if (!prj)
continue;
......@@ -293,7 +294,7 @@ ParserTreeItem::ConstPtr Parser::parse()
if (d->flatMode) {
// use prj path (prjType) as a project id
// addProject(item, prj->files(ProjectExplorer::Project::ExcludeGeneratedFiles), prjType);
// addProject(item, prj->files(Project::ExcludeGeneratedFiles), prjType);
//! \todo return back, works too long
ParserTreeItem::Ptr flatItem = createFlatTree(projectList);
item.swap(flatItem);
......@@ -673,10 +674,9 @@ void Parser::resetData(const CPlusPlus::Snapshot &snapshot)
QStringList fileList;
// check all projects
QList<ProjectExplorer::Project *> projects = getProjectList();
foreach (const ProjectExplorer::Project *prj, projects) {
foreach (const Project *prj, SessionManager::projects()) {
if (prj)
fileList += prj->files(ProjectExplorer::Project::ExcludeGeneratedFiles);
fileList += prj->files(Project::ExcludeGeneratedFiles);
}
setFileList(fileList);
......@@ -819,22 +819,5 @@ QStringList Parser::addProjectNode(const ParserTreeItem::Ptr &item,
return projectList;
}
/*!
Returns the current project list.
*/
QList<ProjectExplorer::Project *> Parser::getProjectList() const
{
QList<ProjectExplorer::Project *> list;
// check all projects
ProjectExplorer::SessionManager *sessionManager
= ProjectExplorer::ProjectExplorerPlugin::instance()->session();
list = sessionManager->projects();
return list;
}
} // namespace Internal
} // namespace ClassView
......@@ -118,8 +118,6 @@ protected:
QStringList projectNodeFileList(const ProjectExplorer::FolderNode *node) const;
QList<ProjectExplorer::Project *> getProjectList() const;
ParserTreeItem::Ptr createFlatTree(const QStringList &projectList);
private:
......
......@@ -94,9 +94,7 @@ void CMakeEditor::markAsChanged()
void CMakeEditor::build()
{
QList<ProjectExplorer::Project *> projects =
ProjectExplorer::ProjectExplorerPlugin::instance()->session()->projects();
foreach (ProjectExplorer::Project *p, projects) {
foreach (ProjectExplorer::Project *p, ProjectExplorer::SessionManager::projects()) {
CMakeProject *cmakeProject = qobject_cast<CMakeProject *>(p);
if (cmakeProject) {
if (cmakeProject->isProjectFile(document()->filePath())) {
......
......@@ -41,6 +41,7 @@
using namespace CMakeProjectManager;
using namespace CMakeProjectManager::Internal;
using namespace ProjectExplorer;
using namespace Utils;
CMakeLocatorFilter::CMakeLocatorFilter()
......@@ -49,10 +50,9 @@ CMakeLocatorFilter::CMakeLocatorFilter()
setDisplayName(tr("Build CMake target"));
setShortcutString(QLatin1String("cm"));
ProjectExplorer::SessionManager *sm = ProjectExplorer::ProjectExplorerPlugin::instance()->session();
connect(sm, SIGNAL(projectAdded(ProjectExplorer::Project*)),
connect(SessionManager::instance(), SIGNAL(projectAdded(ProjectExplorer::Project*)),
this, SLOT(slotProjectListUpdated()));
connect(sm, SIGNAL(projectRemoved(ProjectExplorer::Project*)),
connect(SessionManager::instance(), SIGNAL(projectRemoved(ProjectExplorer::Project*)),
this, SLOT(slotProjectListUpdated()));
// Initialize the filter
......@@ -69,9 +69,7 @@ QList<Locator::FilterEntry> CMakeLocatorFilter::matchesFor(QFutureInterface<Loca
Q_UNUSED(future)
QList<Locator::FilterEntry> result;
QList<ProjectExplorer::Project *> projects =
ProjectExplorer::ProjectExplorerPlugin::instance()->session()->projects();
foreach (ProjectExplorer::Project *p, projects) {
foreach (Project *p, SessionManager::projects()) {
CMakeProject *cmakeProject = qobject_cast<CMakeProject *>(p);
if (cmakeProject) {
foreach (const CMakeBuildTarget &ct, cmakeProject->buildTargets()) {
......@@ -93,9 +91,7 @@ void CMakeLocatorFilter::accept(Locator::FilterEntry selection) const
// Get the project containing the target selected
CMakeProject *cmakeProject = 0;
QList<ProjectExplorer::Project *> projects =
ProjectExplorer::ProjectExplorerPlugin::instance()->session()->projects();
foreach (ProjectExplorer::Project *p, projects) {
foreach (Project *p, SessionManager::projects()) {
cmakeProject = qobject_cast<CMakeProject *>(p);
if (cmakeProject && cmakeProject->projectFilePath() == selection.internalData.toString())
break;
......@@ -136,9 +132,7 @@ void CMakeLocatorFilter::slotProjectListUpdated()
{
CMakeProject *cmakeProject = 0;
QList<ProjectExplorer::Project *> projects =
ProjectExplorer::ProjectExplorerPlugin::instance()->session()->projects();
foreach (ProjectExplorer::Project *p, projects) {
foreach (Project *p, SessionManager::projects()) {
cmakeProject = qobject_cast<CMakeProject *>(p);
if (cmakeProject)
break;
......
......@@ -240,24 +240,18 @@ CppModelManager::CppModelManager(QObject *parent)
m_dirty = true;
ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin::instance();
QTC_ASSERT(pe, return);
m_delayedGcTimer = new QTimer(this);
m_delayedGcTimer->setSingleShot(true);
connect(m_delayedGcTimer, SIGNAL(timeout()), this, SLOT(GC()));
ProjectExplorer::SessionManager *session = pe->session();
connect(session, SIGNAL(projectAdded(ProjectExplorer::Project*)),
QObject *sessionManager = ProjectExplorer::SessionManager::instance();
connect(sessionManager, SIGNAL(projectAdded(ProjectExplorer::Project*)),
this, SLOT(onProjectAdded(ProjectExplorer::Project*)));
connect(session, SIGNAL(aboutToRemoveProject(ProjectExplorer::Project*)),
connect(sessionManager, SIGNAL(aboutToRemoveProject(ProjectExplorer::Project*)),
this, SLOT(onAboutToRemoveProject(ProjectExplorer::Project*)));
connect(session, SIGNAL(aboutToLoadSession(QString)),
connect(sessionManager, SIGNAL(aboutToLoadSession(QString)),
this, SLOT(onAboutToLoadSession()));
connect(session, SIGNAL(aboutToUnloadSession(QString)),
connect(sessionManager, SIGNAL(aboutToUnloadSession(QString)),
this, SLOT(onAboutToUnloadSession()));
connect(Core::ICore::instance(), SIGNAL(coreAboutToClose()),
......
......@@ -49,12 +49,12 @@
#endif
using namespace CppTools::Internal;
using namespace ProjectExplorer;
typedef CPlusPlus::Document Document;
typedef CppTools::CppModelManagerInterface::ProjectInfo ProjectInfo;
typedef CppTools::ProjectPart ProjectPart;
typedef CppTools::ProjectFile ProjectFile;
typedef ProjectExplorer::Project Project;
Q_DECLARE_METATYPE(QList<ProjectFile>)
......@@ -119,7 +119,7 @@ class ExampleProjectConfigurator
{
public:
ExampleProjectConfigurator(const QString &projectFile,
ProjectExplorer::ProjectExplorerPlugin *projectExplorer)
ProjectExplorerPlugin *projectExplorer)
{
const QString projectUserFile = projectFile + QLatin1String(".user");
QVERIFY(!QFileInfo(projectUserFile).exists());
......@@ -142,13 +142,13 @@ public:
QVERIFY(QFile::remove(m_fileToRemove));
}
ProjectExplorer::Project *project() const
Project *project() const
{
return m_project;
}
private:
ProjectExplorer::Project *m_project;
Project *m_project;
QString m_fileToRemove;
};
......@@ -661,7 +661,7 @@ void CppToolsPlugin::test_modelmanager_extraeditorsupport_uiFiles()
const QString projectFile = testDataDirectory.file(QLatin1String("testdata_guiproject1.pro"));
// Open project with *.ui file
ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin::instance();
ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
ExampleProjectConfigurator exampleProjectConfigurator(projectFile, pe);
Project *project = exampleProjectConfigurator.project();
......@@ -698,8 +698,7 @@ void CppToolsPlugin::test_modelmanager_extraeditorsupport_uiFiles()
QCOMPARE(QFileInfo(includedFiles.at(1)).fileName(), QLatin1String("ui_mainwindow.h"));
// Close Project
ProjectExplorer::SessionManager *sm = pe->session();
sm->removeProject(project);
SessionManager::removeProject(project);
helper.waitForFinishedGc();
}
......
......@@ -133,10 +133,8 @@ void SymbolsFindFilter::startSearch(Find::SearchResult *search)
SymbolSearcher::Parameters parameters = search->userData().value<SymbolSearcher::Parameters>();
QSet<QString> projectFileNames;
if (parameters.scope == SymbolSearcher::SearchProjectsOnly) {
foreach (ProjectExplorer::Project *project,
ProjectExplorer::ProjectExplorerPlugin::instance()->session()->projects()) {
foreach (ProjectExplorer::Project *project, ProjectExplorer::SessionManager::projects())
projectFileNames += project->files(ProjectExplorer::Project::AllFiles).toSet();
}
}
QFutureWatcher<Find::SearchResultItem> *watcher = new QFutureWatcher<Find::SearchResultItem>();
......
......@@ -48,7 +48,6 @@
#include <coreplugin/rightpane.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/runconfiguration.h>
#include <projectexplorer/session.h>
#include <projectexplorer/target.h>
......@@ -469,8 +468,7 @@ void DebuggerMainWindow::addStagedMenuEntries()
QWidget *DebuggerMainWindow::createContents(IMode *mode)
{
ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
connect(pe->session(), SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
connect(SessionManager::instance(), SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
d, SLOT(updateUiForProject(ProjectExplorer::Project*)));
d->m_viewsMenu = Core::ActionManager::actionContainer(Core::Id(Core::Constants::M_WINDOW_VIEWS));
......
......@@ -425,11 +425,6 @@ void addTcfOptionPages(QList<IOptionsPage*> *opts);
void addLldbOptionPages(QList<IOptionsPage*> *opts);
#endif
static SessionManager *sessionManager()
{
return ProjectExplorerPlugin::instance()->session();
}
static QToolButton *toolButton(QAction *action)
{
QToolButton *button = new QToolButton;
......@@ -1565,23 +1560,20 @@ void DebuggerPluginPrivate::languagesChanged()
void DebuggerPluginPrivate::debugProject()
{
ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
if (Project *pro = pe->startupProject())
pe->runProject(pro, DebugRunMode);
if (Project *pro = SessionManager::startupProject())
ProjectExplorerPlugin::instance()->runProject(pro, DebugRunMode);
}
void DebuggerPluginPrivate::debugProjectWithoutDeploy()
{
ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
if (Project *pro = pe->startupProject())
pe->runProject(pro, DebugRunMode, true);
if (Project *pro = SessionManager::startupProject())
ProjectExplorerPlugin::instance()->runProject(pro, DebugRunMode, true);
}
void DebuggerPluginPrivate::debugProjectBreakMain()
{
ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
if (Project *pro = pe->startupProject())
pe->runProject(pro, DebugRunModeWithBreakOnMain);
if (Project *pro = SessionManager::startupProject())
ProjectExplorerPlugin::instance()->runProject(pro, DebugRunModeWithBreakOnMain);
}
void DebuggerPluginPrivate::startAndDebugApplication()
......@@ -1776,11 +1768,10 @@ void DebuggerPluginPrivate::attachToQmlPort()
//
// get files from all the projects in the session
//
SessionManager *sessionManager = ProjectExplorerPlugin::instance()->session();
QList<Project *> projects = sessionManager->projects();
if (Project *startupProject = ProjectExplorerPlugin::instance()->startupProject()) {
QList<Project *> projects = SessionManager::projects();
if (Project *startupProject = SessionManager::startupProject()) {
// startup project first
projects.removeOne(ProjectExplorerPlugin::instance()->startupProject());
projects.removeOne(startupProject);
projects.insert(0, startupProject);
}
QStringList sourceFiles;
......@@ -2354,7 +2345,7 @@ void DebuggerPluginPrivate::updateDebugActions()
return;
ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
Project *project = pe->startupProject();
Project *project = SessionManager::startupProject();
const bool canRun = pe->canRun(project, DebugRunMode);
m_startAction->setEnabled(canRun);
m_startAction->setToolTip(canRun ? QString() : pe->cannotRunReason(project, DebugRunMode));
......@@ -2507,14 +2498,12 @@ const CPlusPlus::Snapshot &DebuggerPluginPrivate::cppCodeModelSnapshot() const
void DebuggerCore::setSessionValue(const QByteArray &key, const QVariant &value)
{
QTC_ASSERT(sessionManager(), return);
sessionManager()->setValue(QString::fromUtf8(key), value);
SessionManager::setValue(QString::fromUtf8(key), value);
}
QVariant DebuggerCore::sessionValue(const QByteArray &key)
{
QTC_ASSERT(sessionManager(), return QVariant());
return sessionManager()->value(QString::fromUtf8(key));
return SessionManager::value(QString::fromUtf8(key));
}
void DebuggerPluginPrivate::openTextEditor(const QString &titlePattern0,
......@@ -3198,11 +3187,11 @@ void DebuggerPluginPrivate::extensionsInitialized()
SLOT(fontSettingsChanged(TextEditor::FontSettings)));
// ProjectExplorer
connect(sessionManager(), SIGNAL(sessionLoaded(QString)),
connect(SessionManager::instance(), SIGNAL(sessionLoaded(QString)),
SLOT(sessionLoaded()));
connect(sessionManager(), SIGNAL(aboutToSaveSession()),
connect(SessionManager::instance(), SIGNAL(aboutToSaveSession()),
SLOT(aboutToSaveSession()));
connect(sessionManager(), SIGNAL(aboutToUnloadSession(QString)),
connect(SessionManager::instance(), SIGNAL(aboutToUnloadSession(QString)),
SLOT(aboutToUnloadSession()));
connect(ProjectExplorerPlugin::instance(), SIGNAL(updateRunActions()),
SLOT(updateDebugActions()));
......@@ -3273,7 +3262,7 @@ void DebuggerPluginPrivate::extensionsInitialized()
setInitialState();
connectEngine(0);
connect(sessionManager(),
connect(SessionManager::instance(),
SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
SLOT(onCurrentProjectChanged(ProjectExplorer::Project*)));
......@@ -3370,7 +3359,7 @@ void DebuggerPluginPrivate::showModuleSections(const QString &moduleName,
void DebuggerPluginPrivate::aboutToShutdown()
{
m_plugin->removeObject(this);
disconnect(sessionManager(),
disconnect(SessionManager::instance(),
SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
this, 0);
}
......
......@@ -50,8 +50,7 @@ static const char setupUiC[] = "setupUi";
// Find the generated "ui_form.h" header of the form via project.
static QString generatedHeaderOf(const QString &uiFileName)
{
const ProjectExplorer::SessionManager *sessionMgr = ProjectExplorer::ProjectExplorerPlugin::instance()->session();
if (const ProjectExplorer::Project *uiProject = sessionMgr->projectForFile(uiFileName))
if (const ProjectExplorer::Project *uiProject = ProjectExplorer::SessionManager::projectForFile(uiFileName))
return uiProject->generatedUiHeader(uiFileName);
return QString();
}
......
......@@ -60,6 +60,7 @@ enum { indentation = 4 };
using namespace Designer::Internal;
using namespace CPlusPlus;
using namespace TextEditor;
using namespace ProjectExplorer;
static QString msgClassNotFound(const QString &uiClassName, const QList<Document::Ptr> &docList)
{
......@@ -535,12 +536,11 @@ bool QtCreatorIntegration::navigateToSlot(const QString &objectName,
// Retrieve code model snapshot restricted to project of ui file or the working copy.
Snapshot docTable = CppTools::CppModelManagerInterface::instance()->snapshot();
Snapshot newDocTable;
ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin::instance();
const ProjectExplorer::Project *uiProject = pe->session()->projectForFile(currentUiFile);
const Project *uiProject = SessionManager::projectForFile(currentUiFile);
if (uiProject) {
Snapshot::const_iterator end = docTable.end();
for (Snapshot::iterator it = docTable.begin(); it != end; ++it) {
const ProjectExplorer::Project *project = pe->session()->projectForFile(it.key());
const Project *project = SessionManager::projectForFile(it.key());
if (project == uiProject)
newDocTable.insert(it.value());
}
......
......@@ -45,10 +45,7 @@
#include <utils/qtcassert.h>
using ProjectExplorer::NodesVisitor;
using ProjectExplorer::ProjectNode;
using ProjectExplorer::FolderNode;
using ProjectExplorer::FileNode;
using namespace ProjectExplorer;
namespace Designer {
namespace Internal {
......@@ -100,8 +97,8 @@ void ResourceHandler::ensureInitialized()
{
if (m_sessionNode)
return;
ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin::instance();
m_sessionNode = pe->session()->sessionNode();
m_sessionNode = ProjectExplorer::SessionManager::sessionNode();
m_sessionWatcher = new ProjectExplorer::NodesWatcher();
connect(m_sessionWatcher, SIGNAL(filesAdded()), this, SLOT(updateResources()));
......@@ -137,9 +134,8 @@ void ResourceHandler::updateResources()
if (Designer::Constants::Internal::debug)
qDebug() << "ResourceHandler::updateResources()" << fileName;
ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin::instance();
// filename could change in the meantime.
ProjectExplorer::Project *project = pe->session()->projectForFile(fileName);
// Filename could change in the meantime.
Project *project = SessionManager::projectForFile(fileName);
// Does the file belong to a project?
if (project) {
......
......@@ -107,12 +107,12 @@ MaemoQemuManager::MaemoQemuManager(QObject *parent)
this, SLOT(qtVersionsChanged(QList<int>,QList<int>,QList<int>)));
// listen to project add, remove and startup changes to udate start button
SessionManager *session = ProjectExplorerPlugin::instance()->session();
connect(session, SIGNAL(projectAdded(ProjectExplorer::Project*)), this,
QObject *sessionManager = SessionManager::instance();
connect(sessionManager, SIGNAL(projectAdded(ProjectExplorer::Project*)), this,
SLOT(projectAdded(ProjectExplorer::Project*)));
connect(session, SIGNAL(projectRemoved(ProjectExplorer::Project*)), this,
connect(sessionManager, SIGNAL(projectRemoved(ProjectExplorer::Project*)), this,
SLOT(projectRemoved(ProjectExplorer::Project*)));
connect(session, SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
connect(sessionManager, SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
this, SLOT(projectChanged(ProjectExplorer::Project*)));
connect(m_qemuProcess, SIGNAL(error(QProcess::ProcessError)), this,
......@@ -283,10 +283,8 @@ void MaemoQemuManager::systemChanged()
void MaemoQemuManager::environmentChanged()
{
// likely to happen when the Qt version changes the build config is using
if (ProjectExplorerPlugin *explorer = ProjectExplorerPlugin::instance()) {
if (Project *project = explorer->session()->startupProject())
toggleStarterButton(project->activeTarget());
}
if (Project *project = SessionManager::startupProject())
toggleStarterButton(project->activeTarget());
}
void MaemoQemuManager::deviceConfigurationChanged(ProjectExplorer::Target *target)
......@@ -297,7 +295,7 @@ void MaemoQemuManager::deviceConfigurationChanged(ProjectExplorer::Target *targe
void MaemoQemuManager::startRuntime()
{
m_userTerminated = false;
Project *p = ProjectExplorerPlugin::instance()->session()->startupProject();
Project *p = SessionManager::startupProject();
if (!p)
return;
BaseQtVersion *version;
......@@ -470,8 +468,7 @@ void MaemoQemuManager::toggleStarterButton(Target *target)
if (m_runningQtId == uniqueId)
isRunning = false;
const Project * const p
= ProjectExplorerPlugin::instance()->session()->startupProject();
const Project * const p = SessionManager::startupProject();
const bool qemuButtonEnabled
= p && p->activeTarget() && MaemoGlobal::hasMaemoDevice(target->kit())
&& m_runtimes.value(uniqueId, MaemoQemuRuntime()).isValid()
......@@ -482,9 +479,7 @@ void MaemoQemuManager::toggleStarterButton(Target *target)
bool MaemoQemuManager::sessionHasMaemoTarget() const
{
ProjectExplorerPlugin *explorer = ProjectExplorerPlugin::instance();
const QList<Project*> &projects = explorer->session()->projects();
foreach (const Project *p, projects) {
foreach (const Project *p, SessionManager::projects()) {
foreach (const Target * const target, p->targets()) {
if (MaemoGlobal::hasMaemoDevice(target->kit()))
return true;
......
......@@ -37,8 +37,7 @@ using namespace Locator;
using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;
AllProjectsFilter::AllProjectsFilter(ProjectExplorerPlugin *pe)
: m_projectExplorer(pe), m_filesUpToDate(false)
AllProjectsFilter::AllProjectsFilter() : m_filesUpToDate(false)
{
setId("Files in any project");
setDisplayName(tr("Files in Any Project"));
......@@ -46,7 +45,7 @@ AllProjectsFilter::AllProjectsFilter(ProjectExplorerPlugin *pe)
setPriority(Low);
setIncludedByDefault(true);
connect(m_projectExplorer, SIGNAL(fileListChanged()),
connect(ProjectExplorerPlugin::instance(), SIGNAL(fileListChanged()),
this, SLOT(markFilesAsOutOfDate()));
}
......@@ -61,7 +60,7 @@ void AllProjectsFilter::updateFiles()
return;
m_filesUpToDate = true;
files().clear();
foreach (Project *project, m_projectExplorer->session()->projects())
foreach (Project *project, SessionManager::projects())
files().append(project->files(Project::AllFiles));
qSort(files());
generateFileNames();
......
......@@ -35,9 +35,6 @@
#include <QFutureInterface>
namespace ProjectExplorer {
class ProjectExplorerPlugin;
namespace Internal {
class AllProjectsFilter : public Locator::BaseFileFilter
......@@ -45,7 +42,7 @@ class AllProjectsFilter : public Locator::BaseFileFilter
Q_OBJECT
public: