forked from qt-creator/qt-creator
TextEditor: Some fileName -> filePath renaming
Change-Id: Id0751f936666fa658226d62a1906b82e3bac1660 Reviewed-by: David Schulz <david.schulz@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -66,10 +66,10 @@ void Bookmark::updateBlock(const QTextBlock &block)
|
||||
}
|
||||
}
|
||||
|
||||
void Bookmark::updateFileName(const FilePath &filePath)
|
||||
void Bookmark::updateFilePath(const FilePath &filePath)
|
||||
{
|
||||
const FilePath oldFilePath = this->fileName();
|
||||
TextMark::updateFileName(filePath);
|
||||
const FilePath oldFilePath = this->filePath();
|
||||
TextMark::updateFilePath(filePath);
|
||||
m_manager->updateBookmarkFileName(this, oldFilePath);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
void updateLineNumber(int lineNumber) override;
|
||||
void move(int line) override;
|
||||
void updateBlock(const QTextBlock &block) override;
|
||||
void updateFileName(const Utils::FilePath &filePath) override;
|
||||
void updateFilePath(const Utils::FilePath &filePath) override;
|
||||
void removedFromEditor() override;
|
||||
|
||||
bool isDraggable() const override;
|
||||
|
||||
@@ -57,7 +57,7 @@ void BookmarkFilter::prepareSearch(const QString &entry)
|
||||
|
||||
for (const QModelIndex &idx : matches) {
|
||||
const Bookmark *bookmark = m_manager->bookmarkForIndex(idx);
|
||||
const QString filename = bookmark->fileName().fileName();
|
||||
const QString filename = bookmark->filePath().fileName();
|
||||
LocatorFilterEntry filterEntry(this,
|
||||
QString("%1:%2").arg(filename).arg(bookmark->lineNumber()),
|
||||
QVariant::fromValue(idx));
|
||||
@@ -66,7 +66,7 @@ void BookmarkFilter::prepareSearch(const QString &entry)
|
||||
else if (!bookmark->lineText().isEmpty())
|
||||
filterEntry.extraInfo = bookmark->lineText();
|
||||
else
|
||||
filterEntry.extraInfo = bookmark->fileName().toString();
|
||||
filterEntry.extraInfo = bookmark->filePath().toString();
|
||||
int highlightIndex = filterEntry.displayName.indexOf(entry, 0, Qt::CaseInsensitive);
|
||||
if (highlightIndex >= 0) {
|
||||
filterEntry.highlightInfo = {highlightIndex, int(entry.length())};
|
||||
|
||||
@@ -343,17 +343,17 @@ QVariant BookmarkManager::data(const QModelIndex &index, int role) const
|
||||
|
||||
Bookmark *bookMark = m_bookmarksList.at(index.row());
|
||||
if (role == BookmarkManager::Filename)
|
||||
return bookMark->fileName().fileName();
|
||||
return bookMark->filePath().fileName();
|
||||
if (role == BookmarkManager::LineNumber)
|
||||
return bookMark->lineNumber();
|
||||
if (role == BookmarkManager::Directory)
|
||||
return bookMark->fileName().toFileInfo().path();
|
||||
return bookMark->filePath().toFileInfo().path();
|
||||
if (role == BookmarkManager::LineText)
|
||||
return bookMark->lineText();
|
||||
if (role == BookmarkManager::Note)
|
||||
return bookMark->note();
|
||||
if (role == Qt::ToolTipRole)
|
||||
return bookMark->fileName().toUserOutput();
|
||||
return bookMark->filePath().toUserOutput();
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
@@ -381,7 +381,7 @@ QMimeData *BookmarkManager::mimeData(const QModelIndexList &indexes) const
|
||||
if (!index.isValid() || index.column() != 0 || index.row() < 0 || index.row() >= m_bookmarksList.count())
|
||||
continue;
|
||||
Bookmark *bookMark = m_bookmarksList.at(index.row());
|
||||
data->addFile(bookMark->fileName(), bookMark->lineNumber());
|
||||
data->addFile(bookMark->filePath(), bookMark->lineNumber());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
@@ -400,7 +400,7 @@ void BookmarkManager::toggleBookmark(const FilePath &fileName, int lineNumber)
|
||||
|
||||
// Add a new bookmark if no bookmark existed on this line
|
||||
auto mark = new Bookmark(lineNumber, this);
|
||||
mark->updateFileName(fileName);
|
||||
mark->updateFilePath(fileName);
|
||||
const QModelIndex currentIndex = selectionModel()->currentIndex();
|
||||
const int insertionIndex = currentIndex.isValid() ? currentIndex.row() + 1
|
||||
: m_bookmarksList.size();
|
||||
@@ -419,11 +419,11 @@ void BookmarkManager::updateBookmark(Bookmark *bookmark)
|
||||
|
||||
void BookmarkManager::updateBookmarkFileName(Bookmark *bookmark, const FilePath &oldFilePath)
|
||||
{
|
||||
if (oldFilePath == bookmark->fileName())
|
||||
if (oldFilePath == bookmark->filePath())
|
||||
return;
|
||||
|
||||
m_bookmarksMap[oldFilePath].removeAll(bookmark);
|
||||
m_bookmarksMap[bookmark->fileName()].append(bookmark);
|
||||
m_bookmarksMap[bookmark->filePath()].append(bookmark);
|
||||
updateBookmark(bookmark);
|
||||
}
|
||||
|
||||
@@ -444,7 +444,7 @@ void BookmarkManager::deleteBookmark(Bookmark *bookmark)
|
||||
int idx = m_bookmarksList.indexOf(bookmark);
|
||||
beginRemoveRows(QModelIndex(), idx, idx);
|
||||
|
||||
m_bookmarksMap[bookmark->fileName()].removeAll(bookmark);
|
||||
m_bookmarksMap[bookmark->filePath()].removeAll(bookmark);
|
||||
delete bookmark;
|
||||
|
||||
m_bookmarksList.removeAt(idx);
|
||||
@@ -467,7 +467,7 @@ Bookmark *BookmarkManager::bookmarkForIndex(const QModelIndex &index) const
|
||||
bool BookmarkManager::gotoBookmark(const Bookmark *bookmark) const
|
||||
{
|
||||
if (IEditor *editor = EditorManager::openEditorAt(
|
||||
Utils::Link(bookmark->fileName(), bookmark->lineNumber()))) {
|
||||
Utils::Link(bookmark->filePath(), bookmark->lineNumber()))) {
|
||||
return editor->currentLine() == bookmark->lineNumber();
|
||||
}
|
||||
return false;
|
||||
@@ -687,7 +687,7 @@ void BookmarkManager::insertBookmark(int idx, Bookmark *bookmark, bool userset)
|
||||
idx = qBound(0, idx, m_bookmarksList.size());
|
||||
beginInsertRows(QModelIndex(), idx, idx);
|
||||
|
||||
m_bookmarksMap[bookmark->fileName()].append(bookmark);
|
||||
m_bookmarksMap[bookmark->filePath()].append(bookmark);
|
||||
m_bookmarksList.insert(idx, bookmark);
|
||||
|
||||
endInsertRows();
|
||||
@@ -724,7 +724,7 @@ void BookmarkManager::addBookmark(const QString &s)
|
||||
const int lineNumber = s.mid(index2 + 1, index3 - index2 - 1).toInt();
|
||||
if (!filePath.isEmpty() && !findBookmark(FilePath::fromString(filePath), lineNumber)) {
|
||||
auto b = new Bookmark(lineNumber, this);
|
||||
b->updateFileName(FilePath::fromString(filePath));
|
||||
b->updateFilePath(FilePath::fromString(filePath));
|
||||
b->setNote(note);
|
||||
addBookmark(b, false);
|
||||
}
|
||||
@@ -739,7 +739,7 @@ QString BookmarkManager::bookmarkToString(const Bookmark *b)
|
||||
const QLatin1Char colon(':');
|
||||
// Using \t as delimiter because any another symbol can be a part of note.
|
||||
const QLatin1Char noteDelimiter('\t');
|
||||
return colon + b->fileName().toString() +
|
||||
return colon + b->filePath().toString() +
|
||||
colon + QString::number(b->lineNumber()) +
|
||||
noteDelimiter + b->note();
|
||||
}
|
||||
@@ -772,7 +772,7 @@ bool BookmarkManager::isAtCurrentBookmark() const
|
||||
return true;
|
||||
IEditor *currentEditor = EditorManager::currentEditor();
|
||||
return currentEditor
|
||||
&& currentEditor->document()->filePath() == bk->fileName()
|
||||
&& currentEditor->document()->filePath() == bk->filePath()
|
||||
&& currentEditor->currentLine() == bk->lineNumber();
|
||||
}
|
||||
|
||||
|
||||
@@ -323,7 +323,7 @@ ClangdTextMark::ClangdTextMark(const FilePath &filePath,
|
||||
|
||||
bool ClangdTextMark::addToolTipContent(QLayout *target) const
|
||||
{
|
||||
const auto canApplyFixIt = [c = m_client, diag = m_lspDiagnostic, fp = fileName()] {
|
||||
const auto canApplyFixIt = [c = m_client, diag = m_lspDiagnostic, fp = filePath()] {
|
||||
return QTC_GUARD(c) && c->reachable() && c->hasDiagnostic(fp, diag);
|
||||
};
|
||||
const QString clientName = QTC_GUARD(m_client) ? m_client->name() : "clangd [unknown]";
|
||||
|
||||
@@ -89,9 +89,9 @@ public:
|
||||
gbp->m_params.lineNumber = lineNumber;
|
||||
}
|
||||
|
||||
void updateFileName(const FilePath &fileName) final
|
||||
void updateFilePath(const FilePath &fileName) final
|
||||
{
|
||||
TextMark::updateFileName(fileName);
|
||||
TextMark::updateFilePath(fileName);
|
||||
QTC_ASSERT(m_bp, return);
|
||||
m_bp->setFileName(fileName);
|
||||
if (GlobalBreakpoint gbp = m_bp->globalBreakpoint())
|
||||
@@ -158,9 +158,9 @@ public:
|
||||
m_gbp->updateLineNumber(lineNumber);
|
||||
}
|
||||
|
||||
void updateFileName(const FilePath &fileName) final
|
||||
void updateFilePath(const FilePath &fileName) final
|
||||
{
|
||||
TextMark::updateFileName(fileName);
|
||||
TextMark::updateFilePath(fileName);
|
||||
QTC_ASSERT(m_gbp, return);
|
||||
m_gbp->updateFileName(fileName);
|
||||
}
|
||||
@@ -1883,7 +1883,7 @@ void BreakpointItem::updateMarker()
|
||||
{
|
||||
const FilePath &file = markerFileName();
|
||||
int line = markerLineNumber();
|
||||
if (m_marker && (file != m_marker->fileName() || line != m_marker->lineNumber()))
|
||||
if (m_marker && (file != m_marker->filePath() || line != m_marker->lineNumber()))
|
||||
destroyMarker();
|
||||
|
||||
if (!m_marker && !file.isEmpty() && line > 0)
|
||||
@@ -2308,8 +2308,8 @@ void GlobalBreakpointItem::updateMarker()
|
||||
|
||||
const int line = m_params.lineNumber;
|
||||
if (m_marker) {
|
||||
if (m_params.fileName != m_marker->fileName())
|
||||
m_marker->updateFileName(m_params.fileName);
|
||||
if (m_params.fileName != m_marker->filePath())
|
||||
m_marker->updateFilePath(m_params.fileName);
|
||||
if (line != m_marker->lineNumber())
|
||||
m_marker->move(line);
|
||||
} else if (!m_params.fileName.isEmpty() && line > 0) {
|
||||
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
bool isClickable() const override;
|
||||
void clicked() override;
|
||||
|
||||
void updateFileName(const FilePath &fileName) override;
|
||||
void updateFilePath(const FilePath &fileName) override;
|
||||
void updateLineNumber(int lineNumber) override;
|
||||
void removedFromEditor() override;
|
||||
private:
|
||||
@@ -78,10 +78,10 @@ void TaskMark::updateLineNumber(int lineNumber)
|
||||
TextMark::updateLineNumber(lineNumber);
|
||||
}
|
||||
|
||||
void TaskMark::updateFileName(const FilePath &fileName)
|
||||
void TaskMark::updateFilePath(const FilePath &fileName)
|
||||
{
|
||||
TaskHub::updateTaskFileName(m_task, fileName.toString());
|
||||
TextMark::updateFileName(FilePath::fromString(fileName.toString()));
|
||||
TextMark::updateFilePath(FilePath::fromString(fileName.toString()));
|
||||
}
|
||||
|
||||
void TaskMark::removedFromEditor()
|
||||
|
||||
@@ -995,7 +995,7 @@ void SquishTools::updateLocationMarker(const Utils::FilePath &file, int line)
|
||||
if (QTC_GUARD(!m_locationMarker)) {
|
||||
m_locationMarker = new SquishLocationMark(file, line);
|
||||
} else {
|
||||
m_locationMarker->updateFileName(file);
|
||||
m_locationMarker->updateFilePath(file);
|
||||
m_locationMarker->move(line);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,8 +63,8 @@ private:
|
||||
|
||||
TextMarkRegistry *m_instance = nullptr;
|
||||
|
||||
TextMark::TextMark(const FilePath &fileName, int lineNumber, TextMarkCategory category)
|
||||
: m_fileName(fileName)
|
||||
TextMark::TextMark(const FilePath &filePath, int lineNumber, TextMarkCategory category)
|
||||
: m_fileName(filePath)
|
||||
, m_lineNumber(lineNumber)
|
||||
, m_visible(true)
|
||||
, m_category(category)
|
||||
@@ -82,18 +82,18 @@ TextMark::~TextMark()
|
||||
m_baseTextDocument = nullptr;
|
||||
}
|
||||
|
||||
FilePath TextMark::fileName() const
|
||||
FilePath TextMark::filePath() const
|
||||
{
|
||||
return m_fileName;
|
||||
}
|
||||
|
||||
void TextMark::updateFileName(const FilePath &fileName)
|
||||
void TextMark::updateFilePath(const FilePath &filePath)
|
||||
{
|
||||
if (fileName == m_fileName)
|
||||
if (filePath == m_fileName)
|
||||
return;
|
||||
if (!m_fileName.isEmpty())
|
||||
TextMarkRegistry::remove(this);
|
||||
m_fileName = fileName;
|
||||
m_fileName = filePath;
|
||||
if (!m_fileName.isEmpty())
|
||||
TextMarkRegistry::add(this);
|
||||
}
|
||||
@@ -451,14 +451,14 @@ TextMarkRegistry::TextMarkRegistry(QObject *parent)
|
||||
|
||||
void TextMarkRegistry::add(TextMark *mark)
|
||||
{
|
||||
instance()->m_marks[mark->fileName()].insert(mark);
|
||||
if (TextDocument *document = TextDocument::textDocumentForFilePath(mark->fileName()))
|
||||
instance()->m_marks[mark->filePath()].insert(mark);
|
||||
if (TextDocument *document = TextDocument::textDocumentForFilePath(mark->filePath()))
|
||||
document->addMark(mark);
|
||||
}
|
||||
|
||||
bool TextMarkRegistry::remove(TextMark *mark)
|
||||
{
|
||||
return instance()->m_marks[mark->fileName()].remove(mark);
|
||||
return instance()->m_marks[mark->filePath()].remove(mark);
|
||||
}
|
||||
|
||||
TextMarkRegistry *TextMarkRegistry::instance()
|
||||
@@ -500,7 +500,7 @@ void TextMarkRegistry::documentRenamed(IDocument *document,
|
||||
m_marks[newPath].unite(toBeMoved);
|
||||
|
||||
for (TextMark *mark : std::as_const(toBeMoved))
|
||||
mark->updateFileName(newPath);
|
||||
mark->updateFilePath(newPath);
|
||||
}
|
||||
|
||||
void TextMarkRegistry::allDocumentsRenamed(const FilePath &oldPath, const FilePath &newPath)
|
||||
@@ -514,7 +514,7 @@ void TextMarkRegistry::allDocumentsRenamed(const FilePath &oldPath, const FilePa
|
||||
m_marks[oldPath].clear();
|
||||
|
||||
for (TextMark *mark : oldFileNameMarks)
|
||||
mark->updateFileName(newPath);
|
||||
mark->updateFilePath(newPath);
|
||||
}
|
||||
|
||||
QHash<AnnotationColors::SourceColors, AnnotationColors> AnnotationColors::m_colorCache;
|
||||
|
||||
@@ -38,10 +38,8 @@ public:
|
||||
class TEXTEDITOR_EXPORT TextMark
|
||||
{
|
||||
public:
|
||||
TextMark(const Utils::FilePath &fileName,
|
||||
int lineNumber,
|
||||
TextMarkCategory category);
|
||||
TextMark() = delete;
|
||||
TextMark(const Utils::FilePath &filePath, int lineNumber, TextMarkCategory category);
|
||||
virtual ~TextMark();
|
||||
|
||||
// determine order on markers on the same line.
|
||||
@@ -52,7 +50,7 @@ public:
|
||||
HighPriority // shown on top.
|
||||
};
|
||||
|
||||
Utils::FilePath fileName() const;
|
||||
Utils::FilePath filePath() const;
|
||||
int lineNumber() const;
|
||||
|
||||
virtual void paintIcon(QPainter *painter, const QRect &rect) const;
|
||||
@@ -74,7 +72,7 @@ public:
|
||||
AnnotationRects annotationRects(const QRectF &boundingRect, const QFontMetrics &fm,
|
||||
const qreal fadeInOffset, const qreal fadeOutOffset) const;
|
||||
/// called if the filename of the document changed
|
||||
virtual void updateFileName(const Utils::FilePath &fileName);
|
||||
virtual void updateFilePath(const Utils::FilePath &filePath);
|
||||
virtual void updateLineNumber(int lineNumber);
|
||||
virtual void updateBlock(const QTextBlock &block);
|
||||
virtual void move(int line);
|
||||
|
||||
@@ -833,7 +833,7 @@ void CallgrindToolPrivate::requestContextMenu(TextEditorWidget *widget, int line
|
||||
{
|
||||
// Find callgrind text mark that corresponds to this editor's file and line number
|
||||
for (CallgrindTextMark *textMark : std::as_const(m_textMarks)) {
|
||||
if (textMark->fileName() == widget->textDocument()->filePath() && textMark->lineNumber() == line) {
|
||||
if (textMark->filePath() == widget->textDocument()->filePath() && textMark->lineNumber() == line) {
|
||||
const Function *func = textMark->function();
|
||||
QAction *action = menu->addAction(Tr::tr("Select This Function in the Analyzer Output"));
|
||||
connect(action, &QAction::triggered, this, [this, func] { selectFunction(func); });
|
||||
|
||||
Reference in New Issue
Block a user