source: trunk/src/gui/accessible/qaccessible2.cpp@ 890

Last change on this file since 890 was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 6.3 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtGui module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
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** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
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
48QT_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/*!
124 \class QAccessibleImageInterface
125 \ingroup accessibility
126 \internal
127 \preliminary
128
129 \brief The QAccessibleImageInterface class implements support for
130 the IAccessibleImage interface.
131
132 \link http://www.linux-foundation.org/en/Accessibility/IAccessible2 IAccessible2 Specification \endlink
133*/
134
135QAccessibleSimpleEditableTextInterface::QAccessibleSimpleEditableTextInterface(
136 QAccessibleInterface *accessibleInterface)
137 : iface(accessibleInterface)
138{
139 Q_ASSERT(iface);
140}
141
142#ifndef QT_NO_CLIPBOARD
143static QString textForRange(QAccessibleInterface *iface, int startOffset, int endOffset)
144{
145 return iface->text(QAccessible::Value, 0).mid(startOffset, endOffset - startOffset);
146}
147#endif
148
149void QAccessibleSimpleEditableTextInterface::copyText(int startOffset, int endOffset)
150{
151#ifdef QT_NO_CLIPBOARD
152 Q_UNUSED(startOffset);
153 Q_UNUSED(endOffset);
154#else
155 QApplication::clipboard()->setText(textForRange(iface, startOffset, endOffset));
156#endif
157}
158
159void QAccessibleSimpleEditableTextInterface::deleteText(int startOffset, int endOffset)
160{
161 QString txt = iface->text(QAccessible::Value, 0);
162 txt.remove(startOffset, endOffset - startOffset);
163 iface->setText(QAccessible::Value, 0, txt);
164}
165
166void QAccessibleSimpleEditableTextInterface::insertText(int offset, const QString &text)
167{
168 QString txt = iface->text(QAccessible::Value, 0);
169 txt.insert(offset, text);
170 iface->setText(QAccessible::Value, 0, txt);
171}
172
173void QAccessibleSimpleEditableTextInterface::cutText(int startOffset, int endOffset)
174{
175#ifdef QT_NO_CLIPBOARD
176 Q_UNUSED(startOffset);
177 Q_UNUSED(endOffset);
178#else
179 QString sub = textForRange(iface, startOffset, endOffset);
180 deleteText(startOffset, endOffset);
181 QApplication::clipboard()->setText(sub);
182#endif
183}
184
185void QAccessibleSimpleEditableTextInterface::pasteText(int offset)
186{
187#ifdef QT_NO_CLIPBOARD
188 Q_UNUSED(offset);
189#else
190 QString txt = iface->text(QAccessible::Value, 0);
191 txt.insert(offset, QApplication::clipboard()->text());
192 iface->setText(QAccessible::Value, 0, txt);
193#endif
194}
195
196void QAccessibleSimpleEditableTextInterface::replaceText(int startOffset, int endOffset, const QString &text)
197{
198 QString txt = iface->text(QAccessible::Value, 0);
199 txt.replace(startOffset, endOffset - startOffset, text);
200 iface->setText(QAccessible::Value, 0, txt);
201}
202
203QT_END_NAMESPACE
204
205#endif // QT_NO_ACCESSIBILITY
Note: See TracBrowser for help on using the repository browser.