forked from qt-creator/qt-creator
Use FileName in TextMark
Change-Id: I3666d95dc8ef3b7da099d6d30f5cb4678a349493 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -34,9 +34,10 @@
|
|||||||
#include <QTextBlock>
|
#include <QTextBlock>
|
||||||
|
|
||||||
using namespace Bookmarks::Internal;
|
using namespace Bookmarks::Internal;
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
Bookmark::Bookmark(int lineNumber, BookmarkManager *manager) :
|
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)
|
m_manager(manager)
|
||||||
{
|
{
|
||||||
setColor(Utils::Theme::Bookmarks_TextMarkColor);
|
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);
|
TextMark::updateFileName(fileName);
|
||||||
m_manager->updateBookmarkFileName(this, oldFileName);
|
m_manager->updateBookmarkFileName(this, oldFileName.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bookmark::setNote(const QString ¬e)
|
void Bookmark::setNote(const QString ¬e)
|
||||||
|
@@ -40,7 +40,7 @@ public:
|
|||||||
void updateLineNumber(int lineNumber) override;
|
void updateLineNumber(int lineNumber) override;
|
||||||
void move(int line) override;
|
void move(int line) override;
|
||||||
void updateBlock(const QTextBlock &block) override;
|
void updateBlock(const QTextBlock &block) override;
|
||||||
void updateFileName(const QString &fileName) override;
|
void updateFileName(const Utils::FileName &fileName) override;
|
||||||
void removedFromEditor() override;
|
void removedFromEditor() override;
|
||||||
|
|
||||||
bool isDraggable() const override;
|
bool isDraggable() const override;
|
||||||
|
@@ -58,7 +58,7 @@ QList<LocatorFilterEntry> BookmarkFilter::matchesFor(QFutureInterface<LocatorFil
|
|||||||
QList<LocatorFilterEntry> entries;
|
QList<LocatorFilterEntry> entries;
|
||||||
for (const QModelIndex &idx : matches) {
|
for (const QModelIndex &idx : matches) {
|
||||||
const Bookmark *bookmark = m_manager->bookmarkForIndex(idx);
|
const Bookmark *bookmark = m_manager->bookmarkForIndex(idx);
|
||||||
const QString filename = FileName::fromString(bookmark->fileName()).fileName();
|
const QString filename = bookmark->fileName().fileName();
|
||||||
LocatorFilterEntry filterEntry(this,
|
LocatorFilterEntry filterEntry(this,
|
||||||
QString("%1:%2").arg(filename).arg(bookmark->lineNumber()),
|
QString("%1:%2").arg(filename).arg(bookmark->lineNumber()),
|
||||||
QVariant::fromValue(idx));
|
QVariant::fromValue(idx));
|
||||||
@@ -67,7 +67,7 @@ QList<LocatorFilterEntry> BookmarkFilter::matchesFor(QFutureInterface<LocatorFil
|
|||||||
else if (!bookmark->lineText().isEmpty())
|
else if (!bookmark->lineText().isEmpty())
|
||||||
filterEntry.extraInfo = bookmark->lineText();
|
filterEntry.extraInfo = bookmark->lineText();
|
||||||
else
|
else
|
||||||
filterEntry.extraInfo = bookmark->fileName();
|
filterEntry.extraInfo = bookmark->fileName().toString();
|
||||||
int highlightIndex = filterEntry.displayName.indexOf(entry, 0, Qt::CaseInsensitive);
|
int highlightIndex = filterEntry.displayName.indexOf(entry, 0, Qt::CaseInsensitive);
|
||||||
if (highlightIndex >= 0) {
|
if (highlightIndex >= 0) {
|
||||||
filterEntry.highlightInfo = {highlightIndex, entry.length()};
|
filterEntry.highlightInfo = {highlightIndex, entry.length()};
|
||||||
|
@@ -370,17 +370,17 @@ QVariant BookmarkManager::data(const QModelIndex &index, int role) const
|
|||||||
|
|
||||||
Bookmark *bookMark = m_bookmarksList.at(index.row());
|
Bookmark *bookMark = m_bookmarksList.at(index.row());
|
||||||
if (role == BookmarkManager::Filename)
|
if (role == BookmarkManager::Filename)
|
||||||
return FileName::fromString(bookMark->fileName()).fileName();
|
return bookMark->fileName().fileName();
|
||||||
if (role == BookmarkManager::LineNumber)
|
if (role == BookmarkManager::LineNumber)
|
||||||
return bookMark->lineNumber();
|
return bookMark->lineNumber();
|
||||||
if (role == BookmarkManager::Directory)
|
if (role == BookmarkManager::Directory)
|
||||||
return QFileInfo(bookMark->fileName()).path();
|
return bookMark->fileName().toFileInfo().path();
|
||||||
if (role == BookmarkManager::LineText)
|
if (role == BookmarkManager::LineText)
|
||||||
return bookMark->lineText();
|
return bookMark->lineText();
|
||||||
if (role == BookmarkManager::Note)
|
if (role == BookmarkManager::Note)
|
||||||
return bookMark->note();
|
return bookMark->note();
|
||||||
if (role == Qt::ToolTipRole)
|
if (role == Qt::ToolTipRole)
|
||||||
return QDir::toNativeSeparators(bookMark->fileName());
|
return bookMark->fileName().toUserOutput();
|
||||||
return QVariant();
|
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())
|
if (!index.isValid() || index.column() != 0 || index.row() < 0 || index.row() >= m_bookmarksList.count())
|
||||||
continue;
|
continue;
|
||||||
Bookmark *bookMark = m_bookmarksList.at(index.row());
|
Bookmark *bookMark = m_bookmarksList.at(index.row());
|
||||||
data->addFile(bookMark->fileName(), bookMark->lineNumber());
|
data->addFile(bookMark->fileName().toString(), bookMark->lineNumber());
|
||||||
}
|
}
|
||||||
return data;
|
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
|
// Add a new bookmark if no bookmark existed on this line
|
||||||
Bookmark *mark = new Bookmark(lineNumber, this);
|
Bookmark *mark = new Bookmark(lineNumber, this);
|
||||||
mark->updateFileName(fileName.toString());
|
mark->updateFileName(fileName);
|
||||||
const QModelIndex currentIndex = selectionModel()->currentIndex();
|
const QModelIndex currentIndex = selectionModel()->currentIndex();
|
||||||
const int insertionIndex = currentIndex.isValid() ? currentIndex.row() + 1
|
const int insertionIndex = currentIndex.isValid() ? currentIndex.row() + 1
|
||||||
: m_bookmarksList.size();
|
: m_bookmarksList.size();
|
||||||
@@ -446,11 +446,11 @@ void BookmarkManager::updateBookmark(Bookmark *bookmark)
|
|||||||
|
|
||||||
void BookmarkManager::updateBookmarkFileName(Bookmark *bookmark, const QString &oldFileName)
|
void BookmarkManager::updateBookmarkFileName(Bookmark *bookmark, const QString &oldFileName)
|
||||||
{
|
{
|
||||||
if (oldFileName == bookmark->fileName())
|
if (oldFileName == bookmark->fileName().toString())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_bookmarksMap[Utils::FileName::fromString(oldFileName)].removeAll(bookmark);
|
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);
|
updateBookmark(bookmark);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,7 +471,7 @@ void BookmarkManager::deleteBookmark(Bookmark *bookmark)
|
|||||||
int idx = m_bookmarksList.indexOf(bookmark);
|
int idx = m_bookmarksList.indexOf(bookmark);
|
||||||
beginRemoveRows(QModelIndex(), idx, idx);
|
beginRemoveRows(QModelIndex(), idx, idx);
|
||||||
|
|
||||||
m_bookmarksMap[Utils::FileName::fromString(bookmark->fileName())].removeAll(bookmark);
|
m_bookmarksMap[bookmark->fileName()].removeAll(bookmark);
|
||||||
delete bookmark;
|
delete bookmark;
|
||||||
|
|
||||||
m_bookmarksList.removeAt(idx);
|
m_bookmarksList.removeAt(idx);
|
||||||
@@ -493,7 +493,8 @@ Bookmark *BookmarkManager::bookmarkForIndex(const QModelIndex &index) const
|
|||||||
|
|
||||||
bool BookmarkManager::gotoBookmark(const Bookmark *bookmark) 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 editor->currentLine() == bookmark->lineNumber();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -712,7 +713,7 @@ void BookmarkManager::insertBookmark(int idx, Bookmark *bookmark, bool userset)
|
|||||||
idx = qBound(0, idx, m_bookmarksList.size());
|
idx = qBound(0, idx, m_bookmarksList.size());
|
||||||
beginInsertRows(QModelIndex(), idx, idx);
|
beginInsertRows(QModelIndex(), idx, idx);
|
||||||
|
|
||||||
m_bookmarksMap[FileName::fromString(bookmark->fileName())].append(bookmark);
|
m_bookmarksMap[bookmark->fileName()].append(bookmark);
|
||||||
m_bookmarksList.insert(idx, bookmark);
|
m_bookmarksList.insert(idx, bookmark);
|
||||||
|
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
@@ -749,7 +750,7 @@ void BookmarkManager::addBookmark(const QString &s)
|
|||||||
const int lineNumber = s.midRef(index2 + 1, index3 - index2 - 1).toInt();
|
const int lineNumber = s.midRef(index2 + 1, index3 - index2 - 1).toInt();
|
||||||
if (!filePath.isEmpty() && !findBookmark(FileName::fromString(filePath), lineNumber)) {
|
if (!filePath.isEmpty() && !findBookmark(FileName::fromString(filePath), lineNumber)) {
|
||||||
Bookmark *b = new Bookmark(lineNumber, this);
|
Bookmark *b = new Bookmark(lineNumber, this);
|
||||||
b->updateFileName(filePath);
|
b->updateFileName(FileName::fromString(filePath));
|
||||||
b->setNote(note);
|
b->setNote(note);
|
||||||
addBookmark(b, false);
|
addBookmark(b, false);
|
||||||
}
|
}
|
||||||
@@ -764,7 +765,7 @@ QString BookmarkManager::bookmarkToString(const Bookmark *b)
|
|||||||
const QLatin1Char colon(':');
|
const QLatin1Char colon(':');
|
||||||
// Using \t as delimiter because any another symbol can be a part of note.
|
// Using \t as delimiter because any another symbol can be a part of note.
|
||||||
const QLatin1Char noteDelimiter('\t');
|
const QLatin1Char noteDelimiter('\t');
|
||||||
return colon + b->fileName() +
|
return colon + b->fileName().toString() +
|
||||||
colon + QString::number(b->lineNumber()) +
|
colon + QString::number(b->lineNumber()) +
|
||||||
noteDelimiter + b->note();
|
noteDelimiter + b->note();
|
||||||
}
|
}
|
||||||
@@ -797,7 +798,7 @@ bool BookmarkManager::isAtCurrentBookmark() const
|
|||||||
return true;
|
return true;
|
||||||
IEditor *currentEditor = EditorManager::currentEditor();
|
IEditor *currentEditor = EditorManager::currentEditor();
|
||||||
return currentEditor
|
return currentEditor
|
||||||
&& currentEditor->document()->filePath() == Utils::FileName::fromString(bk->fileName())
|
&& currentEditor->document()->filePath() == bk->fileName()
|
||||||
&& currentEditor->currentLine() == bk->lineNumber();
|
&& currentEditor->currentLine() == bk->lineNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -475,7 +475,9 @@ void ClangDiagnosticManager::addClangTextMarks(
|
|||||||
m_clangTextMarks.erase(it, m_clangTextMarks.end());
|
m_clangTextMarks.erase(it, m_clangTextMarks.end());
|
||||||
delete mark;
|
delete mark;
|
||||||
};
|
};
|
||||||
auto textMark = new ClangTextMark(filePath(), diagnostic, onMarkRemoved,
|
auto textMark = new ClangTextMark(::Utils::FileName::fromString(filePath()),
|
||||||
|
diagnostic,
|
||||||
|
onMarkRemoved,
|
||||||
m_showTextMarkAnnotations);
|
m_showTextMarkAnnotations);
|
||||||
m_clangTextMarks.push_back(textMark);
|
m_clangTextMarks.push_back(textMark);
|
||||||
m_textDocument->addMark(textMark);
|
m_textDocument->addMark(textMark);
|
||||||
|
@@ -36,6 +36,8 @@
|
|||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace ClangCodeModel {
|
namespace ClangCodeModel {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -62,7 +64,7 @@ static Core::Id categoryForSeverity(ClangBackEnd::DiagnosticSeverity severity)
|
|||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
|
|
||||||
ClangTextMark::ClangTextMark(const QString &fileName,
|
ClangTextMark::ClangTextMark(const FileName &fileName,
|
||||||
const ClangBackEnd::DiagnosticContainer &diagnostic,
|
const ClangBackEnd::DiagnosticContainer &diagnostic,
|
||||||
const RemovedFromEditorHandler &removedHandler,
|
const RemovedFromEditorHandler &removedHandler,
|
||||||
bool showLineAnnotations)
|
bool showLineAnnotations)
|
||||||
|
@@ -39,7 +39,7 @@ class ClangTextMark : public TextEditor::TextMark
|
|||||||
public:
|
public:
|
||||||
using RemovedFromEditorHandler = std::function<void(ClangTextMark *)>;
|
using RemovedFromEditorHandler = std::function<void(ClangTextMark *)>;
|
||||||
|
|
||||||
ClangTextMark(const QString &fileName,
|
ClangTextMark(const ::Utils::FileName &fileName,
|
||||||
const ClangBackEnd::DiagnosticContainer &diagnostic,
|
const ClangBackEnd::DiagnosticContainer &diagnostic,
|
||||||
const RemovedFromEditorHandler &removedHandler,
|
const RemovedFromEditorHandler &removedHandler,
|
||||||
bool showLineAnnotations);
|
bool showLineAnnotations);
|
||||||
|
@@ -159,7 +159,7 @@ private:
|
|||||||
class BreakpointMarker : public TextEditor::TextMark
|
class BreakpointMarker : public TextEditor::TextMark
|
||||||
{
|
{
|
||||||
public:
|
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)
|
: TextMark(fileName, lineNumber, Constants::TEXT_MARK_CATEGORY_BREAKPOINT), m_bp(b)
|
||||||
{
|
{
|
||||||
setColor(Theme::Debugger_Breakpoint_TextMarkColor);
|
setColor(Theme::Debugger_Breakpoint_TextMarkColor);
|
||||||
@@ -180,10 +180,10 @@ public:
|
|||||||
m_bp->updateLineNumberFromMarker(lineNumber);
|
m_bp->updateLineNumberFromMarker(lineNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateFileName(const QString &fileName)
|
void updateFileName(const FileName &fileName)
|
||||||
{
|
{
|
||||||
TextMark::updateFileName(fileName);
|
TextMark::updateFileName(fileName);
|
||||||
m_bp->updateFileNameFromMarker(fileName);
|
m_bp->updateFileNameFromMarker(fileName.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isDraggable() const { return true; }
|
bool isDraggable() const { return true; }
|
||||||
@@ -2256,7 +2256,7 @@ void BreakpointItem::updateMarkerIcon()
|
|||||||
|
|
||||||
void BreakpointItem::updateMarker()
|
void BreakpointItem::updateMarker()
|
||||||
{
|
{
|
||||||
QString file = markerFileName();
|
FileName file = FileName::fromString(markerFileName());
|
||||||
int line = markerLineNumber();
|
int line = markerLineNumber();
|
||||||
if (m_marker && (file != m_marker->fileName() || line != m_marker->lineNumber()))
|
if (m_marker && (file != m_marker->fileName() || line != m_marker->lineNumber()))
|
||||||
destroyMarker();
|
destroyMarker();
|
||||||
|
@@ -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)
|
: TextMark(file, line, Constants::TEXT_MARK_CATEGORY_LOCATION), m_engine(engine)
|
||||||
{
|
{
|
||||||
setIcon(Icons::LOCATION.icon());
|
setIcon(Icons::LOCATION.icon());
|
||||||
@@ -544,7 +544,7 @@ void DebuggerEngine::gotoLocation(const Location &loc)
|
|||||||
editor->document()->setProperty(Constants::OPENED_BY_DEBUGGER, true);
|
editor->document()->setProperty(Constants::OPENED_BY_DEBUGGER, true);
|
||||||
|
|
||||||
if (loc.needsMarker())
|
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
|
const DebuggerRunParameters &DebuggerEngine::runParameters() const
|
||||||
|
@@ -485,7 +485,7 @@ private:
|
|||||||
class LocationMark : public TextEditor::TextMark
|
class LocationMark : public TextEditor::TextMark
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LocationMark(DebuggerEngine *engine, const QString &file, int line);
|
LocationMark(DebuggerEngine *engine, const Utils::FileName &file, int line);
|
||||||
void removedFromEditor() override { updateLineNumber(0); }
|
void removedFromEditor() override { updateLineNumber(0); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -66,7 +66,7 @@ class DisassemblerBreakpointMarker : public TextMark
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DisassemblerBreakpointMarker(const Breakpoint &bp, int lineNumber)
|
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());
|
setIcon(bp.icon());
|
||||||
setPriority(TextMark::NormalPriority);
|
setPriority(TextMark::NormalPriority);
|
||||||
@@ -136,7 +136,7 @@ public:
|
|||||||
DisassemblerAgentPrivate::DisassemblerAgentPrivate(DebuggerEngine *engine)
|
DisassemblerAgentPrivate::DisassemblerAgentPrivate(DebuggerEngine *engine)
|
||||||
: document(0),
|
: document(0),
|
||||||
engine(engine),
|
engine(engine),
|
||||||
locationMark(engine, QString(), 0),
|
locationMark(engine, Utils::FileName(), 0),
|
||||||
mimeType("text/x-qtcreator-generic-asm"),
|
mimeType("text/x-qtcreator-generic-asm"),
|
||||||
resetLocationScheduled(false)
|
resetLocationScheduled(false)
|
||||||
{}
|
{}
|
||||||
|
@@ -139,7 +139,7 @@ void SourceAgent::updateLocationMarker()
|
|||||||
if (d->engine->stackHandler()->currentFrame().file == d->path) {
|
if (d->engine->stackHandler()->currentFrame().file == d->path) {
|
||||||
int lineNumber = d->engine->stackHandler()->currentFrame().line;
|
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);
|
Constants::TEXT_MARK_CATEGORY_LOCATION);
|
||||||
d->locationMark->setIcon(Icons::LOCATION.icon());
|
d->locationMark->setIcon(Icons::LOCATION.icon());
|
||||||
d->locationMark->setPriority(TextMark::HighPriority);
|
d->locationMark->setPriority(TextMark::HighPriority);
|
||||||
|
@@ -35,6 +35,8 @@
|
|||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
|
|
||||||
// Task mark categories
|
// Task mark categories
|
||||||
@@ -60,7 +62,7 @@ class TaskMark : public TextEditor::TextMark
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TaskMark(const Task &task) :
|
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)
|
m_id(task.taskId)
|
||||||
{
|
{
|
||||||
setColor(task.type == Task::Error ? Utils::Theme::ProjectExplorer_TaskError_TextMarkColor
|
setColor(task.type == Task::Error ? Utils::Theme::ProjectExplorer_TaskError_TextMarkColor
|
||||||
@@ -77,7 +79,7 @@ public:
|
|||||||
bool isClickable() const;
|
bool isClickable() const;
|
||||||
void clicked();
|
void clicked();
|
||||||
|
|
||||||
void updateFileName(const QString &fileName);
|
void updateFileName(const FileName &fileName);
|
||||||
void updateLineNumber(int lineNumber);
|
void updateLineNumber(int lineNumber);
|
||||||
void removedFromEditor();
|
void removedFromEditor();
|
||||||
private:
|
private:
|
||||||
@@ -90,10 +92,10 @@ void TaskMark::updateLineNumber(int lineNumber)
|
|||||||
TextMark::updateLineNumber(lineNumber);
|
TextMark::updateLineNumber(lineNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskMark::updateFileName(const QString &fileName)
|
void TaskMark::updateFileName(const FileName &fileName)
|
||||||
{
|
{
|
||||||
TaskHub::updateTaskFileName(m_id, fileName);
|
TaskHub::updateTaskFileName(m_id, fileName.toString());
|
||||||
TextMark::updateFileName(fileName);
|
TextMark::updateFileName(FileName::fromString(fileName.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TaskMark::removedFromEditor()
|
void TaskMark::removedFromEditor()
|
||||||
|
@@ -610,8 +610,7 @@ void QmlJSEditorDocumentPrivate::createTextMarks(const QList<DiagnosticMessage>
|
|||||||
delete mark;
|
delete mark;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto mark = new QmlJSTextMark(q->filePath().toString(),
|
auto mark = new QmlJSTextMark(q->filePath(), diagnostic, onMarkRemoved);
|
||||||
diagnostic, onMarkRemoved);
|
|
||||||
m_diagnosticMarks.append(mark);
|
m_diagnosticMarks.append(mark);
|
||||||
q->addMark(mark);
|
q->addMark(mark);
|
||||||
}
|
}
|
||||||
@@ -630,13 +629,13 @@ void QmlJSEditorDocumentPrivate::createTextMarks(const SemanticInfo &info)
|
|||||||
delete mark;
|
delete mark;
|
||||||
};
|
};
|
||||||
for (const DiagnosticMessage &diagnostic : qAsConst(info.semanticMessages)) {
|
for (const DiagnosticMessage &diagnostic : qAsConst(info.semanticMessages)) {
|
||||||
auto mark = new QmlJSTextMark(q->filePath().toString(),
|
auto mark = new QmlJSTextMark(q->filePath(),
|
||||||
diagnostic, onMarkRemoved);
|
diagnostic, onMarkRemoved);
|
||||||
m_semanticMarks.append(mark);
|
m_semanticMarks.append(mark);
|
||||||
q->addMark(mark);
|
q->addMark(mark);
|
||||||
}
|
}
|
||||||
for (const QmlJS::StaticAnalysis::Message &message : qAsConst(info.staticAnalysisMessages)) {
|
for (const QmlJS::StaticAnalysis::Message &message : qAsConst(info.staticAnalysisMessages)) {
|
||||||
auto mark = new QmlJSTextMark(q->filePath().toString(),
|
auto mark = new QmlJSTextMark(q->filePath(),
|
||||||
message, onMarkRemoved);
|
message, onMarkRemoved);
|
||||||
m_semanticMarks.append(mark);
|
m_semanticMarks.append(mark);
|
||||||
q->addMark(mark);
|
q->addMark(mark);
|
||||||
|
@@ -32,6 +32,7 @@
|
|||||||
|
|
||||||
using namespace QmlJSEditor;
|
using namespace QmlJSEditor;
|
||||||
using namespace QmlJSEditor::Internal;
|
using namespace QmlJSEditor::Internal;
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
using namespace TextEditor;
|
using namespace TextEditor;
|
||||||
|
|
||||||
@@ -58,7 +59,7 @@ static Core::Id cartegoryForSeverity(QmlJS::Severity::Enum kind)
|
|||||||
return isWarning(kind) ? QMLJS_WARNING : QMLJS_ERROR;
|
return isWarning(kind) ? QMLJS_WARNING : QMLJS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlJSTextMark::QmlJSTextMark(const QString &fileName,
|
QmlJSTextMark::QmlJSTextMark(const FileName &fileName,
|
||||||
const QmlJS::DiagnosticMessage &diagnostic,
|
const QmlJS::DiagnosticMessage &diagnostic,
|
||||||
const QmlJSTextMark::RemovedFromEditorHandler &removedHandler)
|
const QmlJSTextMark::RemovedFromEditorHandler &removedHandler)
|
||||||
: TextEditor::TextMark(fileName, int(diagnostic.loc.startLine),
|
: TextEditor::TextMark(fileName, int(diagnostic.loc.startLine),
|
||||||
@@ -69,7 +70,7 @@ QmlJSTextMark::QmlJSTextMark(const QString &fileName,
|
|||||||
init(isWarning(diagnostic.kind), diagnostic.message);
|
init(isWarning(diagnostic.kind), diagnostic.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlJSTextMark::QmlJSTextMark(const QString &fileName,
|
QmlJSTextMark::QmlJSTextMark(const FileName &fileName,
|
||||||
const QmlJS::StaticAnalysis::Message &message,
|
const QmlJS::StaticAnalysis::Message &message,
|
||||||
const QmlJSTextMark::RemovedFromEditorHandler &removedHandler)
|
const QmlJSTextMark::RemovedFromEditorHandler &removedHandler)
|
||||||
: TextEditor::TextMark(fileName, int(message.location.startLine),
|
: TextEditor::TextMark(fileName, int(message.location.startLine),
|
||||||
|
@@ -38,10 +38,10 @@ class QmlJSTextMark : public TextEditor::TextMark
|
|||||||
public:
|
public:
|
||||||
using RemovedFromEditorHandler = std::function<void(QmlJSTextMark *)>;
|
using RemovedFromEditorHandler = std::function<void(QmlJSTextMark *)>;
|
||||||
|
|
||||||
QmlJSTextMark(const QString &fileName,
|
QmlJSTextMark(const Utils::FileName &fileName,
|
||||||
const QmlJS::DiagnosticMessage &diagnostic,
|
const QmlJS::DiagnosticMessage &diagnostic,
|
||||||
const RemovedFromEditorHandler &removedHandler);
|
const RemovedFromEditorHandler &removedHandler);
|
||||||
QmlJSTextMark(const QString &fileName,
|
QmlJSTextMark(const Utils::FileName &fileName,
|
||||||
const QmlJS::StaticAnalysis::Message &message,
|
const QmlJS::StaticAnalysis::Message &message,
|
||||||
const RemovedFromEditorHandler &removedHandler);
|
const RemovedFromEditorHandler &removedHandler);
|
||||||
|
|
||||||
|
@@ -33,11 +33,13 @@
|
|||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace QmlProfiler {
|
namespace QmlProfiler {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
QmlProfilerTextMark::QmlProfilerTextMark(QmlProfilerViewManager *viewManager, int typeId,
|
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),
|
TextMark(fileName, lineNumber, Constants::TEXT_MARK_CATEGORY, 3.5), m_viewManager(viewManager),
|
||||||
m_typeIds(1, typeId)
|
m_typeIds(1, typeId)
|
||||||
{
|
{
|
||||||
@@ -109,7 +111,10 @@ void QmlProfilerTextMarkModel::createMarks(QmlProfilerViewManager *viewManager,
|
|||||||
m_marks.last()->addTypeId(it->typeId);
|
m_marks.last()->addTypeId(it->typeId);
|
||||||
} else {
|
} else {
|
||||||
lineNumber = it->lineNumber;
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -36,7 +36,7 @@ class QmlProfilerTextMark : public TextEditor::TextMark
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QmlProfilerTextMark(QmlProfilerViewManager *viewManager, int typeId,
|
QmlProfilerTextMark(QmlProfilerViewManager *viewManager, int typeId,
|
||||||
const QString &fileName, int lineNumber);
|
const Utils::FileName &fileName, int lineNumber);
|
||||||
void addTypeId(int typeId);
|
void addTypeId(int typeId);
|
||||||
|
|
||||||
void paintIcon(QPainter *painter, const QRect &rect) const override;
|
void paintIcon(QPainter *painter, const QRect &rect) const override;
|
||||||
|
@@ -75,7 +75,7 @@ private:
|
|||||||
|
|
||||||
TextMarkRegistry *m_instance = nullptr;
|
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_fileName(fileName)
|
||||||
, m_lineNumber(lineNumber)
|
, m_lineNumber(lineNumber)
|
||||||
, m_visible(true)
|
, m_visible(true)
|
||||||
@@ -95,12 +95,12 @@ TextMark::~TextMark()
|
|||||||
m_baseTextDocument = nullptr;
|
m_baseTextDocument = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TextMark::fileName() const
|
FileName TextMark::fileName() const
|
||||||
{
|
{
|
||||||
return m_fileName;
|
return m_fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextMark::updateFileName(const QString &fileName)
|
void TextMark::updateFileName(const FileName &fileName)
|
||||||
{
|
{
|
||||||
if (fileName == m_fileName)
|
if (fileName == m_fileName)
|
||||||
return;
|
return;
|
||||||
@@ -324,8 +324,9 @@ TextMarkRegistry::TextMarkRegistry(QObject *parent)
|
|||||||
|
|
||||||
void TextMarkRegistry::add(TextMark *mark)
|
void TextMarkRegistry::add(TextMark *mark)
|
||||||
{
|
{
|
||||||
instance()->m_marks[FileName::fromString(mark->fileName())].insert(mark);
|
instance()->m_marks[mark->fileName()].insert(mark);
|
||||||
auto document = qobject_cast<TextDocument*>(DocumentModel::documentForFilePath(mark->fileName()));
|
auto document = qobject_cast<TextDocument *>(
|
||||||
|
DocumentModel::documentForFilePath(mark->fileName().toString()));
|
||||||
if (!document)
|
if (!document)
|
||||||
return;
|
return;
|
||||||
document->addMark(mark);
|
document->addMark(mark);
|
||||||
@@ -333,7 +334,7 @@ void TextMarkRegistry::add(TextMark *mark)
|
|||||||
|
|
||||||
bool TextMarkRegistry::remove(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()
|
TextMarkRegistry *TextMarkRegistry::instance()
|
||||||
@@ -374,7 +375,7 @@ void TextMarkRegistry::documentRenamed(IDocument *document, const
|
|||||||
m_marks[newFileName].unite(toBeMoved);
|
m_marks[newFileName].unite(toBeMoved);
|
||||||
|
|
||||||
foreach (TextMark *mark, toBeMoved)
|
foreach (TextMark *mark, toBeMoved)
|
||||||
mark->updateFileName(newName);
|
mark->updateFileName(newFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextMarkRegistry::allDocumentsRenamed(const QString &oldName, const QString &newName)
|
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();
|
m_marks[oldFileName].clear();
|
||||||
|
|
||||||
foreach (TextMark *mark, oldFileNameMarks)
|
foreach (TextMark *mark, oldFileNameMarks)
|
||||||
mark->updateFileName(newName);
|
mark->updateFileName(newFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<AnnotationColors::SourceColors, AnnotationColors> AnnotationColors::m_colorCache;
|
QHash<AnnotationColors::SourceColors, AnnotationColors> AnnotationColors::m_colorCache;
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
#include <coreplugin/id.h>
|
#include <coreplugin/id.h>
|
||||||
#include <utils/theme/theme.h>
|
#include <utils/theme/theme.h>
|
||||||
|
#include <utils/fileutils.h>
|
||||||
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
@@ -47,7 +48,10 @@ class TextDocument;
|
|||||||
class TEXTEDITOR_EXPORT TextMark
|
class TEXTEDITOR_EXPORT TextMark
|
||||||
{
|
{
|
||||||
public:
|
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;
|
TextMark() = delete;
|
||||||
virtual ~TextMark();
|
virtual ~TextMark();
|
||||||
|
|
||||||
@@ -59,7 +63,7 @@ public:
|
|||||||
HighPriority // shown on top.
|
HighPriority // shown on top.
|
||||||
};
|
};
|
||||||
|
|
||||||
QString fileName() const;
|
Utils::FileName fileName() const;
|
||||||
int lineNumber() const;
|
int lineNumber() const;
|
||||||
|
|
||||||
virtual void paintIcon(QPainter *painter, const QRect &rect) const;
|
virtual void paintIcon(QPainter *painter, const QRect &rect) const;
|
||||||
@@ -78,7 +82,7 @@ public:
|
|||||||
AnnotationRects annotationRects(const QRectF &boundingRect, const QFontMetrics &fm,
|
AnnotationRects annotationRects(const QRectF &boundingRect, const QFontMetrics &fm,
|
||||||
const qreal fadeInOffset, const qreal fadeOutOffset) const;
|
const qreal fadeInOffset, const qreal fadeOutOffset) const;
|
||||||
/// called if the filename of the document changed
|
/// 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 updateLineNumber(int lineNumber);
|
||||||
virtual void updateBlock(const QTextBlock &block);
|
virtual void updateBlock(const QTextBlock &block);
|
||||||
virtual void move(int line);
|
virtual void move(int line);
|
||||||
@@ -122,7 +126,7 @@ private:
|
|||||||
Q_DISABLE_COPY(TextMark)
|
Q_DISABLE_COPY(TextMark)
|
||||||
|
|
||||||
TextDocument *m_baseTextDocument = nullptr;
|
TextDocument *m_baseTextDocument = nullptr;
|
||||||
QString m_fileName;
|
Utils::FileName m_fileName;
|
||||||
int m_lineNumber = 0;
|
int m_lineNumber = 0;
|
||||||
Priority m_priority = LowPriority;
|
Priority m_priority = LowPriority;
|
||||||
QIcon m_icon;
|
QIcon m_icon;
|
||||||
|
@@ -35,13 +35,14 @@
|
|||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
using namespace Valgrind::Internal;
|
using namespace Valgrind::Internal;
|
||||||
using namespace Valgrind::Callgrind;
|
using namespace Valgrind::Callgrind;
|
||||||
|
|
||||||
namespace Constants { const char CALLGRIND_TEXT_MARK_CATEGORY[] = "Callgrind.Textmark"; }
|
namespace Constants { const char CALLGRIND_TEXT_MARK_CATEGORY[] = "Callgrind.Textmark"; }
|
||||||
|
|
||||||
CallgrindTextMark::CallgrindTextMark(const QPersistentModelIndex &index,
|
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)
|
: TextEditor::TextMark(fileName, lineNumber, Constants::CALLGRIND_TEXT_MARK_CATEGORY, 4.0)
|
||||||
, m_modelIndex(index)
|
, m_modelIndex(index)
|
||||||
{
|
{
|
||||||
|
@@ -45,7 +45,7 @@ public:
|
|||||||
* \note The index parameter must refer to one of the DataModel cost columns
|
* \note The index parameter must refer to one of the DataModel cost columns
|
||||||
*/
|
*/
|
||||||
explicit CallgrindTextMark(const QPersistentModelIndex &index,
|
explicit CallgrindTextMark(const QPersistentModelIndex &index,
|
||||||
const QString &fileName, int lineNumber);
|
const Utils::FileName &fileName, int lineNumber);
|
||||||
|
|
||||||
const Valgrind::Callgrind::Function *function() const;
|
const Valgrind::Callgrind::Function *function() const;
|
||||||
|
|
||||||
|
@@ -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
|
// Find callgrind text mark that corresponds to this editor's file and line number
|
||||||
foreach (CallgrindTextMark *textMark, m_textMarks) {
|
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();
|
const Function *func = textMark->function();
|
||||||
QAction *action = menu->addAction(tr("Select This Function in the Analyzer Output"));
|
QAction *action = menu->addAction(tr("Select This Function in the Analyzer Output"));
|
||||||
connect(action, &QAction::triggered, this, [this, func] { selectFunction(func); });
|
connect(action, &QAction::triggered, this, [this, func] { selectFunction(func); });
|
||||||
@@ -956,7 +956,7 @@ void CallgrindTool::createTextMarks()
|
|||||||
continue;
|
continue;
|
||||||
locations << location;
|
locations << location;
|
||||||
|
|
||||||
m_textMarks.append(new CallgrindTextMark(index, fileName, lineNumber));
|
m_textMarks.append(new CallgrindTextMark(index, FileName::fromString(fileName), lineNumber));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user