aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor/textmark.cpp
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@theqtcompany.com>2015-04-17 12:46:28 +0200
committerOrgad Shaneh <orgads@gmail.com>2015-05-21 08:23:16 +0000
commitab2a0d74dec2df08d23e14b5b3ad670d98af435f (patch)
tree02b161b155335a5cfd498fdd2052e86b7c490964 /src/plugins/texteditor/textmark.cpp
parenta6e1c3cb54dcf419aa3b86ecd24865198906e313 (diff)
TextEditor: Sort text marks in categories.
Also adding a color for each category. Change-Id: I3627d13913951a95804b5a816f087a822c01bd86 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
Diffstat (limited to 'src/plugins/texteditor/textmark.cpp')
-rw-r--r--src/plugins/texteditor/textmark.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/plugins/texteditor/textmark.cpp b/src/plugins/texteditor/textmark.cpp
index 222a0ba06f7..e499ada3ba9 100644
--- a/src/plugins/texteditor/textmark.cpp
+++ b/src/plugins/texteditor/textmark.cpp
@@ -44,12 +44,13 @@ using namespace TextEditor::Internal;
namespace TextEditor {
-TextMark::TextMark(const QString &fileName, int lineNumber)
+TextMark::TextMark(const QString &fileName, int lineNumber, Id category)
: m_baseTextDocument(0),
m_fileName(fileName),
m_lineNumber(lineNumber),
m_priority(NormalPriority),
m_visible(true),
+ m_category(category),
m_widthFactor(1.0)
{
if (!m_fileName.isEmpty())
@@ -116,6 +117,16 @@ void TextMark::setIcon(const QIcon &icon)
m_icon = icon;
}
+Theme::Color TextMark::categoryColor(Id category)
+{
+ return TextEditorPlugin::baseTextMarkRegistry()->categoryColor(category);
+}
+
+void TextMark::setCategoryColor(Id category, Theme::Color color)
+{
+ TextEditorPlugin::baseTextMarkRegistry()->setCategoryColor(category, color);
+}
+
void TextMark::updateMarker()
{
if (m_baseTextDocument)
@@ -144,6 +155,11 @@ void TextMark::setVisible(bool visible)
m_baseTextDocument->updateMark(this);
}
+Id TextMark::category() const
+{
+ return m_category;
+}
+
double TextMark::widthFactor() const
{
return m_widthFactor;
@@ -209,6 +225,18 @@ bool TextMarkRegistry::remove(TextMark *mark)
return m_marks[FileName::fromString(mark->fileName())].remove(mark);
}
+Theme::Color TextMarkRegistry::categoryColor(Id category)
+{
+ return m_colors.contains(category) ? m_colors[category] : Theme::InvalidColor;
+}
+
+void TextMarkRegistry::setCategoryColor(Id category, Theme::Color color)
+{
+ if (m_colors[category] == color)
+ return;
+ m_colors[category] = color;
+}
+
void TextMarkRegistry::editorOpened(IEditor *editor)
{
auto document = qobject_cast<TextDocument *>(editor ? editor->document() : 0);