Accessible Slider: Remove virtual children.
Change-Id: I58eca7d807b046b312117f9dbec6e2e36b5332cf Reviewed-on: http://codereview.qt-project.org/4820 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
This commit is contained in:
parent
0992a24653
commit
1782bcefb6
@ -544,116 +544,15 @@ QSlider *QAccessibleSlider::slider() const
|
||||
return qobject_cast<QSlider*>(object());
|
||||
}
|
||||
|
||||
/*! \reimp */
|
||||
QRect QAccessibleSlider::rect(int child) const
|
||||
{
|
||||
QRect rect;
|
||||
if (!slider()->isVisible())
|
||||
return rect;
|
||||
const QStyleOptionSlider option = qt_qsliderStyleOption(slider());
|
||||
QRect srect = slider()->style()->subControlRect(QStyle::CC_Slider, &option,
|
||||
QStyle::SC_SliderHandle, slider());
|
||||
|
||||
switch (child) {
|
||||
case PageLeft:
|
||||
if (slider()->orientation() == Qt::Vertical)
|
||||
rect = QRect(0, 0, slider()->width(), srect.y());
|
||||
else
|
||||
rect = QRect(0, 0, srect.x(), slider()->height());
|
||||
break;
|
||||
case Position:
|
||||
rect = srect;
|
||||
break;
|
||||
case PageRight:
|
||||
if (slider()->orientation() == Qt::Vertical)
|
||||
rect = QRect(0, srect.y() + srect.height(), slider()->width(), slider()->height()- srect.y() - srect.height());
|
||||
else
|
||||
rect = QRect(srect.x() + srect.width(), 0, slider()->width() - srect.x() - srect.width(), slider()->height());
|
||||
break;
|
||||
default:
|
||||
return QAccessibleAbstractSlider::rect(child);
|
||||
}
|
||||
|
||||
QPoint tp = slider()->mapToGlobal(QPoint(0,0));
|
||||
return QRect(tp.x() + rect.x(), tp.y() + rect.y(), rect.width(), rect.height());
|
||||
}
|
||||
|
||||
/*! \reimp */
|
||||
int QAccessibleSlider::childCount() const
|
||||
{
|
||||
return PageRight;
|
||||
}
|
||||
|
||||
/*! \reimp */
|
||||
QString QAccessibleSlider::text(Text t, int child) const
|
||||
{
|
||||
switch (t) {
|
||||
case Value:
|
||||
if (!child || child == 2)
|
||||
return QString::number(slider()->value());
|
||||
return QString();
|
||||
case Name:
|
||||
switch (child) {
|
||||
case PageLeft:
|
||||
return slider()->orientation() == Qt::Horizontal ?
|
||||
QSlider::tr("Page left") : QSlider::tr("Page up");
|
||||
case Position:
|
||||
return QSlider::tr("Position");
|
||||
case PageRight:
|
||||
return slider()->orientation() == Qt::Horizontal ?
|
||||
QSlider::tr("Page right") : QSlider::tr("Page down");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (t == Value)
|
||||
return QString::number(slider()->value());
|
||||
|
||||
return QAccessibleAbstractSlider::text(t, child);
|
||||
}
|
||||
|
||||
/*! \reimp */
|
||||
QAccessible::Role QAccessibleSlider::role(int child) const
|
||||
{
|
||||
switch (child) {
|
||||
case PageLeft:
|
||||
case PageRight:
|
||||
return PushButton;
|
||||
case Position:
|
||||
return Indicator;
|
||||
default:
|
||||
return Slider;
|
||||
}
|
||||
}
|
||||
|
||||
/*! \reimp */
|
||||
QAccessible::State QAccessibleSlider::state(int child) const
|
||||
{
|
||||
const State parentState = QAccessibleAbstractSlider::state(0);
|
||||
|
||||
if (child == 0)
|
||||
return parentState;
|
||||
|
||||
// Inherit the Invisible state from parent.
|
||||
State state = parentState & QAccessible::Invisible;
|
||||
|
||||
// Disable left/right if we are at the minimum/maximum.
|
||||
const QSlider * const slider = QAccessibleSlider::slider();
|
||||
switch (child) {
|
||||
case PageLeft:
|
||||
if (slider->value() <= slider->minimum())
|
||||
state |= Unavailable;
|
||||
break;
|
||||
case PageRight:
|
||||
if (slider->value() >= slider->maximum())
|
||||
state |= Unavailable;
|
||||
break;
|
||||
case Position:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn int QAccessibleSlider::defaultAction(int child) const
|
||||
|
||||
@ -662,16 +561,6 @@ QAccessible::State QAccessibleSlider::state(int child) const
|
||||
*/
|
||||
int QAccessibleSlider::defaultAction(int /*child*/) const
|
||||
{
|
||||
/*
|
||||
switch (child) {
|
||||
case SliderSelf:
|
||||
return SetFocus;
|
||||
case PageLeft:
|
||||
return Press;
|
||||
case PageRight:
|
||||
return Press;
|
||||
}
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -166,20 +166,7 @@ class QAccessibleSlider : public QAccessibleAbstractSlider
|
||||
{
|
||||
public:
|
||||
explicit QAccessibleSlider(QWidget *w);
|
||||
|
||||
enum SliderElements {
|
||||
SliderSelf = 0,
|
||||
PageLeft,
|
||||
Position,
|
||||
PageRight
|
||||
};
|
||||
|
||||
int childCount() const;
|
||||
|
||||
QRect rect(int child) const;
|
||||
QString text(Text t, int child) const;
|
||||
Role role(int child) const;
|
||||
State state(int child) const;
|
||||
|
||||
int defaultAction(int child) const;
|
||||
QString actionText(int action, Text t, int child) const;
|
||||
|
@ -233,7 +233,7 @@ private slots:
|
||||
|
||||
void navigateGeometric();
|
||||
void navigateHierarchy();
|
||||
void navigateSlider();
|
||||
void sliderTest();
|
||||
void navigateCovered();
|
||||
void textAttributes();
|
||||
void hideShowTest();
|
||||
@ -553,7 +553,7 @@ void tst_QAccessibility::navigateGeometric()
|
||||
QTestAccessibility::clearEvents();
|
||||
}
|
||||
|
||||
void tst_QAccessibility::navigateSlider()
|
||||
void tst_QAccessibility::sliderTest()
|
||||
{
|
||||
{
|
||||
QSlider *slider = new QSlider(0);
|
||||
@ -563,9 +563,21 @@ void tst_QAccessibility::navigateSlider()
|
||||
QVERIFY(iface != 0);
|
||||
QVERIFY(iface->isValid());
|
||||
|
||||
QEXPECT_FAIL("", "Implement slider with value interface and no children. Test value interface here.", Continue);
|
||||
QCOMPARE(iface->childCount(), 0);
|
||||
|
||||
QAccessibleValueInterface *valueIface = iface->valueInterface();
|
||||
QVERIFY(valueIface != 0);
|
||||
QCOMPARE(valueIface->minimumValue().toInt(), slider->minimum());
|
||||
QCOMPARE(valueIface->maximumValue().toInt(), slider->maximum());
|
||||
slider->setValue(50);
|
||||
QCOMPARE(valueIface->currentValue().toInt(), slider->value());
|
||||
slider->setValue(0);
|
||||
QCOMPARE(valueIface->currentValue().toInt(), slider->value());
|
||||
slider->setValue(100);
|
||||
QCOMPARE(valueIface->currentValue().toInt(), slider->value());
|
||||
valueIface->setCurrentValue(77);
|
||||
QCOMPARE(77, slider->value());
|
||||
|
||||
delete iface;
|
||||
delete slider;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user