EditorManager: Remove QString openEditor(At) overloads

In favor of the FilePath/Link ones.

Change-Id: I5caf9e0f8de304ff4ee12329557aa50a6f3a0c69
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Eike Ziller
2021-11-01 17:02:02 +01:00
parent 4dac32d661
commit 195abefe7d
56 changed files with 149 additions and 126 deletions

View File

@@ -654,7 +654,7 @@ void BazaarPluginPrivate::showCommitWidget(const QList<VcsBaseClient::StatusItem
return;
}
IEditor *editor = EditorManager::openEditor(saver.filePath().toString(), COMMIT_ID);
IEditor *editor = EditorManager::openEditor(saver.filePath(), COMMIT_ID);
if (!editor) {
VcsOutputWindow::appendError(tr("Unable to create an editor for the commit."));
return;

View File

@@ -141,8 +141,8 @@ void ClangCurrentDocumentFilter::accept(Core::LocatorFilterEntry selection,
if (!m_currentEditor)
return;
auto lineColumn = qvariant_cast<LineColumn>(selection.internalData);
Core::EditorManager::openEditorAt(m_currentPath, lineColumn.line,
lineColumn.column - 1);
Core::EditorManager::openEditorAt(
{FilePath::fromString(m_currentPath), lineColumn.line, lineColumn.column - 1});
}
void ClangCurrentDocumentFilter::reset(Core::IEditor *newCurrent, const QString &path)

View File

@@ -74,9 +74,9 @@ void openEditorAt(const ClangBackEnd::DiagnosticContainer &diagnostic)
{
const ClangBackEnd::SourceLocationContainer &location = diagnostic.location;
Core::EditorManager::openEditorAt(location.filePath.toString(),
int(location.line),
int(location.column - 1));
Core::EditorManager::openEditorAt({Utils::FilePath::fromString(location.filePath.toString()),
int(location.line),
int(location.column - 1)});
}
void applyFixit(const ClangBackEnd::DiagnosticContainer &diagnostic)

View File

@@ -323,7 +323,8 @@ bool OpenDocumentCommand::run()
{
qCDebug(debug) << "line" << context().lineNumber << "OpenDocumentCommand" << m_documentFilePath;
const bool openEditorSucceeded = Core::EditorManager::openEditor(m_documentFilePath);
const bool openEditorSucceeded = Core::EditorManager::openEditor(
Utils::FilePath::fromString(m_documentFilePath));
QTC_ASSERT(openEditorSucceeded, return false);
auto *processor = ClangEditorDocumentProcessor::get(m_documentFilePath);

View File

@@ -181,7 +181,8 @@ private:
OpenEditorAtCursorPosition::OpenEditorAtCursorPosition(const TestDocument &testDocument)
{
Core::IEditor *coreEditor = Core::EditorManager::openEditor(testDocument.filePath);
Core::IEditor *coreEditor = Core::EditorManager::openEditor(
Utils::FilePath::fromString(testDocument.filePath));
m_editor = qobject_cast<TextEditor::BaseTextEditor *>(coreEditor);
QTC_CHECK(m_editor);
if (m_editor) {

View File

@@ -1852,7 +1852,7 @@ void ClangdTestCompletion::getProposal(const QString &fileName,
int line, column;
Utils::Text::convertPosition(doc->document(), pos, &line, &column);
const auto editor = qobject_cast<BaseTextEditor *>(
EditorManager::openEditorAt(doc->filePath().toString(), line, column - 1));
EditorManager::openEditorAt({doc->filePath(), line, column - 1}));
QVERIFY(editor);
QCOMPARE(EditorManager::currentEditor(), editor);
QCOMPARE(editor->textDocument(), doc);

View File

@@ -123,7 +123,7 @@ bool ClangFormatPlugin::initialize(const QStringList &arguments, QString *errorS
[openClangFormatConfigAction]() {
const FilePath fileName = FilePath::fromVariant(openClangFormatConfigAction->data());
if (!fileName.isEmpty())
EditorManager::openEditor(configForFile(fileName));
EditorManager::openEditor(FilePath::fromString(configForFile(fileName)));
});
connect(EditorManager::instance(),

View File

@@ -377,7 +377,7 @@ void Manager::onWidgetVisibilityIsChanged(bool visibility)
void Manager::gotoLocation(const QString &fileName, int line, int column)
{
EditorManager::openEditorAt(fileName, line, column);
EditorManager::openEditorAt({FilePath::fromString(fileName), line, column});
}
/*!

View File

@@ -2689,10 +2689,11 @@ public:
ClearCasePluginPrivate::instance()->setFakeCleartool(true);
VcsManager::clearVersionControlCache();
FileSaver srcSaver(Utils::FilePath::fromString(fileName));
const auto filePath = Utils::FilePath::fromString(fileName);
FileSaver srcSaver(filePath);
srcSaver.write(QByteArray());
srcSaver.finalize();
m_editor = EditorManager::openEditor(fileName);
m_editor = EditorManager::openEditor(filePath);
QCoreApplication::processEvents(); // process any pending events
}

View File

@@ -182,10 +182,10 @@ void OpenCMakeTargetLocatorFilter::accept(Core::LocatorFilterEntry selection,
const QVariantMap extraData = selection.internalData.toMap();
const int line = extraData.value("line").toInt();
const QString file = extraData.value("file").toString();
const auto file = FilePath::fromVariant(extraData.value("file"));
if (line >= 0)
Core::EditorManager::openEditorAt(file, line);
Core::EditorManager::openEditorAt({file, line});
else
Core::EditorManager::openEditor(file);
}

View File

@@ -188,7 +188,7 @@ bool BaseFileWizardFactory::postGenerateOpenEditors(const GeneratedFiles &l, QSt
{
foreach (const GeneratedFile &file, l) {
if (file.attributes() & GeneratedFile::OpenEditorAttribute) {
if (!EditorManager::openEditor(file.path(), file.editorId())) {
if (!EditorManager::openEditor(FilePath::fromString(file.path()), file.editorId())) {
if (errorMessage)
*errorMessage = tr("Failed to open an editor for \"%1\".").arg(QDir::toNativeSeparators(file.path()));
return false;

View File

@@ -3092,12 +3092,6 @@ IEditor *EditorManager::openEditor(const FilePath &filePath, Id editorId,
filePath, editorId, flags, newEditor);
}
IEditor *EditorManager::openEditor(const QString &fileName, Id editorId,
OpenEditorFlags flags, bool *newEditor)
{
return openEditor(FilePath::fromString(fileName), editorId, flags, newEditor);
}
/*!
Opens the document specified by \a filePath using the editor type \a
editorId and the specified \a flags.
@@ -3132,12 +3126,6 @@ IEditor *EditorManager::openEditorAt(const Link &link,
newEditor);
}
IEditor *EditorManager::openEditorAt(const QString &fileName, int line, int column,
Id editorId, OpenEditorFlags flags, bool *newEditor)
{
return openEditorAt(Link(FilePath::fromString(fileName), line, column), editorId, flags, newEditor);
}
/*!
Opens the document at the position of the search result \a item using the
editor type \a editorId and the specified \a flags.
@@ -3157,13 +3145,13 @@ void EditorManager::openEditorAtSearchResult(const SearchResultItem &item,
bool *newEditor)
{
if (item.path().empty()) {
openEditor(QDir::fromNativeSeparators(item.lineText()), editorId, flags, newEditor);
openEditor(FilePath::fromUserInput(item.lineText()), editorId, flags, newEditor);
return;
}
openEditorAt(QDir::fromNativeSeparators(item.path().first()),
item.mainRange().begin.line,
item.mainRange().begin.column,
openEditorAt({FilePath::fromUserInput(item.path().first()),
item.mainRange().begin.line,
item.mainRange().begin.column},
editorId,
flags,
newEditor);
@@ -3603,7 +3591,7 @@ bool EditorManager::restoreState(const QByteArray &state)
continue;
const FilePath rfp = autoSaveName(filePath);
if (rfp.exists() && filePath.lastModified() < rfp.lastModified()) {
if (IEditor *editor = openEditor(fileName, id, DoNotMakeVisible))
if (IEditor *editor = openEditor(filePath, id, DoNotMakeVisible))
DocumentModelPrivate::setPinned(DocumentModel::entryForDocument(editor->document()), pinned);
} else {
if (DocumentModel::Entry *entry = DocumentModelPrivate::addSuspendedDocument(

View File

@@ -97,13 +97,6 @@ public:
OpenEditorFlags flags = NoFlags,
bool *newEditor = nullptr);
// Kept for a while for transition.
static IEditor *openEditor(const QString &fileName, Utils::Id editorId = {},
OpenEditorFlags flags = NoFlags, bool *newEditor = nullptr); // FIXME: Remove overload
static IEditor *openEditorAt(const QString &fileName, int line, int column = 0,
Utils::Id editorId = {}, OpenEditorFlags flags = NoFlags,
bool *newEditor = nullptr); // FIXME: Remove overload
static void openEditorAtSearchResult(const SearchResultItem &item,
Utils::Id editorId = {},
OpenEditorFlags flags = NoFlags,

View File

@@ -616,7 +616,7 @@ void FolderNavigationWidget::openItem(const QModelIndex &index)
if (m_fileSystemModel->isDir(index))
return;
const QString path = m_fileSystemModel->filePath(index);
Core::EditorManager::openEditor(path);
Core::EditorManager::openEditor(FilePath::fromString(path));
}
void FolderNavigationWidget::createNewFolder(const QModelIndex &parent)

View File

@@ -400,10 +400,10 @@ void CodePasterPluginPrivate::finishFetch(const QString &titleDescription,
MessageManager::writeDisrupting(saver.errorString());
return;
}
const QString fileName = saver.filePath().toString();
m_fetchedSnippets.push_back(fileName);
const Utils::FilePath filePath = saver.filePath();
m_fetchedSnippets.push_back(filePath.toString());
// Open editor with title.
IEditor *editor = EditorManager::openEditor(fileName);
IEditor *editor = EditorManager::openEditor(filePath);
QTC_ASSERT(editor, return);
editor->document()->setPreferredDisplayName(titleDescription);
}

View File

@@ -79,7 +79,7 @@ public:
QVERIFY(!fileName.isEmpty());
// Open in editor
m_editor = EditorManager::openEditor(fileName);
m_editor = EditorManager::openEditor(Utils::FilePath::fromString(fileName));
QVERIFY(m_editor);
closeEditorAtEndOfTestCase(m_editor);
m_editorWidget = TextEditorWidget::fromEditor(m_editor);

View File

@@ -125,7 +125,8 @@ void CppCurrentDocumentFilter::accept(Core::LocatorFilterEntry selection,
Q_UNUSED(selectionStart)
Q_UNUSED(selectionLength)
IndexItem::Ptr info = qvariant_cast<IndexItem::Ptr>(selection.internalData);
Core::EditorManager::openEditorAt(info->fileName(), info->line(), info->column());
Core::EditorManager::openEditorAt(
{Utils::FilePath::fromString(info->fileName()), info->line(), info->column()});
}
void CppCurrentDocumentFilter::onDocumentUpdated(Document::Ptr doc)

View File

@@ -626,8 +626,8 @@ void CppEditorPlugin::switchHeaderSource()
void CppEditorPlugin::switchHeaderSourceInNextSplit()
{
QString otherFile = correspondingHeaderOrSource(
EditorManager::currentDocument()->filePath().toString());
const auto otherFile = FilePath::fromString(
correspondingHeaderOrSource(EditorManager::currentDocument()->filePath().toString()));
if (!otherFile.isEmpty())
EditorManager::openEditor(otherFile, Id(), EditorManager::OpenInOtherSplit);
}

View File

@@ -143,7 +143,8 @@ void CppLocatorFilter::accept(Core::LocatorFilterEntry selection,
Q_UNUSED(selectionStart)
Q_UNUSED(selectionLength)
IndexItem::Ptr info = qvariant_cast<IndexItem::Ptr>(selection.internalData);
Core::EditorManager::openEditorAt(info->fileName(), info->line(), info->column());
Core::EditorManager::openEditorAt(
{Utils::FilePath::fromString(info->fileName()), info->line(), info->column()});
}
CppClassesFilter::CppClassesFilter(CppLocatorData *locatorData)

View File

@@ -114,7 +114,7 @@ private:
QVERIFY(DocumentModel::openedDocuments().isEmpty());
QVERIFY(garbageCollectGlobalSnapshot());
m_editor = EditorManager::openEditor(m_fileName);
m_editor = EditorManager::openEditor(FilePath::fromString(m_fileName));
QVERIFY(m_editor);
QVERIFY(waitForFileInGlobalSnapshot(m_fileName));

View File

@@ -653,7 +653,7 @@ void ModelManagerTest::testGcIfLastCppeditorClosed()
// Open a file in the editor
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 0);
Core::IEditor *editor = Core::EditorManager::openEditor(file);
Core::IEditor *editor = Core::EditorManager::openEditor(Utils::FilePath::fromString(file));
QVERIFY(editor);
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 1);
QVERIFY(mm->isCppEditor(editor));
@@ -684,7 +684,7 @@ void ModelManagerTest::testDontGcOpenedFiles()
// Open a file in the editor
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 0);
Core::IEditor *editor = Core::EditorManager::openEditor(file);
Core::IEditor *editor = Core::EditorManager::openEditor(Utils::FilePath::fromString(file));
QVERIFY(editor);
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 1);
QVERIFY(mm->isCppEditor(editor));
@@ -783,7 +783,8 @@ void ModelManagerTest::testDefinesPerProject()
const QString firstDeclarationName = i.firstDeclarationName;
const QString fileName = i.fileName;
Core::IEditor *editor = Core::EditorManager::openEditor(fileName);
Core::IEditor *editor = Core::EditorManager::openEditor(
Utils::FilePath::fromString(fileName));
EditorCloser closer(editor);
QVERIFY(editor);
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 1);
@@ -847,7 +848,8 @@ void ModelManagerTest::testPrecompiledHeaders()
const QByteArray firstClassInPchFile = i.firstClassInPchFile.toUtf8();
const QString fileName = i.fileName;
Core::IEditor *editor = Core::EditorManager::openEditor(fileName);
Core::IEditor *editor = Core::EditorManager::openEditor(
Utils::FilePath::fromString(fileName));
EditorCloser closer(editor);
QVERIFY(editor);
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 1);
@@ -921,7 +923,8 @@ void ModelManagerTest::testDefinesPerEditor()
const QString editorDefines = i.editorDefines;
const QString firstDeclarationName = i.firstDeclarationName;
Core::IEditor *editor = Core::EditorManager::openEditor(main1File);
Core::IEditor *editor = Core::EditorManager::openEditor(
Utils::FilePath::fromString(main1File));
EditorCloser closer(editor);
QVERIFY(editor);
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 1);
@@ -949,7 +952,7 @@ void ModelManagerTest::testUpdateEditorsAfterProjectUpdate()
const QString fileB = testDataDirectory.file(_("main2.cpp")); // content not relevant
// Open file A in editor
Core::IEditor *editorA = Core::EditorManager::openEditor(fileA);
Core::IEditor *editorA = Core::EditorManager::openEditor(Utils::FilePath::fromString(fileA));
QVERIFY(editorA);
EditorCloser closerA(editorA);
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 1);
@@ -958,7 +961,7 @@ void ModelManagerTest::testUpdateEditorsAfterProjectUpdate()
QVERIFY(!documentAProjectPart->hasProject());
// Open file B in editor
Core::IEditor *editorB = Core::EditorManager::openEditor(fileB);
Core::IEditor *editorB = Core::EditorManager::openEditor(Utils::FilePath::fromString(fileB));
QVERIFY(editorB);
EditorCloser closerB(editorB);
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 2);
@@ -1087,7 +1090,7 @@ void ModelManagerTest::testRenameIncludesInEditor()
// Open a file in the editor
QCOMPARE(Core::DocumentModel::openedDocuments().size(), 0);
Core::IEditor *editor = Core::EditorManager::openEditor(mainFile);
Core::IEditor *editor = Core::EditorManager::openEditor(Utils::FilePath::fromString(mainFile));
QVERIFY(editor);
EditorCloser editorCloser(editor);
Utils::ExecuteOnDestruction saveAllFiles([](){

View File

@@ -273,7 +273,8 @@ void switchHeaderSource()
{
const Core::IDocument *currentDocument = Core::EditorManager::currentDocument();
QTC_ASSERT(currentDocument, return);
const QString otherFile = correspondingHeaderOrSource(currentDocument->filePath().toString());
const auto otherFile = Utils::FilePath::fromString(
correspondingHeaderOrSource(currentDocument->filePath().toString()));
if (!otherFile.isEmpty())
Core::EditorManager::openEditor(otherFile);
}

View File

@@ -232,7 +232,8 @@ bool TestCase::succeededSoFar() const
bool TestCase::openCppEditor(const QString &fileName, TextEditor::BaseTextEditor **editor,
CppEditorWidget **editorWidget)
{
if (const auto e = dynamic_cast<TextEditor::BaseTextEditor *>(Core::EditorManager::openEditor(fileName))) {
if (const auto e = dynamic_cast<TextEditor::BaseTextEditor *>(
Core::EditorManager::openEditor(FilePath::fromString(fileName)))) {
if (editor) {
*editor = e;
TextEditor::StorageSettings s = e->textDocument()->storageSettings();

View File

@@ -179,7 +179,8 @@ void SymbolsFindFilter::openEditor(const SearchResultItem &item)
if (!item.userData().canConvert<IndexItem::Ptr>())
return;
IndexItem::Ptr info = item.userData().value<IndexItem::Ptr>();
EditorManager::openEditorAt(info->fileName(), info->line(), info->column());
EditorManager::openEditorAt(
{FilePath::fromString(info->fileName()), info->line(), info->column()});
}
QWidget *SymbolsFindFilter::createConfigWidget()

View File

@@ -802,7 +802,7 @@ static void setDiffBaseDirectory(IEditor *editor, const FilePath &db)
CvsSubmitEditor *CvsPluginPrivate::openCVSSubmitEditor(const QString &fileName)
{
IEditor *editor = EditorManager::openEditor(fileName, CVSCOMMITEDITOR_ID);
IEditor *editor = EditorManager::openEditor(FilePath::fromString(fileName), CVSCOMMITEDITOR_ID);
auto submitEditor = qobject_cast<CvsSubmitEditor*>(editor);
QTC_ASSERT(submitEditor, return nullptr);
connect(submitEditor, &VcsBaseSubmitEditor::diffSelectedFiles,

View File

@@ -182,11 +182,10 @@ void ConsoleView::onRowActivated(const QModelIndex &index)
if (!index.isValid())
return;
const QFileInfo fi = m_finder.findFile(model()->data(index, ConsoleItem::FileRole).toString())
.constFirst().toFileInfo();
if (fi.exists() && fi.isFile() && fi.isReadable()) {
Core::EditorManager::openEditorAt(fi.canonicalFilePath(),
model()->data(index, ConsoleItem::LineRole).toInt());
const Utils::FilePath fp
= m_finder.findFile(model()->data(index, ConsoleItem::FileRole).toString()).constFirst();
if (fp.exists() && fp.isFile() && fp.isReadableFile()) {
Core::EditorManager::openEditorAt({fp, model()->data(index, ConsoleItem::LineRole).toInt()});
}
}

View File

@@ -140,7 +140,7 @@ static void openImageViewer(const QImage &image)
fileName = temporaryFile.fileName();
temporaryFile.close();
}
if (Core::IEditor *e = Core::EditorManager::openEditor(fileName))
if (Core::IEditor *e = Core::EditorManager::openEditor(Utils::FilePath::fromString(fileName)))
e->document()->setProperty(Debugger::Constants::OPENED_BY_DEBUGGER, QVariant(true));
}

View File

@@ -756,8 +756,8 @@ void QmlInspectorAgent::onShowAppOnTopChanged(bool checked)
void QmlInspectorAgent::jumpToObjectDefinitionInEditor(const FileReference &objSource)
{
const QString fileName = m_qmlEngine->toFileInProject(objSource.url());
Core::EditorManager::openEditorAt(fileName, objSource.lineNumber());
const auto filePath = Utils::FilePath::fromString(m_qmlEngine->toFileInProject(objSource.url()));
Core::EditorManager::openEditorAt({filePath, objSource.lineNumber()});
}
void QmlInspectorAgent::selectObjects(const QList<int> &debugIds,

View File

@@ -184,7 +184,7 @@ static QString otherFile()
void FormEditorPlugin::switchSourceForm()
{
const QString fileToOpen = otherFile();
const auto fileToOpen = Utils::FilePath::fromString(otherFile());
if (!fileToOpen.isEmpty())
EditorManager::openEditor(fileToOpen);
}

View File

@@ -154,7 +154,7 @@ public:
QList<TextEditor::BaseTextEditor *> editors;
for (const QString &file : files) {
IEditor *editor = EditorManager::openEditor(file);
IEditor *editor = EditorManager::openEditor(Utils::FilePath::fromString(file));
TextEditor::BaseTextEditor *e = qobject_cast<TextEditor::BaseTextEditor *>(editor);
QVERIFY(e);
closeEditorAtEndOfTestCase(editor);

View File

@@ -246,9 +246,10 @@ static Function *findDeclaration(const Class *cl, const QString &functionName)
static inline BaseTextEditor *editorAt(const QString &fileName, int line, int column)
{
return qobject_cast<BaseTextEditor *>(Core::EditorManager::openEditorAt(fileName, line, column,
Utils::Id(),
Core::EditorManager::DoNotMakeVisible));
return qobject_cast<BaseTextEditor *>(
Core::EditorManager::openEditorAt({FilePath::fromString(fileName), line, column},
Utils::Id(),
Core::EditorManager::DoNotMakeVisible));
}
static void addDeclaration(const Snapshot &snapshot,
@@ -560,8 +561,8 @@ bool QtCreatorIntegration::navigateToSlot(const QString &objectName,
CppEditor::CppRefactoringChanges refactoring(docTable);
CppEditor::SymbolFinder symbolFinder;
if (const Function *funImpl = symbolFinder.findMatchingDefinition(fun, docTable, true)) {
Core::EditorManager::openEditorAt(QString::fromUtf8(funImpl->fileName()),
funImpl->line() + 2);
Core::EditorManager::openEditorAt(
{FilePath::fromString(QString::fromUtf8(funImpl->fileName())), funImpl->line() + 2});
return true;
}
const QString implFilePath = CppEditor::correspondingHeaderOrSource(declFilePath);
@@ -575,9 +576,9 @@ bool QtCreatorIntegration::navigateToSlot(const QString &objectName,
+ functionNameWithParameterNames + "\n{\n" + QString(indentation, ' ') + "\n}\n"
+ location.suffix();
editor->insert(definition);
Core::EditorManager::openEditorAt(location.fileName(),
location.line() + location.prefix().count('\n') + 2,
indentation);
Core::EditorManager::openEditorAt({FilePath::fromString(location.fileName()),
int(location.line() + location.prefix().count('\n') + 2),
indentation});
return true;
}

View File

@@ -217,7 +217,7 @@ void DiffEditorWidgetController::jumpToOriginalFile(const QString &fileName,
const FilePath filePath = m_document->baseDirectory().resolvePath(fileName);
if (filePath.exists() && !filePath.isDir())
EditorManager::openEditorAt(filePath.toString(), lineNumber, columnNumber);
EditorManager::openEditorAt({filePath, lineNumber, columnNumber});
}
void DiffEditorWidgetController::setFontSettings(const FontSettings &fontSettings)

View File

@@ -1841,12 +1841,13 @@ void FakeVimPluginPrivate::editorOpened(IEditor *editor)
}
});
handler->requestJumpToGlobalMark.connect([this](QChar mark, bool backTickMode, const QString &fileName) {
if (IEditor *iedit = EditorManager::openEditor(fileName)) {
if (FakeVimHandler *handler = m_editorToHandler.value(iedit, nullptr))
handler->jumpToLocalMark(mark, backTickMode);
}
});
handler->requestJumpToGlobalMark.connect(
[this](QChar mark, bool backTickMode, const QString &fileName) {
if (IEditor *iedit = EditorManager::openEditor(FilePath::fromString(fileName))) {
if (FakeVimHandler *handler = m_editorToHandler.value(iedit, nullptr))
handler->jumpToLocalMark(mark, backTickMode);
}
});
handler->handleExCommandRequested.connect([this, handler](bool *handled, const ExCommand &cmd) {
handleExCommand(handler, handled, cmd);

View File

@@ -1384,7 +1384,8 @@ void GitPluginPrivate::updateVersionWarning()
IEditor *GitPluginPrivate::openSubmitEditor(const QString &fileName, const CommitData &cd)
{
IEditor *editor = EditorManager::openEditor(fileName, Constants::GITSUBMITEDITOR_ID);
IEditor *editor = EditorManager::openEditor(FilePath::fromString(fileName),
Constants::GITSUBMITEDITOR_ID);
auto submitEditor = qobject_cast<GitSubmitEditor*>(editor);
QTC_ASSERT(submitEditor, return nullptr);
setSubmitEditor(submitEditor);

View File

@@ -156,8 +156,10 @@ void ElementTasks::openClassDefinition(const qmt::MElement *element)
CppEditor::IndexItem::Ptr info = qvariant_cast<CppEditor::IndexItem::Ptr>(entry.internalData);
if (info->scopedSymbolName() != qualifiedClassName)
continue;
if (Core::EditorManager::instance()->openEditorAt(info->fileName(), info->line(), info->column()))
if (Core::EditorManager::instance()->openEditorAt(
{Utils::FilePath::fromString(info->fileName()), info->line(), info->column()})) {
return;
}
}
}
}

View File

@@ -259,7 +259,7 @@ void ModelsManager::onOpenDiagramFromProjectExplorer()
void ModelsManager::onOpenDefaultModel(const qmt::Uid &modelUid)
{
QString modelFile = d->modelIndexer->findModel(modelUid);
const auto modelFile = Utils::FilePath::fromString(d->modelIndexer->findModel(modelUid));
if (!modelFile.isEmpty())
Core::EditorManager::openEditor(modelFile);
}

View File

@@ -802,7 +802,8 @@ void PerforcePluginPrivate::startSubmitProject()
IEditor *PerforcePluginPrivate::openPerforceSubmitEditor(const QString &fileName, const QStringList &depotFileNames)
{
IEditor *editor = EditorManager::openEditor(fileName, PERFORCE_SUBMIT_EDITOR_ID);
IEditor *editor = EditorManager::openEditor(FilePath::fromString(fileName),
PERFORCE_SUBMIT_EDITOR_ID);
auto submitEditor = static_cast<PerforceSubmitEditor*>(editor);
setSubmitEditor(submitEditor);
submitEditor->restrictToProjectFiles(depotFileNames);

View File

@@ -555,10 +555,10 @@ void PerfProfilerTool::gotoSourceLocation(QString filePath, int lineNumber, int
// The text editors count columns starting with 0, but the ASTs store the
// location starting with 1, therefore the -1.
EditorManager::openEditorAt(fi.filePath(), lineNumber, columnNumber - 1, Utils::Id(),
EditorManager::openEditorAt({FilePath::fromFileInfo(fi), lineNumber, columnNumber - 1},
Utils::Id(),
EditorManager::DoNotSwitchToDesignMode
| EditorManager::DoNotSwitchToEditMode);
| EditorManager::DoNotSwitchToEditMode);
}
static Utils::FilePaths collectQtIncludePaths(const ProjectExplorer::Kit *kit)

View File

@@ -466,7 +466,9 @@ void JsonWizard::openFiles(const JsonWizard::GeneratorFiles &files)
openedSomething = true;
}
if (file.attributes() & Core::GeneratedFile::OpenEditorAttribute) {
Core::IEditor *editor = Core::EditorManager::openEditor(file.path(), file.editorId());
Core::IEditor *editor = Core::EditorManager::openEditor(FilePath::fromString(
file.path()),
file.editorId());
if (!editor) {
errorMessage = QCoreApplication::translate("ProjectExplorer::JsonWizard",
"Failed to open an editor for \"%1\".")

View File

@@ -45,9 +45,9 @@ bool ShowInEditorTaskHandler::canHandle(const Task &task) const
void ShowInEditorTaskHandler::handle(const Task &task)
{
QFileInfo fi(task.file.toFileInfo());
const int column = task.column ? task.column - 1 : 0;
Core::EditorManager::openEditorAt(fi.filePath(), task.movedLine, column, {},
Core::EditorManager::openEditorAt({task.file, task.movedLine, column},
{},
Core::EditorManager::SwitchSplitIfAlreadyVisible);
}

View File

@@ -123,7 +123,7 @@ private:
return false;
const QString fileName = match.captured(3);
const int lineNumber = match.captured(4).toInt();
Core::EditorManager::openEditorAt(fileName, lineNumber);
Core::EditorManager::openEditorAt({FilePath::fromString(fileName), lineNumber});
return true;
}

View File

@@ -685,7 +685,9 @@ void addSignalHandlerOrGotoImplementation(const SelectionContext &selectionState
Core::ModeManager::activateMode(Core::Constants::MODE_EDIT);
if (!usages.isEmpty() && (addAlwaysNewSlot || usages.count() < 2) && (!isModelNodeRoot || addAlwaysNewSlot)) {
Core::EditorManager::openEditorAt(usages.constFirst().path, usages.constFirst().line, usages.constFirst().col);
Core::EditorManager::openEditorAt({Utils::FilePath::fromString(usages.constFirst().path),
usages.constFirst().line,
usages.constFirst().col});
if (!signalNames.isEmpty()) {
auto dialog = new AddSignalHandlerDialog(Core::ICore::dialogParent());
@@ -707,7 +709,9 @@ void addSignalHandlerOrGotoImplementation(const SelectionContext &selectionState
//Move cursor to correct curser position
const QString filePath = Core::EditorManager::currentDocument()->filePath().toString();
QList<QmlJSEditor::FindReferences::Usage> usages = FindImplementation::run(filePath, typeName, itemId);
Core::EditorManager::openEditorAt(filePath, usages.constFirst().line, usages.constFirst().col + 1);
Core::EditorManager::openEditorAt({Utils::FilePath::fromString(filePath),
usages.constFirst().line,
usages.constFirst().col + 1});
} );
dialog->show();
@@ -715,7 +719,9 @@ void addSignalHandlerOrGotoImplementation(const SelectionContext &selectionState
return;
}
Core::EditorManager::openEditorAt(usages.constFirst().path, usages.constFirst().line, usages.constFirst().col + 1);
Core::EditorManager::openEditorAt({Utils::FilePath::fromString(usages.constFirst().path),
usages.constFirst().line,
usages.constFirst().col + 1});
}
void removeLayout(const SelectionContext &selectionContext)

View File

@@ -388,8 +388,10 @@ void NavigatorView::changeToComponent(const QModelIndex &index)
if (index.isValid() && currentModel()->data(index, Qt::UserRole).isValid()) {
const ModelNode doubleClickNode = modelNodeForIndex(index);
if (doubleClickNode.metaInfo().isFileComponent())
Core::EditorManager::openEditor(doubleClickNode.metaInfo().componentFileName(),
Utils::Id(), Core::EditorManager::DoNotMakeVisible);
Core::EditorManager::openEditor(Utils::FilePath::fromString(
doubleClickNode.metaInfo().componentFileName()),
Utils::Id(),
Core::EditorManager::DoNotMakeVisible);
}
}

View File

@@ -527,7 +527,8 @@ void DesignModeWidget::toolBarOnGoBackClicked()
if (m_navigatorHistoryCounter > 0) {
--m_navigatorHistoryCounter;
m_keepNavigatorHistory = true;
Core::EditorManager::openEditor(m_navigatorHistory.at(m_navigatorHistoryCounter),
Core::EditorManager::openEditor(Utils::FilePath::fromString(
m_navigatorHistory.at(m_navigatorHistoryCounter)),
Utils::Id(),
Core::EditorManager::DoNotMakeVisible);
m_keepNavigatorHistory = false;
@@ -539,7 +540,8 @@ void DesignModeWidget::toolBarOnGoForwardClicked()
if (m_navigatorHistoryCounter < (m_navigatorHistory.size() - 1)) {
++m_navigatorHistoryCounter;
m_keepNavigatorHistory = true;
Core::EditorManager::openEditor(m_navigatorHistory.at(m_navigatorHistoryCounter),
Core::EditorManager::openEditor(Utils::FilePath::fromString(
m_navigatorHistory.at(m_navigatorHistoryCounter)),
Utils::Id(),
Core::EditorManager::DoNotMakeVisible);
m_keepNavigatorHistory = false;

View File

@@ -111,8 +111,9 @@ static inline void applyProperties(ModelNode &node, const QHash<PropertyName, QV
static void openFileComponent(const ModelNode &modelNode)
{
QmlDesignerPlugin::instance()->viewManager().nextFileIsCalledInternally();
Core::EditorManager::openEditor(modelNode.metaInfo().componentFileName(),
Utils::Id(), Core::EditorManager::DoNotMakeVisible);
Core::EditorManager::openEditor(FilePath::fromString(modelNode.metaInfo().componentFileName()),
Utils::Id(),
Core::EditorManager::DoNotMakeVisible);
}
static void openFileComponentForDelegate(const ModelNode &modelNode)
@@ -138,7 +139,10 @@ static void openComponentSourcePropertyOfLoader(const ModelNode &modelNode)
componentModelNode = modelNode.nodeListProperty("component").toModelNodeList().constFirst();
}
Core::EditorManager::openEditor(componentModelNode.metaInfo().componentFileName(), Utils::Id(), Core::EditorManager::DoNotMakeVisible);
Core::EditorManager::openEditor(FilePath::fromString(
componentModelNode.metaInfo().componentFileName()),
Utils::Id(),
Core::EditorManager::DoNotMakeVisible);
}
static void openSourcePropertyOfLoader(const ModelNode &modelNode)
@@ -148,7 +152,10 @@ static void openSourcePropertyOfLoader(const ModelNode &modelNode)
QString componentFileName = modelNode.variantProperty("source").value().toString();
QFileInfo fileInfo(modelNode.model()->fileUrl().toLocalFile());
Core::EditorManager::openEditor(fileInfo.absolutePath() + "/" + componentFileName, Utils::Id(), Core::EditorManager::DoNotMakeVisible);
Core::EditorManager::openEditor(FilePath::fromString(fileInfo.absolutePath())
/ componentFileName,
Utils::Id(),
Core::EditorManager::DoNotMakeVisible);
}

View File

@@ -383,7 +383,8 @@ void QmlDesignerPlugin::showDesigner()
dialog.exec();
if (dialog.uiFileOpened()) {
Core::ModeManager::activateMode(Core::Constants::MODE_EDIT);
Core::EditorManager::openEditorAt(dialog.uiQmlFile(), 0, 0);
Core::EditorManager::openEditorAt(
{Utils::FilePath::fromString(dialog.uiQmlFile()), 0, 0});
return;
}
}

View File

@@ -102,5 +102,6 @@ void FunctionFilter::accept(Core::LocatorFilterEntry selection,
Q_UNUSED(selectionStart)
Q_UNUSED(selectionLength)
const LocatorData::Entry entry = qvariant_cast<LocatorData::Entry>(selection.internalData);
Core::EditorManager::openEditorAt(entry.fileName, entry.line, entry.column);
Core::EditorManager::openEditorAt(
{Utils::FilePath::fromString(entry.fileName), entry.line, entry.column});
}

View File

@@ -419,17 +419,20 @@ void QmlProfilerTool::gotoSourceLocation(const QString &fileUrl, int lineNumber,
if (lineNumber < 0 || fileUrl.isEmpty())
return;
const QString projectFileName = d->m_profilerModelManager->findLocalFile(fileUrl);
const auto projectFileName = FilePath::fromString(
d->m_profilerModelManager->findLocalFile(fileUrl));
QFileInfo fileInfo(projectFileName);
if (!fileInfo.exists() || !fileInfo.isReadable())
if (!projectFileName.exists() || !projectFileName.isReadableFile())
return;
// The text editors count columns starting with 0, but the ASTs store the
// location starting with 1, therefore the -1.
EditorManager::openEditorAt(
projectFileName, lineNumber == 0 ? 1 : lineNumber, columnNumber - 1, Id(),
EditorManager::DoNotSwitchToDesignMode | EditorManager::DoNotSwitchToEditMode);
EditorManager::openEditorAt({projectFileName,
lineNumber == 0 ? 1 : lineNumber,
columnNumber - 1},
Id(),
EditorManager::DoNotSwitchToDesignMode
| EditorManager::DoNotSwitchToEditMode);
}
void QmlProfilerTool::updateTimeDisplay()

View File

@@ -229,7 +229,7 @@ bool QtOutputLineParser::handleLink(const QString &href)
void QtOutputLineParser::openEditor(const QString &fileName, int line, int column)
{
Core::EditorManager::openEditorAt(fileName, line, column);
Core::EditorManager::openEditorAt({FilePath::fromString(fileName), line, column});
}
void QtOutputLineParser::updateProjectFileList()

View File

@@ -304,7 +304,7 @@ void ResourceEditorW::openCurrentFile()
void ResourceEditorW::openFile(const QString &fileName)
{
Core::EditorManager::openEditor(fileName);
Core::EditorManager::openEditor(FilePath::fromString(fileName));
}
void ResourceEditorW::onRefresh()

View File

@@ -212,7 +212,7 @@ public:
const QString qmlFile = QFileInfo(projectFile).dir().absolutePath() + "/"
+ formFile;
Core::EditorManager::openEditor(qmlFile);
Core::EditorManager::openEditor(Utils::FilePath::fromString(qmlFile));
});
return;
}

View File

@@ -624,7 +624,8 @@ void SubversionPluginPrivate::diffCommitFiles(const QStringList &files)
SubversionSubmitEditor *SubversionPluginPrivate::openSubversionSubmitEditor(const QString &fileName)
{
IEditor *editor = EditorManager::openEditor(fileName, Constants::SUBVERSION_COMMIT_EDITOR_ID);
IEditor *editor = EditorManager::openEditor(FilePath::fromString(fileName),
Constants::SUBVERSION_COMMIT_EDITOR_ID);
auto submitEditor = qobject_cast<SubversionSubmitEditor*>(editor);
QTC_ASSERT(submitEditor, return nullptr);
setSubmitEditor(submitEditor);

View File

@@ -569,10 +569,11 @@ void CallgrindToolPrivate::selectFunction(const Function *func)
if (!item || item != func)
m_stackBrowser.select(func);
if (QFile::exists(func->file())) {
const auto filePath = FilePath::fromString(func->file());
if (filePath.exists()) {
///TODO: custom position support?
int line = func->lineNumber();
EditorManager::openEditorAt(func->file(), qMax(line, 0));
EditorManager::openEditorAt({filePath, qMax(line, 0)});
}
}

View File

@@ -265,7 +265,7 @@ void CleanDialog::slotDoubleClicked(const QModelIndex &index)
// Open file on doubleclick
if (const QStandardItem *item = d->m_filesModel->itemFromIndex(index))
if (!item->data(Internal::isDirectoryRole).toBool()) {
const QString fname = item->data(Internal::fileNameRole).toString();
const auto fname = Utils::FilePath::fromVariant(item->data(Internal::fileNameRole));
Core::EditorManager::openEditor(fname);
}
}

View File

@@ -1190,7 +1190,7 @@ void VcsBaseEditorWidget::jumpToChangeFromDiff(QTextCursor cursor)
if (!exists)
return;
Core::IEditor *ed = Core::EditorManager::openEditor(fileName);
Core::IEditor *ed = Core::EditorManager::openEditor(Utils::FilePath::fromString(fileName));
if (auto editor = qobject_cast<BaseTextEditor *>(ed))
editor->gotoLine(chunkStart + lineCount);
}

View File

@@ -203,7 +203,7 @@ void OutputWindowPlainTextEdit::contextMenuEvent(QContextMenuEvent *event)
return;
}
if (action == openAction) {
const QString fileName = action->data().toString();
const auto fileName = Utils::FilePath::fromVariant(action->data());
Core::EditorManager::openEditor(fileName);
}
}