source: trunk/src/plugins/accessible/widgets/simplewidgets.cpp

Last change on this file 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: 22.4 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 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 plugins 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 qt-info@nokia.com.
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#include "simplewidgets.h"
43
44#include <qabstractbutton.h>
45#include <qcheckbox.h>
46#include <qpushbutton.h>
47#include <qprogressbar.h>
48#include <qradiobutton.h>
49#include <qtoolbutton.h>
50#include <qlabel.h>
51#include <qgroupbox.h>
52#include <qlcdnumber.h>
53#include <qlineedit.h>
54#include <qstyle.h>
55#include <qstyleoption.h>
56
57#ifdef Q_OS_MAC
58#include <qfocusframe.h>
59#endif
60
61QT_BEGIN_NAMESPACE
62
63#ifndef QT_NO_ACCESSIBILITY
64
65using namespace QAccessible2;
66extern QList<QWidget*> childWidgets(const QWidget *widget, bool includeTopLevel = false);
67
68QString Q_GUI_EXPORT qt_accStripAmp(const QString &text);
69QString Q_GUI_EXPORT qt_accHotKey(const QString &text);
70
71/*!
72 \class QAccessibleButton
73 \brief The QAccessibleButton class implements the QAccessibleInterface for button type widgets.
74 \internal
75
76 \ingroup accessibility
77*/
78
79/*!
80 Creates a QAccessibleButton object for \a w.
81 \a role is propagated to the QAccessibleWidgetEx constructor.
82*/
83QAccessibleButton::QAccessibleButton(QWidget *w, Role role)
84: QAccessibleWidgetEx(w, role)
85{
86 Q_ASSERT(button());
87 if (button()->isCheckable())
88 addControllingSignal(QLatin1String("toggled(bool)"));
89 else
90 addControllingSignal(QLatin1String("clicked()"));
91}
92
93/*! Returns the button. */
94QAbstractButton *QAccessibleButton::button() const
95{
96 return qobject_cast<QAbstractButton*>(object());
97}
98
99/*! \reimp */
100QString QAccessibleButton::actionText(int action, Text text, int child) const
101{
102 if (child)
103 return QString();
104
105 if (text == Name) switch (action) {
106 case Press:
107 case DefaultAction: // press, checking or open
108 switch (role(0)) {
109 case ButtonMenu:
110 return QPushButton::tr("Open");
111 case CheckBox:
112 {
113 if (state(child) & Checked)
114 return QCheckBox::tr("Uncheck");
115 QCheckBox *cb = qobject_cast<QCheckBox*>(object());
116 if (!cb || !cb->isTristate() || cb->checkState() == Qt::PartiallyChecked)
117 return QCheckBox::tr("Check");
118 return QCheckBox::tr("Toggle");
119 }
120 break;
121 case RadioButton:
122 return QRadioButton::tr("Check");
123 default:
124 break;
125 }
126 break;
127 }
128 return QAccessibleWidgetEx::actionText(action, text, child);
129}
130
131/*! \reimp */
132bool QAccessibleButton::doAction(int action, int child, const QVariantList &params)
133{
134 if (child || !widget()->isEnabled() || !widget()->isVisible())
135 return false;
136
137 switch (action) {
138 case DefaultAction:
139 case Press:
140 {
141#ifndef QT_NO_MENU
142 QPushButton *pb = qobject_cast<QPushButton*>(object());
143 if (pb && pb->menu())
144 pb->showMenu();
145 else
146#endif
147 button()->animateClick();
148 }
149 return true;
150 }
151 return QAccessibleWidgetEx::doAction(action, child, params);
152}
153
154/*! \reimp */
155QString QAccessibleButton::text(Text t, int child) const
156{
157 QString str;
158 if (!widget()->isVisible())
159 return str;
160
161 switch (t) {
162 case Accelerator:
163 {
164#ifndef QT_NO_SHORTCUT
165 QPushButton *pb = qobject_cast<QPushButton*>(object());
166 if (pb && pb->isDefault())
167 str = (QString)QKeySequence(Qt::Key_Enter);
168#endif
169 if (str.isEmpty())
170 str = qt_accHotKey(button()->text());
171 }
172 break;
173 case Name:
174 str = widget()->accessibleName();
175 if (str.isEmpty())
176 str = button()->text();
177 break;
178 default:
179 break;
180 }
181 if (str.isEmpty())
182 str = QAccessibleWidgetEx::text(t, child);;
183 return qt_accStripAmp(str);
184}
185
186/*! \reimp */
187QAccessible::State QAccessibleButton::state(int child) const
188{
189 State state = QAccessibleWidgetEx::state(child);
190
191 QAbstractButton *b = button();
192 QCheckBox *cb = qobject_cast<QCheckBox *>(b);
193 if (b->isChecked())
194 state |= Checked;
195 else if (cb && cb->checkState() == Qt::PartiallyChecked)
196 state |= Mixed;
197 if (b->isDown())
198 state |= Pressed;
199 QPushButton *pb = qobject_cast<QPushButton*>(b);
200 if (pb) {
201 if (pb->isDefault())
202 state |= DefaultButton;
203#ifndef QT_NO_MENU
204 if (pb->menu())
205 state |= HasPopup;
206#endif
207 }
208
209 return state;
210}
211
212int QAccessibleButton::actionCount()
213{
214 return 1;
215}
216
217void QAccessibleButton::doAction(int actionIndex)
218{
219 switch (actionIndex) {
220 case 0:
221 button()->click();
222 break;
223 }
224}
225
226QString QAccessibleButton::description(int actionIndex)
227{
228 switch (actionIndex) {
229 case 0:
230 return QLatin1String("Clicks the button.");
231 default:
232 return QString();
233 }
234}
235
236QString QAccessibleButton::name(int actionIndex)
237{
238 switch (actionIndex) {
239 case 0:
240 return QLatin1String("Press");
241 default:
242 return QString();
243 }
244}
245
246QString QAccessibleButton::localizedName(int actionIndex)
247{
248 switch (actionIndex) {
249 case 0:
250 return tr("Press");
251 default:
252 return QString();
253 }
254}
255
256QStringList QAccessibleButton::keyBindings(int actionIndex)
257{
258 switch (actionIndex) {
259#ifndef QT_NO_SHORTCUT
260 case 0:
261 return QStringList() << button()->shortcut().toString();
262#endif
263 default:
264 return QStringList();
265 }
266}
267
268#ifndef QT_NO_TOOLBUTTON
269/*!
270 \class QAccessibleToolButton
271 \brief The QAccessibleToolButton class implements the QAccessibleInterface for tool buttons.
272 \internal
273
274 \ingroup accessibility
275*/
276
277/*!
278 \enum QAccessibleToolButton::ToolButtonElements
279
280 This enum identifies the components of the tool button.
281
282 \value ToolButtonSelf The tool button as a whole.
283 \value ButtonExecute The button.
284 \value ButtonDropMenu The drop down menu.
285*/
286
287/*!
288 Creates a QAccessibleToolButton object for \a w.
289 \a role is propagated to the QAccessibleWidgetEx constructor.
290*/
291QAccessibleToolButton::QAccessibleToolButton(QWidget *w, Role role)
292: QAccessibleButton(w, role)
293{
294 Q_ASSERT(toolButton());
295}
296
297/*! Returns the button. */
298QToolButton *QAccessibleToolButton::toolButton() const
299{
300 return qobject_cast<QToolButton*>(object());
301}
302
303/*!
304 Returns true if this tool button is a split button.
305*/
306bool QAccessibleToolButton::isSplitButton() const
307{
308#ifndef QT_NO_MENU
309 return toolButton()->menu() && toolButton()->popupMode() == QToolButton::MenuButtonPopup;
310#else
311 return false;
312#endif
313}
314
315/*! \reimp */
316QAccessible::Role QAccessibleToolButton::role(int child) const
317{
318 if (isSplitButton()) switch(child) {
319 case ButtonExecute:
320 return PushButton;
321 case ButtonDropMenu:
322 return ButtonMenu;
323 }
324 return QAccessibleButton::role(child);
325}
326
327/*! \reimp */
328QAccessible::State QAccessibleToolButton::state(int child) const
329{
330 QAccessible::State st = QAccessibleButton::state(child);
331 if (toolButton()->autoRaise())
332 st |= HotTracked;
333#ifndef QT_NO_MENU
334 if (toolButton()->menu() && child != ButtonExecute)
335 st |= HasPopup;
336#endif
337 return st;
338}
339
340/*! \reimp */
341int QAccessibleToolButton::childCount() const
342{
343 if (!toolButton()->isVisible())
344 return 0;
345 return isSplitButton() ? ButtonDropMenu : 0;
346}
347
348/*!
349 \internal
350
351 Returns the rectangle occupied by this button, depending on \a
352 child.
353*/
354QRect QAccessibleToolButton::rect(int child) const
355{
356 if (!toolButton()->isVisible())
357 return QRect();
358 if (!child)
359 return QAccessibleButton::rect(child);
360
361 QStyleOptionToolButton opt;
362 opt.init(widget());
363 QRect subrect = widget()->style()->subControlRect(QStyle::CC_ToolButton, &opt,
364 QStyle::SC_ToolButtonMenu, toolButton());
365
366 if (child == ButtonExecute)
367 subrect = QRect(0, 0, subrect.x(), widget()->height());
368
369 QPoint ntl = widget()->mapToGlobal(subrect.topLeft());
370 subrect.moveTopLeft(ntl);
371 return subrect;
372}
373
374/*!
375 \internal
376
377 Returns the button's text label, depending on the text \a t, and
378 the \a child.
379*/
380QString QAccessibleToolButton::text(Text t, int child) const
381{
382 QString str;
383 if (!toolButton()->isVisible())
384 return str;
385
386 switch (t) {
387 case Name:
388 str = toolButton()->text();
389 if (str.isEmpty())
390 str = toolButton()->text();
391 break;
392 default:
393 break;
394 }
395 if (str.isEmpty())
396 str = QAccessibleButton::text(t, child);;
397 return qt_accStripAmp(str);
398}
399
400/*!
401 \internal
402
403 Returns the number of actions which is 0, 1, or 2, in part
404 depending on \a child.
405*/
406int QAccessibleToolButton::actionCount(int child) const
407{
408 // each subelement has one action
409 if (child)
410 return isSplitButton() ? 1 : 0;
411 int ac = widget()->focusPolicy() != Qt::NoFocus ? 1 : 0;
412 // button itself has two actions if a menu button
413#ifndef QT_NO_MENU
414 return ac + (toolButton()->menu() ? 2 : 1);
415#else
416 return ac + 1;
417#endif
418}
419
420/*!
421 \internal
422
423 If \a text is \c Name, then depending on the \a child or the \a
424 action, an action text is returned. This is a translated string
425 which in English is one of "Press", "Open", or "Set Focus". If \a
426 text is not \c Name, an empty string is returned.
427*/
428QString QAccessibleToolButton::actionText(int action, Text text, int child) const
429{
430 if (text == Name) switch(child) {
431 case ButtonExecute:
432 return QToolButton::tr("Press");
433 case ButtonDropMenu:
434 return QToolButton::tr("Open");
435 default:
436 switch(action) {
437 case 0:
438 return QToolButton::tr("Press");
439 case 1:
440#ifndef QT_NO_MENU
441 if (toolButton()->menu())
442 return QToolButton::tr("Open");
443#endif
444 //fall through
445 case 2:
446 return QLatin1String("Set Focus");
447 }
448 }
449 return QString();
450}
451
452/*!
453 \internal
454*/
455bool QAccessibleToolButton::doAction(int action, int child, const QVariantList &params)
456{
457 if (!widget()->isEnabled() || !widget()->isVisible())
458 return false;
459 if (action == 1 || child == ButtonDropMenu) {
460 if(!child)
461 toolButton()->setDown(true);
462#ifndef QT_NO_MENU
463 toolButton()->showMenu();
464#endif
465 return true;
466 }
467 return QAccessibleButton::doAction(action, 0, params);
468}
469
470#endif // QT_NO_TOOLBUTTON
471
472/*!
473 \class QAccessibleDisplay
474 \brief The QAccessibleDisplay class implements the QAccessibleInterface for widgets that display information.
475 \internal
476
477 \ingroup accessibility
478*/
479
480/*!
481 Constructs a QAccessibleDisplay object for \a w.
482 \a role is propagated to the QAccessibleWidgetEx constructor.
483*/
484QAccessibleDisplay::QAccessibleDisplay(QWidget *w, Role role)
485: QAccessibleWidgetEx(w, role)
486{
487}
488
489/*! \reimp */
490QAccessible::Role QAccessibleDisplay::role(int child) const
491{
492 QLabel *l = qobject_cast<QLabel*>(object());
493 if (l) {
494 if (l->pixmap())
495 return Graphic;
496#ifndef QT_NO_PICTURE
497 if (l->picture())
498 return Graphic;
499#endif
500#ifndef QT_NO_MOVIE
501 if (l->movie())
502 return Animation;
503#endif
504#ifndef QT_NO_PROGRESSBAR
505 } else if (qobject_cast<QProgressBar*>(object())) {
506 return ProgressBar;
507#endif
508 }
509 return QAccessibleWidgetEx::role(child);
510}
511
512/*! \reimp */
513QString QAccessibleDisplay::text(Text t, int child) const
514{
515 QString str;
516 if (!widget()->isVisible())
517 return str;
518 switch (t) {
519 case Name:
520 str = widget()->accessibleName();
521 if (str.isEmpty()) {
522 if (qobject_cast<QLabel*>(object())) {
523 str = qobject_cast<QLabel*>(object())->text();
524#ifndef QT_NO_GROUPBOX
525 } else if (qobject_cast<QGroupBox*>(object())) {
526 str = qobject_cast<QGroupBox*>(object())->title();
527#endif
528#ifndef QT_NO_LCDNUMBER
529 } else if (qobject_cast<QLCDNumber*>(object())) {
530 QLCDNumber *l = qobject_cast<QLCDNumber*>(object());
531 if (l->digitCount())
532 str = QString::number(l->value());
533 else
534 str = QString::number(l->intValue());
535#endif
536 }
537 }
538 break;
539 case Value:
540#ifndef QT_NO_PROGRESSBAR
541 if (qobject_cast<QProgressBar*>(object()))
542 str = QString::number(qobject_cast<QProgressBar*>(object())->value());
543#endif
544 break;
545 default:
546 break;
547 }
548 if (str.isEmpty())
549 str = QAccessibleWidgetEx::text(t, child);;
550 return qt_accStripAmp(str);
551}
552
553/*! \reimp */
554QAccessible::Relation QAccessibleDisplay::relationTo(int child, const QAccessibleInterface *other,
555 int otherChild) const
556{
557 Relation relation = QAccessibleWidgetEx::relationTo(child, other, otherChild);
558 if (child || otherChild)
559 return relation;
560
561 QObject *o = other->object();
562 QLabel *label = qobject_cast<QLabel*>(object());
563 if (label) {
564#ifndef QT_NO_SHORTCUT
565 if (o == label->buddy())
566 relation |= Label;
567#endif
568#ifndef QT_NO_GROUPBOX
569 } else {
570 QGroupBox *groupbox = qobject_cast<QGroupBox*>(object());
571 if (groupbox && !groupbox->title().isEmpty())
572 if (groupbox->children().contains(o))
573 relation |= Label;
574#endif
575 }
576 return relation;
577}
578
579/*! \reimp */
580int QAccessibleDisplay::navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const
581{
582 *target = 0;
583 if (rel == Labelled) {
584 QObject *targetObject = 0;
585 QLabel *label = qobject_cast<QLabel*>(object());
586 if (label) {
587#ifndef QT_NO_SHORTCUT
588 if (entry == 1)
589 targetObject = label->buddy();
590#endif
591#ifndef QT_NO_GROUPBOX
592 } else {
593 QGroupBox *groupbox = qobject_cast<QGroupBox*>(object());
594 if (groupbox && !groupbox->title().isEmpty())
595 rel = Child;
596#endif
597 }
598 *target = QAccessible::queryAccessibleInterface(targetObject);
599 if (*target)
600 return 0;
601 }
602 return QAccessibleWidgetEx::navigate(rel, entry, target);
603}
604
605/*! \internal */
606QString QAccessibleDisplay::imageDescription()
607{
608#ifndef QT_NO_TOOLTIP
609 return widget()->toolTip();
610#else
611 return QString::null;
612#endif
613}
614
615/*! \internal */
616QSize QAccessibleDisplay::imageSize()
617{
618 QLabel *label = qobject_cast<QLabel *>(widget());
619 if (!label)
620 return QSize();
621 const QPixmap *pixmap = label->pixmap();
622 if (!pixmap)
623 return QSize();
624 return pixmap->size();
625}
626
627/*! \internal */
628QRect QAccessibleDisplay::imagePosition(QAccessible2::CoordinateType coordType)
629{
630 QLabel *label = qobject_cast<QLabel *>(widget());
631 if (!label)
632 return QRect();
633 const QPixmap *pixmap = label->pixmap();
634 if (!pixmap)
635 return QRect();
636
637 switch (coordType) {
638 case QAccessible2::RelativeToScreen:
639 return QRect(label->mapToGlobal(label->pos()), label->size());
640 case QAccessible2::RelativeToParent:
641 return label->geometry();
642 }
643
644 return QRect();
645}
646
647#ifndef QT_NO_LINEEDIT
648/*!
649 \class QAccessibleLineEdit
650 \brief The QAccessibleLineEdit class implements the QAccessibleInterface for widgets with editable text
651 \internal
652
653 \ingroup accessibility
654*/
655
656/*!
657 Constructs a QAccessibleLineEdit object for \a w.
658 \a name is propagated to the QAccessibleWidgetEx constructor.
659*/
660QAccessibleLineEdit::QAccessibleLineEdit(QWidget *w, const QString &name)
661: QAccessibleWidgetEx(w, EditableText, name), QAccessibleSimpleEditableTextInterface(this)
662{
663 addControllingSignal(QLatin1String("textChanged(const QString&)"));
664 addControllingSignal(QLatin1String("returnPressed()"));
665}
666
667/*! Returns the line edit. */
668QLineEdit *QAccessibleLineEdit::lineEdit() const
669{
670 return qobject_cast<QLineEdit*>(object());
671}
672
673/*! \reimp */
674QString QAccessibleLineEdit::text(Text t, int child) const
675{
676 QString str;
677 if (!lineEdit()->isVisible())
678 return str;
679 switch (t) {
680 case Value:
681 if (lineEdit()->echoMode() == QLineEdit::Normal)
682 str = lineEdit()->text();
683 break;
684 default:
685 break;
686 }
687 if (str.isEmpty())
688 str = QAccessibleWidgetEx::text(t, child);;
689 return qt_accStripAmp(str);
690}
691
692/*! \reimp */
693void QAccessibleLineEdit::setText(Text t, int control, const QString &text)
694{
695 if (!lineEdit()->isVisible())
696 return;
697 if (t != Value || control) {
698 QAccessibleWidgetEx::setText(t, control, text);
699 return;
700 }
701 lineEdit()->setText(text);
702}
703
704/*! \reimp */
705QAccessible::State QAccessibleLineEdit::state(int child) const
706{
707 State state = QAccessibleWidgetEx::state(child);
708
709 QLineEdit *l = lineEdit();
710 if (l->isReadOnly())
711 state |= ReadOnly;
712 if (l->echoMode() != QLineEdit::Normal)
713 state |= Protected;
714 state |= Selectable;
715 if (l->hasSelectedText())
716 state |= Selected;
717
718 if (l->contextMenuPolicy() != Qt::NoContextMenu
719 && l->contextMenuPolicy() != Qt::PreventContextMenu)
720 state |= HasPopup;
721
722 return state;
723}
724
725QVariant QAccessibleLineEdit::invokeMethodEx(QAccessible::Method method, int child,
726 const QVariantList &params)
727{
728 if (child)
729 return QVariant();
730
731 switch (method) {
732 case ListSupportedMethods: {
733 QSet<QAccessible::Method> set;
734 set << ListSupportedMethods << SetCursorPosition << GetCursorPosition;
735 return qVariantFromValue(set | qvariant_cast<QSet<QAccessible::Method> >(
736 QAccessibleWidgetEx::invokeMethodEx(method, child, params)));
737 }
738 case SetCursorPosition:
739 setCursorPosition(params.value(0).toInt());
740 return true;
741 case GetCursorPosition:
742 return cursorPosition();
743 default:
744 return QAccessibleWidgetEx::invokeMethodEx(method, child, params);
745 }
746}
747
748void QAccessibleLineEdit::addSelection(int startOffset, int endOffset)
749{
750 setSelection(0, startOffset, endOffset);
751}
752
753QString QAccessibleLineEdit::attributes(int offset, int *startOffset, int *endOffset)
754{
755 // QLineEdit doesn't have text attributes
756 *startOffset = *endOffset = offset;
757 return QString();
758}
759
760int QAccessibleLineEdit::cursorPosition()
761{
762 return lineEdit()->cursorPosition();
763}
764
765QRect QAccessibleLineEdit::characterRect(int /*offset*/, CoordinateType /*coordType*/)
766{
767 // QLineEdit doesn't hand out character rects
768 return QRect();
769}
770
771int QAccessibleLineEdit::selectionCount()
772{
773 return lineEdit()->hasSelectedText() ? 1 : 0;
774}
775
776int QAccessibleLineEdit::offsetAtPoint(const QPoint &point, CoordinateType coordType)
777{
778 QPoint p = point;
779 if (coordType == RelativeToScreen)
780 p = lineEdit()->mapFromGlobal(p);
781
782 return lineEdit()->cursorPositionAt(p);
783}
784
785void QAccessibleLineEdit::selection(int selectionIndex, int *startOffset, int *endOffset)
786{
787 *startOffset = *endOffset = 0;
788 if (selectionIndex != 0)
789 return;
790
791 *startOffset = lineEdit()->selectionStart();
792 *endOffset = *startOffset + lineEdit()->selectedText().count();
793}
794
795QString QAccessibleLineEdit::text(int startOffset, int endOffset)
796{
797 if (startOffset > endOffset)
798 return QString();
799 return lineEdit()->text().mid(startOffset, endOffset - startOffset);
800}
801
802QString QAccessibleLineEdit::textBeforeOffset (int /*offset*/, BoundaryType /*boundaryType*/,
803 int * /*startOffset*/, int * /*endOffset*/)
804{
805 // TODO
806 return QString();
807}
808
809QString QAccessibleLineEdit::textAfterOffset(int /*offset*/, BoundaryType /*boundaryType*/,
810 int * /*startOffset*/, int * /*endOffset*/)
811{
812 // TODO
813 return QString();
814}
815
816QString QAccessibleLineEdit::textAtOffset(int /*offset*/, BoundaryType /*boundaryType*/,
817 int * /*startOffset*/, int * /*endOffset*/)
818{
819 // TODO
820 return QString();
821}
822
823void QAccessibleLineEdit::removeSelection(int selectionIndex)
824{
825 if (selectionIndex != 0)
826 return;
827
828 lineEdit()->deselect();
829}
830
831void QAccessibleLineEdit::setCursorPosition(int position)
832{
833 lineEdit()->setCursorPosition(position);
834}
835
836void QAccessibleLineEdit::setSelection(int selectionIndex, int startOffset, int endOffset)
837{
838 if (selectionIndex != 0)
839 return;
840
841 lineEdit()->setSelection(startOffset, endOffset - startOffset);
842}
843
844int QAccessibleLineEdit::characterCount()
845{
846 return lineEdit()->text().count();
847}
848
849void QAccessibleLineEdit::scrollToSubstring(int startIndex, int endIndex)
850{
851 lineEdit()->setCursorPosition(endIndex);
852 lineEdit()->setCursorPosition(startIndex);
853}
854
855#endif // QT_NO_LINEEDIT
856
857#ifndef QT_NO_PROGRESSBAR
858QAccessibleProgressBar::QAccessibleProgressBar(QWidget *o)
859 : QAccessibleDisplay(o)
860{
861 Q_ASSERT(progressBar());
862}
863
864QVariant QAccessibleProgressBar::currentValue()
865{
866 return progressBar()->value();
867}
868
869QVariant QAccessibleProgressBar::maximumValue()
870{
871 return progressBar()->maximum();
872}
873
874QVariant QAccessibleProgressBar::minimumValue()
875{
876 return progressBar()->minimum();
877}
878
879QProgressBar *QAccessibleProgressBar::progressBar() const
880{
881 return qobject_cast<QProgressBar *>(object());
882}
883#endif
884
885#endif // QT_NO_ACCESSIBILITY
886
887QT_END_NAMESPACE
888
Note: See TracBrowser for help on using the repository browser.