Implement editable text interface for QLineEdit.

This was uncovered by the linux accessibility test which
tried to call non-existing functions.

Change-Id: Iaa9640c23ee77d7c5b2321d7f8cfa6d12d61c0e9
Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
This commit is contained in:
Frederik Gladhorn 2012-10-18 16:59:08 +02:00 committed by The Qt Project
parent 9764907240
commit 5bd55890fa
2 changed files with 22 additions and 1 deletions

View File

@ -653,6 +653,8 @@ void *QAccessibleLineEdit::interface_cast(QAccessible::InterfaceType t)
{
if (t == QAccessible::TextInterface)
return static_cast<QAccessibleTextInterface*>(this);
if (t == QAccessible::EditableTextInterface)
return static_cast<QAccessibleEditableTextInterface*>(this);
return QAccessibleWidget::interface_cast(t);
}
@ -784,6 +786,21 @@ void QAccessibleLineEdit::scrollToSubstring(int startIndex, int endIndex)
lineEdit()->setCursorPosition(startIndex);
}
void QAccessibleLineEdit::deleteText(int startOffset, int endOffset)
{
lineEdit()->setText(lineEdit()->text().remove(startOffset, endOffset - startOffset));
}
void QAccessibleLineEdit::insertText(int offset, const QString &text)
{
lineEdit()->setText(lineEdit()->text().insert(offset, text));
}
void QAccessibleLineEdit::replaceText(int startOffset, int endOffset, const QString &text)
{
lineEdit()->setText(lineEdit()->text().replace(startOffset, endOffset - startOffset, text));
}
#endif // QT_NO_LINEEDIT
#ifndef QT_NO_PROGRESSBAR

View File

@ -137,7 +137,7 @@ private:
#endif
#ifndef QT_NO_LINEEDIT
class QAccessibleLineEdit : public QAccessibleWidget, public QAccessibleTextInterface
class QAccessibleLineEdit : public QAccessibleWidget, public QAccessibleTextInterface, public QAccessibleEditableTextInterface
{
public:
explicit QAccessibleLineEdit(QWidget *o, const QString &name = QString());
@ -168,6 +168,10 @@ public:
int characterCount() const;
void scrollToSubstring(int startIndex, int endIndex);
// QAccessibleEditableTextInterface
void deleteText(int startOffset, int endOffset);
void insertText(int offset, const QString &text);
void replaceText(int startOffset, int endOffset, const QString &text);
protected:
QLineEdit *lineEdit() const;
};