From 81b37f0215f68bb58fb61d1692bf9f20229a5110 Mon Sep 17 00:00:00 2001 From: dt <qtc-committer@nokia.com> Date: Tue, 11 Jan 2011 19:30:25 +0100 Subject: [PATCH] ProjectExplorer: Always give feedback on failed project loading Task-Nr: QTCREATORBUG-3435 --- .../projectexplorer/pluginfilefactory.cpp | 12 +---- .../projectexplorer/projectexplorer.cpp | 45 ++++++++++--------- src/plugins/projectexplorer/projectexplorer.h | 3 +- 3 files changed, 27 insertions(+), 33 deletions(-) diff --git a/src/plugins/projectexplorer/pluginfilefactory.cpp b/src/plugins/projectexplorer/pluginfilefactory.cpp index 46afc56a48a..9be86c04bcf 100644 --- a/src/plugins/projectexplorer/pluginfilefactory.cpp +++ b/src/plugins/projectexplorer/pluginfilefactory.cpp @@ -71,17 +71,9 @@ QString ProjectFileFactory::displayName() const Core::IFile *ProjectFileFactory::open(const QString &fileName) { - Core::IFile *fIFace = 0; - ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance(); - if (!pe->openProject(fileName)) { - Core::ICore::instance()->messageManager()->printToOutputPane(tr("Could not open the following project: '%1'").arg(fileName)); - } else if (pe->session()) { - SessionManager *session = pe->session(); - if (session->projects().count() == 1) - fIFace = session->projects().first()->file(); - } - return fIFace; + pe->openProject(fileName); + return 0; } QList<ProjectFileFactory *> ProjectFileFactory::createFactories(QString *filterString) diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 0b8177b7b44..3989297c8de 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -887,19 +887,6 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er return true; } -ProjectFileFactory *ProjectExplorerPlugin::findProjectFileFactory(const QString &filename) const -{ - // Find factory - if (const Core::MimeType mt = Core::ICore::instance()->mimeDatabase()->findByFile(QFileInfo(filename))) { - const QString mimeType = mt.type(); - foreach (ProjectFileFactory *f, d->m_fileFactories) - if (f->mimeTypes().contains(mimeType)) - return f; - } - qWarning("Unable to find project file factory for '%s'", filename.toUtf8().constData()); - return 0; -} - void ProjectExplorerPlugin::loadAction() { if (debug) @@ -923,8 +910,7 @@ void ProjectExplorerPlugin::loadAction() d->m_projectFilterString); if (filename.isEmpty()) return; - if (ProjectFileFactory *pf = findProjectFileFactory(filename)) - pf->open(filename); + loadProject(filename); updateActions(); } @@ -1110,6 +1096,18 @@ void ProjectExplorerPlugin::savePersistentSettings() } } +void ProjectExplorerPlugin::loadProject(const QString &project) +{ + if (!openProject(project)) { + QMessageBox box(QMessageBox::Warning, + tr("Failed to open project"), + tr("Failed to open project:\n%1").arg(project), + QMessageBox::Ok, + Core::ICore::instance()->mainWindow()); + box.exec(); + } +} + bool ProjectExplorerPlugin::openProject(const QString &fileName) { if (debug) @@ -1161,11 +1159,8 @@ QList<Project *> ProjectExplorerPlugin::openProjects(const QStringList &fileName } updateActions(); - if (openedPro.isEmpty()) { - qDebug() << "ProjectExplorerPlugin - Could not open any projects!"; - } else { + if (!openedPro.isEmpty()) Core::ModeManager::instance()->activateMode(Core::Constants::MODE_EDIT); - } return openedPro; } @@ -1984,8 +1979,16 @@ void ProjectExplorerPlugin::openRecentProject() if (!a) return; QString fileName = a->data().toString(); - if (!fileName.isEmpty()) - openProject(fileName); + if (!fileName.isEmpty()) { + if (!openProject(fileName)) { + QMessageBox box(QMessageBox::Warning, + tr("Failed to open project"), + tr("Failed to open project:\n%1").arg(fileName), + QMessageBox::Ok, + Core::ICore::instance()->mainWindow()); + box.exec(); + } + } } void ProjectExplorerPlugin::invalidateProject(Project *project) diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index 857ac2cbbc3..02f7a4dec22 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -205,7 +205,7 @@ private slots: void updateDeployActions(); void slotUpdateRunActions(); - void loadProject(const QString &project) { openProject(project); } + void loadProject(const QString &project); void currentModeChanged(Core::IMode *mode, Core::IMode *oldMode); void updateActions(); void loadCustomWizards(); @@ -245,7 +245,6 @@ private: void addToRecentProjects(const QString &fileName, const QString &displayName); void updateWelcomePage(); - Internal::ProjectFileFactory *findProjectFileFactory(const QString &filename) const; static ProjectExplorerPlugin *m_instance; ProjectExplorerPluginPrivate *d; -- GitLab