diff --git a/src/plugins/projectexplorer/pluginfilefactory.cpp b/src/plugins/projectexplorer/pluginfilefactory.cpp index 46afc56a48a8f524099150e2d6757e0f5b24faf3..9be86c04bcfd445fae8a4f687e1872a55ea0b664 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 0b8177b7b4491551f143c39df1e67ac9f42a7e96..3989297c8dec3264ceeee78627bd88513529e4f9 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 857ac2cbbc3131afb32893c9938f13dbcfa73057..02f7a4dec22b4bfa969783751b9370ecfff84926 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;