diff options
author | Casper van Donderen <[email protected]> | 2012-06-01 12:41:13 +0200 |
---|---|---|
committer | Marius Storm-Olsen <[email protected]> | 2012-06-07 14:45:52 +0200 |
commit | 08fa70bb5fb97b07f0e85a83352fefdf10e03800 (patch) | |
tree | 382c5cc10c622ddf08dbf47c5801c23d94cf5040 /FoldingCodeExample/editor.h | |
parent | 073c4e7ae33c64105f87f0362e915b480a23091a (diff) |
Diffstat (limited to 'FoldingCodeExample/editor.h')
-rw-r--r-- | FoldingCodeExample/editor.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/FoldingCodeExample/editor.h b/FoldingCodeExample/editor.h new file mode 100644 index 0000000..97e176d --- /dev/null +++ b/FoldingCodeExample/editor.h @@ -0,0 +1,46 @@ +#ifndef EDITOR_H +#define EDITOR_H + +#include <QPlainTextEdit> +#include <QPlainTextDocumentLayout> +#include <QTextBlock> +#include <QSize> +#include <QDebug> + +class QPaintEvent; +class QMouseEvent; + +class EditorLayout : public QPlainTextDocumentLayout +{ + Q_OBJECT + +public: + EditorLayout(QTextDocument *document) : QPlainTextDocumentLayout(document) { + } + + void emitDocumentSizeChanged() { + emit documentSizeChanged(documentSize()); + } +}; + +class Editor : public QPlainTextEdit +{ + Q_OBJECT + +public: + Editor(); + +protected: + void paintEvent(QPaintEvent *event); + void mousePressEvent(QMouseEvent *event); + +private slots: + void updateCursorPosition(); + +private: + QTextBlock foldedBlockAt(const QPoint &point); + + bool folded; +}; + +#endif |