forked from vnotex/vnote
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvdocument.cpp
More file actions
219 lines (182 loc) · 5.57 KB
/
vdocument.cpp
File metadata and controls
219 lines (182 loc) · 5.57 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#include "vdocument.h"
#include <QDebug>
#include "vfile.h"
#include "vplantumlhelper.h"
#include "vgraphvizhelper.h"
VDocument::VDocument(const VFile *v_file, QObject *p_parent)
: QObject(p_parent),
m_file(v_file),
m_readyToHighlight(false),
m_plantUMLHelper(NULL),
m_graphvizHelper(NULL),
m_nextID(0),
m_webViewMuted(false)
{
}
void VDocument::updateText()
{
if (m_file) {
emit textChanged(m_file->getContent());
}
}
void VDocument::setToc(const QString &toc, int /* baseLevel */)
{
if (toc == m_toc) {
return;
}
m_toc = toc;
emit tocChanged(m_toc);
}
QString VDocument::getToc()
{
return m_toc;
}
void VDocument::scrollToAnchor(const QString &anchor)
{
m_header = anchor;
emit requestScrollToAnchor(anchor);
}
void VDocument::setHeader(const QString &anchor)
{
if (m_webViewMuted || anchor == m_header) {
return;
}
m_header = anchor;
emit headerChanged(m_header);
}
void VDocument::setHtml(const QString &html)
{
if (html == m_html) {
return;
}
m_html = html;
emit htmlChanged(m_html);
}
void VDocument::setLog(const QString &p_log)
{
qDebug() << "JS:" << p_log;
}
void VDocument::keyPressEvent(int p_key, bool p_ctrl, bool p_shift, bool p_meta)
{
emit keyPressed(p_key, p_ctrl, p_shift, p_meta);
}
void VDocument::highlightTextAsync(const QString &p_text, int p_id, unsigned long long p_timeStamp)
{
emit requestHighlightText(p_text, p_id, p_timeStamp);
}
void VDocument::highlightTextCB(const QString &p_html, int p_id, unsigned long long p_timeStamp)
{
emit textHighlighted(p_html, p_id, p_timeStamp);
}
void VDocument::textToHtmlAsync(int p_identitifer,
int p_id,
int p_timeStamp,
const QString &p_text,
bool p_inlineStyle)
{
emit requestTextToHtml(p_identitifer, p_id, p_timeStamp, p_text, p_inlineStyle);
}
void VDocument::htmlToTextAsync(int p_identitifer,
int p_id,
int p_timeStamp,
const QString &p_html)
{
emit requestHtmlToText(p_identitifer, p_id, p_timeStamp, p_html);
}
void VDocument::getHtmlContentAsync()
{
emit requestHtmlContent();
}
void VDocument::textToHtmlCB(int p_identitifer, int p_id, int p_timeStamp, const QString &p_html)
{
emit textToHtmlFinished(p_identitifer, p_id, p_timeStamp, p_html);
}
void VDocument::htmlToTextCB(int p_identitifer, int p_id, int p_timeStamp, const QString &p_text)
{
emit htmlToTextFinished(p_identitifer, p_id, p_timeStamp, p_text);
}
void VDocument::noticeReadyToHighlightText()
{
m_readyToHighlight = true;
emit readyToHighlightText();
}
void VDocument::noticeReadyToTextToHtml()
{
m_readyToTextToHtml = true;
}
void VDocument::setFile(const VFile *p_file)
{
m_file = p_file;
}
const VFile *VDocument::getFile() const
{
return m_file;
}
void VDocument::finishLogics()
{
qDebug() << "Web side finished logics" << this;
emit logicsFinished();
}
void VDocument::htmlContentCB(const QString &p_head,
const QString &p_style,
const QString &p_body)
{
emit htmlContentFinished(p_head, p_style, p_body);
}
void VDocument::updateWordCountInfo(int p_wordCount,
int p_charWithoutSpacesCount,
int p_charWithSpacesCount)
{
m_wordCountInfo.m_mode = VWordCountInfo::Read;
m_wordCountInfo.m_wordCount = p_wordCount;
m_wordCountInfo.m_charWithoutSpacesCount = p_charWithoutSpacesCount;
m_wordCountInfo.m_charWithSpacesCount = p_charWithSpacesCount;
emit wordCountInfoUpdated();
}
void VDocument::processPlantUML(int p_id, const QString &p_format, const QString &p_text)
{
if (!m_plantUMLHelper) {
m_plantUMLHelper = new VPlantUMLHelper(this);
connect(m_plantUMLHelper, &VPlantUMLHelper::resultReady,
this, &VDocument::plantUMLResultReady);
}
m_plantUMLHelper->processAsync(p_id, 0, p_format, p_text);
}
void VDocument::processGraphviz(int p_id, const QString &p_format, const QString &p_text)
{
if (!m_graphvizHelper) {
m_graphvizHelper = new VGraphvizHelper(this);
connect(m_graphvizHelper, &VGraphvizHelper::resultReady,
this, &VDocument::graphvizResultReady);
}
m_graphvizHelper->processAsync(p_id, 0, p_format, p_text);
}
void VDocument::setPreviewEnabled(bool p_enabled)
{
emit requestPreviewEnabled(p_enabled);
}
void VDocument::previewCodeBlock(int p_id,
const QString &p_lang,
const QString &p_text,
bool p_livePreview)
{
emit requestPreviewCodeBlock(p_id, p_lang, p_text, p_livePreview);
}
void VDocument::setPreviewContent(const QString &p_lang, const QString &p_html)
{
emit requestSetPreviewContent(p_lang, p_html);
}
void VDocument::previewCodeBlockCB(int p_id, const QString &p_lang, const QString &p_html)
{
emit codeBlockPreviewReady(p_id, p_lang, p_html);
}
void VDocument::performSmartLivePreview(const QString &p_lang,
const QString &p_text,
const QString &p_hints,
bool p_isRegex)
{
if (!p_text.isEmpty()) {
qDebug() << "performSmartLivePreview" << p_lang << p_text << p_hints << p_isRegex;
emit requestPerformSmartLivePreview(p_lang, p_text, p_hints, p_isRegex);
}
}