forked from qt-creator/qt-creator
Core: Add FilePath based overloads to EditorManager::openEditor{,at}
Part of the overall FilePath migration. Keep the original version for a while to allow using code to catch up. Change-Id: Ia7c5ea14416a06e679e8661c0e4045981db87b9b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -489,8 +489,7 @@ Bookmark *BookmarkManager::bookmarkForIndex(const QModelIndex &index) const
|
||||
|
||||
bool BookmarkManager::gotoBookmark(const Bookmark *bookmark) const
|
||||
{
|
||||
if (IEditor *editor = EditorManager::openEditorAt(bookmark->fileName().toString(),
|
||||
bookmark->lineNumber()))
|
||||
if (IEditor *editor = EditorManager::openEditorAt(bookmark->fileName(), bookmark->lineNumber()))
|
||||
return editor->currentLine() == bookmark->lineNumber();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -137,16 +137,14 @@ void ClangdTests::testFindReferences()
|
||||
};
|
||||
const auto headerPath = Utils::FilePath::fromString(testDir.absolutePath("defs.h"));
|
||||
QVERIFY2(headerPath.exists(), qPrintable(headerPath.toUserOutput()));
|
||||
QScopedPointer<IEditor, EditorCloser> headerEditor(
|
||||
EditorManager::openEditor(headerPath.toString()));
|
||||
QScopedPointer<IEditor, EditorCloser> headerEditor(EditorManager::openEditor(headerPath));
|
||||
QVERIFY(headerEditor);
|
||||
const auto headerDoc = qobject_cast<TextEditor::TextDocument *>(headerEditor->document());
|
||||
QVERIFY(headerDoc);
|
||||
QVERIFY(client->documentForFilePath(headerPath) == headerDoc);
|
||||
const auto cppFilePath = Utils::FilePath::fromString(testDir.absolutePath("main.cpp"));
|
||||
QVERIFY2(cppFilePath.exists(), qPrintable(cppFilePath.toUserOutput()));
|
||||
QScopedPointer<IEditor, EditorCloser> cppFileEditor(
|
||||
EditorManager::openEditor(cppFilePath.toString()));
|
||||
QScopedPointer<IEditor, EditorCloser> cppFileEditor(EditorManager::openEditor(cppFilePath));
|
||||
QVERIFY(cppFileEditor);
|
||||
const auto cppDoc = qobject_cast<TextEditor::TextDocument *>(cppFileEditor->document());
|
||||
QVERIFY(cppDoc);
|
||||
|
||||
@@ -740,19 +740,19 @@ EditorArea *EditorManagerPrivate::mainEditorArea()
|
||||
return d->m_editorAreas.at(0);
|
||||
}
|
||||
|
||||
bool EditorManagerPrivate::skipOpeningBigTextFile(const QString &filePath)
|
||||
bool EditorManagerPrivate::skipOpeningBigTextFile(const FilePath &filePath)
|
||||
{
|
||||
if (!d->m_settings.warnBeforeOpeningBigFilesEnabled)
|
||||
return false;
|
||||
|
||||
if (!QFileInfo::exists(filePath))
|
||||
if (!filePath.exists())
|
||||
return false;
|
||||
|
||||
Utils::MimeType mimeType = Utils::mimeTypeForFile(filePath);
|
||||
Utils::MimeType mimeType = Utils::mimeTypeForFile(filePath.toString());
|
||||
if (!mimeType.inherits("text/plain"))
|
||||
return false;
|
||||
|
||||
const QFileInfo fileInfo(filePath);
|
||||
const QFileInfo fileInfo = filePath.toFileInfo();
|
||||
const qint64 fileSize = fileInfo.size();
|
||||
const double fileSizeInMB = fileSize / 1000.0 / 1000.0;
|
||||
if (fileSizeInMB > d->m_settings.bigFileSizeLimitInMB
|
||||
@@ -782,13 +782,13 @@ bool EditorManagerPrivate::skipOpeningBigTextFile(const QString &filePath)
|
||||
return false;
|
||||
}
|
||||
|
||||
IEditor *EditorManagerPrivate::openEditor(EditorView *view, const QString &fileName, Id editorId,
|
||||
IEditor *EditorManagerPrivate::openEditor(EditorView *view, const FilePath &filePath, Id editorId,
|
||||
EditorManager::OpenEditorFlags flags, bool *newEditor)
|
||||
{
|
||||
if (debugEditorManager)
|
||||
qDebug() << Q_FUNC_INFO << fileName << editorId.name();
|
||||
qDebug() << Q_FUNC_INFO << filePath << editorId.name();
|
||||
|
||||
QString fn = fileName;
|
||||
QString fn = filePath.toString();
|
||||
QFileInfo fi(fn);
|
||||
int lineNumber = -1;
|
||||
int columnNumber = -1;
|
||||
@@ -803,7 +803,7 @@ IEditor *EditorManagerPrivate::openEditor(EditorView *view, const QString &fileN
|
||||
|
||||
if (fn.isEmpty())
|
||||
return nullptr;
|
||||
if (fn != fileName)
|
||||
if (fn != filePath.toString())
|
||||
fi.setFile(fn);
|
||||
|
||||
if (newEditor)
|
||||
@@ -855,7 +855,7 @@ IEditor *EditorManagerPrivate::openEditor(EditorView *view, const QString &fileN
|
||||
}
|
||||
}
|
||||
|
||||
if (skipOpeningBigTextFile(fileName))
|
||||
if (skipOpeningBigTextFile(filePath))
|
||||
return nullptr;
|
||||
|
||||
IEditor *editor = nullptr;
|
||||
@@ -952,26 +952,25 @@ IEditor *EditorManagerPrivate::openEditor(EditorView *view, const QString &fileN
|
||||
return result;
|
||||
}
|
||||
|
||||
IEditor *EditorManagerPrivate::openEditorAt(EditorView *view, const QString &fileName, int line,
|
||||
IEditor *EditorManagerPrivate::openEditorAt(EditorView *view, const FilePath &filePath, int line,
|
||||
int column, Id editorId,
|
||||
EditorManager::OpenEditorFlags flags, bool *newEditor)
|
||||
{
|
||||
EditorManager::cutForwardNavigationHistory();
|
||||
EditorManager::addCurrentPositionToNavigationHistory();
|
||||
EditorManager::OpenEditorFlags tempFlags = flags | EditorManager::IgnoreNavigationHistory;
|
||||
IEditor *editor = openEditor(view, fileName, editorId, tempFlags, newEditor);
|
||||
IEditor *editor = openEditor(view, filePath, editorId, tempFlags, newEditor);
|
||||
if (editor && line != -1)
|
||||
editor->gotoLine(line, column);
|
||||
return editor;
|
||||
}
|
||||
|
||||
IEditor *EditorManagerPrivate::openEditorWith(const QString &fileName, Utils::Id editorId)
|
||||
IEditor *EditorManagerPrivate::openEditorWith(const FilePath &filePath, Id editorId)
|
||||
{
|
||||
// close any open editors that have this file open
|
||||
// remember the views to open new editors in there
|
||||
QList<EditorView *> views;
|
||||
QList<IEditor *> editorsOpenForFile = DocumentModel::editorsForFilePath(
|
||||
FilePath::fromString(fileName));
|
||||
QList<IEditor *> editorsOpenForFile = DocumentModel::editorsForFilePath(filePath);
|
||||
foreach (IEditor *openEditor, editorsOpenForFile) {
|
||||
EditorView *view = EditorManagerPrivate::viewForEditor(openEditor);
|
||||
if (view && view->currentEditor() == openEditor) // visible
|
||||
@@ -982,7 +981,7 @@ IEditor *EditorManagerPrivate::openEditorWith(const QString &fileName, Utils::Id
|
||||
|
||||
IEditor *openedEditor = nullptr;
|
||||
if (views.isEmpty()) {
|
||||
openedEditor = EditorManager::openEditor(fileName, editorId);
|
||||
openedEditor = EditorManager::openEditor(filePath, editorId);
|
||||
} else {
|
||||
if (EditorView *currentView = EditorManagerPrivate::currentEditorView()) {
|
||||
if (views.removeOne(currentView))
|
||||
@@ -990,7 +989,7 @@ IEditor *EditorManagerPrivate::openEditorWith(const QString &fileName, Utils::Id
|
||||
}
|
||||
EditorManager::OpenEditorFlags flags;
|
||||
foreach (EditorView *view, views) {
|
||||
IEditor *editor = EditorManagerPrivate::openEditor(view, fileName, editorId, flags);
|
||||
IEditor *editor = EditorManagerPrivate::openEditor(view, filePath, editorId, flags);
|
||||
if (!openedEditor && editor)
|
||||
openedEditor = editor;
|
||||
// Do not change the current editor after opening the first one. That
|
||||
@@ -1592,7 +1591,7 @@ bool EditorManagerPrivate::activateEditorForEntry(EditorView *view, DocumentMode
|
||||
return editor != nullptr;
|
||||
}
|
||||
|
||||
if (!openEditor(view, entry->fileName().toString(), entry->id(), flags)) {
|
||||
if (!openEditor(view, entry->fileName(), entry->id(), flags)) {
|
||||
DocumentModelPrivate::removeEntry(entry);
|
||||
return false;
|
||||
}
|
||||
@@ -2932,7 +2931,7 @@ void EditorManager::populateOpenWithMenu(QMenu *menu, const QString &fileName)
|
||||
// while the menu is still being processed.
|
||||
connect(action, &QAction::triggered, d,
|
||||
[fileName, editorId]() {
|
||||
EditorManagerPrivate::openEditorWith(fileName, editorId);
|
||||
EditorManagerPrivate::openEditorWith(FilePath::fromString(fileName), editorId);
|
||||
}, Qt::QueuedConnection);
|
||||
}
|
||||
// Add all suitable external editors
|
||||
@@ -3061,7 +3060,7 @@ IEditor *EditorManager::activateEditorForDocument(IDocument *document, OpenEdito
|
||||
}
|
||||
|
||||
/*!
|
||||
Opens the document specified by \a fileName using the editor type \a
|
||||
Opens the document specified by \a filePath using the editor type \a
|
||||
editorId and the specified \a flags.
|
||||
|
||||
If \a editorId is \c Id(), the editor type is derived from the file's MIME
|
||||
@@ -3075,18 +3074,24 @@ IEditor *EditorManager::activateEditorForDocument(IDocument *document, OpenEdito
|
||||
\sa openEditorWithContents()
|
||||
\sa openExternalEditor()
|
||||
*/
|
||||
IEditor *EditorManager::openEditor(const QString &fileName, Id editorId,
|
||||
IEditor *EditorManager::openEditor(const FilePath &filePath, Id editorId,
|
||||
OpenEditorFlags flags, bool *newEditor)
|
||||
{
|
||||
if (flags & EditorManager::OpenInOtherSplit)
|
||||
EditorManager::gotoOtherSplit();
|
||||
|
||||
return EditorManagerPrivate::openEditor(EditorManagerPrivate::currentEditorView(),
|
||||
fileName, editorId, flags, newEditor);
|
||||
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 fileName using the editor type \a
|
||||
Opens the document specified by \a filePath using the editor type \a
|
||||
editorId and the specified \a flags.
|
||||
|
||||
Moves the text cursor to the \a line and \a column.
|
||||
@@ -3104,14 +3109,20 @@ IEditor *EditorManager::openEditor(const QString &fileName, Id editorId,
|
||||
\sa openExternalEditor()
|
||||
\sa IEditor::gotoLine()
|
||||
*/
|
||||
IEditor *EditorManager::openEditorAt(const QString &fileName, int line, int column,
|
||||
IEditor *EditorManager::openEditorAt(const FilePath &filePath, int line, int column,
|
||||
Id editorId, OpenEditorFlags flags, bool *newEditor)
|
||||
{
|
||||
if (flags & EditorManager::OpenInOtherSplit)
|
||||
EditorManager::gotoOtherSplit();
|
||||
|
||||
return EditorManagerPrivate::openEditorAt(EditorManagerPrivate::currentEditorView(),
|
||||
fileName, line, column, editorId, flags, newEditor);
|
||||
filePath, line, column, editorId, flags, newEditor);
|
||||
}
|
||||
|
||||
IEditor *EditorManager::openEditorAt(const QString &fileName, int line, int column,
|
||||
Id editorId, OpenEditorFlags flags, bool *newEditor)
|
||||
{
|
||||
return openEditorAt(FilePath::fromString(fileName), line, column, editorId, flags, newEditor);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -3186,9 +3197,9 @@ EditorManager::FilePathInfo EditorManager::splitLineAndColumnNumber(const QStrin
|
||||
/*!
|
||||
Returns whether \a fileName is an auto-save file created by \QC.
|
||||
*/
|
||||
bool EditorManager::isAutoSaveFile(const QString &fileName)
|
||||
bool EditorManager::isAutoSaveFile(const QString &filePath)
|
||||
{
|
||||
return fileName.endsWith(".autosave");
|
||||
return filePath.endsWith(".autosave");
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -3348,7 +3359,7 @@ IEditor *EditorManager::openEditorWithContents(Id editorId,
|
||||
though it is big. Depending on the settings this might ask the user to
|
||||
decide whether the file should be opened.
|
||||
*/
|
||||
bool EditorManager::skipOpeningBigTextFile(const QString &filePath)
|
||||
bool EditorManager::skipOpeningBigTextFile(const FilePath &filePath)
|
||||
{
|
||||
return EditorManagerPrivate::skipOpeningBigTextFile(filePath);
|
||||
}
|
||||
@@ -3449,7 +3460,7 @@ void EditorManager::setLastEditLocation(const IEditor* editor)
|
||||
const QByteArray &state = editor->saveState();
|
||||
EditLocation location;
|
||||
location.document = document;
|
||||
location.fileName = document->filePath().toString();
|
||||
location.filePath = document->filePath();
|
||||
location.id = document->id();
|
||||
location.state = QVariant(state);
|
||||
|
||||
|
||||
@@ -94,11 +94,19 @@ public:
|
||||
};
|
||||
|
||||
static FilePathInfo splitLineAndColumnNumber(const QString &filePath);
|
||||
static IEditor *openEditor(const QString &fileName, Utils::Id editorId = {},
|
||||
static IEditor *openEditor(const Utils::FilePath &filePath, Utils::Id editorId = {},
|
||||
OpenEditorFlags flags = NoFlags, bool *newEditor = nullptr);
|
||||
static IEditor *openEditorAt(const QString &fileName, int line, int column = 0,
|
||||
static IEditor *openEditorAt(const Utils::FilePath &filePath, int line, int column = 0,
|
||||
Utils::Id editorId = {}, 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,
|
||||
@@ -107,7 +115,7 @@ public:
|
||||
const QByteArray &contents = QByteArray(),
|
||||
const QString &uniqueId = QString(),
|
||||
OpenEditorFlags flags = NoFlags);
|
||||
static bool skipOpeningBigTextFile(const QString &filePath);
|
||||
static bool skipOpeningBigTextFile(const Utils::FilePath &filePath);
|
||||
static void clearUniqueId(IDocument *document);
|
||||
|
||||
static bool openExternalEditor(const QString &fileName, Utils::Id editorId);
|
||||
|
||||
@@ -80,18 +80,18 @@ public:
|
||||
static EditorView *currentEditorView();
|
||||
static void setCurrentEditor(IEditor *editor, bool ignoreNavigationHistory = false);
|
||||
static IEditor *openEditor(EditorView *view,
|
||||
const QString &fileName,
|
||||
const Utils::FilePath &filePath,
|
||||
Utils::Id editorId = {},
|
||||
EditorManager::OpenEditorFlags flags = EditorManager::NoFlags,
|
||||
bool *newEditor = nullptr);
|
||||
static IEditor *openEditorAt(EditorView *view,
|
||||
const QString &fileName,
|
||||
const Utils::FilePath &filePath,
|
||||
int line,
|
||||
int column = 0,
|
||||
Utils::Id editorId = {},
|
||||
EditorManager::OpenEditorFlags flags = EditorManager::NoFlags,
|
||||
bool *newEditor = nullptr);
|
||||
static IEditor *openEditorWith(const QString &fileName, Utils::Id editorId);
|
||||
static IEditor *openEditorWith(const Utils::FilePath &filePath, Utils::Id editorId);
|
||||
static IEditor *duplicateEditor(IEditor *editor);
|
||||
static IEditor *activateEditor(EditorView *view, IEditor *editor,
|
||||
EditorManager::OpenEditorFlags flags = EditorManager::NoFlags);
|
||||
@@ -209,7 +209,7 @@ private:
|
||||
static void setupSaveActions(IDocument *document, QAction *saveAction,
|
||||
QAction *saveAsAction, QAction *revertToSavedAction);
|
||||
static void updateWindowTitle();
|
||||
static bool skipOpeningBigTextFile(const QString &filePath);
|
||||
static bool skipOpeningBigTextFile(const Utils::FilePath &filePath);
|
||||
|
||||
private:
|
||||
explicit EditorManagerPrivate(QObject *parent);
|
||||
|
||||
@@ -261,15 +261,14 @@ void EditorView::updateEditorHistory(IEditor *editor, QList<EditLocation> &histo
|
||||
|
||||
EditLocation location;
|
||||
location.document = document;
|
||||
location.fileName = document->filePath().toString();
|
||||
location.filePath = document->filePath();
|
||||
location.id = document->id();
|
||||
location.state = QVariant(state);
|
||||
|
||||
for (int i = 0; i < history.size(); ++i) {
|
||||
const EditLocation &item = history.at(i);
|
||||
if (item.document == document
|
||||
|| (!item.document
|
||||
&& !DocumentModel::indexOfFilePath(FilePath::fromString(item.fileName)))) {
|
||||
|| (!item.document && !DocumentModel::indexOfFilePath(item.filePath))) {
|
||||
history.removeAt(i--);
|
||||
}
|
||||
}
|
||||
@@ -405,10 +404,10 @@ void EditorView::openDroppedFiles(const QList<DropSupport::FileSpec> &files)
|
||||
auto openEntry = [&](const DropSupport::FileSpec &spec) {
|
||||
if (first) {
|
||||
first = false;
|
||||
EditorManagerPrivate::openEditorAt(this, spec.filePath, spec.line, spec.column);
|
||||
EditorManagerPrivate::openEditorAt(this, FilePath::fromString(spec.filePath), spec.line, spec.column);
|
||||
} else if (spec.column != -1 || spec.line != -1) {
|
||||
EditorManagerPrivate::openEditorAt(this,
|
||||
spec.filePath,
|
||||
FilePath::fromString(spec.filePath),
|
||||
spec.line,
|
||||
spec.column,
|
||||
Id(),
|
||||
@@ -495,7 +494,7 @@ void EditorView::addCurrentPositionToNavigationHistory(const QByteArray &saveSta
|
||||
|
||||
EditLocation location;
|
||||
location.document = document;
|
||||
location.fileName = document->filePath().toString();
|
||||
location.filePath = document->filePath();
|
||||
location.id = document->id();
|
||||
location.state = QVariant(state);
|
||||
m_currentNavigationHistoryPosition = qMin(m_currentNavigationHistoryPosition, m_navigationHistory.size()); // paranoia
|
||||
@@ -550,17 +549,15 @@ void EditorView::updateCurrentPositionInNavigationHistory()
|
||||
location = &m_navigationHistory[m_navigationHistory.size()-1];
|
||||
}
|
||||
location->document = document;
|
||||
location->fileName = document->filePath().toString();
|
||||
location->filePath = document->filePath();
|
||||
location->id = document->id();
|
||||
location->state = QVariant(editor->saveState());
|
||||
}
|
||||
|
||||
namespace {
|
||||
static inline bool fileNameWasRemoved(const QString &fileName)
|
||||
static bool fileNameWasRemoved(const FilePath &filePath)
|
||||
{
|
||||
return !fileName.isEmpty() && !QFileInfo::exists(fileName);
|
||||
return !filePath.isEmpty() && !filePath.exists();
|
||||
}
|
||||
} // End of anonymous namespace
|
||||
|
||||
void EditorView::goBackInNavigationHistory()
|
||||
{
|
||||
@@ -574,11 +571,11 @@ void EditorView::goBackInNavigationHistory()
|
||||
EditorManager::IgnoreNavigationHistory);
|
||||
}
|
||||
if (!editor) {
|
||||
if (fileNameWasRemoved(location.fileName)) {
|
||||
if (fileNameWasRemoved(location.filePath)) {
|
||||
m_navigationHistory.removeAt(m_currentNavigationHistoryPosition);
|
||||
continue;
|
||||
}
|
||||
editor = EditorManagerPrivate::openEditor(this, location.fileName, location.id,
|
||||
editor = EditorManagerPrivate::openEditor(this, location.filePath, location.id,
|
||||
EditorManager::IgnoreNavigationHistory);
|
||||
if (!editor) {
|
||||
m_navigationHistory.removeAt(m_currentNavigationHistoryPosition);
|
||||
@@ -605,11 +602,11 @@ void EditorView::goForwardInNavigationHistory()
|
||||
EditorManager::IgnoreNavigationHistory);
|
||||
}
|
||||
if (!editor) {
|
||||
if (fileNameWasRemoved(location.fileName)) {
|
||||
if (fileNameWasRemoved(location.filePath)) {
|
||||
m_navigationHistory.removeAt(m_currentNavigationHistoryPosition);
|
||||
continue;
|
||||
}
|
||||
editor = EditorManagerPrivate::openEditor(this, location.fileName, location.id,
|
||||
editor = EditorManagerPrivate::openEditor(this, location.filePath, location.id,
|
||||
EditorManager::IgnoreNavigationHistory);
|
||||
if (!editor) {
|
||||
m_navigationHistory.removeAt(m_currentNavigationHistoryPosition);
|
||||
@@ -634,10 +631,10 @@ void EditorView::goToEditLocation(const EditLocation &location)
|
||||
}
|
||||
|
||||
if (!editor) {
|
||||
if (fileNameWasRemoved(location.fileName))
|
||||
if (fileNameWasRemoved(location.filePath))
|
||||
return;
|
||||
|
||||
editor = EditorManagerPrivate::openEditor(this, location.fileName, location.id,
|
||||
editor = EditorManagerPrivate::openEditor(this, location.filePath, location.id,
|
||||
EditorManager::IgnoreNavigationHistory);
|
||||
}
|
||||
|
||||
@@ -967,7 +964,7 @@ void SplitterOrView::restoreState(const QByteArray &state)
|
||||
stream >> fileName >> id >> editorState;
|
||||
if (!QFile::exists(fileName))
|
||||
return;
|
||||
IEditor *e = EditorManagerPrivate::openEditor(view(), fileName, Id::fromString(id),
|
||||
IEditor *e = EditorManagerPrivate::openEditor(view(), FilePath::fromString(fileName), Id::fromString(id),
|
||||
EditorManager::IgnoreNavigationHistory
|
||||
| EditorManager::DoNotChangeCurrentEditor);
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <utils/dropsupport.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/id.h>
|
||||
|
||||
#include <QMap>
|
||||
@@ -62,7 +63,7 @@ namespace Internal {
|
||||
|
||||
struct EditLocation {
|
||||
QPointer<IDocument> document;
|
||||
QString fileName;
|
||||
Utils::FilePath filePath;
|
||||
Utils::Id id;
|
||||
QVariant state;
|
||||
};
|
||||
|
||||
@@ -217,7 +217,7 @@ static DocumentModel::Entry *entryForEditLocation(const EditLocation &item)
|
||||
{
|
||||
if (!item.document.isNull())
|
||||
return DocumentModel::entryForDocument(item.document);
|
||||
return DocumentModel::entryForFilePath(Utils::FilePath::fromString(item.fileName));
|
||||
return DocumentModel::entryForFilePath(item.filePath);
|
||||
}
|
||||
|
||||
void OpenEditorsWindow::addHistoryItems(const QList<EditLocation> &history, EditorView *view,
|
||||
|
||||
@@ -950,7 +950,7 @@ void MainWindow::openFileWith()
|
||||
if (isExternal)
|
||||
EditorManager::openExternalEditor(fileName, editorId);
|
||||
else
|
||||
EditorManagerPrivate::openEditorWith(fileName, editorId);
|
||||
EditorManagerPrivate::openEditorWith(FilePath::fromString(fileName), editorId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1490,7 +1490,7 @@ void BreakHandler::gotoLocation(const Breakpoint &bp) const
|
||||
// Don't use gotoLocation unconditionally as this ends up in
|
||||
// disassembly if OperateByInstruction is on. But fallback
|
||||
// to disassembly if we can't open the file.
|
||||
if (IEditor *editor = EditorManager::openEditor(bp->markerFileName().toString()))
|
||||
if (IEditor *editor = EditorManager::openEditor(bp->markerFileName()))
|
||||
editor->gotoLine(bp->markerLineNumber(), 0);
|
||||
else
|
||||
m_engine->openDisassemblerView(Location(bp->m_parameters.address));
|
||||
@@ -2694,7 +2694,7 @@ bool BreakpointManager::contextMenuEvent(const ItemViewEvent &ev)
|
||||
void BreakpointManager::gotoLocation(const GlobalBreakpoint &gbp) const
|
||||
{
|
||||
QTC_ASSERT(gbp, return);
|
||||
if (IEditor *editor = EditorManager::openEditor(gbp->markerFileName().toString()))
|
||||
if (IEditor *editor = EditorManager::openEditor(gbp->markerFileName()))
|
||||
editor->gotoLine(gbp->markerLineNumber(), 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -571,7 +571,7 @@ void DiffEditorPluginPrivate::diffExternalFiles()
|
||||
QString());
|
||||
if (fileName1.isNull())
|
||||
return;
|
||||
if (EditorManager::skipOpeningBigTextFile(fileName1))
|
||||
if (EditorManager::skipOpeningBigTextFile(FilePath::fromString(fileName1)))
|
||||
return;
|
||||
|
||||
const QString fileName2 = QFileDialog::getOpenFileName(ICore::dialogParent(),
|
||||
@@ -579,7 +579,7 @@ void DiffEditorPluginPrivate::diffExternalFiles()
|
||||
QString());
|
||||
if (fileName2.isNull())
|
||||
return;
|
||||
if (EditorManager::skipOpeningBigTextFile(fileName2))
|
||||
if (EditorManager::skipOpeningBigTextFile(FilePath::fromString(fileName2)))
|
||||
return;
|
||||
|
||||
const QString documentId = Constants::DIFF_EDITOR_PLUGIN
|
||||
|
||||
@@ -190,7 +190,7 @@ void DocumentLocatorFilter::accept(Core::LocatorFilterEntry selection,
|
||||
{
|
||||
if (selection.internalData.canConvert<Utils::LineColumn>()) {
|
||||
auto lineColumn = qvariant_cast<Utils::LineColumn>(selection.internalData);
|
||||
Core::EditorManager::openEditorAt(m_currentUri.toFilePath().toString(),
|
||||
Core::EditorManager::openEditorAt(m_currentUri.toFilePath(),
|
||||
lineColumn.line + 1,
|
||||
lineColumn.column);
|
||||
} else if (selection.internalData.canConvert<Utils::Link>()) {
|
||||
|
||||
@@ -643,8 +643,7 @@ void MercurialPluginPrivate::showCommitWidget(const QList<VcsBaseClient::StatusI
|
||||
return;
|
||||
}
|
||||
|
||||
Core::IEditor *editor = Core::EditorManager::openEditor(saver.filePath().toString(),
|
||||
Constants::COMMIT_ID);
|
||||
Core::IEditor *editor = Core::EditorManager::openEditor(saver.filePath(), Constants::COMMIT_ID);
|
||||
if (!editor) {
|
||||
VcsOutputWindow::appendError(tr("Unable to create an editor for the commit."));
|
||||
return;
|
||||
|
||||
@@ -514,7 +514,7 @@ void JsonWizard::openProjectForNode(Node *node)
|
||||
|
||||
Utils::optional<FilePath> projFilePath = projNode->visibleAfterAddFileAction();
|
||||
|
||||
if (projFilePath && !Core::EditorManager::openEditor(projFilePath.value().toString())) {
|
||||
if (projFilePath && !Core::EditorManager::openEditor(projFilePath.value())) {
|
||||
auto errorMessage = QCoreApplication::translate("ProjectExplorer::JsonWizard",
|
||||
"Failed to open an editor for \"%1\".")
|
||||
.arg(QDir::toNativeSeparators(projFilePath.value().toString()));
|
||||
|
||||
@@ -1347,7 +1347,7 @@ void ProjectExplorerPlugin::testProject_multipleBuildConfigs()
|
||||
|
||||
QCOMPARE(SessionManager::startupProject(), theProject.project());
|
||||
QCOMPARE(ProjectTree::currentProject(), theProject.project());
|
||||
QVERIFY(Core::EditorManager::openEditor(projectDir.pathAppended("main.cpp").toString()));
|
||||
QVERIFY(Core::EditorManager::openEditor(projectDir.pathAppended("main.cpp")));
|
||||
QVERIFY(ProjectTree::currentNode());
|
||||
ProjectTree::instance()->expandAll();
|
||||
SessionManager::closeAllProjects(); // QTCREATORBUG-25655
|
||||
|
||||
@@ -3442,7 +3442,7 @@ void ProjectExplorerPluginPrivate::updateLocationSubMenus()
|
||||
: tr("%1 in %2").arg(li.displayName).arg(li.path.toUserOutput());
|
||||
auto *action = new QAction(displayName, nullptr);
|
||||
connect(action, &QAction::triggered, this, [line, path]() {
|
||||
Core::EditorManager::openEditorAt(path.toString(), line);
|
||||
Core::EditorManager::openEditorAt(path, line);
|
||||
});
|
||||
|
||||
projectMenu->addAction(action);
|
||||
@@ -3622,7 +3622,7 @@ void ProjectExplorerPluginPrivate::openFile()
|
||||
{
|
||||
const Node *currentNode = ProjectTree::currentNode();
|
||||
QTC_ASSERT(currentNode, return);
|
||||
EditorManager::openEditor(currentNode->filePath().toString());
|
||||
EditorManager::openEditor(currentNode->filePath());
|
||||
}
|
||||
|
||||
void ProjectExplorerPluginPrivate::searchOnFileSystem()
|
||||
|
||||
@@ -557,7 +557,7 @@ void ProjectTreeWidget::openItem(const QModelIndex &mainIndex)
|
||||
Node *node = m_model->nodeForIndex(mainIndex);
|
||||
if (!node || !node->asFileNode())
|
||||
return;
|
||||
IEditor *editor = EditorManager::openEditor(node->filePath().toString());
|
||||
IEditor *editor = EditorManager::openEditor(node->filePath());
|
||||
if (editor && node->line() >= 0)
|
||||
editor->gotoLine(node->line());
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ bool AssetExporterView::loadQmlFile(const Utils::FilePath &path, uint timeoutSec
|
||||
|
||||
setState(LoadState::Busy);
|
||||
m_retryCount = std::max(MinRetry, static_cast<int>((timeoutSecs * 1000) / RetryIntervalMs));
|
||||
m_currentEditor = Core::EditorManager::openEditor(path.toString(), Utils::Id(),
|
||||
m_currentEditor = Core::EditorManager::openEditor(path, Utils::Id(),
|
||||
Core::EditorManager::DoNotMakeVisible);
|
||||
Core::ModeManager::activateMode(Core::Constants::MODE_DESIGN);
|
||||
Core::ModeManager::setFocusToCurrentMode();
|
||||
|
||||
@@ -178,7 +178,7 @@ void CrumbleBar::onCrumblePathElementClicked(const QVariant &data)
|
||||
} else {
|
||||
crumblePath()->popElement();
|
||||
nextFileIsCalledInternally();
|
||||
Core::EditorManager::openEditor(clickedCrumbleBarInfo.fileName.toString(),
|
||||
Core::EditorManager::openEditor(clickedCrumbleBarInfo.fileName,
|
||||
Utils::Id(),
|
||||
Core::EditorManager::DoNotMakeVisible);
|
||||
if (clickedCrumbleBarInfo.modelNode.isValid()) {
|
||||
|
||||
@@ -213,7 +213,7 @@ public:
|
||||
const Utils::FilePath qmlFile = Core::ICore::resourcePath("examples")
|
||||
/ example / formFile;
|
||||
|
||||
Core::EditorManager::openEditor(qmlFile.toString());
|
||||
Core::EditorManager::openEditor(qmlFile);
|
||||
}
|
||||
public slots:
|
||||
void resetProjects();
|
||||
|
||||
@@ -103,7 +103,7 @@ void TodoPluginPrivate::scanningScopeChanged(ScanningScope scanningScope)
|
||||
void TodoPluginPrivate::todoItemClicked(const TodoItem &item)
|
||||
{
|
||||
if (item.file.exists())
|
||||
Core::EditorManager::openEditorAt(item.file.toString(), item.line);
|
||||
Core::EditorManager::openEditorAt(item.file, item.line);
|
||||
}
|
||||
|
||||
void TodoPluginPrivate::createItemsProvider()
|
||||
|
||||
Reference in New Issue
Block a user