Core::IFile *DocumentEditorFactory::open(const QString &fileName) { Core::EditorManager *em = Core::EditorManager::instance(); Core::IEditor *iface = em->openEditor(fileName, kind()); return iface ? iface->file() : 0; }
Core::IFile * SequenceEditorFactory::open(const QString& filename ) { Core::EditorManager * em = Core::EditorManager::instance(); Core::IEditor * iface = em->openEditor( filename, kind_ ); return iface ? iface->file() : 0; }
void CppPlugin::jumpToDefinition() { Core::EditorManager *em = Core::EditorManager::instance(); CPPEditorWidget *editor = qobject_cast<CPPEditorWidget*>(em->currentEditor()->widget()); if (editor) editor->jumpToDefinition(); }
void QmlJSEditorPlugin::followSymbolUnderCursor() { Core::EditorManager *em = Core::EditorManager::instance(); if (QmlJSTextEditorWidget *editor = qobject_cast<QmlJSTextEditorWidget*>(em->currentEditor()->widget())) editor->followSymbolUnderCursor(); }
void QmlJSOutlineWidget::updateTextCursor(const QModelIndex &index) { QModelIndex sourceIndex = m_filterModel->mapToSource(index); AST::SourceLocation location = m_editor->outlineModel()->sourceLocation(sourceIndex); if (!location.isValid()) return; const QTextBlock lastBlock = m_editor->document()->lastBlock(); const uint textLength = lastBlock.position() + lastBlock.length(); if (location.offset >= textLength) return; Core::EditorManager *editorManager = Core::EditorManager::instance(); editorManager->cutForwardNavigationHistory(); editorManager->addCurrentPositionToNavigationHistory(); QTextCursor textCursor = m_editor->textCursor(); m_blockCursorSync = true; textCursor.setPosition(location.offset); m_editor->setTextCursor(textCursor); m_editor->centerCursor(); m_editor->setFocus(); m_blockCursorSync = false; }
ITextEditor *LineNumberFilter::currentTextEditor() const { Core::EditorManager *editorManager = Core::EditorManager::instance(); if (!editorManager->currentEditor()) return 0; return qobject_cast<TextEditor::ITextEditor*>(editorManager->currentEditor()); }
void QmlEngine::gotoLocation(const Location &location) { const QString fileName = location.fileName(); // TODO: QUrl::isLocalFile() once we depend on Qt 4.8 if (QUrl(fileName).scheme().compare(QLatin1String("file"), Qt::CaseInsensitive) == 0) { // internal file from source files -> show generated .js QTC_ASSERT(m_sourceDocuments.contains(fileName), return); Core::IEditor *editor = 0; Core::EditorManager *editorManager = Core::EditorManager::instance(); QString titlePattern = tr("JS Source for %1").arg(fileName); //Check if there are open editors with the same title QList<Core::IEditor *> editors = editorManager->openedEditors(); foreach (Core::IEditor *ed, editors) { if (ed->displayName() == titlePattern) { editor = ed; break; } } if (!editor) { editor = Core::EditorManager::openEditorWithContents(QmlJSEditor::Constants::C_QMLJSEDITOR_ID, &titlePattern); if (editor) { editor->setProperty(Constants::OPENED_BY_DEBUGGER, true); } updateEditor(editor, m_sourceDocuments.value(fileName)); } Core::EditorManager::activateEditor(editor); } else {
void CppPlugin::findUsages() { Core::EditorManager *em = Core::EditorManager::instance(); CPPEditorWidget *editor = qobject_cast<CPPEditorWidget*>(em->currentEditor()->widget()); if (editor) editor->findUsages(); }
void CppPlugin::renameSymbolUnderCursor() { Core::EditorManager *em = Core::EditorManager::instance(); CPPEditorWidget *editor = qobject_cast<CPPEditorWidget*>(em->currentEditor()->widget()); if (editor) editor->renameSymbolUnderCursor(); }
void CppToolsPlugin::switchHeaderSource() { Core::EditorManager *editorManager = Core::EditorManager::instance(); Core::IEditor *editor = editorManager->currentEditor(); QString otherFile = correspondingHeaderOrSource(editor->file()->fileName()); if (!otherFile.isEmpty()) editorManager->openEditor(otherFile); }
void QmlJSEditorPlugin::openPreview() { Core::EditorManager *em = Core::EditorManager::instance(); if (em->currentEditor() && em->currentEditor()->id() == Constants::C_QMLJSEDITOR_ID) m_previewRunner->run(em->currentEditor()->file()->fileName()); }
TabBar::TabBar(QWidget *parent) : QTabBar(parent) { setExpanding(false); setMovable(true); setTabsClosable(true); setUsesScrollButtons(true); QSizePolicy sp(QSizePolicy::Preferred, QSizePolicy::Fixed); sp.setHorizontalStretch(1); sp.setVerticalStretch(0); sp.setHeightForWidth(sizePolicy().hasHeightForWidth()); setSizePolicy(sp); connect(this, &QTabBar::tabMoved, [this](int from, int to) { m_editors.move(from, to); }); Core::EditorManager *em = Core::EditorManager::instance(); connect(em, &Core::EditorManager::editorOpened, this, &TabBar::addEditorTab); connect(em, &Core::EditorManager::editorsClosed, this, &TabBar::removeEditorTabs); connect(em, SIGNAL(currentEditorChanged(Core::IEditor*)), SLOT(selectEditorTab(Core::IEditor*))); connect(this, &QTabBar::currentChanged, this, &TabBar::activateEditor); connect(this, &QTabBar::tabCloseRequested, this, &TabBar::closeTab); ProjectExplorer::SessionManager *sm = ProjectExplorer::SessionManager::instance(); connect(sm, &ProjectExplorer::SessionManager::sessionLoaded, [this, em]() { foreach (Core::DocumentModel::Entry *entry, Core::DocumentModel::entries()) em->activateEditorForEntry(entry, Core::EditorManager::DoNotChangeCurrentEditor); }); const QString shortCutSequence = QStringLiteral("Ctrl+Alt+%1"); for (int i = 1; i <= 10; ++i) { QShortcut *shortcut = new QShortcut(shortCutSequence.arg(i % 10), this); connect(shortcut, &QShortcut::activated, [this, shortcut]() { setCurrentIndex(m_shortcuts.indexOf(shortcut)); }); m_shortcuts.append(shortcut); } QAction *prevTabAction = new QAction(tr("Switch to previous tab"), this); Core::Command *prevTabCommand = Core::ActionManager::registerAction(prevTabAction, TabbedEditor::Constants::PREV_TAB_ID, Core::Context(Core::Constants::C_GLOBAL)); prevTabCommand->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+J"))); connect(prevTabAction, SIGNAL(triggered()), this, SLOT(prevTabAction())); QAction *nextTabAction = new QAction(tr("Switch to next tab"), this); Core::Command *nextTabCommand = Core::ActionManager::registerAction(nextTabAction, TabbedEditor::Constants::NEXT_TAB_ID, Core::Context(Core::Constants::C_GLOBAL)); nextTabCommand->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+K"))); connect(nextTabAction, SIGNAL(triggered()), this, SLOT(nextTabAction())); }
Core::IFile *ProjectFilesFactory::open(const QString &fileName) { Core::EditorManager *editorManager = Core::EditorManager::instance(); if (Core::IEditor *editor = editorManager->openEditor(fileName, id())) return editor->file(); return 0; }
void Mode::grabEditorManager( Core::IMode * mode ) { if ( mode != this ) return; Core::EditorManager * em = Core::EditorManager::instance(); if ( em && em->currentEditor() ) em->currentEditor()->widget()->setFocus(); }
BaseTextEditorWidget *RefactoringChanges::editorForFile(const QString &fileName) { Core::EditorManager *editorManager = Core::EditorManager::instance(); const QList<Core::IEditor *> editors = editorManager->editorsForFileName(fileName); foreach (Core::IEditor *editor, editors) { BaseTextEditorWidget *textEditor = qobject_cast<BaseTextEditorWidget *>(editor->widget()); if (textEditor != 0) return textEditor; }
void CppPlugin::openTypeHierarchy() { Core::EditorManager *em = Core::EditorManager::instance(); CPPEditorWidget *editor = qobject_cast<CPPEditorWidget*>(em->currentEditor()->widget()); if (editor) { Core::NavigationWidget *navigation = Core::NavigationWidget::instance(); navigation->activateSubWidget(QLatin1String(Constants::TYPE_HIERARCHY_ID)); emit typeHierarchyRequested(); } }
void BaseTextMark::init() { m_init = true; Core::EditorManager *em = Core::EditorManager::instance(); connect(em, SIGNAL(editorOpened(Core::IEditor *)), SLOT(editorOpened(Core::IEditor *))); foreach (Core::IEditor *editor, em->openedEditors()) editorOpened(editor); }
void VCSBaseEditor::slotDiffBrowse(int index) { // goto diffed file as indicated by index/line number if (index < 0 || index >= d->m_diffSections.size()) return; const int lineNumber = d->m_diffSections.at(index); Core::EditorManager *editorManager = Core::EditorManager::instance(); editorManager->addCurrentPositionToNavigationHistory(); gotoLine(lineNumber + 1, 0); // TextEdit uses 1..n convention }
void LineNumberFilter::accept(FilterEntry selection) const { ITextEditor *editor = currentTextEditor(); if (editor) { Core::EditorManager *editorManager = Core::EditorManager::instance(); editorManager->addCurrentPositionToNavigationHistory(); editor->gotoLine(selection.internalData.toInt()); editor->widget()->setFocus(); Core::ModeManager::instance()->activateModeType(Core::Constants::MODE_EDIT_TYPE); } }
void QmlJSEditorPlugin::reformatFile() { Core::EditorManager *em = Core::EditorManager::instance(); if (QmlJSTextEditorWidget *editor = qobject_cast<QmlJSTextEditorWidget*>(em->currentEditor()->widget())) { QTC_ASSERT(!editor->isSemanticInfoOutdated(), return); const QString &newText = QmlJS::reformat(editor->semanticInfo().document); QTextCursor tc(editor->textCursor()); tc.movePosition(QTextCursor::Start); tc.movePosition(QTextCursor::End, QTextCursor::KeepAnchor); tc.insertText(newText); }
void BaseTextMark::moveMark(const QString & /* filename */, int /* line */) { Core::EditorManager *em = Core::EditorManager::instance(); if (!m_init) { connect(em, SIGNAL(editorOpened(Core::IEditor *)), SLOT(editorOpened(Core::IEditor *))); m_init = true; } if (m_markableInterface) m_markableInterface->removeMark(this); foreach (Core::IEditor *editor, em->openedEditors()) editorOpened(editor); }
void LineNumberFilter::accept(FilterEntry selection) const { ITextEditor *editor = currentTextEditor(); if (editor) { Core::EditorManager *editorManager = Core::EditorManager::instance(); editorManager->addCurrentPositionToNavigationHistory(); LineColumn data = selection.internalData.value<LineColumn>(); if (data.first < 1) { // jump to column in same line int currLine, currColumn; editor->convertPosition(editor->position(), &currLine, &currColumn); data.first = currLine; } editor->gotoLine(data.first, data.second); editor->widget()->setFocus(); Core::ModeManager::activateModeType(Id(Core::Constants::MODE_EDIT_TYPE)); } }
void CppPlugin::quickFixNow() { if (! m_currentEditor) return; Core::EditorManager *em = Core::EditorManager::instance(); CPPEditorWidget *currentEditor = qobject_cast<CPPEditorWidget*>(em->currentEditor()->widget()); if (CPPEditorWidget *editor = qobject_cast<CPPEditorWidget*>(m_currentEditor->widget())) { if (currentEditor == editor) { if (editor->isOutdated()) m_quickFixTimer->start(QUICKFIX_INTERVAL); else TextEditor::CompletionSupport::instance()-> complete(m_currentEditor, TextEditor::QuickFixCompletion, true); } } }
void CoolScroll::Internal::CoolScrollPlugin::onSettingChanged() { saveSettings(); Core::EditorManager* em = Core::EditorManager::instance(); QList<Core::IEditor*> editors = em->visibleEditors(); QList<Core::IEditor*>::iterator it = editors.begin(); // editors will update settings after next opening for( ; it != editors.end(); ++it) { CoolScrollBar* bar = getEditorScrollBar(*it); Q_ASSERT(bar); bar->markStateDirty(); } // update current editor right now CoolScrollBar* bar = getEditorScrollBar(em->currentEditor()); Q_ASSERT(bar); bar->fullUpdateSettings(); }
void QmlProfilerTool::gotoSourceLocation(const QString &fileUrl, int lineNumber) { if (lineNumber < 0 || fileUrl.isEmpty()) return; #if 0 const QString fileName = QUrl(fileUrl).toLocalFile(); const QString projectFileName = d->m_projectFinder.findFile(fileName); Core::EditorManager *editorManager = Core::EditorManager::instance(); Core::IEditor *editor = editorManager->openEditor(projectFileName); TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor*>(editor); if (textEditor) { editorManager->addCurrentPositionToNavigationHistory(); textEditor->gotoLine(lineNumber); textEditor->widget()->setFocus(); } #endif }
void CppOutlineWidget::updateTextCursor(const QModelIndex &proxyIndex) { QModelIndex index = m_proxyModel->mapToSource(proxyIndex); CPlusPlus::Symbol *symbol = m_model->symbolFromIndex(index); if (symbol) { m_blockCursorSync = true; if (debug) qDebug() << "CppOutline - moving cursor to" << symbol->line() << symbol->column() - 1; Core::EditorManager *editorManager = Core::EditorManager::instance(); editorManager->cutForwardNavigationHistory(); editorManager->addCurrentPositionToNavigationHistory(); // line has to be 1 based, column 0 based! m_editor->gotoLine(symbol->line(), symbol->column() - 1); m_editor->setFocus(); m_blockCursorSync = false; } }
void FolderNavigationWidget::openItem(const QModelIndex &srcIndex) { const QString fileName = m_fileSystemModel->fileName(srcIndex); if (fileName == QLatin1String(".")) return; if (fileName == QLatin1String("..")) { // cd up: Special behaviour: The fileInfo of ".." is that of the parent directory. const QString parentPath = m_fileSystemModel->fileInfo(srcIndex).absoluteFilePath(); setCurrentDirectory(parentPath); return; } if (m_fileSystemModel->isDir(srcIndex)) { // Change to directory const QFileInfo fi = m_fileSystemModel->fileInfo(srcIndex); if (fi.isReadable() && fi.isExecutable()) setCurrentDirectory(m_fileSystemModel->filePath(srcIndex)); return; } // Open file. Core::EditorManager *editorManager = Core::EditorManager::instance(); editorManager->openEditor(m_fileSystemModel->filePath(srcIndex), Core::Id(), Core::EditorManager::ModeSwitch); }
void BaseFileFilter::accept(Locator::FilterEntry selection) const { Core::EditorManager *em = Core::EditorManager::instance(); em->openEditor(selection.internalData.toString(), QString(), Core::EditorManager::ModeSwitch); }
void BaseFileFilter::accept(QuickOpen::FilterEntry selection) const { Core::EditorManager *em = Core::EditorManager::instance(); em->openEditor(selection.internalData.toString()); em->ensureEditorManagerVisible(); }
void QmlJSEditorPlugin::renameUsages() { Core::EditorManager *em = Core::EditorManager::instance(); if (QmlJSTextEditorWidget *editor = qobject_cast<QmlJSTextEditorWidget*>(em->currentEditor()->widget())) editor->renameUsages(); }