diff options
author | hjk <hjk@qt.io> | 2023-02-07 18:14:53 +0100 |
---|---|---|
committer | hjk <hjk@qt.io> | 2023-02-08 13:48:30 +0000 |
commit | 3f8240a7de9be6df01b5f56ce57d2750bcbbf187 (patch) | |
tree | 99bf029466141218828281fbd7ec7e5bbc63e610 | |
parent | a7bf65c2888f179a8697912be521ebe1b33d0efd (diff) |
TextEditor: Some fileName -> filePath renaming
Change-Id: Id0751f936666fa658226d62a1906b82e3bac1660
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
-rw-r--r-- | src/plugins/bookmarks/bookmark.cpp | 6 | ||||
-rw-r--r-- | src/plugins/bookmarks/bookmark.h | 2 | ||||
-rw-r--r-- | src/plugins/bookmarks/bookmarkfilter.cpp | 4 | ||||
-rw-r--r-- | src/plugins/bookmarks/bookmarkmanager.cpp | 26 | ||||
-rw-r--r-- | src/plugins/clangcodemodel/clangtextmark.cpp | 2 | ||||
-rw-r--r-- | src/plugins/debugger/breakhandler.cpp | 14 | ||||
-rw-r--r-- | src/plugins/projectexplorer/taskhub.cpp | 6 | ||||
-rw-r--r-- | src/plugins/squish/squishtools.cpp | 2 | ||||
-rw-r--r-- | src/plugins/texteditor/textmark.cpp | 22 | ||||
-rw-r--r-- | src/plugins/texteditor/textmark.h | 8 | ||||
-rw-r--r-- | src/plugins/valgrind/callgrindtool.cpp | 2 |
11 files changed, 46 insertions, 48 deletions
diff --git a/src/plugins/bookmarks/bookmark.cpp b/src/plugins/bookmarks/bookmark.cpp index 5a2420246b9..27c8365e19e 100644 --- a/src/plugins/bookmarks/bookmark.cpp +++ b/src/plugins/bookmarks/bookmark.cpp @@ -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); } diff --git a/src/plugins/bookmarks/bookmark.h b/src/plugins/bookmarks/bookmark.h index a40939be2c1..44277d19c60 100644 --- a/src/plugins/bookmarks/bookmark.h +++ b/src/plugins/bookmarks/bookmark.h @@ -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; diff --git a/src/plugins/bookmarks/bookmarkfilter.cpp b/src/plugins/bookmarks/bookmarkfilter.cpp index 9c00adb46c5..7cc9bf2a759 100644 --- a/src/plugins/bookmarks/bookmarkfilter.cpp +++ b/src/plugins/bookmarks/bookmarkfilter.cpp @@ -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())}; diff --git a/src/plugins/bookmarks/bookmarkmanager.cpp b/src/plugins/bookmarks/bookmarkmanager.cpp index 344893a8ec3..e7c5a4e388e 100644 --- a/src/plugins/bookmarks/bookmarkmanager.cpp +++ b/src/plugins/bookmarks/bookmarkmanager.cpp @@ -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(); } diff --git a/src/plugins/clangcodemodel/clangtextmark.cpp b/src/plugins/clangcodemodel/clangtextmark.cpp index c67a5cab182..6b2ba2940aa 100644 --- a/src/plugins/clangcodemodel/clangtextmark.cpp +++ b/src/plugins/clangcodemodel/clangtextmark.cpp @@ -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]"; diff --git a/src/plugins/debugger/breakhandler.cpp b/src/plugins/debugger/breakhandler.cpp index 6581dfa39c9..bcc50a4b0d0 100644 --- a/src/plugins/debugger/breakhandler.cpp +++ b/src/plugins/debugger/breakhandler.cpp @@ -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) { diff --git a/src/plugins/projectexplorer/taskhub.cpp b/src/plugins/projectexplorer/taskhub.cpp index 841bfb5d4e9..da839e89f19 100644 --- a/src/plugins/projectexplorer/taskhub.cpp +++ b/src/plugins/projectexplorer/taskhub.cpp @@ -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() diff --git a/src/plugins/squish/squishtools.cpp b/src/plugins/squish/squishtools.cpp index 58be2a78c30..bc09e2fa6cb 100644 --- a/src/plugins/squish/squishtools.cpp +++ b/src/plugins/squish/squishtools.cpp @@ -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); } } diff --git a/src/plugins/texteditor/textmark.cpp b/src/plugins/texteditor/textmark.cpp index cf391fa1060..19ab3d1d346 100644 --- a/src/plugins/texteditor/textmark.cpp +++ b/src/plugins/texteditor/textmark.cpp @@ -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; diff --git a/src/plugins/texteditor/textmark.h b/src/plugins/texteditor/textmark.h index 0a34139ec55..72712557058 100644 --- a/src/plugins/texteditor/textmark.h +++ b/src/plugins/texteditor/textmark.h @@ -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); diff --git a/src/plugins/valgrind/callgrindtool.cpp b/src/plugins/valgrind/callgrindtool.cpp index 851b89f10cb..76edbbbbb3f 100644 --- a/src/plugins/valgrind/callgrindtool.cpp +++ b/src/plugins/valgrind/callgrindtool.cpp @@ -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); }); |