forked from qt-creator/qt-creator
texteditor: give priorities to mark to ensure z-order when drawing
This commit is contained in:
@@ -59,6 +59,7 @@ public:
|
|||||||
void updateLineNumber(int lineNumber);
|
void updateLineNumber(int lineNumber);
|
||||||
void updateBlock(const QTextBlock &block);
|
void updateBlock(const QTextBlock &block);
|
||||||
void removedFromEditor();
|
void removedFromEditor();
|
||||||
|
TextEditor::ITextMark::Priority priority() const { return TextEditor::ITextMark::LowPriority; }
|
||||||
|
|
||||||
QString filePath() const;
|
QString filePath() const;
|
||||||
QString fileName() const;
|
QString fileName() const;
|
||||||
|
@@ -52,6 +52,8 @@ public:
|
|||||||
void updateBlock(const QTextBlock &);
|
void updateBlock(const QTextBlock &);
|
||||||
void removedFromEditor();
|
void removedFromEditor();
|
||||||
void updateLineNumber(int lineNumber);
|
void updateLineNumber(int lineNumber);
|
||||||
|
TextEditor::ITextMark::Priority priority() const { return TextEditor::ITextMark::NormalPriority; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BreakpointId m_id;
|
BreakpointId m_id;
|
||||||
friend class BreakHandler;
|
friend class BreakHandler;
|
||||||
|
@@ -143,6 +143,7 @@ public:
|
|||||||
void updateLineNumber(int /*lineNumber*/) {}
|
void updateLineNumber(int /*lineNumber*/) {}
|
||||||
void updateBlock(const QTextBlock & /*block*/) {}
|
void updateBlock(const QTextBlock & /*block*/) {}
|
||||||
void removedFromEditor() {}
|
void removedFromEditor() {}
|
||||||
|
TextEditor::ITextMark::Priority priority() const { return TextEditor::ITextMark::HighPriority; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -78,6 +78,8 @@ public:
|
|||||||
void updateBlock(const QTextBlock & /*block*/) {}
|
void updateBlock(const QTextBlock & /*block*/) {}
|
||||||
void removedFromEditor() {}
|
void removedFromEditor() {}
|
||||||
void documentClosing() {}
|
void documentClosing() {}
|
||||||
|
TextEditor::ITextMark::Priority priority() const
|
||||||
|
{ return TextEditor::ITextMark::HighPriority; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class BreakpointMarker2 : public TextEditor::ITextMark
|
class BreakpointMarker2 : public TextEditor::ITextMark
|
||||||
@@ -90,6 +92,8 @@ public:
|
|||||||
void updateBlock(const QTextBlock &) {}
|
void updateBlock(const QTextBlock &) {}
|
||||||
void removedFromEditor() {}
|
void removedFromEditor() {}
|
||||||
void documentClosing() {}
|
void documentClosing() {}
|
||||||
|
TextEditor::ITextMark::Priority priority() const
|
||||||
|
{ return TextEditor::ITextMark::NormalPriority; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QIcon m_icon;
|
QIcon m_icon;
|
||||||
|
@@ -84,6 +84,8 @@ public:
|
|||||||
void updateBlock(const QTextBlock & /*block*/) {}
|
void updateBlock(const QTextBlock & /*block*/) {}
|
||||||
void removedFromEditor() {}
|
void removedFromEditor() {}
|
||||||
void documentClosing() {}
|
void documentClosing() {}
|
||||||
|
TextEditor::ITextMark::Priority priority() const
|
||||||
|
{ return TextEditor::ITextMark::HighPriority; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class SourceAgentPrivate
|
class SourceAgentPrivate
|
||||||
|
@@ -378,6 +378,17 @@ void TextBlockUserData::setCodeFormatterData(CodeFormatterData *data)
|
|||||||
m_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)
|
BaseTextDocumentLayout::BaseTextDocumentLayout(QTextDocument *doc)
|
||||||
:QPlainTextDocumentLayout(doc) {
|
:QPlainTextDocumentLayout(doc) {
|
||||||
lastSaveRevision = 0;
|
lastSaveRevision = 0;
|
||||||
|
@@ -80,7 +80,7 @@ public:
|
|||||||
~TextBlockUserData();
|
~TextBlockUserData();
|
||||||
|
|
||||||
inline TextMarks marks() const { return m_marks; }
|
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 removeMark(ITextMark *mark) { return m_marks.removeAll(mark); }
|
||||||
inline bool hasMark(ITextMark *mark) const { return m_marks.contains(mark); }
|
inline bool hasMark(ITextMark *mark) const { return m_marks.contains(mark); }
|
||||||
inline void clearMarks() { m_marks.clear(); }
|
inline void clearMarks() { m_marks.clear(); }
|
||||||
|
@@ -73,6 +73,11 @@ public:
|
|||||||
{
|
{
|
||||||
m_parent->documentClosingFor(this);
|
m_parent->documentClosingFor(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual Priority priority() const
|
||||||
|
{
|
||||||
|
return m_parent->priority();
|
||||||
|
}
|
||||||
private:
|
private:
|
||||||
BaseTextMark *m_parent;
|
BaseTextMark *m_parent;
|
||||||
};
|
};
|
||||||
|
@@ -35,17 +35,13 @@
|
|||||||
#define BASETEXTMARK_H
|
#define BASETEXTMARK_H
|
||||||
|
|
||||||
#include "texteditor_global.h"
|
#include "texteditor_global.h"
|
||||||
#include <QtCore/QObject>
|
#include "itexteditor.h"
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QIcon;
|
class QIcon;
|
||||||
class QTextBlock;
|
class QTextBlock;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Core {
|
|
||||||
class IEditor;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
|
|
||||||
class ITextMarkable;
|
class ITextMarkable;
|
||||||
@@ -83,6 +79,8 @@ public:
|
|||||||
|
|
||||||
void moveMark(const QString &filename, int line);
|
void moveMark(const QString &filename, int line);
|
||||||
|
|
||||||
|
virtual TextEditor::ITextMark::Priority priority() const = 0;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void init();
|
void init();
|
||||||
void editorOpened(Core::IEditor *editor);
|
void editorOpened(Core::IEditor *editor);
|
||||||
|
@@ -67,6 +67,16 @@ public:
|
|||||||
virtual void updateBlock(const QTextBlock &block) = 0;
|
virtual void updateBlock(const QTextBlock &block) = 0;
|
||||||
virtual void removedFromEditor() = 0;
|
virtual void removedFromEditor() = 0;
|
||||||
virtual void documentClosing() = 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;
|
typedef QList<ITextMark *> TextMarks;
|
||||||
|
Reference in New Issue
Block a user