Vagyojaka 5.5.7
Loading...
Searching...
No Matches
texteditor.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <QPlainTextEdit>
6
8
9class TextEditor : public QPlainTextEdit
10{
11 Q_OBJECT
12
13public:
14 explicit TextEditor(QWidget *parent = nullptr);
15 void lineNumberAreaPaintEvent(QPaintEvent *event);
17
18 void setLineNumberAreaFont(const QFont& font)
19 {
20 lineNumberArea->setFont(font);
21 }
22
23public slots:
24 void findReplace();
25
26signals:
27 void message(const QString& text, int timeout = 5000);
28 void openMessage(const QString& text);
29
30protected:
31 void resizeEvent(QResizeEvent *event) override;
32 void keyPressEvent(QKeyEvent *event) override;
33
34private slots:
35 void updateLineNumberAreaWidth(int newBlockCount);
37 void updateLineNumberArea(const QRect &rect, int dy);
38
39private:
42};
43
44class LineNumberArea : public QWidget
45{
46public:
47 explicit LineNumberArea(TextEditor *parentEditor) : QWidget(parentEditor), m_editor(parentEditor)
48 {}
49
50 QSize sizeHint() const override
51 {
52 return QSize(m_editor->lineNumberAreaWidth(), 0);
53 }
54
55protected:
56 void paintEvent(QPaintEvent *event) override
57 {
59 }
60
61private:
63};
Definition findreplacedialog.h:11
Definition texteditor.h:45
void paintEvent(QPaintEvent *event) override
Definition texteditor.h:56
TextEditor * m_editor
Definition texteditor.h:62
QSize sizeHint() const override
Definition texteditor.h:50
LineNumberArea(TextEditor *parentEditor)
Definition texteditor.h:47
Definition texteditor.h:10
TextEditor(QWidget *parent=nullptr)
Definition texteditor.cpp:6
QWidget * lineNumberArea
Definition texteditor.h:40
FindReplaceDialog * m_findReplace
Definition texteditor.h:41
void resizeEvent(QResizeEvent *event) override
Definition texteditor.cpp:64
void openMessage(const QString &text)
void lineNumberAreaPaintEvent(QPaintEvent *event)
Definition texteditor.cpp:91
void message(const QString &text, int timeout=5000)
int lineNumberAreaWidth()
Definition texteditor.cpp:19
void keyPressEvent(QKeyEvent *event) override
Definition texteditor.cpp:118
void findReplace()
Definition texteditor.cpp:34
void highlightCurrentLine()
Definition texteditor.cpp:72
void updateLineNumberAreaWidth(int newBlockCount)
Definition texteditor.cpp:48
void updateLineNumberArea(const QRect &rect, int dy)
Definition texteditor.cpp:53
void setLineNumberAreaFont(const QFont &font)
Definition texteditor.h:18