From 0402a3ff7f67ade40700b2105dfabe647fe0a73d Mon Sep 17 00:00:00 2001 From: Tobias Hunger <tobias.hunger@nokia.com> Date: Wed, 15 Sep 2010 16:40:41 +0200 Subject: [PATCH] Inform about projects in a session that failed to load Inform the user about projects that failed to load as part of a session. Reviewed-by: dt --- src/plugins/projectexplorer/session.cpp | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/plugins/projectexplorer/session.cpp b/src/plugins/projectexplorer/session.cpp index b71ff7f8e08..642dbdd8974 100644 --- a/src/plugins/projectexplorer/session.cpp +++ b/src/plugins/projectexplorer/session.cpp @@ -59,6 +59,7 @@ #include <QtGui/QApplication> #include <QtGui/QMainWindow> #include <QtGui/QMessageBox> +#include <QtGui/QPushButton> #include <QtCore/QTextCodec> namespace { @@ -83,6 +84,7 @@ public: void setFileName(const QString &fileName); QStringList failedProjectFileNames() const; + void clearFailedProjectFileNames(); public slots: void sessionLoadingProgress(); @@ -303,6 +305,11 @@ QStringList SessionFile::failedProjectFileNames() const return m_failedProjects; } +void SessionFile::clearFailedProjectFileNames() +{ + m_failedProjects.clear(); +} + Internal::SessionNodeImpl::SessionNodeImpl(SessionManager *manager) : ProjectExplorer::SessionNode(manager->currentSession(), manager) { @@ -629,6 +636,25 @@ bool SessionManager::loadImpl(const QString &fileName) // m_file->load() sets the m_file->startupProject // but doesn't emit this signal, so we do it here emit startupProjectChanged(m_file->m_startupProject); + + QStringList failedProjects = m_file->failedProjectFileNames(); + if (!failedProjects.isEmpty()) { + QString fileList = + QDir::toNativeSeparators(failedProjects.join(QLatin1String("<br>"))); + QMessageBox * box = new QMessageBox(QMessageBox::Warning, + tr("Failed to restore project files"), + tr("Could not restore the following project files:<br><b>%1</b>"). + arg(fileList)); + QPushButton * keepButton = new QPushButton(tr("Keep projects in Session"), box); + QPushButton * removeButton = new QPushButton(tr("Remove projects from Session"), box); + box->addButton(keepButton, QMessageBox::AcceptRole); + box->addButton(removeButton, QMessageBox::DestructiveRole); + + box->exec(); + + if (box->clickedButton() == removeButton) + m_file->clearFailedProjectFileNames(); + } } if (success) { -- GitLab