-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathgcoderdocument.h
More file actions
174 lines (148 loc) · 5.43 KB
/
Copy pathgcoderdocument.h
File metadata and controls
174 lines (148 loc) · 5.43 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*
* Copyright (C) 2024 Nick Egorrov, nicegorov@yandex.ru
*
* This file is part of GCodeWorkShop.
*
* GCodeWorkShop is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GCODERDOCUMENT_H
#define GCODERDOCUMENT_H
#include <QByteArray> // for QByteArray
#include <QList> // for QList
#include <QObject> // for slots, signals, Q_OBJECT
#include <QString> // for QString
#include <QTextCursor> // for QTextCursor
#include <QTextEdit> // for QTextEdit::ExtraSelection, QTextEdit
class QCloseEvent;
template <class Key, class T> class QHash;
class QMenu;
class QPlainTextEdit;
class QPoint;
class QPrinter;
class QTextDocument;
#include <document.h>
#include <documentinfo.h> // for DocumentInfo, DocumentInfo::Ptr
#include <documentstyle.h> // for DocumentStyle, DocumentStyle::Ptr
#include <documentwidgetproperties.h> // for DocumentWidgetProperties, DocumentWidgetProperties::Ptr
#include <gcoderstyle.h>
#include <gcoderwidgetproperties.h>
class CapsLockEventFilter;
class GCoderEventFilter;
class Highlighter;
class InLineCalc;
class GCoderDocument : public Document
{
Q_OBJECT
public:
GCoderDocument();
QString type() const override;
QString guessFileName() const override;
void loadTemplate(const QString& fileName = QString()) override;
bool load() override;
bool save() override;
QByteArray rawData() const override;
void setRawData(const QByteArray& data) override;
QMenu* createStandardContextMenu(const QPoint& pos) override;
DocumentInfo::Ptr documentInfo() const override;
void setDocumentInfo(const DocumentInfo::Ptr& info) override;
DocumentStyle::Ptr documentStyle() const override;
void setDocumentStyle(const DocumentStyle::Ptr& style) override;
DocumentWidgetProperties::Ptr documentWidgetProperties() const override;
void setDocumentWidgetProperties(const DocumentWidgetProperties::Ptr& properties) override;
void redo() override;
void undo() override;
void clearUndoRedoStacks() override;
bool isReadOnly() const override;
void setReadOnly(bool ro) override;
QString text(bool addCR = false) const;
void setText(const QString& text);
bool hasSelection() const;
void selectAll();
void clearSelection(bool toAnchor = false);
QString selectedText() const;
void insertText(const QString& text);
void cut();
void copy();
void paste();
void setHighlightMode(int mod);
int highlightMode() const;
bool foundTextMatched(const QString& pattern, QString text);
bool findNext(QString textToFind,
bool wholeWords = false,
bool ignoreCase = true,
bool ignoreComments = true,
bool backward = false);
bool replaceNext(QString textToFind,
QString replacedText,
bool wholeWords = false,
bool ignoreCase = true,
bool ignoreComments = true,
bool backward = false);
bool replaceAll(QString textToFind,
QString replacedText,
bool wholeWords = false,
bool ignoreCase = true,
bool ignoreComments = true,
bool backward = false);
void highlightFindText(const QString& searchString,
bool wholeWords = false,
bool ignoreCase = true,
bool ignoreComments = true,
bool backward = false);
bool overwriteMode();
void centerCursor();
QString wordUnderCursor() const;
void removeSelectedText();
void clear();
void print(QPrinter* printer);
int currentLine() const;
int currentColumn() const;
void goToLine(int line);
QPlainTextEdit* textEdit() const;
public slots:
void showInLineCalc();
protected:
QPlainTextEdit* m_textEdit;
Highlighter* m_highlighter;
int m_highlightMode;
int m_preLoadCursorPosition;
GCoderStyle m_codeStyle;
GCoderWidgetProperties m_widgetProperties;
CapsLockEventFilter* m_capsLockEventFilter;
GCoderEventFilter* m_gCoderEventFilter;
QList<QTextEdit::ExtraSelection> m_extraSelections;
QList<QTextEdit::ExtraSelection> m_findTextExtraSelections;
QTextEdit::ExtraSelection m_selection;
QList<QTextEdit::ExtraSelection> m_blockExtraSelections;
InLineCalc* m_inLineCalc;
QTextDocument* document() const;
QTextCursor textCursor() const;
void setTextCursor(const QTextCursor& cursor);
void changeDateInComment();
void closeEvent(QCloseEvent* event);
void updateBrief();
void updateWindowTitle();
void updateToolTips();
void loadToolTips(QHash<QString, QString>& tips, const QString& fileName, const QString& group);
bool maybeSave();
void rehighlight();
void detectHighlightMode();
bool findText(const QString& text, bool wholeWords, bool ignoreCase, bool ignoreComments, bool backward);
private slots :
void underLine();
void cursorMoved();
void highlightCurrentLine();
void inLineCalcComplete(const QString& text);
};
#endif // GCODERDOCUMENT_H