author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 19 Feb 2010 23:40:16 +0200 | |
branch | RCL_3 |
changeset 4 | 3b1da2848fc7 |
parent 0 | 1918ee327afb |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the plugins 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 "q3simplewidgets.h" |
|
43 |
||
44 |
#include <q3groupbox.h> |
|
45 |
#include <qlabel.h> |
|
46 |
||
47 |
QT_BEGIN_NAMESPACE |
|
48 |
||
49 |
QString Q_GUI_EXPORT qt_accStripAmp(const QString &text); |
|
50 |
||
51 |
Q3AccessibleDisplay::Q3AccessibleDisplay(QWidget *w, Role role) |
|
52 |
: QAccessibleWidget(w, role) |
|
53 |
{ |
|
54 |
} |
|
55 |
||
56 |
/*! \reimp */ |
|
57 |
QAccessible::Role Q3AccessibleDisplay::role(int child) const |
|
58 |
{ |
|
59 |
QLabel *l = qobject_cast<QLabel*>(object()); |
|
60 |
if (l) { |
|
61 |
if (l->pixmap() || l->picture()) |
|
62 |
return Graphic; |
|
63 |
if (l->picture()) |
|
64 |
return Graphic; |
|
65 |
if (l->movie()) |
|
66 |
return Animation; |
|
67 |
} |
|
68 |
return QAccessibleWidget::role(child); |
|
69 |
} |
|
70 |
||
71 |
/*! \reimp */ |
|
72 |
QString Q3AccessibleDisplay::text(Text t, int child) const |
|
73 |
{ |
|
74 |
QString str; |
|
75 |
switch (t) { |
|
76 |
case Name: |
|
77 |
if (qobject_cast<QLabel*>(object())) { |
|
78 |
str = qobject_cast<QLabel*>(object())->text(); |
|
79 |
} else if (qobject_cast<Q3GroupBox*>(object())) { |
|
80 |
str = qobject_cast<Q3GroupBox*>(object())->title(); |
|
81 |
} |
|
82 |
break; |
|
83 |
default: |
|
84 |
break; |
|
85 |
} |
|
86 |
if (str.isEmpty()) |
|
87 |
str = QAccessibleWidget::text(t, child);; |
|
88 |
return qt_accStripAmp(str); |
|
89 |
} |
|
90 |
||
91 |
/*! \reimp */ |
|
92 |
QAccessible::Relation Q3AccessibleDisplay::relationTo(int child, const QAccessibleInterface *other, |
|
93 |
int otherChild) const |
|
94 |
{ |
|
95 |
Relation relation = QAccessibleWidget::relationTo(child, other, otherChild); |
|
96 |
if (child || otherChild) |
|
97 |
return relation; |
|
98 |
||
99 |
QObject *o = other->object(); |
|
100 |
QLabel *label = qobject_cast<QLabel*>(object()); |
|
101 |
Q3GroupBox *groupbox = qobject_cast<Q3GroupBox*>(object()); |
|
102 |
if (label) { |
|
103 |
if (o == label->buddy()) |
|
104 |
relation |= Label; |
|
105 |
} else if (groupbox && !groupbox->title().isEmpty()) { |
|
106 |
if (groupbox->children().contains(o)) |
|
107 |
relation |= Label; |
|
108 |
} |
|
109 |
return relation; |
|
110 |
} |
|
111 |
||
112 |
/*! \reimp */ |
|
113 |
int Q3AccessibleDisplay::navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const |
|
114 |
{ |
|
115 |
*target = 0; |
|
116 |
if (rel == Labelled) { |
|
117 |
QObject *targetObject = 0; |
|
118 |
QLabel *label = qobject_cast<QLabel*>(object()); |
|
119 |
Q3GroupBox *groupbox = qobject_cast<Q3GroupBox*>(object()); |
|
120 |
if (label) { |
|
121 |
if (entry == 1) |
|
122 |
targetObject = label->buddy(); |
|
123 |
} else if (groupbox && !groupbox->title().isEmpty()) { |
|
124 |
rel = Child; |
|
125 |
} |
|
126 |
*target = QAccessible::queryAccessibleInterface(targetObject); |
|
127 |
if (*target) |
|
128 |
return 0; |
|
129 |
} |
|
130 |
return QAccessibleWidget::navigate(rel, entry, target); |
|
131 |
} |
|
132 |
||
133 |
QT_END_NAMESPACE |