summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederik Gladhorn <gladhorn@kde.org>2014-01-12 02:16:42 (GMT)
committerFrederik Gladhorn <gladhorn@kde.org>2014-01-19 16:34:18 (GMT)
commit37a79b2aed45278e7ce9de23fa3759e4584e1178 (patch)
tree44d16672ca7f4c0adce071fd78057624da272f0b
parent7f0c00fd2ca1813cb62ac405bd10cd833e782186 (diff)
Accessibility text changes
By informing the accessibility framework about text changes the assistive tools can keep track of the text editing.
-rw-r--r--src/view/kateviewinternal.cpp31
-rw-r--r--src/view/kateviewinternal.h4
2 files changed, 35 insertions, 0 deletions
diff --git a/src/view/kateviewinternal.cpp b/src/view/kateviewinternal.cpp
index d0b0149..764a268 100644
--- a/src/view/kateviewinternal.cpp
+++ b/src/view/kateviewinternal.cpp
@@ -214,6 +214,11 @@ KateViewInternal::KateViewInternal(KTextEditor::ViewPrivate *view)
#ifndef QT_NO_ACCESSIBILITY
QAccessible::installFactory(accessibleInterfaceFactory);
#endif
+ connect(doc(), &KTextEditor::Document::textInserted, this, &KateViewInternal::documentTextInserted);
+ connect(doc(), &KTextEditor::Document::textRemoved, this, &KateViewInternal::documentTextRemoved);
+ connect(doc(),
+ static_cast<void (KTextEditor::Document::*)(KTextEditor::Document *, const KTextEditor::Range&, const QString&, const KTextEditor::Range&)>(&KTextEditor::Document::textChanged),
+ this, &KateViewInternal::documentTextChanged);
// update is called in KTextEditor::ViewPrivate, after construction and layout is over
// but before any other kateviewinternal call
@@ -3737,3 +3742,29 @@ void KateViewInternal::flashChar(const KTextEditor::Cursor &pos, KTextEditor::At
m_textAnimation = new KateTextAnimation(range, attribute, this);
}
+void KateViewInternal::documentTextInserted(KTextEditor::Document *document, const KTextEditor::Range &range)
+{
+ if (QAccessible::isActive()) {
+ QAccessibleTextInsertEvent ev(this,
+ KateViewAccessible::positionFromCursor(this, range.start()), document->text(range));
+ QAccessible::updateAccessibility(&ev);
+ }
+}
+
+void KateViewInternal::documentTextRemoved(KTextEditor::Document */*document*/, const KTextEditor::Range &range, const QString &oldText)
+{
+ if (QAccessible::isActive()) {
+ QAccessibleTextRemoveEvent ev(this,
+ KateViewAccessible::positionFromCursor(this, range.start()), oldText);
+ QAccessible::updateAccessibility(&ev);
+ }
+}
+
+void KateViewInternal::documentTextChanged(KTextEditor::Document *document, const KTextEditor::Range &oldRange, const QString &oldText, const KTextEditor::Range &newRange)
+{
+ if (QAccessible::isActive()) {
+ QAccessibleTextUpdateEvent ev(this,
+ KateViewAccessible::positionFromCursor(this, oldRange.start()), oldText, document->text(newRange));
+ QAccessible::updateAccessibility(&ev);
+ }
+}
diff --git a/src/view/kateviewinternal.h b/src/view/kateviewinternal.h
index 6d370ef..3c57949 100644
--- a/src/view/kateviewinternal.h
+++ b/src/view/kateviewinternal.h
@@ -415,6 +415,10 @@ private Q_SLOTS:
void cursorTimeout();
void textHintTimeout();
+ void documentTextInserted(KTextEditor::Document *document, const KTextEditor::Range &range);
+ void documentTextRemoved(KTextEditor::Document *document, const KTextEditor::Range &range, const QString &oldText);
+ void documentTextChanged(KTextEditor::Document *document, const KTextEditor::Range &oldRange, const QString &oldText, const KTextEditor::Range &newRange);
+
//TextHint
public:
void enableTextHints(int timeout);