Accessible SpinBox remove dead code.

Change-Id: I8f3110a1683af98af605982277a618aa0ba97a64
Reviewed-on: http://codereview.qt-project.org/4822
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:
Frederik Gladhorn 2011-09-15 22:37:59 +02:00 committed by Qt by Nokia
parent 9b0b72fa48
commit 2af41a655a
2 changed files with 5 additions and 144 deletions

View File

@ -80,120 +80,28 @@ QAbstractSpinBox *QAccessibleAbstractSpinBox::abstractSpinBox() const
return qobject_cast<QAbstractSpinBox*>(object());
}
/*! \reimp */
int QAccessibleAbstractSpinBox::childCount() const
{
return ValueDown;
}
/*! \reimp */
QRect QAccessibleAbstractSpinBox::rect(int child) const
{
QRect rect;
if (!abstractSpinBox()->isVisible())
return rect;
QStyleOptionSpinBox so;
so.rect = widget()->rect();
switch(child) {
case Editor:
rect = widget()->style()->subControlRect(QStyle::CC_SpinBox, &so,
QStyle::SC_SpinBoxEditField, widget());
break;
case ValueUp:
rect = widget()->style()->subControlRect(QStyle::CC_SpinBox, &so,
QStyle::SC_SpinBoxUp, widget());
break;
case ValueDown:
rect = widget()->style()->subControlRect(QStyle::CC_SpinBox, &so,
QStyle::SC_SpinBoxDown, widget());
break;
default:
rect = so.rect;
break;
}
QPoint tl = widget()->mapToGlobal(QPoint(0, 0));
return QRect(tl.x() + rect.x(), tl.y() + rect.y(), rect.width(), rect.height());
}
/*! \reimp */
int QAccessibleAbstractSpinBox::navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const
{
*target = 0;
if (entry) switch (rel) {
case Child:
return entry <= childCount() ? entry : -1;
case QAccessible::Left:
return (entry == ValueUp || entry == ValueDown) ? Editor : -1;
case QAccessible::Right:
return entry == Editor ? ValueUp : -1;
case QAccessible::Up:
return entry == ValueDown ? ValueUp : -1;
case QAccessible::Down:
return entry == ValueUp ? ValueDown : -1;
default:
break;
}
return QAccessibleWidget::navigate(rel, entry, target);
return widget()->rect();
}
/*! \reimp */
QString QAccessibleAbstractSpinBox::text(Text t, int child) const
{
if (!abstractSpinBox()->isVisible())
return QString();
switch (t) {
case Name:
switch (child) {
case ValueUp:
return QSpinBox::tr("More");
case ValueDown:
return QSpinBox::tr("Less");
}
break;
case Value:
if (child == Editor || child == SpinBoxSelf)
return abstractSpinBox()->text();
break;
default:
break;
}
if (t == QAccessible::Value)
return abstractSpinBox()->text();
return QAccessibleWidget::text(t, 0);
}
/*! \reimp */
QAccessible::Role QAccessibleAbstractSpinBox::role(int child) const
{
switch(child) {
case Editor:
return EditableText;
case ValueUp:
case ValueDown:
return PushButton;
default:
break;
}
return QAccessibleWidget::role(child);
}
/*! \reimp */
bool QAccessibleAbstractSpinBox::doAction(int action, int child, const QVariantList &params)
{
if (!widget()->isEnabled())
return false;
if (action == Press) {
switch(child) {
case ValueUp:
abstractSpinBox()->stepUp();
return true;
case ValueDown:
abstractSpinBox()->stepDown();
return true;
default:
break;
}
}
return QAccessibleWidget::doAction(action, 0, params);
}
@ -278,47 +186,12 @@ QSpinBox *QAccessibleSpinBox::spinBox() const
return qobject_cast<QSpinBox*>(object());
}
/*! \reimp */
QAccessible::State QAccessibleSpinBox::state(int child) const
{
State state = QAccessibleAbstractSpinBox::state(child);
switch(child) {
case ValueUp:
if (spinBox()->value() >= spinBox()->maximum())
state |= Unavailable;
return state;
case ValueDown:
if (spinBox()->value() <= spinBox()->minimum())
state |= Unavailable;
return state;
default:
break;
}
return state;
}
/*! \reimp */
bool QAccessibleSpinBox::doAction(int action, int child, const QVariantList &params)
{
if (!widget()->isEnabled())
return false;
if (action == Press) {
switch(child) {
case ValueUp:
if (spinBox()->value() >= spinBox()->maximum())
return false;
spinBox()->stepUp();
return true;
case ValueDown:
if (spinBox()->value() <= spinBox()->minimum())
return false;
spinBox()->stepDown();
return true;
default:
break;
}
}
return QAccessibleAbstractSpinBox::doAction(action, 0, params);
}

View File

@ -64,20 +64,9 @@ class QAccessibleAbstractSpinBox: public QAccessibleWidget, public QAccessibleVa
public:
explicit QAccessibleAbstractSpinBox(QWidget *w);
enum SpinBoxElements {
SpinBoxSelf = 0,
Editor,
ValueUp,
ValueDown
};
int childCount() const;
QRect rect(int child) const;
int navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const;
QString text(Text t, int child) const;
Role role(int child) const;
bool doAction(int action, int child, const QVariantList &params);
@ -89,6 +78,8 @@ public:
QVariant maximumValue();
QVariant minimumValue();
// FIXME Action interface
protected:
QAbstractSpinBox *abstractSpinBox() const;
};
@ -97,9 +88,6 @@ class QAccessibleSpinBox : public QAccessibleAbstractSpinBox
{
public:
explicit QAccessibleSpinBox(QWidget *w);
State state(int child) const;
bool doAction(int action, int child, const QVariantList &params);
protected: