diff options
Diffstat (limited to 'src/widgets/accessible/simplewidgets.cpp')
-rw-r--r-- | src/widgets/accessible/simplewidgets.cpp | 59 |
1 files changed, 45 insertions, 14 deletions
diff --git a/src/widgets/accessible/simplewidgets.cpp b/src/widgets/accessible/simplewidgets.cpp index a806cb7af6..a53e5eaf30 100644 --- a/src/widgets/accessible/simplewidgets.cpp +++ b/src/widgets/accessible/simplewidgets.cpp @@ -39,15 +39,25 @@ #include "simplewidgets_p.h" +#if QT_CONFIG(abstractbutton) #include <qabstractbutton.h> +#endif +#if QT_CONFIG(checkbox) #include <qcheckbox.h> +#endif +#if QT_CONFIG(pushbutton) #include <qpushbutton.h> +#endif #include <qprogressbar.h> #include <qstatusbar.h> +#if QT_CONFIG(radiobutton) #include <qradiobutton.h> +#endif #include <qtoolbutton.h> #include <qmenu.h> +#if QT_CONFIG(label) #include <qlabel.h> +#endif #include <qgroupbox.h> #include <qlcdnumber.h> #include <qlineedit.h> @@ -72,6 +82,7 @@ extern QList<QWidget*> childWidgets(const QWidget *widget); QString qt_accStripAmp(const QString &text); QString qt_accHotKey(const QString &text); +#if QT_CONFIG(abstractbutton) /*! \class QAccessibleButton \brief The QAccessibleButton class implements the QAccessibleInterface for button type widgets. @@ -109,7 +120,7 @@ QString QAccessibleButton::text(QAccessible::Text t) const switch (t) { case QAccessible::Accelerator: { -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) && QT_CONFIG(pushbutton) QPushButton *pb = qobject_cast<QPushButton*>(object()); if (pb && pb->isDefault()) str = QKeySequence(Qt::Key_Enter).toString(QKeySequence::NativeText); @@ -136,15 +147,20 @@ QAccessible::State QAccessibleButton::state() const QAccessible::State state = QAccessibleWidget::state(); QAbstractButton *b = button(); +#if QT_CONFIG(checkbox) QCheckBox *cb = qobject_cast<QCheckBox *>(b); +#endif if (b->isCheckable()) state.checkable = true; if (b->isChecked()) state.checked = true; +#if QT_CONFIG(checkbox) else if (cb && cb->checkState() == Qt::PartiallyChecked) state.checkStateMixed = true; +#endif if (b->isDown()) state.pressed = true; +#if QT_CONFIG(pushbutton) QPushButton *pb = qobject_cast<QPushButton*>(b); if (pb) { if (pb->isDefault()) @@ -154,6 +170,7 @@ QAccessible::State QAccessibleButton::state() const state.hasPopup = true; #endif } +#endif return state; } @@ -164,17 +181,22 @@ QRect QAccessibleButton::rect() const if (!ab->isVisible()) return QRect(); +#if QT_CONFIG(checkbox) if (QCheckBox *cb = qobject_cast<QCheckBox *>(ab)) { QPoint wpos = cb->mapToGlobal(QPoint(0, 0)); QStyleOptionButton opt; cb->initStyleOption(&opt); return cb->style()->subElementRect(QStyle::SE_CheckBoxClickRect, &opt, cb).translated(wpos); - } else if (QRadioButton *rb = qobject_cast<QRadioButton *>(ab)) { + } +#endif +#if QT_CONFIG(radiobutton) + else if (QRadioButton *rb = qobject_cast<QRadioButton *>(ab)) { QPoint wpos = rb->mapToGlobal(QPoint(0, 0)); QStyleOptionButton opt; rb->initStyleOption(&opt); return rb->style()->subElementRect(QStyle::SE_RadioButtonClickRect, &opt, rb).translated(wpos); } +#endif return QAccessibleWidget::rect(); } @@ -248,7 +270,7 @@ QStringList QAccessibleButton::keyBindingsForAction(const QString &actionName) c } return QStringList(); } - +#endif // QT_CONFIG(abstractbutton) #ifndef QT_NO_TOOLBUTTON /*! @@ -390,6 +412,7 @@ QAccessibleDisplay::QAccessibleDisplay(QWidget *w, QAccessible::Role role) QAccessible::Role QAccessibleDisplay::role() const { +#if QT_CONFIG(label) QLabel *l = qobject_cast<QLabel*>(object()); if (l) { if (l->pixmap()) @@ -411,6 +434,7 @@ QAccessible::Role QAccessibleDisplay::role() const return QAccessible::StatusBar; #endif } +#endif return QAccessibleWidget::role(); } @@ -421,7 +445,9 @@ QString QAccessibleDisplay::text(QAccessible::Text t) const case QAccessible::Name: str = widget()->accessibleName(); if (str.isEmpty()) { - if (qobject_cast<QLabel*>(object())) { + if (false) { +#if QT_CONFIG(label) + } else if (qobject_cast<QLabel*>(object())) { QLabel *label = qobject_cast<QLabel*>(object()); str = label->text(); #ifndef QT_NO_TEXTHTMLPARSER @@ -436,6 +462,7 @@ QString QAccessibleDisplay::text(QAccessible::Text t) const if (label->buddy()) str = qt_accStripAmp(str); #endif +#endif // QT_CONFIG(label) #ifndef QT_NO_LCDNUMBER } else if (qobject_cast<QLCDNumber*>(object())) { QLCDNumber *l = qobject_cast<QLCDNumber*>(object()); @@ -470,21 +497,15 @@ QVector<QPair<QAccessibleInterface*, QAccessible::Relation> > QAccessibleDisplay::relations(QAccessible::Relation match /* = QAccessible::AllRelations */) const { QVector<QPair<QAccessibleInterface*, QAccessible::Relation> > rels = QAccessibleWidget::relations(match); +#if QT_CONFIG(shortcut) && QT_CONFIG(label) if (match & QAccessible::Labelled) { - QVarLengthArray<QObject *, 4> relatedObjects; - -#ifndef QT_NO_SHORTCUT if (QLabel *label = qobject_cast<QLabel*>(object())) { - relatedObjects.append(label->buddy()); - } -#endif - for (int i = 0; i < relatedObjects.count(); ++i) { const QAccessible::Relation rel = QAccessible::Labelled; - QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(relatedObjects.at(i)); - if (iface) + if (QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(label->buddy())) rels.append(qMakePair(iface, rel)); } } +#endif return rels; } @@ -501,33 +522,41 @@ QString QAccessibleDisplay::imageDescription() const #ifndef QT_NO_TOOLTIP return widget()->toolTip(); #else - return QString::null; + return QString(); #endif } /*! \internal */ QSize QAccessibleDisplay::imageSize() const { +#if QT_CONFIG(label) QLabel *label = qobject_cast<QLabel *>(widget()); if (!label) +#endif return QSize(); +#if QT_CONFIG(label) const QPixmap *pixmap = label->pixmap(); if (!pixmap) return QSize(); return pixmap->size(); +#endif } /*! \internal */ QPoint QAccessibleDisplay::imagePosition() const { +#if QT_CONFIG(label) QLabel *label = qobject_cast<QLabel *>(widget()); if (!label) +#endif return QPoint(); +#if QT_CONFIG(label) const QPixmap *pixmap = label->pixmap(); if (!pixmap) return QPoint(); return QPoint(label->mapToGlobal(label->pos())); +#endif } #ifndef QT_NO_GROUPBOX @@ -670,11 +699,13 @@ void QAccessibleLineEdit::setText(QAccessible::Text t, const QString &text) } QString newText = text; +#if QT_CONFIG(validator) if (lineEdit()->validator()) { int pos = 0; if (lineEdit()->validator()->validate(newText, pos) != QValidator::Acceptable) return; } +#endif lineEdit()->setText(newText); } |