Git commit 0d8a7c1f0968d40e0c64003e6b693d2768aa17d7 by Jos=C3=A9 Mill=C3=A1= n Soto. Committed on 16/08/2012 at 16:38. Pushed by millansoto into branch 'master'. Handle TableModelChange AtSpiAdaptor::handleModelChange was created to be handle TableModelChange e= vent. This method will be called when notify is called with TableModelChange as r= eason and will send PropertyChange signals with name and description as arguments. REVIEW: 106178 M +67 -1 src/atspiadaptor.cpp M +1 -0 src/atspiadaptor.h http://commits.kde.org/qtatspi/0d8a7c1f0968d40e0c64003e6b693d2768aa17d7 diff --git a/src/atspiadaptor.cpp b/src/atspiadaptor.cpp index 314acad..b09f2b8 100644 --- a/src/atspiadaptor.cpp +++ b/src/atspiadaptor.cpp @@ -24,6 +24,8 @@ #include #include #include +#include +#include = #include = @@ -890,7 +892,69 @@ QPair AtSpiAdaptor::interfaceFromPath= (const QString& dbusPath) return qMakePair(QAIPointer(), 0); } = +void AtSpiAdaptor::handleModelChange(QAccessibleInterface *interface) { + QAccessibleTable2Interface *table2Interface =3D interface->table2Inter= face(); + if (!table2Interface) + return; + + QAbstractItemView *view =3D qobject_cast< QAbstractItemView* >(interfa= ce->object()); + if (view) { + if (qobject_cast< QAbstractProxyModel* >(view->model())) + return; //Handling it like a normal model would crash + } + + int firstEntry; + int lastEntry; + QAccessible2::TableModelChange change =3D table2Interface->modelChange= (); + + switch (change.type) { + case QAccessible2::TableModelChangeInsert: + if ((change.firstRow < table2Interface->rowCount()) && (change.fir= stColumn < table2Interface->columnCount())) { + QAccessibleTable2CellInterface *firstCell =3D table2Interface-= >cellAt(change.firstRow, change.firstColumn); + firstEntry =3D firstCell ? interface->indexOfChild(firstCell) = : 0; + lastEntry =3D interface->childCount(); + } else { + firstEntry =3D 0; + lastEntry =3D interface->childCount(); + } + break; + case QAccessible2::TableModelChangeDelete: + if (change.firstRow < table2Interface->rowCount()) { + if (change.firstColumn < table2Interface->columnCount()) { + QAccessibleTable2CellInterface *firstCell =3D table2Interf= ace->cellAt(change.firstRow, change.firstColumn); + firstEntry =3D firstCell ? interface->indexOfChild(firstCe= ll) : 0; + lastEntry =3D interface->childCount(); + } else { + firstEntry =3D 0; + lastEntry =3D interface->childCount(); + } + } else { + return; + } + break; + case QAccessible2::TableModelChangeUpdate: + if ((change.firstRow < table2Interface->rowCount()) && (change.fir= stColumn < table2Interface->columnCount())) { + QAccessibleTable2CellInterface *firstCell =3D table2Interface-= >cellAt(change.firstRow, change.firstColumn); + firstEntry =3D firstCell ? interface->indexOfChild(firstCell) = : 0; + QAccessibleTable2CellInterface *lastCell =3D table2Interface->= cellAt(change.lastRow, change.lastColumn); + lastEntry =3D lastCell ? interface->indexOfChild(lastCell) : i= nterface->childCount(); + } else { + firstEntry =3D 0; + lastEntry =3D interface->childCount(); + } + break; + } = + for (int i =3D firstEntry; i <=3D lastEntry; i++) { + QString path =3D pathForInterface(interface, i); + QVariantList args =3D packDBusSignalArguments(QLatin1String("acc= essible-name"), 0, 0, variantForPath(path)); + sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OB= JECT), + QLatin1String("PropertyChange"), args); + args =3D packDBusSignalArguments(QLatin1String("accessible-descr= iption"), 0, 0, variantForPath(path)); + sendDBusSignal(path, QLatin1String(ATSPI_DBUS_INTERFACE_EVENT_OB= JECT), + QLatin1String("PropertyChange"), args); + } +} /*! This function gets called when Qt notifies about accessibility updates. */ @@ -1088,7 +1152,9 @@ void AtSpiAdaptor::notify(int reason, QAccessibleInte= rface *interface, int child case QAccessible::DialogEnd: break; case QAccessible::TableModelChanged: - // For now ignore this event, should be handled together with acti= ve descendant changed + if (sendObject || sendObject_property_change || sendObject_propert= y_change_accessible_name) { + handleModelChange(interface); + } break; case QAccessible::SelectionRemove: break; diff --git a/src/atspiadaptor.h b/src/atspiadaptor.h index 56b9790..2a18ed5 100644 --- a/src/atspiadaptor.h +++ b/src/atspiadaptor.h @@ -62,6 +62,7 @@ private: bool sendDBusSignal(const QString &path, const QString &interface, con= st QString &name, const QVariantList &arguments) const; QVariant variantForPath(const QString &path) const; = + void handleModelChange(QAccessibleInterface *interface); void sendFocusChanged(QAccessibleInterface *interface, int child) cons= t; void notifyAboutCreation(QAccessibleInterface *interface, int child) c= onst; void notifyAboutDestruction(QAccessibleInterface *interface, int child= ) const;