1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QQUICKTEXTDOCUMENT_H |
5 | #define QQUICKTEXTDOCUMENT_H |
6 | |
7 | #include <QtGui/QTextDocument> |
8 | #include <QtQuick/QQuickItem> |
9 | |
10 | QT_BEGIN_NAMESPACE |
11 | |
12 | class QQuickTextDocumentPrivate; |
13 | class Q_QUICK_EXPORT QQuickTextDocument : public QObject |
14 | { |
15 | Q_OBJECT |
16 | Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged REVISION(6, 7)) |
17 | Q_PROPERTY(bool modified READ isModified WRITE setModified NOTIFY modifiedChanged REVISION(6, 7)) |
18 | Q_PROPERTY(Status status READ status NOTIFY statusChanged REVISION(6, 7)) |
19 | Q_PROPERTY(QString errorString READ errorString NOTIFY errorStringChanged REVISION(6, 7)) |
20 | |
21 | QML_NAMED_ELEMENT(TextDocument) |
22 | QML_UNCREATABLE("TextDocument is only available as a property of TextEdit or TextArea." ) |
23 | QML_ADDED_IN_VERSION(2, 0) |
24 | |
25 | public: |
26 | enum class Status : quint8 { |
27 | Null = 0, |
28 | Loading, |
29 | Loaded, |
30 | Saving, |
31 | Saved, |
32 | ReadError, |
33 | WriteError, |
34 | NonLocalFileError, |
35 | }; |
36 | Q_ENUM(Status) |
37 | |
38 | QQuickTextDocument(QQuickItem *parent); |
39 | |
40 | QUrl source() const; |
41 | void setSource(const QUrl &url); |
42 | |
43 | bool isModified() const; |
44 | void setModified(bool modified); |
45 | |
46 | QTextDocument *textDocument() const; |
47 | void setTextDocument(QTextDocument *document); |
48 | |
49 | Q_REVISION(6, 7) Q_INVOKABLE void save(); |
50 | Q_REVISION(6, 7) Q_INVOKABLE void saveAs(const QUrl &url); |
51 | |
52 | Status status() const; |
53 | QString errorString() const; |
54 | |
55 | Q_SIGNALS: |
56 | Q_REVISION(6,7) void textDocumentChanged(); |
57 | Q_REVISION(6, 7) void sourceChanged(); |
58 | Q_REVISION(6, 7) void modifiedChanged(); |
59 | Q_REVISION(6, 7) void statusChanged(); |
60 | Q_REVISION(6, 7) void errorStringChanged(); |
61 | |
62 | private: |
63 | Q_DISABLE_COPY(QQuickTextDocument) |
64 | Q_DECLARE_PRIVATE(QQuickTextDocument) |
65 | }; |
66 | |
67 | QT_END_NAMESPACE |
68 | |
69 | #endif |
70 | |