|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the QtGui module of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include "qaccessible2.h" |
|
43 #include "qapplication.h" |
|
44 #include "qclipboard.h" |
|
45 |
|
46 #ifndef QT_NO_ACCESSIBILITY |
|
47 |
|
48 QT_BEGIN_NAMESPACE |
|
49 |
|
50 /*! |
|
51 \namespace QAccessible2 |
|
52 \ingroup accessibility |
|
53 \internal |
|
54 \preliminary |
|
55 |
|
56 \brief The QAccessible2 namespace defines constants relating to |
|
57 IAccessible2-based interfaces |
|
58 |
|
59 \link http://www.linux-foundation.org/en/Accessibility/IAccessible2 IAccessible2 Specification \endlink |
|
60 */ |
|
61 |
|
62 /*! |
|
63 \class QAccessibleTextInterface |
|
64 |
|
65 \ingroup accessibility |
|
66 \internal |
|
67 \preliminary |
|
68 |
|
69 \brief The QAccessibleTextInterface class implements support for |
|
70 the IAccessibleText interface. |
|
71 |
|
72 \link http://www.linux-foundation.org/en/Accessibility/IAccessible2 IAccessible2 Specification \endlink |
|
73 */ |
|
74 |
|
75 /*! |
|
76 \class QAccessibleEditableTextInterface |
|
77 \ingroup accessibility |
|
78 \internal |
|
79 \preliminary |
|
80 |
|
81 \brief The QAccessibleEditableTextInterface class implements support for |
|
82 the IAccessibleEditableText interface. |
|
83 |
|
84 \link http://www.linux-foundation.org/en/Accessibility/IAccessible2 IAccessible2 Specification \endlink |
|
85 */ |
|
86 |
|
87 /*! |
|
88 \class QAccessibleSimpleEditableTextInterface |
|
89 \ingroup accessibility |
|
90 \internal |
|
91 \preliminary |
|
92 |
|
93 \brief The QAccessibleSimpleEditableTextInterface class is a convenience class for |
|
94 text-based widgets. |
|
95 |
|
96 \link http://www.linux-foundation.org/en/Accessibility/IAccessible2 IAccessible2 Specification \endlink |
|
97 */ |
|
98 |
|
99 /*! |
|
100 \class QAccessibleValueInterface |
|
101 \ingroup accessibility |
|
102 \internal |
|
103 \preliminary |
|
104 |
|
105 \brief The QAccessibleValueInterface class implements support for |
|
106 the IAccessibleValue interface. |
|
107 |
|
108 \link http://www.linux-foundation.org/en/Accessibility/IAccessible2 IAccessible2 Specification \endlink |
|
109 */ |
|
110 |
|
111 /*! |
|
112 \class QAccessibleActionInterface |
|
113 \ingroup accessibility |
|
114 \internal |
|
115 \preliminary |
|
116 |
|
117 \brief The QAccessibleActionInterface class implements support for |
|
118 the IAccessibleAction interface. |
|
119 |
|
120 \link http://www.linux-foundation.org/en/Accessibility/IAccessible2 IAccessible2 Specification \endlink |
|
121 */ |
|
122 |
|
123 QAccessibleSimpleEditableTextInterface::QAccessibleSimpleEditableTextInterface( |
|
124 QAccessibleInterface *accessibleInterface) |
|
125 : iface(accessibleInterface) |
|
126 { |
|
127 Q_ASSERT(iface); |
|
128 } |
|
129 |
|
130 #ifndef QT_NO_CLIPBOARD |
|
131 static QString textForRange(QAccessibleInterface *iface, int startOffset, int endOffset) |
|
132 { |
|
133 return iface->text(QAccessible::Value, 0).mid(startOffset, endOffset - startOffset); |
|
134 } |
|
135 #endif |
|
136 |
|
137 void QAccessibleSimpleEditableTextInterface::copyText(int startOffset, int endOffset) |
|
138 { |
|
139 #ifdef QT_NO_CLIPBOARD |
|
140 Q_UNUSED(startOffset); |
|
141 Q_UNUSED(endOffset); |
|
142 #else |
|
143 QApplication::clipboard()->setText(textForRange(iface, startOffset, endOffset)); |
|
144 #endif |
|
145 } |
|
146 |
|
147 void QAccessibleSimpleEditableTextInterface::deleteText(int startOffset, int endOffset) |
|
148 { |
|
149 QString txt = iface->text(QAccessible::Value, 0); |
|
150 txt.remove(startOffset, endOffset - startOffset); |
|
151 iface->setText(QAccessible::Value, 0, txt); |
|
152 } |
|
153 |
|
154 void QAccessibleSimpleEditableTextInterface::insertText(int offset, const QString &text) |
|
155 { |
|
156 QString txt = iface->text(QAccessible::Value, 0); |
|
157 txt.insert(offset, text); |
|
158 iface->setText(QAccessible::Value, 0, txt); |
|
159 } |
|
160 |
|
161 void QAccessibleSimpleEditableTextInterface::cutText(int startOffset, int endOffset) |
|
162 { |
|
163 #ifdef QT_NO_CLIPBOARD |
|
164 Q_UNUSED(startOffset); |
|
165 Q_UNUSED(endOffset); |
|
166 #else |
|
167 QString sub = textForRange(iface, startOffset, endOffset); |
|
168 deleteText(startOffset, endOffset); |
|
169 QApplication::clipboard()->setText(sub); |
|
170 #endif |
|
171 } |
|
172 |
|
173 void QAccessibleSimpleEditableTextInterface::pasteText(int offset) |
|
174 { |
|
175 #ifdef QT_NO_CLIPBOARD |
|
176 Q_UNUSED(offset); |
|
177 #else |
|
178 QString txt = iface->text(QAccessible::Value, 0); |
|
179 txt.insert(offset, QApplication::clipboard()->text()); |
|
180 iface->setText(QAccessible::Value, 0, txt); |
|
181 #endif |
|
182 } |
|
183 |
|
184 void QAccessibleSimpleEditableTextInterface::replaceText(int startOffset, int endOffset, const QString &text) |
|
185 { |
|
186 QString txt = iface->text(QAccessible::Value, 0); |
|
187 txt.replace(startOffset, endOffset - startOffset, text); |
|
188 iface->setText(QAccessible::Value, 0, txt); |
|
189 } |
|
190 |
|
191 QT_END_NAMESPACE |
|
192 |
|
193 #endif // QT_NO_ACCESSIBILITY |