diff options
Diffstat (limited to 'src/plugins/projectexplorer/projectexplorer.cpp')
-rw-r--r-- | src/plugins/projectexplorer/projectexplorer.cpp | 108 |
1 files changed, 50 insertions, 58 deletions
diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 73810342bb..ac1fc6508d 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -328,15 +328,14 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er addAutoReleasedObject(new TaskHub); - Core::ICore *core = Core::ICore::instance(); - Core::ActionManager *am = core->actionManager(); - connect(core, SIGNAL(newItemsDialogRequested()), this, SLOT(loadCustomWizards())); + Core::ActionManager *am = Core::ICore::actionManager(); + connect(Core::ICore::instance(), SIGNAL(newItemsDialogRequested()), this, SLOT(loadCustomWizards())); d->m_welcomePage = new ProjectWelcomePage; connect(d->m_welcomePage, SIGNAL(manageSessions()), this, SLOT(showSessionManager())); addObject(d->m_welcomePage); - connect(core->fileManager(), SIGNAL(currentFileChanged(QString)), + connect(Core::ICore::fileManager(), SIGNAL(currentFileChanged(QString)), this, SLOT(setCurrentFile(QString))); d->m_session = new SessionManager(this); @@ -491,7 +490,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er msubProjectContextMenu->appendGroup(Constants::G_PROJECT_LAST); msubProjectContextMenu->appendGroup(Constants::G_PROJECT_TREE); - Core::ActionContainer *runMenu = Core::ICore::instance()->actionManager()->createMenu(Constants::RUNMENUCONTEXTMENU); + Core::ActionContainer *runMenu = Core::ICore::actionManager()->createMenu(Constants::RUNMENUCONTEXTMENU); runMenu->setOnAllDisabledBehavior(Core::ActionContainer::Hide); QIcon runIcon = QIcon(QLatin1String(Constants::ICON_RUN)); runIcon.addFile(QLatin1String(Constants::ICON_RUN_SMALL)); @@ -884,7 +883,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er d->m_projectSelectorAction = new QAction(this); d->m_projectSelectorAction->setCheckable(true); d->m_projectSelectorAction->setEnabled(false); - QWidget *mainWindow = Core::ICore::instance()->mainWindow(); + QWidget *mainWindow = Core::ICore::mainWindow(); d->m_targetSelector = new Internal::MiniProjectTargetSelector(d->m_projectSelectorAction, d->m_session, mainWindow); connect(d->m_projectSelectorAction, SIGNAL(triggered()), d->m_targetSelector, SLOT(show())); Core::ModeManager::instance()->addProjectSelector(d->m_projectSelectorAction); @@ -904,14 +903,14 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er cmd = am->registerAction(d->m_projectSelectorActionQuick, ProjectExplorer::Constants::SELECTTARGETQUICK, globalcontext); cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+T"))); - connect(core, SIGNAL(saveSettingsRequested()), + connect(Core::ICore::instance(), SIGNAL(saveSettingsRequested()), this, SLOT(savePersistentSettings())); addAutoReleasedObject(new ProjectTreeWidgetFactory); addAutoReleasedObject(new FolderNavigationWidgetFactory); addAutoReleasedObject(new DeployConfigurationFactory); - if (QSettings *s = core->settings()) { + if (QSettings *s = Core::ICore::settings()) { const QStringList fileNames = s->value(QLatin1String("ProjectExplorer/RecentProjects/FileNames")).toStringList(); const QStringList displayNames = @@ -924,7 +923,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er } } - if (QSettings *s = core->settings()) { + if (QSettings *s = Core::ICore::settings()) { d->m_projectExplorerSettings.buildBeforeDeploy = s->value(QLatin1String("ProjectExplorer/Settings/BuildBeforeDeploy"), true).toBool(); d->m_projectExplorerSettings.deployBeforeRun = @@ -1045,7 +1044,7 @@ void ProjectExplorerPlugin::loadAction() openProject(filename, &errorMessage); if (!errorMessage.isEmpty()) - QMessageBox::critical(Core::ICore::instance()->mainWindow(), tr("Failed to open project"), errorMessage); + QMessageBox::critical(Core::ICore::mainWindow(), tr("Failed to open project"), errorMessage); updateActions(); } @@ -1085,9 +1084,9 @@ void ProjectExplorerPlugin::unloadProject() bool success = false; if (readonlycount > 0) - success = Core::ICore::instance()->fileManager()->saveModifiedFiles(filesToSave).isEmpty(); + success = Core::ICore::fileManager()->saveModifiedFiles(filesToSave).isEmpty(); else - success = Core::ICore::instance()->fileManager()->saveModifiedFilesSilently(filesToSave).isEmpty(); + success = Core::ICore::fileManager()->saveModifiedFilesSilently(filesToSave).isEmpty(); if (!success) return; @@ -1176,7 +1175,7 @@ void ProjectExplorerPlugin::newProject() if (debug) qDebug() << "ProjectExplorerPlugin::newProject"; - Core::ICore::instance()->showNewItemDialog(tr("New Project", "Title of dialog"), + Core::ICore::showNewItemDialog(tr("New Project", "Title of dialog"), Core::IWizard::wizardsOfKind(Core::IWizard::ProjectWizard)); updateActions(); } @@ -1191,7 +1190,7 @@ void ProjectExplorerPlugin::showSessionManager() } else { d->m_session->save(); } - SessionDialog sessionDialog(d->m_session, Core::ICore::instance()->mainWindow()); + SessionDialog sessionDialog(d->m_session, Core::ICore::mainWindow()); sessionDialog.setAutoLoadSession(d->m_projectExplorerSettings.autorestoreLastSession); sessionDialog.exec(); d->m_projectExplorerSettings.autorestoreLastSession = sessionDialog.autoLoadSession(); @@ -1242,7 +1241,7 @@ void ProjectExplorerPlugin::savePersistentSettings() d->m_session->save(); } - QSettings *s = Core::ICore::instance()->settings(); + QSettings *s = Core::ICore::settings(); if (s) { s->setValue(QLatin1String("ProjectExplorer/StartupSession"), d->m_session->currentSession()); s->remove(QLatin1String("ProjectExplorer/RecentProjects/Files")); @@ -1281,7 +1280,7 @@ 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); + QMessageBox::critical(Core::ICore::mainWindow(), tr("Failed to open project"), errorMessage); } bool ProjectExplorerPlugin::openProject(const QString &fileName, QString *errorString) @@ -1313,7 +1312,7 @@ QList<Project *> ProjectExplorerPlugin::openProjects(const QStringList &fileName QList<Project*> openedPro; foreach (const QString &fileName, fileNames) { - if (const Core::MimeType mt = Core::ICore::instance()->mimeDatabase()->findByFile(QFileInfo(fileName))) { + if (const Core::MimeType mt = Core::ICore::mimeDatabase()->findByFile(QFileInfo(fileName))) { foreach (IProjectManager *manager, projectManagers) { if (manager->mimeType() == mt.type()) { QString tmp; @@ -1481,7 +1480,7 @@ void ProjectExplorerPlugin::restoreSession() } } - Core::ICore::instance()->openFiles(combinedList, Core::ICore::OpenFilesFlags(Core::ICore::CanContainLineNumbers | Core::ICore::SwitchMode)); + Core::ICore::openFiles(combinedList, Core::ICore::OpenFilesFlags(Core::ICore::CanContainLineNumbers | Core::ICore::SwitchMode)); updateActions(); } @@ -1592,7 +1591,7 @@ void ProjectExplorerPlugin::buildQueueFinished(bool success) bool ignoreErrors = true; if (d->m_delayedRunConfiguration && success && d->m_buildManager->getErrorTaskCount() > 0) { - ignoreErrors = QMessageBox::question(Core::ICore::instance()->mainWindow(), + ignoreErrors = QMessageBox::question(Core::ICore::mainWindow(), tr("Ignore all errors?"), tr("Found some build errors in current task.\n" "Do you want to ignore them?"), @@ -1621,8 +1620,6 @@ void ProjectExplorerPlugin::setCurrent(Project *project, QString filePath, Node else node = d->m_session->nodeForFile(filePath, project); - Core::ICore *core = Core::ICore::instance(); - bool projectChanged = false; if (d->m_currentProject != project) { Core::Context oldContext; @@ -1637,7 +1634,7 @@ void ProjectExplorerPlugin::setCurrent(Project *project, QString filePath, Node newContext.add(project->projectLanguage()); } - core->updateAdditionalContexts(oldContext, newContext); + Core::ICore::updateAdditionalContexts(oldContext, newContext); d->m_currentProject = project; @@ -1658,7 +1655,7 @@ void ProjectExplorerPlugin::setCurrent(Project *project, QString filePath, Node updateActions(); } - core->fileManager()->setCurrentFile(filePath); + Core::ICore::fileManager()->setCurrentFile(filePath); } void ProjectExplorerPlugin::updateActions() @@ -1756,18 +1753,18 @@ bool ProjectExplorerPlugin::saveModifiedFiles() if (debug) qDebug() << "ProjectExplorerPlugin::saveModifiedFiles"; - QList<Core::IFile *> filesToSave = Core::ICore::instance()->fileManager()->modifiedFiles(); + QList<Core::IFile *> filesToSave = Core::ICore::fileManager()->modifiedFiles(); if (!filesToSave.isEmpty()) { if (d->m_projectExplorerSettings.saveBeforeBuild) { bool cancelled = false; - Core::ICore::instance()->fileManager()->saveModifiedFilesSilently(filesToSave, &cancelled); + Core::ICore::fileManager()->saveModifiedFilesSilently(filesToSave, &cancelled); if (cancelled) return false; } else { bool cancelled = false; bool alwaysSave = false; - Core::FileManager *fm = Core::ICore::instance()->fileManager(); + Core::FileManager *fm = Core::ICore::fileManager(); fm->saveModifiedFiles(filesToSave, &cancelled, QString(), tr("Always save files before build"), &alwaysSave); @@ -2370,7 +2367,7 @@ void ProjectExplorerPlugin::updateRecentProjectMenu() qDebug() << "ProjectExplorerPlugin::updateRecentProjectMenu"; Core::ActionContainer *aci = - Core::ICore::instance()->actionManager()->actionContainer(Constants::M_RECENTPROJECTS); + Core::ICore::actionManager()->actionContainer(Constants::M_RECENTPROJECTS); QMenu *menu = aci->menu(); menu->clear(); @@ -2417,7 +2414,7 @@ void ProjectExplorerPlugin::openRecentProject() QString errorMessage; openProject(fileName, &errorMessage); if (!errorMessage.isEmpty()) - QMessageBox::critical(Core::ICore::instance()->mainWindow(), tr("Failed to open project"), errorMessage); + QMessageBox::critical(Core::ICore::mainWindow(), tr("Failed to open project"), errorMessage); } } @@ -2452,7 +2449,7 @@ void ProjectExplorerPlugin::updateContextMenuActions() d->m_deleteFileAction->setVisible(true); d->m_runActionContextMenu->setVisible(false); - Core::ActionContainer *runMenu = Core::ICore::instance()->actionManager()->actionContainer(Constants::RUNMENUCONTEXTMENU); + Core::ActionContainer *runMenu = Core::ICore::actionManager()->actionContainer(Constants::RUNMENUCONTEXTMENU); runMenu->menu()->clear(); if (d->m_currentNode && d->m_currentNode->projectNode()) { @@ -2548,7 +2545,7 @@ void ProjectExplorerPlugin::addNewFile() QTC_ASSERT(d->m_currentNode, return) QString location = directoryFor(d->m_currentNode); - Core::ICore::instance()->showNewItemDialog(tr("New File", "Title of dialog"), + Core::ICore::showNewItemDialog(tr("New File", "Title of dialog"), Core::IWizard::wizardsOfKind(Core::IWizard::FileWizard) + Core::IWizard::wizardsOfKind(Core::IWizard::ClassWizard), location); @@ -2562,7 +2559,7 @@ void ProjectExplorerPlugin::addNewSubproject() if (d->m_currentNode->nodeType() == ProjectNodeType && d->m_currentNode->projectNode()->supportedActions( d->m_currentNode->projectNode()).contains(ProjectNode::AddSubProject)) { - Core::ICore::instance()->showNewItemDialog(tr("New Subproject", "Title of dialog"), + Core::ICore::showNewItemDialog(tr("New Subproject", "Title of dialog"), Core::IWizard::wizardsOfKind(Core::IWizard::ProjectWizard), location); } @@ -2572,7 +2569,7 @@ void ProjectExplorerPlugin::addExistingFiles() { QTC_ASSERT(d->m_currentNode, return) - QStringList fileNames = QFileDialog::getOpenFileNames(Core::ICore::instance()->mainWindow(), + QStringList fileNames = QFileDialog::getOpenFileNames(Core::ICore::mainWindow(), tr("Add Existing Files"), directoryFor(d->m_currentNode)); if (fileNames.isEmpty()) return; @@ -2587,12 +2584,11 @@ void ProjectExplorerPlugin::addExistingFiles(const QStringList &filePaths) void ProjectExplorerPlugin::addExistingFiles(ProjectNode *projectNode, const QStringList &filePaths) { - Core::ICore *core = Core::ICore::instance(); const QString dir = directoryFor(projectNode); QStringList fileNames = filePaths; QHash<FileType, QString> fileTypeToFiles; foreach (const QString &fileName, fileNames) { - FileType fileType = typeForFileName(core->mimeDatabase(), QFileInfo(fileName)); + FileType fileType = typeForFileName(Core::ICore::mimeDatabase(), QFileInfo(fileName)); fileTypeToFiles.insertMulti(fileType, fileName); } @@ -2603,17 +2599,17 @@ void ProjectExplorerPlugin::addExistingFiles(ProjectNode *projectNode, const QSt if (!notAdded.isEmpty()) { QString message = tr("Could not add following files to project %1:\n").arg(projectNode->displayName()); QString files = notAdded.join(QString(QLatin1Char('\n'))); - QMessageBox::warning(core->mainWindow(), tr("Adding Files to Project Failed"), + QMessageBox::warning(Core::ICore::mainWindow(), tr("Adding Files to Project Failed"), message + files); foreach (const QString &file, notAdded) fileNames.removeOne(file); } - if (Core::IVersionControl *vcManager = core->vcsManager()->findVersionControlForDirectory(dir)) + if (Core::IVersionControl *vcManager = Core::ICore::vcsManager()->findVersionControlForDirectory(dir)) if (vcManager->supportsOperation(Core::IVersionControl::AddOperation)) { const QString files = fileNames.join(QString(QLatin1Char('\n'))); QMessageBox::StandardButton button = - QMessageBox::question(core->mainWindow(), tr("Add to Version Control"), + QMessageBox::question(Core::ICore::mainWindow(), tr("Add to Version Control"), tr("Add files\n%1\nto version control (%2)?").arg(files, vcManager->displayName()), QMessageBox::Yes | QMessageBox::No); if (button == QMessageBox::Yes) { @@ -2626,7 +2622,7 @@ void ProjectExplorerPlugin::addExistingFiles(ProjectNode *projectNode, const QSt if (!notAddedToVc.isEmpty()) { const QString message = tr("Could not add following files to version control (%1)\n").arg(vcManager->displayName()); const QString filesNotAdded = notAddedToVc.join(QString(QLatin1Char('\n'))); - QMessageBox::warning(core->mainWindow(), tr("Adding to Version Control Failed"), + QMessageBox::warning(Core::ICore::mainWindow(), tr("Adding to Version Control Failed"), message + filesNotAdded); } } @@ -2638,8 +2634,7 @@ void ProjectExplorerPlugin::removeProject() ProjectNode *subProjectNode = qobject_cast<ProjectNode*>(d->m_currentNode->projectNode()); ProjectNode *projectNode = qobject_cast<ProjectNode *>(subProjectNode->parentFolderNode()); if (projectNode) { - Core::ICore *core = Core::ICore::instance(); - RemoveFileDialog removeFileDialog(subProjectNode->path(), core->mainWindow()); + RemoveFileDialog removeFileDialog(subProjectNode->path(), Core::ICore::mainWindow()); removeFileDialog.setDeleteFileVisible(false); if (removeFileDialog.exec() == QDialog::Accepted) projectNode->removeSubProjects(QStringList() << subProjectNode->path()); @@ -2662,7 +2657,7 @@ void ProjectExplorerPlugin::searchOnFileSystem() void ProjectExplorerPlugin::showInGraphicalShell() { QTC_ASSERT(d->m_currentNode, return) - Core::FileUtils::showInGraphicalShell(Core::ICore::instance()->mainWindow(), + Core::FileUtils::showInGraphicalShell(Core::ICore::mainWindow(), pathFor(d->m_currentNode)); } @@ -2677,10 +2672,9 @@ void ProjectExplorerPlugin::removeFile() QTC_ASSERT(d->m_currentNode && d->m_currentNode->nodeType() == FileNodeType, return) FileNode *fileNode = qobject_cast<FileNode*>(d->m_currentNode); - Core::ICore *core = Core::ICore::instance(); QString filePath = d->m_currentNode->path(); - RemoveFileDialog removeFileDialog(filePath, core->mainWindow()); + RemoveFileDialog removeFileDialog(filePath, Core::ICore::mainWindow()); if (removeFileDialog.exec() == QDialog::Accepted) { const bool deleteFile = removeFileDialog.isDeleteFileChecked(); @@ -2690,13 +2684,13 @@ void ProjectExplorerPlugin::removeFile() Q_ASSERT(projectNode); if (!projectNode->removeFiles(fileNode->fileType(), QStringList(filePath))) { - QMessageBox::warning(core->mainWindow(), tr("Removing File Failed"), + QMessageBox::warning(Core::ICore::mainWindow(), tr("Removing File Failed"), tr("Could not remove file %1 from project %2.").arg(filePath).arg(projectNode->displayName())); return; } // remove from version control - core->vcsManager()->promptToDelete(filePath); + Core::ICore::vcsManager()->promptToDelete(filePath); // remove from file system if (deleteFile) { @@ -2705,7 +2699,7 @@ void ProjectExplorerPlugin::removeFile() if (file.exists()) { // could have been deleted by vc if (!file.remove()) - QMessageBox::warning(core->mainWindow(), tr("Deleting File Failed"), + QMessageBox::warning(Core::ICore::mainWindow(), tr("Deleting File Failed"), tr("Could not delete file %1.").arg(filePath)); } } @@ -2717,11 +2711,10 @@ void ProjectExplorerPlugin::deleteFile() QTC_ASSERT(d->m_currentNode && d->m_currentNode->nodeType() == FileNodeType, return) FileNode *fileNode = qobject_cast<FileNode*>(d->m_currentNode); - Core::ICore *core = Core::ICore::instance(); QString filePath = d->m_currentNode->path(); QMessageBox::StandardButton button = - QMessageBox::question(core->mainWindow(), + QMessageBox::question(Core::ICore::mainWindow(), tr("Delete File"), tr("Delete %1 from file system?").arg(filePath), QMessageBox::Yes | QMessageBox::No); @@ -2733,18 +2726,18 @@ void ProjectExplorerPlugin::deleteFile() projectNode->deleteFiles(fileNode->fileType(), QStringList(filePath)); - core->fileManager()->expectFileChange(filePath); + Core::ICore::fileManager()->expectFileChange(filePath); if (Core::IVersionControl *vc = - core->vcsManager()->findVersionControlForDirectory(QFileInfo(filePath).absolutePath())) { + Core::ICore::vcsManager()->findVersionControlForDirectory(QFileInfo(filePath).absolutePath())) { vc->vcsDelete(filePath); } QFile file(filePath); if (file.exists()) { if (!file.remove()) - QMessageBox::warning(core->mainWindow(), tr("Deleting File Failed"), + QMessageBox::warning(Core::ICore::mainWindow(), tr("Deleting File Failed"), tr("Could not delete file %1.").arg(filePath)); } - core->fileManager()->unexpectFileChange(filePath); + Core::ICore::fileManager()->unexpectFileChange(filePath); } void ProjectExplorerPlugin::renameFile() @@ -2772,8 +2765,7 @@ void ProjectExplorerPlugin::renameFile(Node *node, const QString &to) if (orgFilePath == newFilePath) return; - Core::ICore *core = Core::ICore::instance(); - Core::IVersionControl *vc = core->vcsManager()->findVersionControlForDirectory(dir); + Core::IVersionControl *vc = Core::ICore::vcsManager()->findVersionControlForDirectory(dir); bool result = false; if (vc && vc->supportsOperation(Core::IVersionControl::MoveOperation)) @@ -2790,7 +2782,7 @@ void ProjectExplorerPlugin::renameFile(Node *node, const QString &to) } if (result) { // yeah we moved, tell the filemanager about it - Core::ICore::instance()->fileManager()->renamedFile(orgFilePath, newFilePath); + Core::ICore::fileManager()->renamedFile(orgFilePath, newFilePath); // Tell the project plugin about it ProjectNode *projectNode = fileNode->projectNode(); projectNode->renameFile(fileNode->fileType(), orgFilePath, newFilePath); @@ -2847,7 +2839,7 @@ Internal::ProjectExplorerSettings ProjectExplorerPlugin::projectExplorerSettings QStringList ProjectExplorerPlugin::projectFilePatterns() { QStringList patterns; - const Core::MimeDatabase *mdb = Core::ICore::instance()->mimeDatabase(); + const Core::MimeDatabase *mdb = Core::ICore::mimeDatabase(); foreach(const IProjectManager *pm, allProjectManagers()) if (const Core::MimeType mt = mdb->findByType(pm->mimeType())) foreach(const Core::MimeGlobPattern &gp, mt.globPatterns()) @@ -2857,11 +2849,11 @@ QStringList ProjectExplorerPlugin::projectFilePatterns() void ProjectExplorerPlugin::openOpenProjectDialog() { - Core::FileManager *fileMananger = Core::ICore::instance()->fileManager(); + Core::FileManager *fileMananger = Core::ICore::fileManager(); const QString path = fileMananger->useProjectsDirectory() ? fileMananger->projectsDirectory() : QString(); const QStringList files = fileMananger->getOpenFileNames(d->m_projectFilterString, path); if (!files.isEmpty()) - Core::ICore::instance()->openFiles(files, Core::ICore::SwitchMode); + Core::ICore::openFiles(files, Core::ICore::SwitchMode); } QList<QPair<QString, QString> > ProjectExplorerPlugin::recentProjects() |