summaryrefslogtreecommitdiffstats
path: root/src/widgets/accessible/qaccessiblewidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/accessible/qaccessiblewidget.cpp')
-rw-r--r--src/widgets/accessible/qaccessiblewidget.cpp103
1 files changed, 28 insertions, 75 deletions
diff --git a/src/widgets/accessible/qaccessiblewidget.cpp b/src/widgets/accessible/qaccessiblewidget.cpp
index 1a7372728d..b0bb12ea86 100644
--- a/src/widgets/accessible/qaccessiblewidget.cpp
+++ b/src/widgets/accessible/qaccessiblewidget.cpp
@@ -1,45 +1,9 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWidgets module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qaccessiblewidget.h"
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
#include "qapplication.h"
#if QT_CONFIG(groupbox)
@@ -48,7 +12,9 @@
#if QT_CONFIG(label)
#include "qlabel.h"
#endif
+#if QT_CONFIG(tooltip)
#include "qtooltip.h"
+#endif
#if QT_CONFIG(whatsthis)
#include "qwhatsthis.h"
#endif
@@ -66,22 +32,9 @@
QT_BEGIN_NAMESPACE
-static QList<QWidget*> childWidgets(const QWidget *widget)
-{
- QList<QWidget*> widgets;
- for (QObject *o : widget->children()) {
- QWidget *w = qobject_cast<QWidget *>(o);
- if (w && !w->isWindow()
- && !qobject_cast<QFocusFrame*>(w)
-#if QT_CONFIG(menu)
- && !qobject_cast<QMenu*>(w)
-#endif
- && w->objectName() != QLatin1String("qt_rubberband")
- && w->objectName() != QLatin1String("qt_spinbox_lineedit"))
- widgets.append(w);
- }
- return widgets;
-}
+using namespace Qt::StringLiterals;
+
+QWidgetList _q_ac_childWidgets(const QWidget *widget);
static QString buddyString(const QWidget *widget)
{
@@ -110,18 +63,18 @@ static QString buddyString(const QWidget *widget)
/* This function will return the offset of the '&' in the text that would be
preceding the accelerator character.
If this text does not have an accelerator, -1 will be returned. */
-static int qt_accAmpIndex(const QString &text)
+static qsizetype qt_accAmpIndex(const QString &text)
{
#ifndef QT_NO_SHORTCUT
if (text.isEmpty())
return -1;
- int fa = 0;
- while ((fa = text.indexOf(QLatin1Char('&'), fa)) != -1) {
+ qsizetype fa = 0;
+ while ((fa = text.indexOf(u'&', fa)) != -1) {
++fa;
- if (fa < text.length()) {
+ if (fa < text.size()) {
// ignore "&&"
- if (text.at(fa) == QLatin1Char('&')) {
+ if (text.at(fa) == u'&') {
++fa;
continue;
@@ -142,21 +95,21 @@ static int qt_accAmpIndex(const QString &text)
QString qt_accStripAmp(const QString &text)
{
QString newText(text);
- int ampIndex = qt_accAmpIndex(newText);
+ qsizetype ampIndex = qt_accAmpIndex(newText);
if (ampIndex != -1)
newText.remove(ampIndex, 1);
- return newText.replace(QLatin1String("&&"), QLatin1String("&"));
+ return newText.replace("&&"_L1, "&"_L1);
}
QString qt_accHotKey(const QString &text)
{
#ifndef QT_NO_SHORTCUT
- int ampIndex = qt_accAmpIndex(text);
+ qsizetype ampIndex = qt_accAmpIndex(text);
if (ampIndex != -1)
return QKeySequence(Qt::ALT).toString(QKeySequence::NativeText) + text.at(ampIndex + 1);
#else
- Q_UNUSED(text)
+ Q_UNUSED(text);
#endif
return QString();
@@ -283,7 +236,7 @@ void QAccessibleWidget::addControllingSignal(const QString &signal)
QByteArray s = QMetaObject::normalizedSignature(signal.toLatin1());
if (Q_UNLIKELY(object()->metaObject()->indexOfSignal(s) < 0))
qWarning("Signal %s unknown in %s", s.constData(), object()->metaObject()->className());
- d->primarySignals << QLatin1String(s);
+ d->primarySignals << QLatin1StringView(s);
}
static inline bool isAncestor(const QObject *obj, const QObject *child)
@@ -297,10 +250,10 @@ static inline bool isAncestor(const QObject *obj, const QObject *child)
}
/*! \reimp */
-QVector<QPair<QAccessibleInterface*, QAccessible::Relation> >
+QList<QPair<QAccessibleInterface *, QAccessible::Relation>>
QAccessibleWidget::relations(QAccessible::Relation match /*= QAccessible::AllRelations*/) const
{
- QVector<QPair<QAccessibleInterface*, QAccessible::Relation> > rels;
+ QList<QPair<QAccessibleInterface *, QAccessible::Relation>> rels;
if (match & QAccessible::Label) {
const QAccessible::Relation rel = QAccessible::Label;
if (QWidget *parent = widget()->parentWidget()) {
@@ -308,7 +261,7 @@ QAccessibleWidget::relations(QAccessible::Relation match /*= QAccessible::AllRel
// first check for all siblings that are labels to us
// ideally we would go through all objects and check, but that
// will be too expensive
- const QList<QWidget*> kids = childWidgets(parent);
+ const QList<QWidget*> kids = _q_ac_childWidgets(parent);
for (QWidget *kid : kids) {
if (QLabel *labelSibling = qobject_cast<QLabel*>(kid)) {
if (labelSibling->buddy() == widget()) {
@@ -331,14 +284,14 @@ QAccessibleWidget::relations(QAccessible::Relation match /*= QAccessible::AllRel
if (match & QAccessible::Controlled) {
QObjectList allReceivers;
QObject *connectionObject = object();
- for (int sig = 0; sig < d->primarySignals.count(); ++sig) {
+ for (int sig = 0; sig < d->primarySignals.size(); ++sig) {
const QObjectList receivers = connectionObject->d_func()->receiverList(d->primarySignals.at(sig).toLatin1());
allReceivers += receivers;
}
allReceivers.removeAll(object()); //### The object might connect to itself internally
- for (int i = 0; i < allReceivers.count(); ++i) {
+ for (int i = 0; i < allReceivers.size(); ++i) {
const QAccessible::Relation rel = QAccessible::Controlled;
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(allReceivers.at(i));
if (iface)
@@ -359,7 +312,7 @@ QAccessibleInterface *QAccessibleWidget::parent() const
QAccessibleInterface *QAccessibleWidget::child(int index) const
{
Q_ASSERT(widget());
- QWidgetList childList = childWidgets(widget());
+ QWidgetList childList = _q_ac_childWidgets(widget());
if (index >= 0 && index < childList.size())
return QAccessible::queryAccessibleInterface(childList.at(index));
return nullptr;
@@ -387,7 +340,7 @@ QAccessibleInterface *QAccessibleWidget::focusChild() const
/*! \reimp */
int QAccessibleWidget::childCount() const
{
- QWidgetList cl = childWidgets(widget());
+ QWidgetList cl = _q_ac_childWidgets(widget());
return cl.size();
}
@@ -396,7 +349,7 @@ int QAccessibleWidget::indexOfChild(const QAccessibleInterface *child) const
{
if (!child)
return -1;
- QWidgetList cl = childWidgets(widget());
+ QWidgetList cl = _q_ac_childWidgets(widget());
return cl.indexOf(qobject_cast<QWidget *>(child->object()));
}
@@ -425,7 +378,7 @@ QString QAccessibleWidget::text(QAccessible::Text t) const
break;
case QAccessible::Description:
str = widget()->accessibleDescription();
-#ifndef QT_NO_TOOLTIP
+#if QT_CONFIG(tooltip)
if (str.isEmpty())
str = widget()->toolTip();
#endif
@@ -530,4 +483,4 @@ void *QAccessibleWidget::interface_cast(QAccessible::InterfaceType t)
QT_END_NAMESPACE
-#endif //QT_NO_ACCESSIBILITY
+#endif // QT_CONFIG(accessibility)