Rename SessionManager::clear() to closeAllProjects()

Also move the editor closing out of the function. It isn't needed on
shutdown as all editors are already closed then.

Change-Id: Ie50a238e0a0382a99b0a267b286f9ed9484f26f6
Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
This commit is contained in:
Daniel Teske
2012-02-10 12:55:15 +01:00
parent aa7efa417d
commit 854fbd1e41
3 changed files with 17 additions and 31 deletions

View File

@@ -172,7 +172,7 @@ struct ProjectExplorerPluginPrivate {
QAction *m_newAction; QAction *m_newAction;
QAction *m_loadAction; QAction *m_loadAction;
Utils::ParameterAction *m_unloadAction; Utils::ParameterAction *m_unloadAction;
QAction *m_clearSession; QAction *m_closeAllProjects;
QAction *m_buildProjectOnlyAction; QAction *m_buildProjectOnlyAction;
Utils::ParameterAction *m_buildAction; Utils::ParameterAction *m_buildAction;
Utils::ParameterAction *m_buildActionContextMenu; Utils::ParameterAction *m_buildActionContextMenu;
@@ -645,8 +645,8 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
mfile->addAction(cmd, Core::Constants::G_FILE_PROJECT); mfile->addAction(cmd, Core::Constants::G_FILE_PROJECT);
// unload session action // unload session action
d->m_clearSession = new QAction(tr("Close All Projects"), this); d->m_closeAllProjects = new QAction(tr("Close All Projects"), this);
cmd = am->registerAction(d->m_clearSession, Constants::CLEARSESSION, globalcontext); cmd = am->registerAction(d->m_closeAllProjects, Constants::CLEARSESSION, globalcontext);
mfile->addAction(cmd, Core::Constants::G_FILE_PROJECT); mfile->addAction(cmd, Core::Constants::G_FILE_PROJECT);
msessionContextMenu->addAction(cmd, Constants::G_SESSION_FILES); msessionContextMenu->addAction(cmd, Constants::G_SESSION_FILES);
@@ -983,7 +983,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
connect(d->m_runWithoutDeployAction, SIGNAL(triggered()), this, SLOT(runProjectWithoutDeploy())); connect(d->m_runWithoutDeployAction, SIGNAL(triggered()), this, SLOT(runProjectWithoutDeploy()));
connect(d->m_cancelBuildAction, SIGNAL(triggered()), this, SLOT(cancelBuild())); connect(d->m_cancelBuildAction, SIGNAL(triggered()), this, SLOT(cancelBuild()));
connect(d->m_unloadAction, SIGNAL(triggered()), this, SLOT(unloadProject())); connect(d->m_unloadAction, SIGNAL(triggered()), this, SLOT(unloadProject()));
connect(d->m_clearSession, SIGNAL(triggered()), this, SLOT(clearSession())); connect(d->m_closeAllProjects, SIGNAL(triggered()), this, SLOT(closeAllProjects()));
connect(d->m_addNewFileAction, SIGNAL(triggered()), this, SLOT(addNewFile())); connect(d->m_addNewFileAction, SIGNAL(triggered()), this, SLOT(addNewFile()));
connect(d->m_addExistingFilesAction, SIGNAL(triggered()), this, SLOT(addExistingFiles())); connect(d->m_addExistingFilesAction, SIGNAL(triggered()), this, SLOT(addExistingFiles()));
connect(d->m_addNewSubprojectAction, SIGNAL(triggered()), this, SLOT(addNewSubproject())); connect(d->m_addNewSubprojectAction, SIGNAL(triggered()), this, SLOT(addNewSubproject()));
@@ -1098,13 +1098,15 @@ void ProjectExplorerPlugin::unloadProject()
updateActions(); updateActions();
} }
void ProjectExplorerPlugin::clearSession() void ProjectExplorerPlugin::closeAllProjects()
{ {
if (debug) if (debug)
qDebug() << "ProjectExplorerPlugin::clearSession"; qDebug() << "ProjectExplorerPlugin::closeAllProject";
if (!d->m_session->clear()) if (!ICore::editorManager()->closeAllEditors())
return; // Action has been cancelled return; // Action has been cancelled
d->m_session->closeAllProjects();
updateActions(); updateActions();
} }
@@ -1158,7 +1160,7 @@ void ProjectExplorerPlugin::updateRunWithoutDeployMenu()
ExtensionSystem::IPlugin::ShutdownFlag ProjectExplorerPlugin::aboutToShutdown() ExtensionSystem::IPlugin::ShutdownFlag ProjectExplorerPlugin::aboutToShutdown()
{ {
d->m_proWindow->aboutToShutdown(); // disconnect from session d->m_proWindow->aboutToShutdown(); // disconnect from session
d->m_session->clear(); d->m_session->closeAllProjects();
d->m_projectsMode = 0; d->m_projectsMode = 0;
// Attempt to synchronously shutdown all run controls. // Attempt to synchronously shutdown all run controls.
// If that fails, fall back to asynchronous shutdown (Debugger run controls // If that fails, fall back to asynchronous shutdown (Debugger run controls
@@ -1719,7 +1721,7 @@ void ProjectExplorerPlugin::updateActions()
d->m_cleanProjectOnlyAction->setToolTip(buildActionState.second); d->m_cleanProjectOnlyAction->setToolTip(buildActionState.second);
// Session actions // Session actions
d->m_clearSession->setEnabled(!d->m_session->projects().isEmpty()); d->m_closeAllProjects->setEnabled(!d->m_session->projects().isEmpty());
d->m_buildSessionAction->setEnabled(buildSessionState.first); d->m_buildSessionAction->setEnabled(buildSessionState.first);
d->m_rebuildSessionAction->setEnabled(buildSessionState.first); d->m_rebuildSessionAction->setEnabled(buildSessionState.first);

View File

@@ -372,31 +372,15 @@ bool SessionManager::save()
return result; return result;
} }
/*! /*!
\fn bool SessionManager::clear() \fn bool SessionManager::closeAllProjects()
Returns whether the clear operation has been not cancelled & all projects could be closed. Closes all projects
*/ */
bool SessionManager::clear() void SessionManager::closeAllProjects()
{ {
if (debug) setStartupProject(0);
qDebug() << "SessionManager - clearing session ..."; removeProjects(projects());
bool success = ICore::editorManager()->closeAllEditors();
if (success) {
if (debug)
qDebug() << "SessionManager - Removing projects ...";
setStartupProject(0);
removeProjects(projects());
}
if (debug)
qDebug() << "SessionManager - clearing session result is " << success;
return success;
} }
const QList<Project *> &SessionManager::projects() const const QList<Project *> &SessionManager::projects() const

View File

@@ -84,7 +84,7 @@ public:
bool loadSession(const QString &session); bool loadSession(const QString &session);
bool save(); bool save();
bool clear(); void closeAllProjects();
void addProject(Project *project); void addProject(Project *project);
void addProjects(const QList<Project*> &projects); void addProjects(const QList<Project*> &projects);