Remove "All rights reserved" line from license headers.
[profile/ivi/qtdeclarative.git] / src / quick / items / qquicktextcontrol_p.h
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
16 **
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
20 **
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
28 **
29 ** Other Usage
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
32 **
33 **
34 **
35 **
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41
42 #ifndef QQUICKTEXTCONTROL_P_H
43 #define QQUICKTEXTCONTROL_P_H
44
45 //
46 //  W A R N I N G
47 //  -------------
48 //
49 // This file is not part of the Qt API.  It exists purely as an
50 // implementation detail.  This header file may change from version to
51 // version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55
56 #include <QtGui/qtextdocument.h>
57 #include <QtGui/qtextoption.h>
58 #include <QtGui/qtextcursor.h>
59 #include <QtGui/qtextformat.h>
60 #include <QtCore/qrect.h>
61 #include <QtGui/qabstracttextdocumentlayout.h>
62 #include <QtGui/qtextdocumentfragment.h>
63 #include <QtGui/qclipboard.h>
64 #include <QtCore/qmimedata.h>
65
66 QT_BEGIN_HEADER
67
68 QT_BEGIN_NAMESPACE
69
70
71 class QStyleSheet;
72 class QTextDocument;
73 class QQuickTextControlPrivate;
74 class QAbstractScrollArea;
75 class QEvent;
76 class QTimerEvent;
77 class QPagedPaintDevice;
78
79 class Q_AUTOTEST_EXPORT QQuickTextControl : public QObject
80 {
81     Q_OBJECT
82     Q_DECLARE_PRIVATE(QQuickTextControl)
83 #ifndef QT_NO_TEXTHTMLPARSER
84     Q_PROPERTY(QString html READ toHtml WRITE setHtml NOTIFY textChanged USER true)
85 #endif
86     Q_PROPERTY(bool acceptRichText READ acceptRichText WRITE setAcceptRichText)
87     Q_PROPERTY(int cursorWidth READ cursorWidth WRITE setCursorWidth)
88     Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags)
89 public:
90     explicit QQuickTextControl(QTextDocument *doc, QObject *parent = 0);
91     virtual ~QQuickTextControl();
92
93     void setView(QObject *view);
94     QObject *view() const;
95
96     QTextDocument *document() const;
97
98     void setTextCursor(const QTextCursor &cursor);
99     QTextCursor textCursor() const;
100
101     void setTextInteractionFlags(Qt::TextInteractionFlags flags);
102     Qt::TextInteractionFlags textInteractionFlags() const;
103
104     QString toPlainText() const;
105
106 #ifndef QT_NO_TEXTHTMLPARSER
107     QString toHtml() const;
108 #endif
109
110     QTextCursor cursorForPosition(const QPointF &pos) const;
111     QRectF cursorRect(const QTextCursor &cursor) const;
112     QRectF cursorRect() const;
113     QRectF selectionRect(const QTextCursor &cursor) const;
114     QRectF selectionRect() const;
115
116     QString anchorAt(const QPointF &pos) const;
117
118     QString anchorAtCursor() const;
119
120     int cursorWidth() const;
121     void setCursorWidth(int width);
122
123     bool acceptRichText() const;
124     void setAcceptRichText(bool accept);
125
126     void setTextWidth(qreal width);
127     qreal textWidth() const;
128     QSizeF size() const;
129
130     void setIgnoreUnusedNavigationEvents(bool ignore);
131     bool ignoreUnusedNavigationEvents() const;
132
133     void moveCursor(QTextCursor::MoveOperation op, QTextCursor::MoveMode mode = QTextCursor::MoveAnchor);
134
135     bool canPaste() const;
136
137     void setCursorIsFocusIndicator(bool b);
138     bool cursorIsFocusIndicator() const;
139
140     bool isWordSelectionEnabled() const;
141     void setWordSelectionEnabled(bool enabled);
142
143     virtual int hitTest(const QPointF &point, Qt::HitTestAccuracy accuracy) const;
144     virtual QRectF blockBoundingRect(const QTextBlock &block) const;
145     QAbstractTextDocumentLayout::PaintContext getPaintContext() const;
146
147 public Q_SLOTS:
148     void setPlainText(const QString &text);
149     void setHtml(const QString &text);
150
151 #ifndef QT_NO_CLIPBOARD
152     void cut();
153     void copy();
154     void paste(QClipboard::Mode mode = QClipboard::Clipboard);
155 #endif
156
157     void undo();
158     void redo();
159
160     void clear();
161     void selectAll();
162
163 Q_SIGNALS:
164     void textChanged();
165     void undoAvailable(bool b);
166     void redoAvailable(bool b);
167     void currentCharFormatChanged(const QTextCharFormat &format);
168     void copyAvailable(bool b);
169     void selectionChanged();
170     void cursorPositionChanged();
171
172     // control signals
173     void updateCursorRequest(const QRectF &rect = QRectF());
174     void updateRequest(const QRectF &rect = QRectF());
175     void documentSizeChanged(const QSizeF &);
176     void cursorRectangleChanged();
177     void linkActivated(const QString &link);
178     void linkHovered(const QString &);
179
180 public:
181     // control properties
182     QPalette palette() const;
183     void setPalette(const QPalette &pal);
184
185     virtual void processEvent(QEvent *e, const QMatrix &matrix);
186     void processEvent(QEvent *e, const QPointF &coordinateOffset = QPointF());
187
188     // control methods
189     void drawContents(QPainter *painter, const QRectF &rect = QRectF());
190
191     void setFocus(bool focus, Qt::FocusReason = Qt::OtherFocusReason);
192
193     virtual QVariant inputMethodQuery(Qt::InputMethodQuery property) const;
194
195     virtual QMimeData *createMimeDataFromSelection() const;
196     virtual bool canInsertFromMimeData(const QMimeData *source) const;
197     virtual void insertFromMimeData(const QMimeData *source);
198
199     bool cursorOn() const;
200
201 protected:
202     virtual void timerEvent(QTimerEvent *e);
203
204     virtual bool event(QEvent *e);
205
206 private:
207     Q_DISABLE_COPY(QQuickTextControl)
208     Q_PRIVATE_SLOT(d_func(), void _q_updateCurrentCharFormatAndSelection())
209     Q_PRIVATE_SLOT(d_func(), void _q_emitCursorPosChanged(const QTextCursor &))
210     Q_PRIVATE_SLOT(d_func(), void _q_deleteSelected())
211     Q_PRIVATE_SLOT(d_func(), void _q_updateBlock(const QTextBlock &))
212     Q_PRIVATE_SLOT(d_func(), void _q_documentLayoutChanged())
213 };
214
215
216 // also used by QLabel
217 class QQuickTextEditMimeData : public QMimeData
218 {
219 public:
220     inline QQuickTextEditMimeData(const QTextDocumentFragment &aFragment) : fragment(aFragment) {}
221
222     virtual QStringList formats() const;
223 protected:
224     virtual QVariant retrieveData(const QString &mimeType, QVariant::Type type) const;
225 private:
226     void setup() const;
227
228     mutable QTextDocumentFragment fragment;
229 };
230
231 QT_END_NAMESPACE
232
233 QT_END_HEADER
234
235 #endif // QQuickTextControl_H