-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfoldingQTextEdit.cpp
More file actions
31 lines (27 loc) · 915 Bytes
/
foldingQTextEdit.cpp
File metadata and controls
31 lines (27 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
* example code to complete my answer to my question on StackOverflow: see
* http://stackoverflow.com/questions/19232882/nice-text-formatting-in-qtextedit-like-qtcreator-does
* author: CapelliC @2015
* license: MIT
*/
#include "foldingQTextEdit.h"
foldingQTextEdit::foldingQTextEdit()
: framed_handler(new framedTextAttr(this))
, folded_handler(new foldedTextAttr(this))
{
document()->documentLayout()->registerHandler(framed_handler->type(), framed_handler);
document()->documentLayout()->registerHandler(folded_handler->type(), folded_handler);
setLineWrapMode(NoWrap);
}
void foldingQTextEdit::fold() {
folded_handler->fold(textCursor());
}
void foldingQTextEdit::unfold() {
folded_handler->unfold(textCursor());
}
void foldingQTextEdit::frame() {
framed_handler->frame(textCursor());
}
void foldingQTextEdit::unframe() {
framed_handler->unframe(textCursor());
}