QString BaseCheckoutWizard::openProject(const QString &path, QString *errorMessage) { ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin::instance(); if (!pe) { *errorMessage = tr("The Project Explorer is not available."); return QString(); } // Search the directory for project files const QDir dir(path); if (!dir.exists()) { *errorMessage = tr("'%1' does not exist."). arg(QDir::toNativeSeparators(path)); // Should not happen return QString(); } QFileInfoList projectFiles = findProjectFiles(dir, errorMessage); if (projectFiles.empty()) 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)) return QString(); return projectFile; }
// Figure out the Qt4 project used by the file if any static Qt4Project *qt4ProjectFor(const QString &fileName) { ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin::instance(); if (ProjectExplorer::Project *baseProject = pe->session()->projectForFile(fileName)) if (Qt4Project *project = qobject_cast<Qt4Project*>(baseProject)) return project; return 0; }
void TodoItemsProvider::setupStartupProjectBinding() { ProjectExplorer::ProjectExplorerPlugin *projectExplorerPlugin = ProjectExplorer::ProjectExplorerPlugin::instance(); m_startupProject = projectExplorerPlugin->startupProject(); connect(projectExplorerPlugin->session(), SIGNAL(startupProjectChanged(ProjectExplorer::Project*)), SLOT(startupProjectChanged(ProjectExplorer::Project*))); connect(projectExplorerPlugin, SIGNAL(fileListChanged()), SLOT(projectsFilesChanged())); }
void QtTestPlugin::extensionsInitialized() { ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); Core::ICore *core = Core::ICore::instance(); Core::ActionManager *am = core->actionManager(); m_messageOutputWindow = new TestOutputWindow(); pm->addObject(m_messageOutputWindow); m_testResultsWindow = TestResultsWindow::instance(); connect(m_testResultsWindow, SIGNAL(stopTest()), this, SLOT(stopTesting())); connect(m_testResultsWindow, SIGNAL(retryFailedTests(QStringList)), this, SLOT(retryTests(QStringList))); connect(TestExecuter::instance(), SIGNAL(testStarted()), m_testResultsWindow, SLOT(onTestStarted())); connect(TestExecuter::instance(), SIGNAL(testStop()), m_testResultsWindow, SLOT(onTestStopped())); connect(TestExecuter::instance(), SIGNAL(testFinished()), m_testResultsWindow, SLOT(onTestFinished())); pm->addObject(m_testResultsWindow); connect(testResultsPane(), SIGNAL(defectSelected(TestCaseRec)), this, SLOT(onDefectSelected(TestCaseRec))); // Add context menu to CPP editor Core::ActionContainer *mcontext = am->actionContainer(CppEditor::Constants::M_CONTEXT); m_contextMenu->init(mcontext->menu(), 2, this); // Add context menu to JS editor mcontext = am->actionContainer(QmlJSEditor::Constants::M_CONTEXT); m_contextMenu->init(mcontext->menu(), 2, this); // Add a Test menu to the menu bar Core::ActionContainer* ac = am->createMenu("QtTestPlugin.TestMenu"); ac->menu()->setTitle(tr("&Test")); m_contextMenu->init(ac->menu(), 0, 0); // Insert the "Test" menu between "Window" and "Help". QMenu *windowMenu = am->actionContainer(Core::Constants::M_TOOLS)->menu(); QMenuBar *menuBar = am->actionContainer(Core::Constants::MENU_BAR)->menuBar(); menuBar->insertMenu(windowMenu->menuAction(), ac->menu()); ProjectExplorer::ProjectExplorerPlugin *explorer = ProjectExplorer::ProjectExplorerPlugin::instance(); connect(explorer->session(), SIGNAL(startupProjectChanged(ProjectExplorer::Project*)), this, SLOT(onStartupProjectChanged(ProjectExplorer::Project *))); connect(core->progressManager(), SIGNAL(allTasksFinished(QString)), this, SLOT(onAllTasksFinished(QString))); connect(explorer->session(), SIGNAL(aboutToRemoveProject(ProjectExplorer::Project *)), this, SLOT(onProjectRemoved(ProjectExplorer::Project *))); m_contextMenu->init(0, 3, this); }
void CallgrindToolPrivate::handleFilterProjectCosts() { ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin::instance(); ProjectExplorer::Project *pro = pe->currentProject(); QTC_ASSERT(pro, return) if (m_filterProjectCosts->isChecked()) { const QString projectDir = pro->projectDirectory(); m_proxyModel->setFilterBaseDir(projectDir); } else { m_proxyModel->setFilterBaseDir(QString()); } }
void ResourceHandler::updateResources() { ensureInitialized(); const QString fileName = m_form->fileName(); QTC_ASSERT(!fileName.isEmpty(), return) if (Designer::Constants::Internal::debug) qDebug() << "ResourceHandler::updateResources()" << fileName; ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin::instance(); // filename could change in the meantime. ProjectExplorer::Project *project = pe->session()->projectForFile(fileName); // Does the file belong to a project? if (project) { // Collect project resource files. ProjectNode *root = project->rootProjectNode(); QrcFilesVisitor qrcVisitor; root->accept(&qrcVisitor); const QStringList projectQrcFiles = qrcVisitor.qrcFiles(); #if QT_VERSION >= 0x050000 m_form->activateResourceFilePaths(projectQrcFiles); m_form->setResourceFileSaveMode(QDesignerFormWindowInterface::SaveOnlyUsedResourceFiles); #else m_form->resourceSet()->activateQrcPaths(projectQrcFiles); m_form->setSaveResourcesBehaviour(qdesigner_internal::FormWindowBase::SaveOnlyUsedQrcFiles); #endif if (Designer::Constants::Internal::debug) qDebug() << "ResourceHandler::updateResources()" << fileName << " associated with project" << project->rootProjectNode()->path() << " using project qrc files" << projectQrcFiles.size(); } else { // Use resource file originally used in form #if QT_VERSION >= 0x050000 m_form->activateResourceFilePaths(m_originalUiQrcPaths); m_form->setResourceFileSaveMode(QDesignerFormWindowInterface::SaveAllResourceFiles); #else m_form->resourceSet()->activateQrcPaths(m_originalUiQrcPaths); m_form->setSaveResourcesBehaviour(qdesigner_internal::FormWindowBase::SaveAll); #endif if (Designer::Constants::Internal::debug) qDebug() << "ResourceHandler::updateResources()" << fileName << " not associated with project, using loaded qrc files."; } }
void ResourceHandler::ensureInitialized() { if (m_sessionNode) return; ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin::instance(); ProjectExplorer::SessionManager *session = pe->session(); m_sessionNode = session->sessionNode(); m_sessionWatcher = new ProjectExplorer::NodesWatcher(); connect(m_sessionWatcher, SIGNAL(filesAdded()), this, SLOT(updateResources())); connect(m_sessionWatcher, SIGNAL(filesRemoved()), this, SLOT(updateResources())); connect(m_sessionWatcher, SIGNAL(foldersAdded()), this, SLOT(updateResources())); connect(m_sessionWatcher, SIGNAL(foldersRemoved()), this, SLOT(updateResources())); m_sessionNode->registerWatcher(m_sessionWatcher); #if QT_VERSION >= 0x050000 m_originalUiQrcPaths = m_form->activeResourceFilePaths(); #else m_originalUiQrcPaths = m_form->resourceSet()->activeQrcPaths(); #endif if (Designer::Constants::Internal::debug) qDebug() << "ResourceHandler::ensureInitialized() origPaths=" << m_originalUiQrcPaths; }
QString CppToolsPlugin::correspondingHeaderOrSourceI(const QString &fileName) const { const Core::ICore *core = Core::ICore::instance(); const Core::MimeDatabase *mimeDatase = core->mimeDatabase(); ProjectExplorer::ProjectExplorerPlugin *explorer = ProjectExplorer::ProjectExplorerPlugin::instance(); ProjectExplorer::Project *project = (explorer ? explorer->currentProject() : 0); const QFileInfo fi(fileName); const FileType type = fileType(mimeDatase, fi); if (debug) qDebug() << Q_FUNC_INFO << fileName << type; if (type == UnknownType) return QString(); const QDir absoluteDir = fi.absoluteDir(); const QString baseName = fi.completeBaseName(); const QStringList suffixes = matchingCandidateSuffixes(mimeDatase, type); const QString privateHeaderSuffix = QLatin1String("_p"); const QChar dot = QLatin1Char('.'); // Check base matches 'source.h'-> 'source.cpp' and vice versa const QStringList::const_iterator scend = suffixes.constEnd(); for (QStringList::const_iterator it = suffixes.constBegin(); it != scend; ++it) { QString candidate = baseName; candidate += dot; candidate += *it; const QFileInfo candidateFi = findFile(absoluteDir, candidate, project); if (candidateFi.isFile()) return candidateFi.absoluteFilePath(); } if (type == HeaderFile) { // 'source_p.h': try 'source.cpp' if (baseName.endsWith(privateHeaderSuffix)) { QString sourceBaseName = baseName; sourceBaseName.truncate(sourceBaseName.size() - privateHeaderSuffix.size()); for (QStringList::const_iterator it = suffixes.constBegin(); it != scend; ++it) { QString candidate = sourceBaseName; candidate += dot; candidate += *it; const QFileInfo candidateFi = findFile(absoluteDir, candidate, project); if (candidateFi.isFile()) return candidateFi.absoluteFilePath(); } } } else { // 'source.cpp': try 'source_p.h' const QStringList::const_iterator scend = suffixes.constEnd(); for (QStringList::const_iterator it = suffixes.constBegin(); it != scend; ++it) { QString candidate = baseName; candidate += privateHeaderSuffix; candidate += dot; candidate += *it; const QFileInfo candidateFi = findFile(absoluteDir, candidate, project); if (candidateFi.isFile()) return candidateFi.absoluteFilePath(); } } return QString(); }