1 #ifndef MARKDOWNDOCUMENT_H
2 #define MARKDOWNDOCUMENT_H
10 #include <QQuickTextDocument>
11 #include <QQmlAutoPropertyHelpers.h>
12 #include "MarkdownHighlighter.h"
18 QML_WRITABLE_AUTO_PROPERTY(QQuickTextDocument*, textDocument)
19 QML_WRITABLE_AUTO_PROPERTY(
bool, enabled)
20 QML_WRITABLE_AUTO_PROPERTY(
bool, hasSelection)
21 QML_WRITABLE_AUTO_PROPERTY(
int, selectionStart)
22 QML_WRITABLE_AUTO_PROPERTY(
int, selectionEnd)
23 Q_PROPERTY(
int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged)
24 Q_ENUMS(BulletListMarkerType)
25 Q_ENUMS(NumberedListMarkerType)
29 if (m_highlighter != Q_NULLPTR) {
35 enum BulletListMarkerType {
41 enum NumberedListMarkerType {
46 int cursorPosition()
const;
49 void cursorPositionChanged(
int cursorPosition);
54 void setCursorPosition(
int cursorPosition);
57 QTextDocument *document()
const;
58 void keyPressEvent(QKeyEvent *event);
60 bool handleBackspace();
61 QString getBlockStart(QRegExp ®exp);
62 QString getPreviousIndentation();
65 void onDocumentChanged();
66 void onContentsChange(
const int &pos,
const int &rm,
const int &add);
68 QTextCursor textCursor();
71 bool insertPair(
const QChar &c);
72 bool endPairHandled(
const QChar &c);
73 QHash<QChar, QChar> m_pairs;
74 QHash<QChar, bool> m_matches;
83 #endif // MARKDOWNDOCUMENT_H