summaryrefslogtreecommitdiffstats
path: root/framework/src/domain/documenthandler.h
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/domain/documenthandler.h')
-rw-r--r--framework/src/domain/documenthandler.h161
1 files changed, 0 insertions, 161 deletions
diff --git a/framework/src/domain/documenthandler.h b/framework/src/domain/documenthandler.h
deleted file mode 100644
index 8be3ba16..00000000
--- a/framework/src/domain/documenthandler.h
+++ /dev/null
@@ -1,161 +0,0 @@
1/****************************************************************************
2**
3** Copyright (C) 2017 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the examples of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:BSD$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** BSD License Usage
18** Alternatively, you may use this file under the terms of the BSD license
19** as follows:
20**
21** "Redistribution and use in source and binary forms, with or without
22** modification, are permitted provided that the following conditions are
23** met:
24** * Redistributions of source code must retain the above copyright
25** notice, this list of conditions and the following disclaimer.
26** * Redistributions in binary form must reproduce the above copyright
27** notice, this list of conditions and the following disclaimer in
28** the documentation and/or other materials provided with the
29** distribution.
30** * Neither the name of The Qt Company Ltd nor the names of its
31** contributors may be used to endorse or promote products derived
32** from this software without specific prior written permission.
33**
34**
35** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
36** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
37** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
38** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
39** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
42** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
43** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
44** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
45** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
46**
47** $QT_END_LICENSE$
48**
49****************************************************************************/
50
51#ifndef DOCUMENTHANDLER_H
52#define DOCUMENTHANDLER_H
53
54#include <QFont>
55#include <QObject>
56#include <QTextCursor>
57#include <QUrl>
58
59QT_BEGIN_NAMESPACE
60class QTextDocument;
61class QQuickTextDocument;
62QT_END_NAMESPACE
63
64class DocumentHandler : public QObject
65{
66 Q_OBJECT
67
68 Q_PROPERTY(QQuickTextDocument *document READ document WRITE setDocument NOTIFY documentChanged)
69 Q_PROPERTY(int cursorPosition READ cursorPosition WRITE setCursorPosition NOTIFY cursorPositionChanged)
70 Q_PROPERTY(int selectionStart READ selectionStart WRITE setSelectionStart NOTIFY selectionStartChanged)
71 Q_PROPERTY(int selectionEnd READ selectionEnd WRITE setSelectionEnd NOTIFY selectionEndChanged)
72
73 Q_PROPERTY(QColor textColor READ textColor WRITE setTextColor NOTIFY textColorChanged)
74 Q_PROPERTY(QString fontFamily READ fontFamily WRITE setFontFamily NOTIFY fontFamilyChanged)
75 Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged)
76
77 Q_PROPERTY(bool bold READ bold WRITE setBold NOTIFY boldChanged)
78 Q_PROPERTY(bool italic READ italic WRITE setItalic NOTIFY italicChanged)
79 Q_PROPERTY(bool underline READ underline WRITE setUnderline NOTIFY underlineChanged)
80
81 Q_PROPERTY(int fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged)
82
83 Q_PROPERTY(QString plainText READ plainText NOTIFY textChanged)
84 Q_PROPERTY(QString htmlText READ htmlText NOTIFY textChanged)
85
86public:
87 explicit DocumentHandler(QObject *parent = nullptr);
88
89 QQuickTextDocument *document() const;
90 void setDocument(QQuickTextDocument *document);
91
92 QString plainText() const;
93 QString htmlText() const;
94
95 int cursorPosition() const;
96 void setCursorPosition(int position);
97
98 int selectionStart() const;
99 void setSelectionStart(int position);
100
101 int selectionEnd() const;
102 void setSelectionEnd(int position);
103
104 QString fontFamily() const;
105 void setFontFamily(const QString &family);
106
107 QColor textColor() const;
108 void setTextColor(const QColor &color);
109
110 Qt::Alignment alignment() const;
111 void setAlignment(Qt::Alignment alignment);
112
113 bool bold() const;
114 void setBold(bool bold);
115
116 bool italic() const;
117 void setItalic(bool italic);
118
119 bool underline() const;
120 void setUnderline(bool underline);
121
122 int fontSize() const;
123 void setFontSize(int size);
124
125Q_SIGNALS:
126 void documentChanged();
127 void cursorPositionChanged();
128 void selectionStartChanged();
129 void selectionEndChanged();
130
131 void fontFamilyChanged();
132 void textColorChanged();
133 void alignmentChanged();
134
135 void boldChanged();
136 void italicChanged();
137 void underlineChanged();
138
139 void fontSizeChanged();
140
141 void textChanged();
142
143private Q_SLOTS:
144 void contentsChange(int position, int charsRemoved, int charsAdded);
145
146private:
147 void reset();
148 QTextCharFormat charFormat() const;
149 QTextCursor textCursor() const;
150 QTextDocument *textDocument() const;
151 void mergeFormatOnWordOrSelection(const QTextCharFormat &format);
152
153 QQuickTextDocument *m_document;
154
155 int m_cursorPosition;
156 int m_selectionStart;
157 int m_selectionEnd;
158 QSharedPointer<QTextCharFormat> m_cachedTextFormat;
159};
160
161#endif // DOCUMENTHANDLER_H