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>
This commit is contained in:
David Schulz
2015-04-17 12:46:28 +02:00
committed by Orgad Shaneh
parent a6e1c3cb54
commit ab2a0d74de
17 changed files with 122 additions and 14 deletions

View File

@@ -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);