This repository has been archived by the owner on Mar 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ztextedit.h
73 lines (68 loc) · 1.87 KB
/
ztextedit.h
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
#ifndef ZTEXTEDIT_H
#define ZTEXTEDIT_H
#include "zlistmodel.h"
#include <DTextEdit>
#include <QtWidgets>
DWIDGET_USE_NAMESPACE
class ZTextEdit : public DTextEdit {
Q_OBJECT
public:
ZTextEdit(QWidget* p, bool DStyle = true);
void setNote(const ZNote& note);
inline InnerIndex index() const;
public slots:
void fBold(bool);
void fItalic(bool);
void fUnderline(bool);
void fLinethrough(bool);
void fUrl(bool);
void pSplitline();
void pInsImage(const QVariant& data = QVariant());
void pInsUrl(bool);
void pInsList();
void pInsOrderedList();
void pInsCode();
QString getUrlString();
void updateCharFormat(const QTextCharFormat&);
void setBottomMargin(int d);
void setTopMargin(int d);
signals:
void fBoldState(bool);
void fItalicState(bool);
void fUnderlineState(bool);
void fLinethroughState(bool);
void pIsUrl(bool);
void indexChanged(const InnerIndex& ori, const InnerIndex& idx);
protected:
void keyPressEvent(QKeyEvent*);
void keyReleaseEvent(QKeyEvent*);
void mouseReleaseEvent(QMouseEvent*);
void insertFromMimeData(const QMimeData*);
void resizeEvent(QResizeEvent*);
bool event(QEvent* e);
private slots:
private:
enum DefaultCharFormatProperty {
DefaultFontPointSize = 14,
};
void
fEdit(QTextCharFormat&);
void updateDocumentFormat();
void initResources();
QImage processImage(const QByteArray& data);
void updateResources();
void updateResourcesList(QString html);
void commitModifications();
void setHtml(const QString& html);
QTextCharFormat sample;
QStringList resources;
bool ctrlPressed;
bool editing;
bool hackDStyle;
int marginBottom;
int marginTop;
const double ImagePercentage = 0.95;
InnerIndex idx;
};
InnerIndex ZTextEdit::index() const { return idx; }
#endif // ZTEXTEDIT_H