forked from qt-creator/qt-creator
Axivion: Store marks into the plugin
Enables an easier handling and better control over the axivion text marks. Change-Id: Ifd07d8bd56285bfebd452cc1f1e75aa393f07839 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -247,6 +247,7 @@ public:
|
|||||||
TaskTreeRunner m_issueInfoRunner;
|
TaskTreeRunner m_issueInfoRunner;
|
||||||
FileInProjectFinder m_fileFinder; // FIXME maybe obsolete when path mapping is implemented
|
FileInProjectFinder m_fileFinder; // FIXME maybe obsolete when path mapping is implemented
|
||||||
QMetaObject::Connection m_fileFinderConnection;
|
QMetaObject::Connection m_fileFinderConnection;
|
||||||
|
QHash<FilePath, QSet<TextMark *>> m_allMarks;
|
||||||
};
|
};
|
||||||
|
|
||||||
static AxivionPluginPrivate *dd = nullptr;
|
static AxivionPluginPrivate *dd = nullptr;
|
||||||
@@ -929,9 +930,9 @@ void AxivionPluginPrivate::handleOpenedDocs()
|
|||||||
|
|
||||||
void AxivionPluginPrivate::clearAllMarks()
|
void AxivionPluginPrivate::clearAllMarks()
|
||||||
{
|
{
|
||||||
const QList<IDocument *> openDocuments = DocumentModel::openedDocuments();
|
for (const QSet<TextMark *> &marks : std::as_const(m_allMarks))
|
||||||
for (IDocument *doc : openDocuments)
|
qDeleteAll(marks);
|
||||||
onDocumentClosed(doc);
|
m_allMarks.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AxivionPluginPrivate::updateExistingMarks() // update whether highlight marks or not
|
void AxivionPluginPrivate::updateExistingMarks() // update whether highlight marks or not
|
||||||
@@ -939,19 +940,12 @@ void AxivionPluginPrivate::updateExistingMarks() // update whether highlight mar
|
|||||||
static Theme::Color color = Theme::Color(Theme::Bookmarks_TextMarkColor); // FIXME!
|
static Theme::Color color = Theme::Color(Theme::Bookmarks_TextMarkColor); // FIXME!
|
||||||
const bool colored = settings().highlightMarks();
|
const bool colored = settings().highlightMarks();
|
||||||
|
|
||||||
const QList<IDocument *> openDocuments = DocumentModel::openedDocuments();
|
auto changeColor = colored ? [](TextMark *mark) { mark->setColor(color); }
|
||||||
for (IDocument *doc : openDocuments) {
|
: [](TextMark *mark) { mark->unsetColor(); };
|
||||||
if (auto textDoc = qobject_cast<TextEditor::TextDocument *>(doc)) {
|
|
||||||
const TextMarks textMarks = textDoc->marks();
|
for (const QSet<TextMark *> &marksForFile : std::as_const(m_allMarks)) {
|
||||||
for (TextEditor::TextMark *mark : textMarks) {
|
for (auto mark : marksForFile)
|
||||||
if (mark->category().id != s_axivionTextMarkId)
|
changeColor(mark);
|
||||||
continue;
|
|
||||||
if (colored)
|
|
||||||
mark->setColor(color);
|
|
||||||
else
|
|
||||||
mark->unsetColor();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -963,6 +957,8 @@ void AxivionPluginPrivate::onDocumentOpened(IDocument *doc)
|
|||||||
const FilePath filePath = doc->filePath().relativeChildPath(m_project->projectDirectory());
|
const FilePath filePath = doc->filePath().relativeChildPath(m_project->projectDirectory());
|
||||||
if (filePath.isEmpty())
|
if (filePath.isEmpty())
|
||||||
return; // Empty is fine
|
return; // Empty is fine
|
||||||
|
if (m_allMarks.contains(filePath))
|
||||||
|
return;
|
||||||
|
|
||||||
const auto handler = [this](const Dto::FileViewDto &data) {
|
const auto handler = [this](const Dto::FileViewDto &data) {
|
||||||
if (data.lineMarkers.empty())
|
if (data.lineMarkers.empty())
|
||||||
@@ -991,11 +987,7 @@ void AxivionPluginPrivate::onDocumentClosed(IDocument *doc)
|
|||||||
if (it != m_docMarksTrees.end())
|
if (it != m_docMarksTrees.end())
|
||||||
m_docMarksTrees.erase(it);
|
m_docMarksTrees.erase(it);
|
||||||
|
|
||||||
const TextMarks &marks = document->marks();
|
qDeleteAll(m_allMarks.take(document->filePath()));
|
||||||
for (TextMark *mark : marks) {
|
|
||||||
if (mark->category().id == s_axivionTextMarkId)
|
|
||||||
delete mark;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AxivionPluginPrivate::handleIssuesForFile(const Dto::FileViewDto &fileView)
|
void AxivionPluginPrivate::handleIssuesForFile(const Dto::FileViewDto &fileView)
|
||||||
@@ -1015,7 +1007,7 @@ void AxivionPluginPrivate::handleIssuesForFile(const Dto::FileViewDto &fileView)
|
|||||||
// FIXME the line location can be wrong (even the whole issue could be wrong)
|
// FIXME the line location can be wrong (even the whole issue could be wrong)
|
||||||
// depending on whether this line has been changed since the last axivion run and the
|
// depending on whether this line has been changed since the last axivion run and the
|
||||||
// current state of the file - some magic has to happen here
|
// current state of the file - some magic has to happen here
|
||||||
new AxivionTextMark(filePath, marker, color);
|
m_allMarks[filePath] << new AxivionTextMark(filePath, marker, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user