diff --git a/src/plugins/bookmarks/bookmark.cpp b/src/plugins/bookmarks/bookmark.cpp index e35b702b8f9..cf591035d79 100644 --- a/src/plugins/bookmarks/bookmark.cpp +++ b/src/plugins/bookmarks/bookmark.cpp @@ -34,9 +34,10 @@ #include using namespace Bookmarks::Internal; +using namespace Utils; Bookmark::Bookmark(int lineNumber, BookmarkManager *manager) : - TextMark(QString(), lineNumber, Constants::BOOKMARKS_TEXT_MARK_CATEGORY), + TextMark(FileName(), lineNumber, Constants::BOOKMARKS_TEXT_MARK_CATEGORY), m_manager(manager) { setColor(Utils::Theme::Bookmarks_TextMarkColor); @@ -86,11 +87,11 @@ void Bookmark::updateBlock(const QTextBlock &block) } } -void Bookmark::updateFileName(const QString &fileName) +void Bookmark::updateFileName(const FileName &fileName) { - const QString &oldFileName = this->fileName(); + const FileName &oldFileName = this->fileName(); TextMark::updateFileName(fileName); - m_manager->updateBookmarkFileName(this, oldFileName); + m_manager->updateBookmarkFileName(this, oldFileName.toString()); } void Bookmark::setNote(const QString ¬e) diff --git a/src/plugins/bookmarks/bookmark.h b/src/plugins/bookmarks/bookmark.h index ad9a1d7f53d..1dceba433c4 100644 --- a/src/plugins/bookmarks/bookmark.h +++ b/src/plugins/bookmarks/bookmark.h @@ -40,7 +40,7 @@ public: void updateLineNumber(int lineNumber) override; void move(int line) override; void updateBlock(const QTextBlock &block) override; - void updateFileName(const QString &fileName) override; + void updateFileName(const Utils::FileName &fileName) override; void removedFromEditor() override; bool isDraggable() const override; diff --git a/src/plugins/bookmarks/bookmarkfilter.cpp b/src/plugins/bookmarks/bookmarkfilter.cpp index c57f72fedf1..c211ad0beb5 100644 --- a/src/plugins/bookmarks/bookmarkfilter.cpp +++ b/src/plugins/bookmarks/bookmarkfilter.cpp @@ -58,7 +58,7 @@ QList BookmarkFilter::matchesFor(QFutureInterface entries; for (const QModelIndex &idx : matches) { const Bookmark *bookmark = m_manager->bookmarkForIndex(idx); - const QString filename = FileName::fromString(bookmark->fileName()).fileName(); + const QString filename = bookmark->fileName().fileName(); LocatorFilterEntry filterEntry(this, QString("%1:%2").arg(filename).arg(bookmark->lineNumber()), QVariant::fromValue(idx)); @@ -67,7 +67,7 @@ QList BookmarkFilter::matchesFor(QFutureInterfacelineText().isEmpty()) filterEntry.extraInfo = bookmark->lineText(); else - filterEntry.extraInfo = bookmark->fileName(); + filterEntry.extraInfo = bookmark->fileName().toString(); int highlightIndex = filterEntry.displayName.indexOf(entry, 0, Qt::CaseInsensitive); if (highlightIndex >= 0) { filterEntry.highlightInfo = {highlightIndex, entry.length()}; diff --git a/src/plugins/bookmarks/bookmarkmanager.cpp b/src/plugins/bookmarks/bookmarkmanager.cpp index e75664ce453..8516ea31890 100644 --- a/src/plugins/bookmarks/bookmarkmanager.cpp +++ b/src/plugins/bookmarks/bookmarkmanager.cpp @@ -370,17 +370,17 @@ QVariant BookmarkManager::data(const QModelIndex &index, int role) const Bookmark *bookMark = m_bookmarksList.at(index.row()); if (role == BookmarkManager::Filename) - return FileName::fromString(bookMark->fileName()).fileName(); + return bookMark->fileName().fileName(); if (role == BookmarkManager::LineNumber) return bookMark->lineNumber(); if (role == BookmarkManager::Directory) - return QFileInfo(bookMark->fileName()).path(); + return bookMark->fileName().toFileInfo().path(); if (role == BookmarkManager::LineText) return bookMark->lineText(); if (role == BookmarkManager::Note) return bookMark->note(); if (role == Qt::ToolTipRole) - return QDir::toNativeSeparators(bookMark->fileName()); + return bookMark->fileName().toUserOutput(); return QVariant(); } @@ -408,7 +408,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->fileName().toString(), bookMark->lineNumber()); } return data; } @@ -427,7 +427,7 @@ void BookmarkManager::toggleBookmark(const FileName &fileName, int lineNumber) // Add a new bookmark if no bookmark existed on this line Bookmark *mark = new Bookmark(lineNumber, this); - mark->updateFileName(fileName.toString()); + mark->updateFileName(fileName); const QModelIndex currentIndex = selectionModel()->currentIndex(); const int insertionIndex = currentIndex.isValid() ? currentIndex.row() + 1 : m_bookmarksList.size(); @@ -446,11 +446,11 @@ void BookmarkManager::updateBookmark(Bookmark *bookmark) void BookmarkManager::updateBookmarkFileName(Bookmark *bookmark, const QString &oldFileName) { - if (oldFileName == bookmark->fileName()) + if (oldFileName == bookmark->fileName().toString()) return; m_bookmarksMap[Utils::FileName::fromString(oldFileName)].removeAll(bookmark); - m_bookmarksMap[Utils::FileName::fromString(bookmark->fileName())].append(bookmark); + m_bookmarksMap[bookmark->fileName()].append(bookmark); updateBookmark(bookmark); } @@ -471,7 +471,7 @@ void BookmarkManager::deleteBookmark(Bookmark *bookmark) int idx = m_bookmarksList.indexOf(bookmark); beginRemoveRows(QModelIndex(), idx, idx); - m_bookmarksMap[Utils::FileName::fromString(bookmark->fileName())].removeAll(bookmark); + m_bookmarksMap[bookmark->fileName()].removeAll(bookmark); delete bookmark; m_bookmarksList.removeAt(idx); @@ -493,7 +493,8 @@ Bookmark *BookmarkManager::bookmarkForIndex(const QModelIndex &index) const bool BookmarkManager::gotoBookmark(const Bookmark *bookmark) const { - if (IEditor *editor = EditorManager::openEditorAt(bookmark->fileName(), bookmark->lineNumber())) + if (IEditor *editor = EditorManager::openEditorAt(bookmark->fileName().toString(), + bookmark->lineNumber())) return editor->currentLine() == bookmark->lineNumber(); return false; } @@ -712,7 +713,7 @@ void BookmarkManager::insertBookmark(int idx, Bookmark *bookmark, bool userset) idx = qBound(0, idx, m_bookmarksList.size()); beginInsertRows(QModelIndex(), idx, idx); - m_bookmarksMap[FileName::fromString(bookmark->fileName())].append(bookmark); + m_bookmarksMap[bookmark->fileName()].append(bookmark); m_bookmarksList.insert(idx, bookmark); endInsertRows(); @@ -749,7 +750,7 @@ void BookmarkManager::addBookmark(const QString &s) const int lineNumber = s.midRef(index2 + 1, index3 - index2 - 1).toInt(); if (!filePath.isEmpty() && !findBookmark(FileName::fromString(filePath), lineNumber)) { Bookmark *b = new Bookmark(lineNumber, this); - b->updateFileName(filePath); + b->updateFileName(FileName::fromString(filePath)); b->setNote(note); addBookmark(b, false); } @@ -764,7 +765,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() + + return colon + b->fileName().toString() + colon + QString::number(b->lineNumber()) + noteDelimiter + b->note(); } @@ -797,7 +798,7 @@ bool BookmarkManager::isAtCurrentBookmark() const return true; IEditor *currentEditor = EditorManager::currentEditor(); return currentEditor - && currentEditor->document()->filePath() == Utils::FileName::fromString(bk->fileName()) + && currentEditor->document()->filePath() == bk->fileName() && currentEditor->currentLine() == bk->lineNumber(); } diff --git a/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp b/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp index 9923d849179..53df8cc0aad 100644 --- a/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp +++ b/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp @@ -475,7 +475,9 @@ void ClangDiagnosticManager::addClangTextMarks( m_clangTextMarks.erase(it, m_clangTextMarks.end()); delete mark; }; - auto textMark = new ClangTextMark(filePath(), diagnostic, onMarkRemoved, + auto textMark = new ClangTextMark(::Utils::FileName::fromString(filePath()), + diagnostic, + onMarkRemoved, m_showTextMarkAnnotations); m_clangTextMarks.push_back(textMark); m_textDocument->addMark(textMark); diff --git a/src/plugins/clangcodemodel/clangtextmark.cpp b/src/plugins/clangcodemodel/clangtextmark.cpp index c6a23653dc8..44156c8bee7 100644 --- a/src/plugins/clangcodemodel/clangtextmark.cpp +++ b/src/plugins/clangcodemodel/clangtextmark.cpp @@ -36,6 +36,8 @@ #include #include +using namespace Utils; + namespace ClangCodeModel { namespace { @@ -62,7 +64,7 @@ static Core::Id categoryForSeverity(ClangBackEnd::DiagnosticSeverity severity) } // anonymous namespace -ClangTextMark::ClangTextMark(const QString &fileName, +ClangTextMark::ClangTextMark(const FileName &fileName, const ClangBackEnd::DiagnosticContainer &diagnostic, const RemovedFromEditorHandler &removedHandler, bool showLineAnnotations) diff --git a/src/plugins/clangcodemodel/clangtextmark.h b/src/plugins/clangcodemodel/clangtextmark.h index 5c794d970c3..6b7424ae91f 100644 --- a/src/plugins/clangcodemodel/clangtextmark.h +++ b/src/plugins/clangcodemodel/clangtextmark.h @@ -39,7 +39,7 @@ class ClangTextMark : public TextEditor::TextMark public: using RemovedFromEditorHandler = std::function; - ClangTextMark(const QString &fileName, + ClangTextMark(const ::Utils::FileName &fileName, const ClangBackEnd::DiagnosticContainer &diagnostic, const RemovedFromEditorHandler &removedHandler, bool showLineAnnotations); diff --git a/src/plugins/debugger/breakhandler.cpp b/src/plugins/debugger/breakhandler.cpp index 83414cdeb7a..1ee95f4ab68 100644 --- a/src/plugins/debugger/breakhandler.cpp +++ b/src/plugins/debugger/breakhandler.cpp @@ -159,7 +159,7 @@ private: class BreakpointMarker : public TextEditor::TextMark { public: - BreakpointMarker(BreakpointItem *b, const QString &fileName, int lineNumber) + BreakpointMarker(BreakpointItem *b, const FileName &fileName, int lineNumber) : TextMark(fileName, lineNumber, Constants::TEXT_MARK_CATEGORY_BREAKPOINT), m_bp(b) { setColor(Theme::Debugger_Breakpoint_TextMarkColor); @@ -180,10 +180,10 @@ public: m_bp->updateLineNumberFromMarker(lineNumber); } - void updateFileName(const QString &fileName) + void updateFileName(const FileName &fileName) { TextMark::updateFileName(fileName); - m_bp->updateFileNameFromMarker(fileName); + m_bp->updateFileNameFromMarker(fileName.toString()); } bool isDraggable() const { return true; } @@ -2256,7 +2256,7 @@ void BreakpointItem::updateMarkerIcon() void BreakpointItem::updateMarker() { - QString file = markerFileName(); + FileName file = FileName::fromString(markerFileName()); int line = markerLineNumber(); if (m_marker && (file != m_marker->fileName() || line != m_marker->lineNumber())) destroyMarker(); diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index a61f5d2da0f..4df97238907 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -125,7 +125,7 @@ Location::Location(const StackFrame &frame, bool marker) } -LocationMark::LocationMark(DebuggerEngine *engine, const QString &file, int line) +LocationMark::LocationMark(DebuggerEngine *engine, const FileName &file, int line) : TextMark(file, line, Constants::TEXT_MARK_CATEGORY_LOCATION), m_engine(engine) { setIcon(Icons::LOCATION.icon()); @@ -544,7 +544,7 @@ void DebuggerEngine::gotoLocation(const Location &loc) editor->document()->setProperty(Constants::OPENED_BY_DEBUGGER, true); if (loc.needsMarker()) - d->m_locationMark.reset(new LocationMark(this, file, line)); + d->m_locationMark.reset(new LocationMark(this, FileName::fromString(file), line)); } const DebuggerRunParameters &DebuggerEngine::runParameters() const diff --git a/src/plugins/debugger/debuggerengine.h b/src/plugins/debugger/debuggerengine.h index 14f6defacd5..09dd6aa6e62 100644 --- a/src/plugins/debugger/debuggerengine.h +++ b/src/plugins/debugger/debuggerengine.h @@ -485,7 +485,7 @@ private: class LocationMark : public TextEditor::TextMark { public: - LocationMark(DebuggerEngine *engine, const QString &file, int line); + LocationMark(DebuggerEngine *engine, const Utils::FileName &file, int line); void removedFromEditor() override { updateLineNumber(0); } private: diff --git a/src/plugins/debugger/disassembleragent.cpp b/src/plugins/debugger/disassembleragent.cpp index 980eb949d5a..6268d758bd3 100644 --- a/src/plugins/debugger/disassembleragent.cpp +++ b/src/plugins/debugger/disassembleragent.cpp @@ -66,7 +66,7 @@ class DisassemblerBreakpointMarker : public TextMark { public: DisassemblerBreakpointMarker(const Breakpoint &bp, int lineNumber) - : TextMark(QString(), lineNumber, Constants::TEXT_MARK_CATEGORY_BREAKPOINT), m_bp(bp) + : TextMark(Utils::FileName(), lineNumber, Constants::TEXT_MARK_CATEGORY_BREAKPOINT), m_bp(bp) { setIcon(bp.icon()); setPriority(TextMark::NormalPriority); @@ -136,7 +136,7 @@ public: DisassemblerAgentPrivate::DisassemblerAgentPrivate(DebuggerEngine *engine) : document(0), engine(engine), - locationMark(engine, QString(), 0), + locationMark(engine, Utils::FileName(), 0), mimeType("text/x-qtcreator-generic-asm"), resetLocationScheduled(false) {} diff --git a/src/plugins/debugger/sourceagent.cpp b/src/plugins/debugger/sourceagent.cpp index d5371adf06a..f17f7e59289 100644 --- a/src/plugins/debugger/sourceagent.cpp +++ b/src/plugins/debugger/sourceagent.cpp @@ -139,7 +139,7 @@ void SourceAgent::updateLocationMarker() if (d->engine->stackHandler()->currentFrame().file == d->path) { int lineNumber = d->engine->stackHandler()->currentFrame().line; - d->locationMark = new TextMark(QString(), lineNumber, + d->locationMark = new TextMark(Utils::FileName(), lineNumber, Constants::TEXT_MARK_CATEGORY_LOCATION); d->locationMark->setIcon(Icons::LOCATION.icon()); d->locationMark->setPriority(TextMark::HighPriority); diff --git a/src/plugins/projectexplorer/taskhub.cpp b/src/plugins/projectexplorer/taskhub.cpp index d56c275a581..0f00e79e9a6 100644 --- a/src/plugins/projectexplorer/taskhub.cpp +++ b/src/plugins/projectexplorer/taskhub.cpp @@ -35,6 +35,8 @@ #include +using namespace Utils; + namespace ProjectExplorer { // Task mark categories @@ -60,7 +62,7 @@ class TaskMark : public TextEditor::TextMark { public: TaskMark(const Task &task) : - TextMark(task.file.toString(), task.line, categoryForType(task.type)), + TextMark(task.file, task.line, categoryForType(task.type)), m_id(task.taskId) { setColor(task.type == Task::Error ? Utils::Theme::ProjectExplorer_TaskError_TextMarkColor @@ -77,7 +79,7 @@ public: bool isClickable() const; void clicked(); - void updateFileName(const QString &fileName); + void updateFileName(const FileName &fileName); void updateLineNumber(int lineNumber); void removedFromEditor(); private: @@ -90,10 +92,10 @@ void TaskMark::updateLineNumber(int lineNumber) TextMark::updateLineNumber(lineNumber); } -void TaskMark::updateFileName(const QString &fileName) +void TaskMark::updateFileName(const FileName &fileName) { - TaskHub::updateTaskFileName(m_id, fileName); - TextMark::updateFileName(fileName); + TaskHub::updateTaskFileName(m_id, fileName.toString()); + TextMark::updateFileName(FileName::fromString(fileName.toString())); } void TaskMark::removedFromEditor() diff --git a/src/plugins/qmljseditor/qmljseditordocument.cpp b/src/plugins/qmljseditor/qmljseditordocument.cpp index 6325c7b6736..03f5904981d 100644 --- a/src/plugins/qmljseditor/qmljseditordocument.cpp +++ b/src/plugins/qmljseditor/qmljseditordocument.cpp @@ -610,8 +610,7 @@ void QmlJSEditorDocumentPrivate::createTextMarks(const QList delete mark; }; - auto mark = new QmlJSTextMark(q->filePath().toString(), - diagnostic, onMarkRemoved); + auto mark = new QmlJSTextMark(q->filePath(), diagnostic, onMarkRemoved); m_diagnosticMarks.append(mark); q->addMark(mark); } @@ -630,13 +629,13 @@ void QmlJSEditorDocumentPrivate::createTextMarks(const SemanticInfo &info) delete mark; }; for (const DiagnosticMessage &diagnostic : qAsConst(info.semanticMessages)) { - auto mark = new QmlJSTextMark(q->filePath().toString(), + auto mark = new QmlJSTextMark(q->filePath(), diagnostic, onMarkRemoved); m_semanticMarks.append(mark); q->addMark(mark); } for (const QmlJS::StaticAnalysis::Message &message : qAsConst(info.staticAnalysisMessages)) { - auto mark = new QmlJSTextMark(q->filePath().toString(), + auto mark = new QmlJSTextMark(q->filePath(), message, onMarkRemoved); m_semanticMarks.append(mark); q->addMark(mark); diff --git a/src/plugins/qmljseditor/qmljstextmark.cpp b/src/plugins/qmljseditor/qmljstextmark.cpp index 1cf93453a94..542450a9d4b 100644 --- a/src/plugins/qmljseditor/qmljstextmark.cpp +++ b/src/plugins/qmljseditor/qmljstextmark.cpp @@ -32,6 +32,7 @@ using namespace QmlJSEditor; using namespace QmlJSEditor::Internal; +using namespace Utils; using namespace TextEditor; @@ -58,7 +59,7 @@ static Core::Id cartegoryForSeverity(QmlJS::Severity::Enum kind) return isWarning(kind) ? QMLJS_WARNING : QMLJS_ERROR; } -QmlJSTextMark::QmlJSTextMark(const QString &fileName, +QmlJSTextMark::QmlJSTextMark(const FileName &fileName, const QmlJS::DiagnosticMessage &diagnostic, const QmlJSTextMark::RemovedFromEditorHandler &removedHandler) : TextEditor::TextMark(fileName, int(diagnostic.loc.startLine), @@ -69,7 +70,7 @@ QmlJSTextMark::QmlJSTextMark(const QString &fileName, init(isWarning(diagnostic.kind), diagnostic.message); } -QmlJSTextMark::QmlJSTextMark(const QString &fileName, +QmlJSTextMark::QmlJSTextMark(const FileName &fileName, const QmlJS::StaticAnalysis::Message &message, const QmlJSTextMark::RemovedFromEditorHandler &removedHandler) : TextEditor::TextMark(fileName, int(message.location.startLine), diff --git a/src/plugins/qmljseditor/qmljstextmark.h b/src/plugins/qmljseditor/qmljstextmark.h index 52e5ea60523..fb3fe684d66 100644 --- a/src/plugins/qmljseditor/qmljstextmark.h +++ b/src/plugins/qmljseditor/qmljstextmark.h @@ -38,10 +38,10 @@ class QmlJSTextMark : public TextEditor::TextMark public: using RemovedFromEditorHandler = std::function; - QmlJSTextMark(const QString &fileName, + QmlJSTextMark(const Utils::FileName &fileName, const QmlJS::DiagnosticMessage &diagnostic, const RemovedFromEditorHandler &removedHandler); - QmlJSTextMark(const QString &fileName, + QmlJSTextMark(const Utils::FileName &fileName, const QmlJS::StaticAnalysis::Message &message, const RemovedFromEditorHandler &removedHandler); diff --git a/src/plugins/qmlprofiler/qmlprofilertextmark.cpp b/src/plugins/qmlprofiler/qmlprofilertextmark.cpp index 4a7bf4ae389..2112bd172aa 100644 --- a/src/plugins/qmlprofiler/qmlprofilertextmark.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertextmark.cpp @@ -33,11 +33,13 @@ #include #include +using namespace Utils; + namespace QmlProfiler { namespace Internal { QmlProfilerTextMark::QmlProfilerTextMark(QmlProfilerViewManager *viewManager, int typeId, - const QString &fileName, int lineNumber) : + const FileName &fileName, int lineNumber) : TextMark(fileName, lineNumber, Constants::TEXT_MARK_CATEGORY, 3.5), m_viewManager(viewManager), m_typeIds(1, typeId) { @@ -109,7 +111,10 @@ void QmlProfilerTextMarkModel::createMarks(QmlProfilerViewManager *viewManager, m_marks.last()->addTypeId(it->typeId); } else { lineNumber = it->lineNumber; - m_marks << new QmlProfilerTextMark(viewManager, it->typeId, fileName, it->lineNumber); + m_marks << new QmlProfilerTextMark(viewManager, + it->typeId, + FileName::fromString(fileName), + it->lineNumber); } } } diff --git a/src/plugins/qmlprofiler/qmlprofilertextmark.h b/src/plugins/qmlprofiler/qmlprofilertextmark.h index 19d13dcf79b..6747498361b 100644 --- a/src/plugins/qmlprofiler/qmlprofilertextmark.h +++ b/src/plugins/qmlprofiler/qmlprofilertextmark.h @@ -36,7 +36,7 @@ class QmlProfilerTextMark : public TextEditor::TextMark { public: QmlProfilerTextMark(QmlProfilerViewManager *viewManager, int typeId, - const QString &fileName, int lineNumber); + const Utils::FileName &fileName, int lineNumber); void addTypeId(int typeId); void paintIcon(QPainter *painter, const QRect &rect) const override; diff --git a/src/plugins/texteditor/textmark.cpp b/src/plugins/texteditor/textmark.cpp index 89c2385f9af..142cbdc2dcc 100644 --- a/src/plugins/texteditor/textmark.cpp +++ b/src/plugins/texteditor/textmark.cpp @@ -75,7 +75,7 @@ private: TextMarkRegistry *m_instance = nullptr; -TextMark::TextMark(const QString &fileName, int lineNumber, Id category, double widthFactor) +TextMark::TextMark(const FileName &fileName, int lineNumber, Id category, double widthFactor) : m_fileName(fileName) , m_lineNumber(lineNumber) , m_visible(true) @@ -95,12 +95,12 @@ TextMark::~TextMark() m_baseTextDocument = nullptr; } -QString TextMark::fileName() const +FileName TextMark::fileName() const { return m_fileName; } -void TextMark::updateFileName(const QString &fileName) +void TextMark::updateFileName(const FileName &fileName) { if (fileName == m_fileName) return; @@ -324,8 +324,9 @@ TextMarkRegistry::TextMarkRegistry(QObject *parent) void TextMarkRegistry::add(TextMark *mark) { - instance()->m_marks[FileName::fromString(mark->fileName())].insert(mark); - auto document = qobject_cast(DocumentModel::documentForFilePath(mark->fileName())); + instance()->m_marks[mark->fileName()].insert(mark); + auto document = qobject_cast( + DocumentModel::documentForFilePath(mark->fileName().toString())); if (!document) return; document->addMark(mark); @@ -333,7 +334,7 @@ void TextMarkRegistry::add(TextMark *mark) bool TextMarkRegistry::remove(TextMark *mark) { - return instance()->m_marks[FileName::fromString(mark->fileName())].remove(mark); + return instance()->m_marks[mark->fileName()].remove(mark); } TextMarkRegistry *TextMarkRegistry::instance() @@ -374,7 +375,7 @@ void TextMarkRegistry::documentRenamed(IDocument *document, const m_marks[newFileName].unite(toBeMoved); foreach (TextMark *mark, toBeMoved) - mark->updateFileName(newName); + mark->updateFileName(newFileName); } void TextMarkRegistry::allDocumentsRenamed(const QString &oldName, const QString &newName) @@ -390,7 +391,7 @@ void TextMarkRegistry::allDocumentsRenamed(const QString &oldName, const QString m_marks[oldFileName].clear(); foreach (TextMark *mark, oldFileNameMarks) - mark->updateFileName(newName); + mark->updateFileName(newFileName); } QHash AnnotationColors::m_colorCache; diff --git a/src/plugins/texteditor/textmark.h b/src/plugins/texteditor/textmark.h index f68f92c11d9..9275c254aeb 100644 --- a/src/plugins/texteditor/textmark.h +++ b/src/plugins/texteditor/textmark.h @@ -29,6 +29,7 @@ #include #include +#include #include @@ -47,7 +48,10 @@ class TextDocument; class TEXTEDITOR_EXPORT TextMark { public: - TextMark(const QString &fileName, int lineNumber, Core::Id category, double widthFactor = 1.0); + TextMark(const Utils::FileName &fileName, + int lineNumber, + Core::Id category, + double widthFactor = 1.0); TextMark() = delete; virtual ~TextMark(); @@ -59,7 +63,7 @@ public: HighPriority // shown on top. }; - QString fileName() const; + Utils::FileName fileName() const; int lineNumber() const; virtual void paintIcon(QPainter *painter, const QRect &rect) const; @@ -78,7 +82,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 QString &fileName); + virtual void updateFileName(const Utils::FileName &fileName); virtual void updateLineNumber(int lineNumber); virtual void updateBlock(const QTextBlock &block); virtual void move(int line); @@ -122,7 +126,7 @@ private: Q_DISABLE_COPY(TextMark) TextDocument *m_baseTextDocument = nullptr; - QString m_fileName; + Utils::FileName m_fileName; int m_lineNumber = 0; Priority m_priority = LowPriority; QIcon m_icon; diff --git a/src/plugins/valgrind/callgrindtextmark.cpp b/src/plugins/valgrind/callgrindtextmark.cpp index e08d42f0400..f0fb48a1768 100644 --- a/src/plugins/valgrind/callgrindtextmark.cpp +++ b/src/plugins/valgrind/callgrindtextmark.cpp @@ -35,13 +35,14 @@ #include +using namespace Utils; using namespace Valgrind::Internal; using namespace Valgrind::Callgrind; namespace Constants { const char CALLGRIND_TEXT_MARK_CATEGORY[] = "Callgrind.Textmark"; } CallgrindTextMark::CallgrindTextMark(const QPersistentModelIndex &index, - const QString &fileName, int lineNumber) + const FileName &fileName, int lineNumber) : TextEditor::TextMark(fileName, lineNumber, Constants::CALLGRIND_TEXT_MARK_CATEGORY, 4.0) , m_modelIndex(index) { diff --git a/src/plugins/valgrind/callgrindtextmark.h b/src/plugins/valgrind/callgrindtextmark.h index 828dc7f5bd6..fa0a43c915b 100644 --- a/src/plugins/valgrind/callgrindtextmark.h +++ b/src/plugins/valgrind/callgrindtextmark.h @@ -45,7 +45,7 @@ public: * \note The index parameter must refer to one of the DataModel cost columns */ explicit CallgrindTextMark(const QPersistentModelIndex &index, - const QString &fileName, int lineNumber); + const Utils::FileName &fileName, int lineNumber); const Valgrind::Callgrind::Function *function() const; diff --git a/src/plugins/valgrind/callgrindtool.cpp b/src/plugins/valgrind/callgrindtool.cpp index c4215e3d702..294e28e665d 100644 --- a/src/plugins/valgrind/callgrindtool.cpp +++ b/src/plugins/valgrind/callgrindtool.cpp @@ -848,7 +848,7 @@ void CallgrindTool::requestContextMenu(TextEditorWidget *widget, int line, QMenu { // Find callgrind text mark that corresponds to this editor's file and line number foreach (CallgrindTextMark *textMark, m_textMarks) { - if (textMark->fileName() == widget->textDocument()->filePath().toString() && textMark->lineNumber() == line) { + if (textMark->fileName() == widget->textDocument()->filePath() && textMark->lineNumber() == line) { const Function *func = textMark->function(); QAction *action = menu->addAction(tr("Select This Function in the Analyzer Output")); connect(action, &QAction::triggered, this, [this, func] { selectFunction(func); }); @@ -956,7 +956,7 @@ void CallgrindTool::createTextMarks() continue; locations << location; - m_textMarks.append(new CallgrindTextMark(index, fileName, lineNumber)); + m_textMarks.append(new CallgrindTextMark(index, FileName::fromString(fileName), lineNumber)); } }