Commit 1b1896b3 authored by hjk's avatar hjk

texteditor: give priorities to mark to ensure z-order when drawing

parent 4a179b7c
......@@ -59,6 +59,7 @@ public:
void updateLineNumber(int lineNumber);
void updateBlock(const QTextBlock &block);
void removedFromEditor();
TextEditor::ITextMark::Priority priority() const { return TextEditor::ITextMark::LowPriority; }
QString filePath() const;
QString fileName() const;
......
......@@ -52,6 +52,8 @@ public:
void updateBlock(const QTextBlock &);
void removedFromEditor();
void updateLineNumber(int lineNumber);
TextEditor::ITextMark::Priority priority() const { return TextEditor::ITextMark::NormalPriority; }
private:
BreakpointId m_id;
friend class BreakHandler;
......
......@@ -143,6 +143,7 @@ public:
void updateLineNumber(int /*lineNumber*/) {}
void updateBlock(const QTextBlock & /*block*/) {}
void removedFromEditor() {}
TextEditor::ITextMark::Priority priority() const { return TextEditor::ITextMark::HighPriority; }
};
......
......@@ -78,6 +78,8 @@ public:
void updateBlock(const QTextBlock & /*block*/) {}
void removedFromEditor() {}
void documentClosing() {}
TextEditor::ITextMark::Priority priority() const
{ return TextEditor::ITextMark::HighPriority; }
};
class BreakpointMarker2 : public TextEditor::ITextMark
......@@ -90,6 +92,8 @@ public:
void updateBlock(const QTextBlock &) {}
void removedFromEditor() {}
void documentClosing() {}
TextEditor::ITextMark::Priority priority() const
{ return TextEditor::ITextMark::NormalPriority; }
private:
QIcon m_icon;
......
......@@ -84,6 +84,8 @@ public:
void updateBlock(const QTextBlock & /*block*/) {}
void removedFromEditor() {}
void documentClosing() {}
TextEditor::ITextMark::Priority priority() const
{ return TextEditor::ITextMark::HighPriority; }
};
class SourceAgentPrivate
......
......@@ -378,6 +378,17 @@ void TextBlockUserData::setCodeFormatterData(CodeFormatterData *data)
m_codeFormatterData = data;
}
void TextBlockUserData::addMark(ITextMark *mark)
{
int i = 0;
for ( ; i < m_marks.size(); ++i) {
if (mark->priority() < m_marks.at(i)->priority())
break;
}
m_marks.insert(i, mark);
}
BaseTextDocumentLayout::BaseTextDocumentLayout(QTextDocument *doc)
:QPlainTextDocumentLayout(doc) {
lastSaveRevision = 0;
......
......@@ -80,7 +80,7 @@ public:
~TextBlockUserData();
inline TextMarks marks() const { return m_marks; }
inline void addMark(ITextMark *mark) { m_marks += mark; }
void addMark(ITextMark *mark);
inline bool removeMark(ITextMark *mark) { return m_marks.removeAll(mark); }
inline bool hasMark(ITextMark *mark) const { return m_marks.contains(mark); }
inline void clearMarks() { m_marks.clear(); }
......
......@@ -73,6 +73,11 @@ public:
{
m_parent->documentClosingFor(this);
}
virtual Priority priority() const
{
return m_parent->priority();
}
private:
BaseTextMark *m_parent;
};
......
......@@ -35,17 +35,13 @@
#define BASETEXTMARK_H
#include "texteditor_global.h"
#include <QtCore/QObject>
#include "itexteditor.h"
QT_BEGIN_NAMESPACE
class QIcon;
class QTextBlock;
QT_END_NAMESPACE
namespace Core {
class IEditor;
}
namespace TextEditor {
class ITextMarkable;
......@@ -83,6 +79,8 @@ public:
void moveMark(const QString &filename, int line);
virtual TextEditor::ITextMark::Priority priority() const = 0;
private slots:
void init();
void editorOpened(Core::IEditor *editor);
......
......@@ -67,6 +67,16 @@ public:
virtual void updateBlock(const QTextBlock &block) = 0;
virtual void removedFromEditor() = 0;
virtual void documentClosing() = 0;
// determine order on markers on the same line.
enum Priority
{
LowPriority,
NormalPriority,
HighPriority // shown on top.
};
virtual Priority priority() const = 0;
};
typedef QList<ITextMark *> TextMarks;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment