Axivion: Fix changing highlighting of issues

So far we are only fetching line markers for newly opened
documents. So, only re-opening a file updates the appearance
of text marks stored for a document.
This patch allows to remove an already set color of the mark
which in turn is responsible for highlighting the marks on
the scrollbar.
Toggling the respective setting now updates existing marks.

Change-Id: I95f65b8c48cb1f125740b88e7f744398b72ee92b
Reviewed-by: Mohammad Mehdi Salem Naraghi <mehdi.salem@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
Christian Stenger
2024-08-07 12:50:19 +02:00
parent 1726998244
commit 191c6603da
3 changed files with 31 additions and 0 deletions

View File

@@ -219,6 +219,7 @@ public:
void onDocumentOpened(IDocument *doc);
void onDocumentClosed(IDocument * doc);
void clearAllMarks();
void updateExistingMarks();
void handleIssuesForFile(const Dto::FileViewDto &fileView);
void fetchIssueInfo(const QString &id);
void setIssueDetails(const QString &issueDetailsHtml);
@@ -313,6 +314,8 @@ AxivionPluginPrivate::AxivionPluginPrivate()
connect(&m_networkAccessManager, &QNetworkAccessManager::sslErrors,
this, &AxivionPluginPrivate::handleSslErrors);
#endif // ssl
connect(&settings().highlightMarks, &BoolAspect::changed,
this, &AxivionPluginPrivate::updateExistingMarks);
}
void AxivionPluginPrivate::handleSslErrors(QNetworkReply *reply, const QList<QSslError> &errors)
@@ -930,6 +933,27 @@ void AxivionPluginPrivate::clearAllMarks()
onDocumentClosed(doc);
}
void AxivionPluginPrivate::updateExistingMarks() // update whether highlight marks or not
{
static Theme::Color color = Theme::Color(Theme::Bookmarks_TextMarkColor); // FIXME!
const bool colored = settings().highlightMarks();
const QList<IDocument *> openDocuments = DocumentModel::openedDocuments();
for (IDocument *doc : openDocuments) {
if (auto textDoc = qobject_cast<TextEditor::TextDocument *>(doc)) {
const TextMarks textMarks = textDoc->marks();
for (TextEditor::TextMark *mark : textMarks) {
if (mark->category().id != s_axivionTextMarkId)
continue;
if (colored)
mark->setColor(color);
else
mark->unsetColor();
}
}
}
}
void AxivionPluginPrivate::onDocumentOpened(IDocument *doc)
{
if (!doc || !m_currentProjectInfo || !m_project || !m_project->isKnownFile(doc->filePath()))

View File

@@ -406,6 +406,12 @@ void TextMark::setColor(const Theme::Color &color)
updateMarker();
}
void TextMark::unsetColor()
{
m_color.reset();
updateMarker();
}
void TextMark::setLineAnnotation(const QString &lineAnnotation)
{
m_lineAnnotation = lineAnnotation;

View File

@@ -99,6 +99,7 @@ public:
std::optional<Utils::Theme::Color> color() const;
void setColor(const Utils::Theme::Color &color);
void unsetColor();
QString defaultToolTip() const { return m_defaultToolTip; }
void setDefaultToolTip(const QString &toolTip) { m_defaultToolTip = toolTip; }