}
}
-ProjectExplorer::Project *CMakeManager::openProject(const QString &fileName)
+ProjectExplorer::Project *CMakeManager::openProject(const QString &fileName, QString *errorString)
{
+ Q_UNUSED(errorString)
// TODO check whether this project is already opened
return new CMakeProject(this, fileName);
}
public:
CMakeManager(CMakeSettingsPage *cmakeSettingsPage);
- virtual ProjectExplorer::Project *openProject(const QString &fileName);
+ virtual ProjectExplorer::Project *openProject(const QString &fileName, QString *errorString);
virtual QString mimeType() const;
QString cmakeExecutable() const;
#include "genericproject.h"
#include <coreplugin/icore.h>
-#include <coreplugin/messagemanager.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/session.h>
return QLatin1String(Constants::GENERICMIMETYPE);
}
-ProjectExplorer::Project *Manager::openProject(const QString &fileName)
+ProjectExplorer::Project *Manager::openProject(const QString &fileName, QString *errorString)
{
if (!QFileInfo(fileName).isFile())
return 0;
ProjectExplorer::ProjectExplorerPlugin *projectExplorer = ProjectExplorer::ProjectExplorerPlugin::instance();
foreach (ProjectExplorer::Project *pi, projectExplorer->session()->projects()) {
if (fileName == pi->file()->fileName()) {
- Core::MessageManager *messageManager = Core::ICore::instance()->messageManager();
- messageManager->printToOutputPanePopup(tr("Failed opening project '%1': Project already open")
- .arg(QDir::toNativeSeparators(fileName)));
+ if (errorString)
+ *errorString = tr("Failed opening project '%1': Project already open")
+ .arg(QDir::toNativeSeparators(fileName));
return 0;
}
}
Manager();
virtual QString mimeType() const;
- virtual ProjectExplorer::Project *openProject(const QString &fileName);
+ virtual ProjectExplorer::Project *openProject(const QString &fileName, QString *errorString);
void notifyChanged(const QString &fileName);
// Post-Generate: Open the project and the editors as desired
foreach(const Core::GeneratedFile &file, l) {
if (file.attributes() & Core::GeneratedFile::OpenProjectAttribute) {
- if (!ProjectExplorer::ProjectExplorerPlugin::instance()->openProject(file.path())) {
- if (errorMessage)
- *errorMessage = tr("The project %1 could not be opened.").
- arg(QDir::toNativeSeparators(file.path()));
+ if (!ProjectExplorer::ProjectExplorerPlugin::instance()->openProject(file.path(), errorMessage)) {
return false;
}
}
IProjectManager() {}
virtual QString mimeType() const = 0;
- virtual Project *openProject(const QString &fileName) = 0;
+ virtual Project *openProject(const QString &fileName, QString *errorString) = 0;
};
} // namespace ProjectExplorer
Core::IFile *ProjectFileFactory::open(const QString &fileName)
{
ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
- pe->openProject(fileName);
+ pe->openProject(fileName, 0);
return 0;
}
d->m_projectFilterString);
if (filename.isEmpty())
return;
- openProject(filename);
+ QString errorMessage;
+ openProject(filename, &errorMessage);
+
+ if (!errorMessage.isEmpty())
+ QMessageBox::critical(Core::ICore::instance()->mainWindow(), tr("Failed to open project"), errorMessage);
updateActions();
}
}
}
-bool ProjectExplorerPlugin::openProject(const QString &fileName)
+void ProjectExplorerPlugin::openProjectWelcomePage(const QString &fileName)
+{
+ QString errorMessage;
+ openProject(fileName, &errorMessage);
+ if (!errorMessage.isEmpty())
+ QMessageBox::critical(Core::ICore::instance()->mainWindow(), tr("Failed to open project"), errorMessage);
+}
+
+bool ProjectExplorerPlugin::openProject(const QString &fileName, QString *errorString)
{
if (debug)
qDebug() << "ProjectExplorerPlugin::openProject";
- QList<Project *> list = openProjects(QStringList() << fileName);
+ QList<Project *> list = openProjects(QStringList() << fileName, errorString);
if (!list.isEmpty()) {
addToRecentProjects(fileName, list.first()->displayName());
d->m_session->setStartupProject(list.first());
return pm->getObjects<IProjectManager>();
}
-QList<Project *> ProjectExplorerPlugin::openProjects(const QStringList &fileNames)
+QList<Project *> ProjectExplorerPlugin::openProjects(const QStringList &fileNames, QString *errorString)
{
if (debug)
qDebug() << "ProjectExplorerPlugin - opening projects " << fileNames;
if (const Core::MimeType mt = Core::ICore::instance()->mimeDatabase()->findByFile(QFileInfo(fileName))) {
foreach (IProjectManager *manager, projectManagers) {
if (manager->mimeType() == mt.type()) {
- if (Project *pro = manager->openProject(fileName)) {
+ QString tmp;
+ if (Project *pro = manager->openProject(fileName, &tmp)) {
if (pro->restoreSettings()) {
connect(pro, SIGNAL(fileListChanged()), this, SIGNAL(fileListChanged()));
d->m_session->addProject(pro);
delete pro;
}
}
+ if (errorString) {
+ if (!errorString->isEmpty() && !tmp.isEmpty())
+ errorString->append('\n');
+ errorString->append(tmp);
+ }
d->m_session->reportProjectLoadingProgress();
break;
}
connect(modeManager, SIGNAL(currentModeChanged(Core::IMode*, Core::IMode*)),
this, SLOT(currentModeChanged(Core::IMode*, Core::IMode*)));
connect(d->m_welcomePage, SIGNAL(requestSession(QString)), this, SLOT(loadSession(QString)));
- connect(d->m_welcomePage, SIGNAL(requestProject(QString)), this, SLOT(openProject(QString)));
+ connect(d->m_welcomePage, SIGNAL(requestProject(QString)), this, SLOT(openProjectWelcomePage(QString)));
QStringList combinedList;
// Converts "filename" "+45" or "filename" ":23"
return;
QString fileName = a->data().toString();
if (!fileName.isEmpty()) {
- openProject(fileName);
+ QString errorMessage;
+ openProject(fileName, &errorMessage);
+ if (!errorMessage.isEmpty())
+ QMessageBox::critical(Core::ICore::instance()->mainWindow(), tr("Failed to open project"), errorMessage);
}
}
static ProjectExplorerPlugin *instance();
- Q_SLOT bool openProject(const QString &fileName);
- QList<Project *> openProjects(const QStringList &fileNames);
+ bool openProject(const QString &fileName, QString *error);
+ QList<Project *> openProjects(const QStringList &fileNames, QString *error);
+ Q_SLOT void openProjectWelcomePage(const QString &fileName);
SessionManager *session() const;
// Keep projects that failed to load in the session!
m_failedProjects = fileList;
if (!fileList.isEmpty()) {
- QList<Project *> projects = ProjectExplorerPlugin::instance()->openProjects(fileList);
+ QString errors;
+ QList<Project *> projects = ProjectExplorerPlugin::instance()->openProjects(fileList, &errors);
+ if (!errors.isEmpty())
+ QMessageBox::critical(Core::ICore::instance()->mainWindow(), tr("Failed to open project"), errors);
foreach (Project *p, projects)
m_failedProjects.removeAll(p->file()->fileName());
}
#include <coreplugin/icore.h>
#include <coreplugin/ifile.h>
-#include <coreplugin/messagemanager.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/session.h>
QString Manager::mimeType() const
{ return QLatin1String(Constants::QMLMIMETYPE); }
-ProjectExplorer::Project *Manager::openProject(const QString &fileName)
+ProjectExplorer::Project *Manager::openProject(const QString &fileName, QString *errorString)
{
- Core::MessageManager *messageManager = Core::ICore::instance()->messageManager();
-
QFileInfo fileInfo(fileName);
ProjectExplorer::ProjectExplorerPlugin *projectExplorer = ProjectExplorer::ProjectExplorerPlugin::instance();
foreach (ProjectExplorer::Project *pi, projectExplorer->session()->projects()) {
if (fileName == pi->file()->fileName()) {
- messageManager->printToOutputPanePopup(tr("Failed opening project '%1': Project already open")
- .arg(QDir::toNativeSeparators(fileName)));
+ if (errorString)
+ *errorString = tr("Failed opening project '%1': Project already open") .arg(QDir::toNativeSeparators(fileName));
return 0;
}
}
if (fileInfo.isFile())
return new QmlProject(this, fileName);
+ *errorString = tr("Failed opening project '%1': Project file is not a file").arg(QDir::toNativeSeparators(fileName));
return 0;
}
Manager();
virtual QString mimeType() const;
- virtual ProjectExplorer::Project *openProject(const QString &fileName);
+ virtual ProjectExplorer::Project *openProject(const QString &fileName, QString *errorString);
void notifyChanged(const QString &fileName);
#include <coreplugin/icore.h>
#include <coreplugin/basefilewizard.h>
-#include <coreplugin/messagemanager.h>
#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/ieditor.h>
}
}
-ProjectExplorer::Project *Qt4Manager::openProject(const QString &fileName)
+ProjectExplorer::Project *Qt4Manager::openProject(const QString &fileName, QString *errorString)
{
- Core::MessageManager *messageManager = Core::ICore::instance()->messageManager();
-
// TODO Make all file paths relative & remove this hack
// We convert the path to an absolute one here because qt4project.cpp
// && profileevaluator use absolute/canonical file paths all over the place
QString canonicalFilePath = QFileInfo(fileName).canonicalFilePath();
if (canonicalFilePath.isEmpty()) {
- messageManager->printToOutputPane(tr("Failed opening project '%1': Project file does not exist").arg(QDir::toNativeSeparators(canonicalFilePath)));
+ if (errorString)
+ *errorString = tr("Failed opening project '%1': Project file does not exist").arg(QDir::toNativeSeparators(fileName));
return 0;
}
foreach (ProjectExplorer::Project *pi, projectExplorer()->session()->projects()) {
if (canonicalFilePath == pi->file()->fileName()) {
- messageManager->printToOutputPane(tr("Failed opening project '%1': Project already open").arg(QDir::toNativeSeparators(canonicalFilePath)));
+ if (errorString)
+ *errorString = tr("Failed opening project '%1': Project already open").arg(QDir::toNativeSeparators(canonicalFilePath));
return 0;
}
}
ProjectExplorer::ProjectExplorerPlugin *projectExplorer() const;
virtual QString mimeType() const;
- ProjectExplorer::Project *openProject(const QString &fileName);
+ ProjectExplorer::Project *openProject(const QString &fileName, QString *errorString);
// Context information used in the slot implementations
ProjectExplorer::Node *contextNode() const;
proFile = copyToAlternativeLocation(proFileInfo, filesToOpen);
// don't try to load help and files if loading the help request is being cancelled
- if (!proFile.isEmpty() && ProjectExplorer::ProjectExplorerPlugin::instance()->openProject(proFile)) {
+ QString errorMessage;
+ if (!proFile.isEmpty() && ProjectExplorer::ProjectExplorerPlugin::instance()->openProject(proFile, &errorMessage)) {
Core::ICore::instance()->openFiles(filesToOpen);
Core::ICore::instance()->helpManager()->handleHelpRequest(help.toString()+QLatin1String("?view=split"));
}
+ if (!errorMessage.isEmpty())
+ QMessageBox::critical(Core::ICore::instance()->mainWindow(), tr("Failed to open project"), errorMessage);
}
void GettingStartedWelcomePage::updateTagsModel()
return QString();
// Open. Do not use a busy cursor here as additional wizards might pop up
const QString projectFile = projectFiles.front().absoluteFilePath();
- if (!pe->openProject(projectFile)) {
- *errorMessage = tr("Unable to open the project '%1'.").
- arg(QDir::toNativeSeparators(projectFile));
+ if (!pe->openProject(projectFile, errorMessage)) {
return QString();
}
return projectFile;