9#if QT_CONFIG(itemviews)
14#include <private/qtabbar_p.h>
16#if QT_CONFIG(combobox)
19#if QT_CONFIG(lineedit)
27#if QT_CONFIG(whatsthis)
30#include <QAbstractScrollArea>
31#if QT_CONFIG(scrollarea)
34#if QT_CONFIG(scrollbar)
39#if QT_CONFIG(accessibility)
57class QAccessibleTabButton:
public QAccessibleInterface,
public QAccessibleActionInterface
61 : m_parent(parent), m_index(
index)
64 void *interface_cast(QAccessible::InterfaceType
t)
override {
65 if (
t == QAccessible::ActionInterface) {
66 return static_cast<QAccessibleActionInterface*
>(
this);
72 QAccessible::Role role()
const override {
return QAccessible::PageTab; }
82 s.focused = (m_index == m_parent->currentIndex());
83 s.selected =
s.focused;
91 QRect rec = m_parent->tabRect(m_index);
96 bool isValid()
const override {
98 if (
static_cast<QWidget *
>(m_parent.data())->d_func()->data.in_destructor)
100 return m_parent->count() > m_index;
105 QAccessibleInterface *childAt(
int,
int)
const override {
return nullptr; }
106 int childCount()
const override {
return 0; }
107 int indexOfChild(
const QAccessibleInterface *)
const override {
return -1; }
115 case QAccessible::Name:
116 str = m_parent->accessibleTabName(m_index);
118 str = qt_accStripAmp(m_parent->tabText(m_index));
120 case QAccessible::Accelerator:
121 str = qt_accHotKey(m_parent->tabText(m_index));
123#if QT_CONFIG(tooltip)
124 case QAccessible::Description:
125 str = m_parent->tabToolTip(m_index);
128#if QT_CONFIG(whatsthis)
129 case QAccessible::Help:
130 str = m_parent->tabWhatsThis(m_index);
141 QAccessibleInterface *parent()
const override {
142 return QAccessible::queryAccessibleInterface(m_parent.data());
144 QAccessibleInterface *
child(
int)
const override {
return nullptr; }
152 void doAction(
const QString &actionName)
override
154 if (isValid() && actionName == pressAction())
155 m_parent->setCurrentIndex(m_index);
163 int index()
const {
return m_index; }
166 QPointer<QTabBar> m_parent;
174QAccessibleTabBar::QAccessibleTabBar(
QWidget *
w)
180QAccessibleTabBar::~QAccessibleTabBar()
182 for (QAccessible::Id
id :
std::as_const(m_childInterfaces))
186void *QAccessibleTabBar::interface_cast(QAccessible::InterfaceType
t)
188 if (
t == QAccessible::SelectionInterface) {
189 return static_cast<QAccessibleSelectionInterface*
>(
this);
191 return QAccessibleWidget::interface_cast(
t);
195QTabBar *QAccessibleTabBar::tabBar()
const
197 return qobject_cast<QTabBar*>(
object());
200QAccessibleInterface* QAccessibleTabBar::focusChild()
const
202 for (
int i = 0;
i < childCount(); ++
i) {
203 if (
child(
i)->state().focused)
210QAccessibleInterface* QAccessibleTabBar::child(
int index)
const
212 if (QAccessible::Id
id = m_childInterfaces.value(
index))
213 return QAccessible::accessibleInterface(
id);
217 QAccessibleTabButton *
button =
new QAccessibleTabButton(tabBar(),
index);
218 QAccessible::registerAccessibleInterface(
button);
219 m_childInterfaces.insert(
index, QAccessible::uniqueId(
button));
224 return QAccessible::queryAccessibleInterface(tabBar()->d_func()->leftB);
228 return QAccessible::queryAccessibleInterface(tabBar()->d_func()->rightB);
234int QAccessibleTabBar::indexOfChild(
const QAccessibleInterface *
child)
const
236 if (
child->object() &&
child->object() == tabBar()->d_func()->leftB)
237 return tabBar()->count();
238 if (
child->object() &&
child->object() == tabBar()->d_func()->rightB)
239 return tabBar()->count() + 1;
240 if (
child->role() == QAccessible::PageTab) {
241 QAccessibleInterface *parent =
child->parent();
242 if (parent ==
this) {
243 const QAccessibleTabButton *tabButton =
static_cast<const QAccessibleTabButton *
>(
child);
244 return tabButton->index();
250int QAccessibleTabBar::childCount()
const
253 return tabBar()->count() + 2;
256QString QAccessibleTabBar::text(QAccessible::Text
t)
const
258 if (
t == QAccessible::Name) {
259 const QTabBar *tBar = tabBar();
260 int idx = tBar->currentIndex();
263 str = qt_accStripAmp(tBar->tabText(idx));
265 }
else if (
t == QAccessible::Accelerator) {
266 return qt_accHotKey(tabBar()->tabText(tabBar()->currentIndex()));
271int QAccessibleTabBar::selectedItemCount()
const
273 if (tabBar()->currentIndex() >= 0)
278QList<QAccessibleInterface*> QAccessibleTabBar::selectedItems()
const
280 QList<QAccessibleInterface*>
items;
281 QAccessibleInterface *selected = selectedItem(0);
287QAccessibleInterface* QAccessibleTabBar::selectedItem(
int selectionIndex)
const
289 const int currentIndex = tabBar()->currentIndex();
290 if (selectionIndex != 0 || currentIndex < 0)
292 return child(currentIndex);
295bool QAccessibleTabBar::isSelected(QAccessibleInterface *childItem)
const
297 return childItem && selectedItem(0) == childItem;
300bool QAccessibleTabBar::select(QAccessibleInterface *childItem)
302 const int childIndex = indexOfChild(childItem);
303 if (childIndex >= 0) {
304 tabBar()->setCurrentIndex(childIndex);
310bool QAccessibleTabBar::unselect(QAccessibleInterface *)
315bool QAccessibleTabBar::selectAll()
320bool QAccessibleTabBar::clear()
327#if QT_CONFIG(combobox)
339QAccessibleComboBox::QAccessibleComboBox(
QWidget *
w)
348QComboBox *QAccessibleComboBox::comboBox()
const
350 return qobject_cast<QComboBox *>(
object());
353QAccessibleInterface *QAccessibleComboBox::child(
int index)
const
359 return QAccessible::queryAccessibleInterface(
view);
360 }
else if (
index == 1 && cBox->isEditable()) {
361 return QAccessible::queryAccessibleInterface(cBox->lineEdit());
367int QAccessibleComboBox::childCount()
const
371 return (cBox->isEditable()) ? 2 : 1;
375QAccessibleInterface *QAccessibleComboBox::childAt(
int x,
int y)
const
378 if (cBox->isEditable() && cBox->lineEdit()->rect().contains(
x,
y))
384int QAccessibleComboBox::indexOfChild(
const QAccessibleInterface *
child)
const
387 if (cBox->view() ==
child->object())
389 if (cBox->isEditable() && cBox->lineEdit() ==
child->object())
395QAccessibleInterface *QAccessibleComboBox::focusChild()
const
401 if (cBox->isEditable())
408QString QAccessibleComboBox::text(QAccessible::Text
t)
const
413 case QAccessible::Name:
415 str = QAccessibleWidget::text(
t);
418 case QAccessible::Value:
419 if (cBox->isEditable())
420 str = cBox->lineEdit()->text();
422 str = cBox->currentText();
424#ifndef QT_NO_SHORTCUT
425 case QAccessible::Accelerator:
433 str = QAccessibleWidget::text(
t);
444 s.expanded = isValid() && cBox->view()->isVisible();
445 s.editable = cBox->isEditable();
450QStringList QAccessibleComboBox::actionNames()
const
452 return QStringList() << showMenuAction() << pressAction();
455QString QAccessibleComboBox::localizedActionDescription(
const QString &actionName)
const
457 if (actionName == showMenuAction() || actionName == pressAction())
458 return QComboBox::tr(
"Open the combo box selection popup");
462void QAccessibleComboBox::doAction(
const QString &actionName)
465 if (actionName == showMenuAction() || actionName == pressAction()) {
466 if (cBox->view()->isVisible()) {
467#if defined(Q_OS_ANDROID)
468 const auto list =
child(0)->tableInterface();
469 if (
list &&
list->selectedRowCount() > 0) {
470 cBox->setCurrentIndex(
list->selectedRows().
at(0));
477#if defined(Q_OS_ANDROID)
478 const auto list =
child(0)->tableInterface();
479 if (
list &&
list->selectedRowCount() > 0) {
480 auto selectedCells =
list->selectedCells();
481 QAccessibleEvent ev(selectedCells.at(0),QAccessible::Focus);
482 QAccessible::updateAccessibility(&ev);
497#if QT_CONFIG(scrollarea)
499QAccessibleAbstractScrollArea::QAccessibleAbstractScrollArea(
QWidget *
widget)
505QAccessibleInterface *QAccessibleAbstractScrollArea::child(
int index)
const
507 return QAccessible::queryAccessibleInterface(accessibleChildren().
at(
index));
510int QAccessibleAbstractScrollArea::childCount()
const
512 return accessibleChildren().size();
515int QAccessibleAbstractScrollArea::indexOfChild(
const QAccessibleInterface *
child)
const
519 return accessibleChildren().indexOf(qobject_cast<QWidget *>(
child->object()));
522bool QAccessibleAbstractScrollArea::isValid()
const
524 return (QAccessibleWidget::isValid() && abstractScrollArea() && abstractScrollArea()->
viewport());
527QAccessibleInterface *QAccessibleAbstractScrollArea::childAt(
int x,
int y)
const
532 for (
int i = 0;
i < childCount(); ++
i) {
533 QPoint wpos = accessibleChildren().at(
i)->mapToGlobal(
QPoint(0, 0));
541QAbstractScrollArea *QAccessibleAbstractScrollArea::abstractScrollArea()
const
543 return static_cast<QAbstractScrollArea *
>(
object());
546QWidgetList QAccessibleAbstractScrollArea::accessibleChildren()
const
556 QScrollBar *horizontalScrollBar = abstractScrollArea()->horizontalScrollBar();
557 if (horizontalScrollBar && horizontalScrollBar->
isVisible()) {
560 if (elementType(scrollBarParent) == HorizontalContainer)
561 children.
append(scrollBarParent);
565 QScrollBar *verticalScrollBar = abstractScrollArea()->verticalScrollBar();
566 if (verticalScrollBar && verticalScrollBar->
isVisible()) {
569 if (elementType(scrollBarParent) == VerticalContainer)
570 children.
append(scrollBarParent);
574 QWidget *cornerWidget = abstractScrollArea()->cornerWidget();
575 if (cornerWidget && cornerWidget->
isVisible())
576 children.
append(cornerWidget);
581QAccessibleAbstractScrollArea::AbstractScrollAreaElement
582QAccessibleAbstractScrollArea::elementType(
QWidget *
widget)
const
587 if (
widget == abstractScrollArea())
592 return HorizontalContainer;
594 return VerticalContainer;
595 if (
widget == abstractScrollArea()->cornerWidget())
601bool QAccessibleAbstractScrollArea::isLeftToRight()
const
603 return abstractScrollArea()->isLeftToRight();
608 : QAccessibleAbstractScrollArea(
widget)
The QAbstractItemView class provides the basic functionality for item view classes.
The QAccessible class provides enums and static functions related to accessibility.
The QComboBox widget combines a button with a dropdown list.
The QKeySequence class encapsulates a key sequence as used by shortcuts.
QString toString(SequenceFormat format=PortableText) const
void push_back(parameter_type t)
const_reference at(qsizetype i) const noexcept
void append(parameter_type t)
QString objectName
the name of this object
\inmodule QtCore\reentrant
constexpr int x() const noexcept
Returns the x coordinate of this point.
constexpr int y() const noexcept
Returns the y coordinate of this point.
\inmodule QtCore\reentrant
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr int width() const noexcept
Returns the width of the rectangle.
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
The QTabBar class provides a tab bar, e.g.
Combined button and popup list for selecting options.
QList< QString > QStringList
Constructs a string list that contains the given string, str.
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum GLenum GLsizei count
view viewport() -> scroll(dx, dy, deviceRect)
insertRed setText("insert red text")