#include "kitemlistview.h"
#include "private/kitemlistviewlayouter.h"
-#include <qaccessible.h>
-#include <qgraphicsscene.h>
-#include <qgraphicsview.h>
-
-#include <QHash>
+#include <QGraphicsScene>
+#include <QGraphicsView>
KItemListView* KItemListViewAccessible::view() const
{
KItemListViewAccessible::~KItemListViewAccessible()
{
- foreach (QAccessibleInterface* child, m_cells) {
- if (child) {
- QAccessible::Id childId = QAccessible::uniqueId(child);
- QAccessible::deleteAccessibleInterface(childId);
+ foreach (AccessibleIdWrapper idWrapper, m_cells) {
+ if (idWrapper.isValid) {
+ QAccessible::deleteAccessibleInterface(idWrapper.id);
}
}
}
if (type == QAccessible::TableInterface) {
return static_cast<QAccessibleTableInterface*>(this);
}
- return Q_NULLPTR;
+ return nullptr;
}
void KItemListViewAccessible::modelReset()
QAccessibleInterface* KItemListViewAccessible::cell(int index) const
{
if (index < 0 || index >= view()->model()->count()) {
- return 0;
+ return nullptr;
}
- if (m_cells.size() < index - 1)
+ if (m_cells.size() <= index) {
m_cells.resize(childCount());
+ }
+ Q_ASSERT(index < m_cells.size());
- QAccessibleInterface* child = m_cells.at(index);
- if (!child) {
- child = new KItemListAccessibleCell(view(), index);
- QAccessible::registerAccessibleInterface(child);
+ AccessibleIdWrapper idWrapper = m_cells.at(index);
+ if (!idWrapper.isValid) {
+ idWrapper.id = QAccessible::registerAccessibleInterface(new KItemListAccessibleCell(view(), index));
+ idWrapper.isValid = true;
+ m_cells.insert(index, idWrapper);
}
- return child;
+ return QAccessible::accessibleInterface(idWrapper.id);
}
QAccessibleInterface* KItemListViewAccessible::cellAt(int row, int column) const
QAccessibleInterface* KItemListViewAccessible::caption() const
{
- return 0;
+ return nullptr;
}
QString KItemListViewAccessible::columnDescription(int) const
QAccessibleInterface* KItemListViewAccessible::summary() const
{
- return 0;
+ return nullptr;
}
bool KItemListViewAccessible::isColumnSelected(int) const
QAccessibleInterface* KItemListViewAccessible::parent() const
{
// FIXME: return KItemListContainerAccessible here
- return Q_NULLPTR;
+ return nullptr;
}
int KItemListViewAccessible::childCount() const
if (index >= 0 && index < childCount()) {
return cell(index);
}
- return Q_NULLPTR;
+ return nullptr;
+}
+
+KItemListViewAccessible::AccessibleIdWrapper::AccessibleIdWrapper() :
+ isValid(false),
+ id(0)
+{
}
// Table Cell
if (type == QAccessible::TableCellInterface) {
return static_cast<QAccessibleTableCellInterface*>(this);
}
- return Q_NULLPTR;
+ return nullptr;
}
int KItemListAccessibleCell::columnExtent() const
QAccessibleInterface* KItemListAccessibleCell::child(int) const
{
- return Q_NULLPTR;
+ return nullptr;
}
bool KItemListAccessibleCell::isValid() const
QAccessibleInterface* KItemListAccessibleCell::childAt(int, int) const
{
- return Q_NULLPTR;
+ return nullptr;
}
int KItemListAccessibleCell::childCount() const
int KItemListAccessibleCell::indexOfChild(const QAccessibleInterface* child) const
{
- Q_UNUSED(child);
+ Q_UNUSED(child)
return -1;
}
QObject* KItemListAccessibleCell::object() const
{
- return 0;
+ return nullptr;
}
// Container Interface
if (index == 0) {
return QAccessible::queryAccessibleInterface(container()->controller()->view());
}
- return Q_NULLPTR;
+ return nullptr;
}
const KItemListContainer* KItemListContainerAccessible::container() const