Replace (un)checkAction with toggleAction (3/3)

Remove all references to (un)checkAction.
This commit finalizes the intended change.

Change-Id: I79d3b30b5c3d9fbe276c2c94fed5971bb21d6c02
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
This commit is contained in:
Jan-Arve Saether 2012-05-22 09:15:38 +02:00 committed by Qt by Nokia
parent 25f40b2de2
commit 018cb899d4
4 changed files with 20 additions and 57 deletions

View File

@ -372,13 +372,12 @@ QT_BEGIN_NAMESPACE
In general you should use one of the predefined action names, unless describing an action that does not fit these:
\table
\header \li Action name \li Description
\row \li \l checkAction() \li checks the item (checkbox, radio button, ...)
\row \li \l toggleAction() \li toggles the item (checkbox, radio button, switch, ...)
\row \li \l decreaseAction() \li decrease the value of the accessible (e.g. spinbox)
\row \li \l increaseAction() \li increase the value of the accessible (e.g. spinbox)
\row \li \l pressAction() \li press or click or activate the accessible (should correspont to clicking the object with the mouse)
\row \li \l setFocusAction() \li set the focus to this accessible
\row \li \l showMenuAction() \li show a context menu, corresponds to right-clicks
\row \li \l uncheckAction() \li uncheck the item (checkbox, radio button, ...)
\endtable
In order to invoke the action, \l doAction() is called with an action name.
@ -461,9 +460,7 @@ struct QAccessibleActionStrings
decreaseAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Decrease"))),
showMenuAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "ShowMenu"))),
setFocusAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "SetFocus"))),
toggleAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Toggle"))),
checkAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Check"))),
uncheckAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Uncheck"))) {}
toggleAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Toggle"))) {}
const QString pressAction;
const QString increaseAction;
@ -471,8 +468,6 @@ struct QAccessibleActionStrings
const QString showMenuAction;
const QString setFocusAction;
const QString toggleAction;
const QString checkAction;
const QString uncheckAction;
};
Q_GLOBAL_STATIC(QAccessibleActionStrings, accessibleActionStrings)
@ -497,10 +492,6 @@ QString QAccessibleActionInterface::localizedActionDescription(const QString &ac
return tr("Sets the focus");
else if (actionName == strings->toggleAction)
return tr("Toggles the state");
else if (actionName == strings->checkAction)
return tr("Checks the checkbox");
else if (actionName == strings->uncheckAction)
return tr("Unchecks the checkbox");
return QString();
}
@ -559,23 +550,6 @@ const QString &QAccessibleActionInterface::toggleAction()
return accessibleActionStrings()->toggleAction;
}
/*!
Returns the name of the check default action.
\sa actionNames(), localizedActionName()
*/
const QString &QAccessibleActionInterface::checkAction()
{
return accessibleActionStrings()->checkAction;
}
/*!
Returns the name of the uncheck default action.
\sa actionNames(), localizedActionName()
*/
const QString &QAccessibleActionInterface::uncheckAction()
{
return accessibleActionStrings()->uncheckAction;
}
/*!
\internal

View File

@ -233,8 +233,6 @@ public:
static const QString &showMenuAction();
static const QString &setFocusAction();
static const QString &toggleAction();
static const QString &checkAction();
static const QString &uncheckAction();
};
class Q_GUI_EXPORT QAccessibleImageInterface

View File

@ -168,18 +168,11 @@ QStringList QAccessibleButton::actionNames() const
names << showMenuAction();
break;
case QAccessible::RadioButton:
names << checkAction();
names << toggleAction();
break;
default:
if (button()->isCheckable()) {
if (state().checked) {
names << uncheckAction();
} else {
// FIXME
// QCheckBox *cb = qobject_cast<QCheckBox*>(object());
// if (!cb || !cb->isTristate() || cb->checkState() == Qt::PartiallyChecked)
names << checkAction();
}
names << toggleAction();
} else {
names << pressAction();
}
@ -203,10 +196,8 @@ void QAccessibleButton::doAction(const QString &actionName)
else
#endif
button()->animateClick();
} else if (actionName == checkAction()) {
button()->setChecked(true);
} else if (actionName == uncheckAction()) {
button()->setChecked(false);
} else if (actionName == toggleAction()) {
button()->toggle();
} else {
QAccessibleWidget::doAction(actionName);
}
@ -552,14 +543,14 @@ QStringList QAccessibleGroupBox::actionNames() const
QStringList actions = QAccessibleWidget::actionNames();
if (groupBox()->isCheckable()) {
actions.prepend(QAccessibleActionInterface::checkAction());
actions.prepend(QAccessibleActionInterface::toggleAction());
}
return actions;
}
void QAccessibleGroupBox::doAction(const QString &actionName)
{
if (actionName == QAccessibleActionInterface::checkAction())
if (actionName == QAccessibleActionInterface::toggleAction())
groupBox()->setChecked(!groupBox()->isChecked());
}

View File

@ -949,14 +949,14 @@ void tst_QAccessibility::buttonTest()
interface = QAccessible::queryAccessibleInterface(&toggleButton);
actionInterface = interface->actionInterface();
QCOMPARE(interface->role(), QAccessible::CheckBox);
QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::checkAction() << QAccessibleActionInterface::setFocusAction());
QCOMPARE(actionInterface->localizedActionDescription(QAccessibleActionInterface::checkAction()), QString("Checks the checkbox"));
QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::toggleAction() << QAccessibleActionInterface::setFocusAction());
QCOMPARE(actionInterface->localizedActionDescription(QAccessibleActionInterface::toggleAction()), QString("Toggles the state"));
QVERIFY(!toggleButton.isChecked());
QVERIFY(!interface->state().checked);
actionInterface->doAction(QAccessibleActionInterface::checkAction());
actionInterface->doAction(QAccessibleActionInterface::toggleAction());
QTest::qWait(500);
QVERIFY(toggleButton.isChecked());
QCOMPARE(actionInterface->actionNames().at(0), QAccessibleActionInterface::uncheckAction());
QCOMPARE(actionInterface->actionNames().at(0), QAccessibleActionInterface::toggleAction());
QVERIFY(interface->state().checked);
delete interface;
@ -987,12 +987,12 @@ void tst_QAccessibility::buttonTest()
interface = QAccessible::queryAccessibleInterface(&checkBox);
actionInterface = interface->actionInterface();
QCOMPARE(interface->role(), QAccessible::CheckBox);
QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::checkAction() << QAccessibleActionInterface::setFocusAction());
QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::toggleAction() << QAccessibleActionInterface::setFocusAction());
QVERIFY(!interface->state().checked);
actionInterface->doAction(QAccessibleActionInterface::checkAction());
actionInterface->doAction(QAccessibleActionInterface::toggleAction());
QTest::qWait(500);
QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::uncheckAction() << QAccessibleActionInterface::setFocusAction());
QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::toggleAction() << QAccessibleActionInterface::setFocusAction());
QVERIFY(interface->state().checked);
QVERIFY(checkBox.isChecked());
QAccessible::State st;
@ -1009,11 +1009,11 @@ void tst_QAccessibility::buttonTest()
interface = QAccessible::queryAccessibleInterface(&radio);
actionInterface = interface->actionInterface();
QCOMPARE(interface->role(), QAccessible::RadioButton);
QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::checkAction() << QAccessibleActionInterface::setFocusAction());
QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::toggleAction() << QAccessibleActionInterface::setFocusAction());
QVERIFY(!interface->state().checked);
actionInterface->doAction(QAccessibleActionInterface::checkAction());
actionInterface->doAction(QAccessibleActionInterface::toggleAction());
QTest::qWait(500);
QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::checkAction() << QAccessibleActionInterface::setFocusAction());
QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::toggleAction() << QAccessibleActionInterface::setFocusAction());
QVERIFY(interface->state().checked);
QVERIFY(radio.isChecked());
QAccessible::State st;
@ -2045,8 +2045,8 @@ void tst_QAccessibility::groupBoxTest()
QAccessible::State state = iface->state();
QVERIFY(state.checkable);
QVERIFY(!state.checked);
QVERIFY(actionIface->actionNames().contains(QAccessibleActionInterface::checkAction()));
actionIface->doAction(QAccessibleActionInterface::checkAction());
QVERIFY(actionIface->actionNames().contains(QAccessibleActionInterface::toggleAction()));
actionIface->doAction(QAccessibleActionInterface::toggleAction());
QVERIFY(groupBox->isChecked());
state = iface->state();
QVERIFY(state.checked);