Simplify QAccessibleSpinboxes.
Change-Id: I2fb3ef0ccd108539d8a4abbf3bbd3fdf6d94fac2 Reviewed-on: http://codereview.qt-project.org/4823 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
c7fa7475c9
commit
a8dc1b15dc
@ -80,15 +80,6 @@ QAbstractSpinBox *QAccessibleAbstractSpinBox::abstractSpinBox() const
|
|||||||
return qobject_cast<QAbstractSpinBox*>(object());
|
return qobject_cast<QAbstractSpinBox*>(object());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \reimp */
|
|
||||||
QRect QAccessibleAbstractSpinBox::rect(int child) const
|
|
||||||
{
|
|
||||||
QRect rect;
|
|
||||||
if (!abstractSpinBox()->isVisible())
|
|
||||||
return rect;
|
|
||||||
return widget()->rect();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! \reimp */
|
/*! \reimp */
|
||||||
QString QAccessibleAbstractSpinBox::text(Text t, int child) const
|
QString QAccessibleAbstractSpinBox::text(Text t, int child) const
|
||||||
{
|
{
|
||||||
@ -197,7 +188,7 @@ bool QAccessibleSpinBox::doAction(int action, int child, const QVariantList &par
|
|||||||
|
|
||||||
// ================================== QAccessibleDoubleSpinBox ==================================
|
// ================================== QAccessibleDoubleSpinBox ==================================
|
||||||
QAccessibleDoubleSpinBox::QAccessibleDoubleSpinBox(QWidget *widget)
|
QAccessibleDoubleSpinBox::QAccessibleDoubleSpinBox(QWidget *widget)
|
||||||
: QAccessibleWidget(widget, SpinBox)
|
: QAccessibleAbstractSpinBox(widget)
|
||||||
{
|
{
|
||||||
Q_ASSERT(qobject_cast<QDoubleSpinBox *>(widget));
|
Q_ASSERT(qobject_cast<QDoubleSpinBox *>(widget));
|
||||||
addControllingSignal(QLatin1String("valueChanged(double)"));
|
addControllingSignal(QLatin1String("valueChanged(double)"));
|
||||||
@ -212,65 +203,6 @@ QDoubleSpinBox *QAccessibleDoubleSpinBox::doubleSpinBox() const
|
|||||||
return static_cast<QDoubleSpinBox*>(object());
|
return static_cast<QDoubleSpinBox*>(object());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \reimp */
|
|
||||||
int QAccessibleDoubleSpinBox::childCount() const
|
|
||||||
{
|
|
||||||
return ValueDown;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! \reimp */
|
|
||||||
QRect QAccessibleDoubleSpinBox::rect(int child) const
|
|
||||||
{
|
|
||||||
QRect rect;
|
|
||||||
if (!doubleSpinBox()->isVisible())
|
|
||||||
return rect;
|
|
||||||
QStyleOptionSpinBox spinBoxOption;
|
|
||||||
spinBoxOption.initFrom(doubleSpinBox());
|
|
||||||
switch (child) {
|
|
||||||
case Editor:
|
|
||||||
rect = doubleSpinBox()->style()->subControlRect(QStyle::CC_SpinBox, &spinBoxOption,
|
|
||||||
QStyle::SC_SpinBoxEditField, doubleSpinBox());
|
|
||||||
break;
|
|
||||||
case ValueUp:
|
|
||||||
rect = doubleSpinBox()->style()->subControlRect(QStyle::CC_SpinBox, &spinBoxOption,
|
|
||||||
QStyle::SC_SpinBoxUp, doubleSpinBox());
|
|
||||||
break;
|
|
||||||
case ValueDown:
|
|
||||||
rect = doubleSpinBox()->style()->subControlRect(QStyle::CC_SpinBox, &spinBoxOption,
|
|
||||||
QStyle::SC_SpinBoxDown, doubleSpinBox());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
rect = spinBoxOption.rect;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
const QPoint globalPos = doubleSpinBox()->mapToGlobal(QPoint(0, 0));
|
|
||||||
return QRect(globalPos.x() + rect.x(), globalPos.y() + rect.y(), rect.width(), rect.height());
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! \reimp */
|
|
||||||
int QAccessibleDoubleSpinBox::navigate(RelationFlag relation, int entry, QAccessibleInterface **target) const
|
|
||||||
{
|
|
||||||
if (entry <= 0)
|
|
||||||
return QAccessibleWidget::navigate(relation, entry, target);
|
|
||||||
|
|
||||||
*target = 0;
|
|
||||||
switch (relation) {
|
|
||||||
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(relation, entry, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant QAccessibleDoubleSpinBox::invokeMethod(QAccessible::Method, int, const QVariantList &)
|
QVariant QAccessibleDoubleSpinBox::invokeMethod(QAccessible::Method, int, const QVariantList &)
|
||||||
{
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
@ -279,56 +211,11 @@ QVariant QAccessibleDoubleSpinBox::invokeMethod(QAccessible::Method, int, const
|
|||||||
/*! \reimp */
|
/*! \reimp */
|
||||||
QString QAccessibleDoubleSpinBox::text(Text textType, int child) const
|
QString QAccessibleDoubleSpinBox::text(Text textType, int child) const
|
||||||
{
|
{
|
||||||
switch (textType) {
|
if (textType == Value)
|
||||||
case Name:
|
return doubleSpinBox()->textFromValue(doubleSpinBox()->value());
|
||||||
if (child == ValueUp)
|
|
||||||
return QDoubleSpinBox::tr("More");
|
|
||||||
else if (child == ValueDown)
|
|
||||||
return QDoubleSpinBox::tr("Less");
|
|
||||||
break;
|
|
||||||
case Value:
|
|
||||||
if (child == Editor || child == SpinBoxSelf)
|
|
||||||
return doubleSpinBox()->textFromValue(doubleSpinBox()->value());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return QAccessibleWidget::text(textType, 0);
|
return QAccessibleWidget::text(textType, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! \reimp */
|
|
||||||
QAccessible::Role QAccessibleDoubleSpinBox::role(int child) const
|
|
||||||
{
|
|
||||||
switch (child) {
|
|
||||||
case Editor:
|
|
||||||
return EditableText;
|
|
||||||
case ValueUp:
|
|
||||||
case ValueDown:
|
|
||||||
return PushButton;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return QAccessibleWidget::role(child);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*! \reimp */
|
|
||||||
QAccessible::State QAccessibleDoubleSpinBox::state(int child) const
|
|
||||||
{
|
|
||||||
State state = QAccessibleWidget::state(child);
|
|
||||||
switch (child) {
|
|
||||||
case ValueUp:
|
|
||||||
if (doubleSpinBox()->value() >= doubleSpinBox()->maximum())
|
|
||||||
state |= Unavailable;
|
|
||||||
break;
|
|
||||||
case ValueDown:
|
|
||||||
if (doubleSpinBox()->value() <= doubleSpinBox()->minimum())
|
|
||||||
state |= Unavailable;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
#endif // QT_NO_SPINBOX
|
#endif // QT_NO_SPINBOX
|
||||||
|
|
||||||
#ifndef QT_NO_SCROLLBAR
|
#ifndef QT_NO_SCROLLBAR
|
||||||
|
@ -64,8 +64,6 @@ class QAccessibleAbstractSpinBox: public QAccessibleWidget, public QAccessibleVa
|
|||||||
public:
|
public:
|
||||||
explicit QAccessibleAbstractSpinBox(QWidget *w);
|
explicit QAccessibleAbstractSpinBox(QWidget *w);
|
||||||
|
|
||||||
QRect rect(int child) const;
|
|
||||||
|
|
||||||
QString text(Text t, int child) const;
|
QString text(Text t, int child) const;
|
||||||
|
|
||||||
bool doAction(int action, int child, const QVariantList ¶ms);
|
bool doAction(int action, int child, const QVariantList ¶ms);
|
||||||
@ -94,25 +92,13 @@ protected:
|
|||||||
QSpinBox *spinBox() const;
|
QSpinBox *spinBox() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QAccessibleDoubleSpinBox : public QAccessibleWidget
|
class QAccessibleDoubleSpinBox : public QAccessibleAbstractSpinBox
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit QAccessibleDoubleSpinBox(QWidget *widget);
|
explicit QAccessibleDoubleSpinBox(QWidget *widget);
|
||||||
|
|
||||||
enum DoubleSpinBoxElements {
|
|
||||||
SpinBoxSelf = 0,
|
|
||||||
Editor,
|
|
||||||
ValueUp,
|
|
||||||
ValueDown
|
|
||||||
};
|
|
||||||
|
|
||||||
int childCount() const;
|
|
||||||
QRect rect(int child) const;
|
|
||||||
int navigate(RelationFlag rel, int entry, QAccessibleInterface **target) const;
|
|
||||||
QVariant invokeMethod(QAccessible::Method method, int child, const QVariantList ¶ms);
|
QVariant invokeMethod(QAccessible::Method method, int child, const QVariantList ¶ms);
|
||||||
QString text(Text t, int child) const;
|
QString text(Text t, int child) const;
|
||||||
Role role(int child) const;
|
|
||||||
State state(int child) const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QDoubleSpinBox *doubleSpinBox() const;
|
QDoubleSpinBox *doubleSpinBox() const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user