blob: c196b7a443a6c5aa1ec5a8e9a0615910dd95c233 (
plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
#ifndef MO_TEXTEDITOR_H
#define MO_TEXTEDITOR_H
#include <QPlainTextEdit>
class TextEditor;
class TextEditorToolbar
{
public:
TextEditorToolbar(TextEditor& editor);
QWidget* widget();
private:
TextEditor& m_editor;
QWidget* m_widget;
QAction* m_save;
QAction* m_wordWrap;
void onTextModified(bool b);
void onWordWrap(bool b);
};
class TextEditor : public QObject
{
Q_OBJECT
public:
TextEditor(QPlainTextEdit* edit);
bool load(const QString& filename);
bool save();
const QString& filename() const;
void wordWrap(bool b);
void toggleWordWrap();
bool wordWrap() const;
bool dirty() const;
signals:
void modified(bool b);
void wordWrapChanged(bool b);
private:
QPlainTextEdit* m_edit;
TextEditorToolbar m_toolbar;
QString m_filename;
QString m_encoding;
bool m_dirty;
void onModified(bool b);
void dirty(bool b);
void setupToolbar();
QWidget* wrapEditWidget();
};
#endif // MO_TEXTEDITOR_H
|