-
Notifications
You must be signed in to change notification settings - Fork 3
/
xmledit.h
73 lines (58 loc) · 1.57 KB
/
xmledit.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 XMLEDIT_H
#define XMLEDIT_H
#include <QScrollArea>
#include <QDomDocument>
#include <QVBoxLayout>
// Frustratingly, Qt has no abstract document class.
// They have a text document class but it cannot be separated from its text model.
// Therefore, this class reimplements much of the interface of QPlainTextEdit and QTextDocument.
class DocumentEdit : public QScrollArea
{
Q_OBJECT
protected:
public:
explicit DocumentEdit(QWidget *parent = nullptr);
virtual ~DocumentEdit() {}
virtual bool isModified() const = 0;
public Q_SLOTS:
#ifndef QT_NO_CLIPBOARD
virtual void cut() = 0;
virtual void copy() = 0;
virtual void paste() = 0;
#endif
//virtual void undo() = 0;
//virtual void redo() = 0;
virtual void clear() = 0; // Also resets file state
virtual void clearUi(); // Also resets file state
Q_SIGNALS:
void contentsChanged();
void copyAvailable(bool b);
//void undoAvailable(bool);
//void redoAvailable(bool);
//void undoCommandAdded();
};
class XmlEdit : public DocumentEdit
{
Q_OBJECT
protected:
QDomDocument domDocument; // "Model"
QVBoxLayout *vLayout;
void addNode(QDomNode node, int depth);
public:
explicit XmlEdit(QWidget *parent = nullptr);
virtual ~XmlEdit();
bool isModified() const;
bool read(QIODevice *device);
bool write(QIODevice *device) const;
public Q_SLOTS:
#ifndef QT_NO_CLIPBOARD
void cut();
void copy();
void paste();
#endif
//void undo();
//void redo();
void clear(); // Also resets file state
void clearUi(); // Also resets file state
};
#endif