QtGui: Fix compilation with gcc 4.4

- Do not mix QStringLiteral and Q_TR_NOOP.
- Replace static QString member variables by
- static member functions to return the strings.
- Use tr() since QAccessibleActionInterface declares it.

Acked-by: Frederik Gladhorn <frederik.gladhorn@nokia.com>

Change-Id: Iabbee8ef61a5d7bfd35978a3f1cce1866329d065
Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
This commit is contained in:
Friedemann Kleint 2011-11-01 14:36:20 +01:00 committed by Qt by Nokia
parent d2f1c6cd75
commit 7d7b2d4218
7 changed files with 137 additions and 88 deletions

View File

@ -198,13 +198,27 @@ QT_BEGIN_NAMESPACE
\sa actionNames()
*/
const QString QAccessibleActionInterface::PressAction = QStringLiteral(QT_TR_NOOP("Press"));
const QString QAccessibleActionInterface::IncreaseAction = QStringLiteral(QT_TR_NOOP("Increase"));
const QString QAccessibleActionInterface::DecreaseAction = QStringLiteral(QT_TR_NOOP("Decrease"));
const QString QAccessibleActionInterface::ShowMenuAction = QStringLiteral(QT_TR_NOOP("ShowMenu"));
const QString QAccessibleActionInterface::SetFocusAction = QStringLiteral(QT_TR_NOOP("SetFocus"));
const QString QAccessibleActionInterface::CheckAction = QStringLiteral(QT_TR_NOOP("Check"));
const QString QAccessibleActionInterface::UncheckAction = QStringLiteral(QT_TR_NOOP("Uncheck"));
struct QAccessibleActionStrings
{
QAccessibleActionStrings() :
pressAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Press"))),
increaseAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Increase"))),
decreaseAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Decrease"))),
showMenuAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "ShowMenu"))),
setFocusAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "SetFocus"))),
checkAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Check"))),
uncheckAction(QStringLiteral(QT_TRANSLATE_NOOP("QAccessibleActionInterface", "Uncheck"))) {}
const QString pressAction;
const QString increaseAction;
const QString decreaseAction;
const QString showMenuAction;
const QString setFocusAction;
const QString checkAction;
const QString uncheckAction;
};
Q_GLOBAL_STATIC(QAccessibleActionStrings, accessibleActionStrings)
QString QAccessibleActionInterface::localizedActionName(const QString &actionName) const
{
@ -213,24 +227,59 @@ QString QAccessibleActionInterface::localizedActionName(const QString &actionNam
QString QAccessibleActionInterface::localizedActionDescription(const QString &actionName) const
{
if (actionName == PressAction)
return QCoreApplication::translate("QAccessibleActionInterface", "Triggers the action");
else if (actionName == IncreaseAction)
return QCoreApplication::translate("QAccessibleActionInterface", "Increase the value");
else if (actionName == DecreaseAction)
return QCoreApplication::translate("QAccessibleActionInterface", "Decrease the value");
else if (actionName == ShowMenuAction)
return QCoreApplication::translate("QAccessibleActionInterface", "Shows the menu");
else if (actionName == SetFocusAction)
return QCoreApplication::translate("QAccessibleActionInterface", "Sets the focus");
else if (actionName == CheckAction)
return QCoreApplication::translate("QAccessibleActionInterface", "Checks the checkbox");
else if (actionName == UncheckAction)
return QCoreApplication::translate("QAccessibleActionInterface", "Unchecks the checkbox");
const QAccessibleActionStrings *strings = accessibleActionStrings();
if (actionName == strings->pressAction)
return tr("Triggers the action");
else if (actionName == strings->increaseAction)
return tr("Increase the value");
else if (actionName == strings->decreaseAction)
return tr("Decrease the value");
else if (actionName == strings->showMenuAction)
return tr("Shows the menu");
else if (actionName == strings->setFocusAction)
return tr("Sets the focus");
else if (actionName == strings->checkAction)
return tr("Checks the checkbox");
else if (actionName == strings->uncheckAction)
return tr("Unchecks the checkbox");
return QString();
}
const QString &QAccessibleActionInterface::pressAction()
{
return accessibleActionStrings()->pressAction;
}
const QString &QAccessibleActionInterface::increaseAction()
{
return accessibleActionStrings()->increaseAction;
}
const QString &QAccessibleActionInterface::decreaseAction()
{
return accessibleActionStrings()->decreaseAction;
}
const QString &QAccessibleActionInterface::showMenuAction()
{
return accessibleActionStrings()->showMenuAction;
}
const QString &QAccessibleActionInterface::setFocusAction()
{
return accessibleActionStrings()->setFocusAction;
}
const QString &QAccessibleActionInterface::checkAction()
{
return accessibleActionStrings()->checkAction;
}
const QString &QAccessibleActionInterface::uncheckAction()
{
return accessibleActionStrings()->uncheckAction;
}
/*!
\internal

View File

@ -339,13 +339,13 @@ public:
virtual void doAction(const QString &actionName) = 0;
virtual QStringList keyBindingsForAction(const QString &actionName) const = 0;
static const QString PressAction;
static const QString IncreaseAction;
static const QString DecreaseAction;
static const QString ShowMenuAction;
static const QString SetFocusAction;
static const QString CheckAction;
static const QString UncheckAction;
static const QString &pressAction();
static const QString &increaseAction();
static const QString &decreaseAction();
static const QString &showMenuAction();
static const QString &setFocusAction();
static const QString &checkAction();
static const QString &uncheckAction();
};
class Q_GUI_EXPORT QAccessibleImageInterface : public QAccessible2Interface

View File

@ -1508,12 +1508,12 @@ public:
QStringList actionNames() const
{
return QStringList() << PressAction;
return QStringList(pressAction());
}
void doAction(const QString &actionName)
{
if (actionName == PressAction)
if (actionName == pressAction())
m_parent->setCurrentIndex(m_index);
}
@ -1726,19 +1726,19 @@ QString QAccessibleComboBox::text(Text t, int) const
QStringList QAccessibleComboBox::actionNames() const
{
return QStringList() << ShowMenuAction;
return QStringList(showMenuAction());
}
QString QAccessibleComboBox::localizedActionDescription(const QString &actionName) const
{
if (actionName == ShowMenuAction)
if (actionName == showMenuAction())
return QComboBox::tr("Open the combo box selection popup");
return QString();
}
void QAccessibleComboBox::doAction(const QString &actionName)
{
if (actionName == ShowMenuAction) {
if (actionName == showMenuAction()) {
if (comboBox()->view()->isVisible()) {
comboBox()->hidePopup();
} else {

View File

@ -444,9 +444,9 @@ QStringList QAccessibleMenuItem::actionNames() const
return actions;
if (m_action->menu()) {
actions << ShowMenuAction;
actions << showMenuAction();
} else {
actions << PressAction;
actions << pressAction();
}
return actions;
}
@ -456,9 +456,9 @@ void QAccessibleMenuItem::doAction(const QString &actionName)
if (!m_action->isEnabled())
return;
if (actionName == PressAction) {
if (actionName == pressAction()) {
m_action->trigger();
} else if (actionName == ShowMenuAction) {
} else if (actionName == showMenuAction()) {
if (QMenuBar *bar = qobject_cast<QMenuBar*>(owner())) {
if (m_action->menu() && m_action->menu()->isVisible()) {
m_action->menu()->hide();

View File

@ -166,23 +166,23 @@ QStringList QAccessibleButton::actionNames() const
if (widget()->isEnabled()) {
switch (role()) {
case ButtonMenu:
names << ShowMenuAction;
names << showMenuAction();
break;
case RadioButton:
names << CheckAction;
names << checkAction();
break;
default:
if (button()->isCheckable()) {
if (state() & Checked) {
names << UncheckAction;
names << uncheckAction();
} else {
// FIXME
// QCheckBox *cb = qobject_cast<QCheckBox*>(object());
// if (!cb || !cb->isTristate() || cb->checkState() == Qt::PartiallyChecked)
names << CheckAction;
names << checkAction();
}
} else {
names << PressAction;
names << pressAction();
}
break;
}
@ -195,8 +195,8 @@ void QAccessibleButton::doAction(const QString &actionName)
{
if (!widget()->isEnabled())
return;
if (actionName == PressAction ||
actionName == ShowMenuAction) {
if (actionName == pressAction() ||
actionName == showMenuAction()) {
#ifndef QT_NO_MENU
QPushButton *pb = qobject_cast<QPushButton*>(object());
if (pb && pb->menu())
@ -204,9 +204,9 @@ void QAccessibleButton::doAction(const QString &actionName)
else
#endif
button()->animateClick();
} else if (actionName == CheckAction) {
} else if (actionName == checkAction()) {
button()->setChecked(true);
} else if (actionName == UncheckAction) {
} else if (actionName == uncheckAction()) {
button()->setChecked(false);
} else {
QAccessibleWidget::doAction(actionName);
@ -215,7 +215,7 @@ void QAccessibleButton::doAction(const QString &actionName)
QStringList QAccessibleButton::keyBindingsForAction(const QString &actionName) const
{
if (actionName == PressAction) {
if (actionName == pressAction()) {
#ifndef QT_NO_SHORTCUT
return QStringList() << button()->shortcut().toString();
#endif
@ -333,7 +333,7 @@ QStringList QAccessibleToolButton::actionNames() const
QStringList names;
if (widget()->isEnabled()) {
if (toolButton()->menu())
names << ShowMenuAction;
names << showMenuAction();
if (toolButton()->popupMode() != QToolButton::InstantPopup)
names << QAccessibleButton::actionNames();
}
@ -345,9 +345,9 @@ void QAccessibleToolButton::doAction(const QString &actionName)
if (!widget()->isEnabled())
return;
if (actionName == PressAction) {
if (actionName == pressAction()) {
button()->click();
} else if (actionName == ShowMenuAction) {
} else if (actionName == showMenuAction()) {
if (toolButton()->popupMode() != QToolButton::InstantPopup) {
toolButton()->setDown(true);
#ifndef QT_NO_MENU

View File

@ -824,7 +824,7 @@ QStringList QAccessibleWidget::actionNames() const
QStringList names;
if (widget()->isEnabled()) {
if (widget()->focusPolicy() != Qt::NoFocus)
names << SetFocusAction;
names << setFocusAction();
}
return names;
}
@ -834,7 +834,7 @@ void QAccessibleWidget::doAction(const QString &actionName)
if (!widget()->isEnabled())
return;
if (actionName == SetFocusAction) {
if (actionName == setFocusAction()) {
if (widget()->isWindow())
widget()->activateWindow();
widget()->setFocus();

View File

@ -947,7 +947,7 @@ void tst_QAccessibility::hideShowTest()
void tst_QAccessibility::actionTest()
{
{
QCOMPARE(QAccessibleActionInterface::PressAction, QString("Press"));
QCOMPARE(QAccessibleActionInterface::pressAction(), QString(QStringLiteral("Press")));
QWidget *widget = new QWidget;
widget->setFocusPolicy(Qt::NoFocus);
@ -962,7 +962,7 @@ void tst_QAccessibility::actionTest()
// no actions by default, except when focusable
QCOMPARE(actions->actionNames(), QStringList());
widget->setFocusPolicy(Qt::StrongFocus);
QCOMPARE(actions->actionNames(), QStringList() << QAccessibleActionInterface::SetFocusAction);
QCOMPARE(actions->actionNames(), QStringList(QAccessibleActionInterface::setFocusAction()));
delete interface;
delete widget;
@ -978,15 +978,15 @@ void tst_QAccessibility::actionTest()
QVERIFY(actions);
// Make sure the "primary action" press comes first!
QCOMPARE(actions->actionNames(), QStringList() << QAccessibleActionInterface::PressAction << QAccessibleActionInterface::SetFocusAction);
QCOMPARE(actions->actionNames(), QStringList() << QAccessibleActionInterface::pressAction() << QAccessibleActionInterface::setFocusAction());
actions->doAction(QAccessibleActionInterface::SetFocusAction);
actions->doAction(QAccessibleActionInterface::setFocusAction());
QTest::qWait(500);
QCOMPARE(button->hasFocus(), true);
connect(button, SIGNAL(clicked()), this, SLOT(onClicked()));
QCOMPARE(click_count, 0);
actions->doAction(QAccessibleActionInterface::PressAction);
actions->doAction(QAccessibleActionInterface::pressAction());
QTest::qWait(500);
QCOMPARE(click_count, 1);
@ -1081,9 +1081,9 @@ void tst_QAccessibility::buttonTest()
// buttons only have a click action
QCOMPARE(actionInterface->actionNames().size(), 2);
QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::PressAction << QAccessibleActionInterface::SetFocusAction);
QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::pressAction() << QAccessibleActionInterface::setFocusAction());
QCOMPARE(pushButton.clickCount, 0);
actionInterface->doAction(QAccessibleActionInterface::PressAction);
actionInterface->doAction(QAccessibleActionInterface::pressAction());
QTest::qWait(500);
QCOMPARE(pushButton.clickCount, 1);
delete interface;
@ -1092,14 +1092,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::checkAction() << QAccessibleActionInterface::setFocusAction());
QCOMPARE(actionInterface->localizedActionDescription(QAccessibleActionInterface::checkAction()), QString("Checks the checkbox"));
QVERIFY(!toggleButton.isChecked());
QVERIFY((interface->state() & QAccessible::Checked) == 0);
actionInterface->doAction(QAccessibleActionInterface::CheckAction);
actionInterface->doAction(QAccessibleActionInterface::checkAction());
QTest::qWait(500);
QVERIFY(toggleButton.isChecked());
QCOMPARE(actionInterface->actionNames().at(0), QAccessibleActionInterface::UncheckAction);
QCOMPARE(actionInterface->actionNames().at(0), QAccessibleActionInterface::uncheckAction());
QVERIFY(interface->state() & QAccessible::Checked);
delete interface;
@ -1115,9 +1115,9 @@ void tst_QAccessibility::buttonTest()
QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(&menuButton);
QCOMPARE(interface->role(), QAccessible::ButtonMenu);
QVERIFY(interface->state() & QAccessible::HasPopup);
QCOMPARE(interface->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::ShowMenuAction << QAccessibleActionInterface::SetFocusAction);
QCOMPARE(interface->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::showMenuAction() << QAccessibleActionInterface::setFocusAction());
// showing the menu enters a new event loop...
// interface->actionInterface()->doAction(QAccessibleActionInterface::ShowMenuAction);
// interface->actionInterface()->doAction(QAccessibleActionInterface::showMenuAction());
// QTest::qWait(500);
delete interface;
delete menu;
@ -1127,11 +1127,11 @@ 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::checkAction() << QAccessibleActionInterface::setFocusAction());
QVERIFY((interface->state() & QAccessible::Checked) == 0);
actionInterface->doAction(QAccessibleActionInterface::CheckAction);
actionInterface->doAction(QAccessibleActionInterface::checkAction());
QTest::qWait(500);
QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::UncheckAction << QAccessibleActionInterface::SetFocusAction);
QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::uncheckAction() << QAccessibleActionInterface::setFocusAction());
QVERIFY(interface->state() & QAccessible::Checked);
QVERIFY(checkBox.isChecked());
delete interface;
@ -1140,11 +1140,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::checkAction() << QAccessibleActionInterface::setFocusAction());
QVERIFY((interface->state() & QAccessible::Checked) == 0);
actionInterface->doAction(QAccessibleActionInterface::CheckAction);
actionInterface->doAction(QAccessibleActionInterface::checkAction());
QTest::qWait(500);
QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::CheckAction << QAccessibleActionInterface::SetFocusAction);
QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::checkAction() << QAccessibleActionInterface::setFocusAction());
QVERIFY(interface->state() & QAccessible::Checked);
QVERIFY(checkBox.isChecked());
delete interface;
@ -1289,9 +1289,9 @@ void tst_QAccessibility::tabTest()
// Test that sending a press action to a tab selects it.
QVERIFY(child2->actionInterface());
QCOMPARE(child2->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::PressAction);
QCOMPARE(child2->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::pressAction());
QCOMPARE(tabBar->currentIndex(), 0);
child2->actionInterface()->doAction(QAccessibleActionInterface::PressAction);
child2->actionInterface()->doAction(QAccessibleActionInterface::pressAction());
QCOMPARE(tabBar->currentIndex(), 1);
delete tabBar;
@ -1485,26 +1485,26 @@ void tst_QAccessibility::menuTest()
QVERIFY(iFile->actionInterface());
QCOMPARE(iFile->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::ShowMenuAction);
QCOMPARE(iFile->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::showMenuAction());
QCOMPARE(iSeparator->actionInterface()->actionNames(), QStringList());
QCOMPARE(iHelp->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::ShowMenuAction);
QCOMPARE(iAction->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::PressAction);
QCOMPARE(iHelp->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::showMenuAction());
QCOMPARE(iAction->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::pressAction());
bool menuFade = qApp->isEffectEnabled(Qt::UI_FadeMenu);
int menuFadeDelay = 300;
iFile->actionInterface()->doAction(QAccessibleActionInterface::ShowMenuAction);
iFile->actionInterface()->doAction(QAccessibleActionInterface::showMenuAction());
if(menuFade)
QTest::qWait(menuFadeDelay);
QVERIFY(file->isVisible() && !edit->isVisible() && !help->isVisible());
iEdit->actionInterface()->doAction(QAccessibleActionInterface::ShowMenuAction);
iEdit->actionInterface()->doAction(QAccessibleActionInterface::showMenuAction());
if(menuFade)
QTest::qWait(menuFadeDelay);
QVERIFY(!file->isVisible() && edit->isVisible() && !help->isVisible());
iHelp->actionInterface()->doAction(QAccessibleActionInterface::ShowMenuAction);
iHelp->actionInterface()->doAction(QAccessibleActionInterface::showMenuAction());
if(menuFade)
QTest::qWait(menuFadeDelay);
QVERIFY(!file->isVisible() && !edit->isVisible() && help->isVisible());
iAction->actionInterface()->doAction(QAccessibleActionInterface::ShowMenuAction);
iAction->actionInterface()->doAction(QAccessibleActionInterface::showMenuAction());
if(menuFade)
QTest::qWait(menuFadeDelay);
QVERIFY(!file->isVisible() && !edit->isVisible() && !help->isVisible());
@ -1527,11 +1527,11 @@ void tst_QAccessibility::menuTest()
QCOMPARE(iFileSave->role(), QAccessible::MenuItem);
QCOMPARE(iFileSeparator->role(), QAccessible::Separator);
QCOMPARE(iFileExit->role(), QAccessible::MenuItem);
QCOMPARE(iFileNew->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::ShowMenuAction);
QCOMPARE(iFileOpen->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::PressAction);
QCOMPARE(iFileSave->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::PressAction);
QCOMPARE(iFileNew->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::showMenuAction());
QCOMPARE(iFileOpen->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::pressAction());
QCOMPARE(iFileSave->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::pressAction());
QCOMPARE(iFileSeparator->actionInterface()->actionNames(), QStringList());
QCOMPARE(iFileExit->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::PressAction);
QCOMPARE(iFileExit->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::pressAction());
QAccessibleInterface *iface = 0;
QAccessibleInterface *iface2 = 0;
@ -1621,8 +1621,8 @@ void tst_QAccessibility::menuTest()
if (menuFade)
QTest::qWait(menuFadeDelay);
iFile->actionInterface()->doAction(QAccessibleActionInterface::ShowMenuAction);
iFileNew->actionInterface()->doAction(QAccessibleActionInterface::ShowMenuAction);
iFile->actionInterface()->doAction(QAccessibleActionInterface::showMenuAction());
iFileNew->actionInterface()->doAction(QAccessibleActionInterface::showMenuAction());
QVERIFY(file->isVisible());
QVERIFY(fileNew->isVisible());
@ -3291,8 +3291,8 @@ void tst_QAccessibility::comboBoxTest()
QVERIFY(!combo.view()->isVisible());
QVERIFY(iface->actionInterface());
QCOMPARE(iface->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::ShowMenuAction);
iface->actionInterface()->doAction(QAccessibleActionInterface::ShowMenuAction);
QCOMPARE(iface->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::showMenuAction());
iface->actionInterface()->doAction(QAccessibleActionInterface::showMenuAction());
QVERIFY(combo.view()->isVisible());
delete iface;