-#ifndef ACCESSIBLE_ITEMVIEWS_H
-#define ACCESSIBLE_ITEMVIEWS_H
+/***************************************************************************
+ * Copyright (C) 2012 by Amandeep Singh <aman.dedman@gmail.com> *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
+ ***************************************************************************/
+
+#ifndef KITEMLISTVIEWACCESSIBLE_H
+#define KITEMLISTVIEWACCESSIBLE_H
-#include "QtCore/qpointer.h"
-#include <QtGui/qabstractitemview.h>
-#include <QtGui/qheaderview.h>
+#ifndef QT_NO_ACCESSIBILITY
+
+#include <QtCore/qpointer.h>
#include <QtGui/qaccessible.h>
#include <QtGui/qaccessible2.h>
#include <QtGui/qaccessiblewidget.h>
+#include <QtGui/qaccessibleobject.h>
-#include "kitemlistview.h"
-#include "kitemlistcontainer.h"
-
-#ifndef QT_NO_ACCESSIBILITY
-
-#ifndef QT_NO_ITEMVIEWS
-
-class KItemListWidgetAccessible;
+class KItemListView;
+class KItemListContainer;
class KItemListViewAccessible: public QAccessibleTable2Interface, public QAccessibleObjectEx
{
Q_ACCESSIBLE_OBJECT
-public:
- explicit KItemListViewAccessible(KItemListView *view);
- virtual ~KItemListViewAccessible();
+public:
+ explicit KItemListViewAccessible(KItemListView* view);
Role role(int child) const;
State state(int child) const;
int childAt(int x, int y) const;
int childCount() const;
- int indexOfChild(const QAccessibleInterface *) const;
+ int indexOfChild(const QAccessibleInterface*) const;
- int navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const;
- Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const;
+ int navigate(RelationFlag relation, int index, QAccessibleInterface** interface) const;
+ Relation relationTo(int child, const QAccessibleInterface* other, int otherChild) const;
#ifndef QT_NO_ACTION
int userActionCount(int child) const;
QString actionText(int action, Text t, int child) const;
- bool doAction(int action, int child, const QVariantList ¶ms);
+ bool doAction(int action, int child, const QVariantList& params);
#endif
- QVariant invokeMethodEx(Method, int, const QVariantList &) { return QVariant(); }
+ QVariant invokeMethodEx(Method, int, const QVariantList&);
- // table2 interface
- virtual QAccessibleTable2CellInterface *cellAt(int row, int column) const;
- virtual QAccessibleInterface *caption() const;
- virtual QAccessibleInterface *summary() const;
+ // Table2 interface
+ virtual QAccessibleTable2CellInterface* cellAt(int row, int column) const;
+ virtual QAccessibleInterface* caption() const;
+ virtual QAccessibleInterface* summary() const;
virtual QString columnDescription(int column) const;
virtual QString rowDescription(int row) const;
virtual int columnCount() const;
virtual int rowCount() const;
virtual QAccessible2::TableModelChange modelChange() const;
-
- //Table
virtual void rowsInserted(const QModelIndex&, int, int) {}
virtual void rowsRemoved(const QModelIndex&, int, int) {}
virtual void columnsInserted(const QModelIndex&, int, int) {}
virtual void rowsMoved(const QModelIndex&, int, int, const QModelIndex&, int) {}
virtual void columnsMoved(const QModelIndex&, int, int, const QModelIndex&, int) {}
- // selection
+ // Selection
virtual int selectedCellCount() const;
virtual int selectedColumnCount() const;
virtual int selectedRowCount() const;
virtual bool unselectRow(int row);
virtual bool unselectColumn(int column);
- KItemListView *view() const;
+ KItemListView* view() const;
protected:
virtual void modelReset();
-
-protected:
- inline QAccessibleTable2CellInterface *cell(int index) const;
- inline QAccessible::Role cellRole() const {
- /*
- switch (m_role) {
- case QAccessible::List:
- return QAccessible::ListItem;
- case QAccessible::Table:
- return QAccessible::Cell;
- case QAccessible::Tree:
- return QAccessible::TreeItem;
- default:
- Q_ASSERT(0);
- }
- return QAccessible::NoRole;
- */
- return QAccessible::Cell;
- }
-
-private:
- //QAccessible::Role m_role;
- // the child index for a model index
- //inline int logicalIndex(const QModelIndex &index) const;
- // the model index from the child index
- //QAccessibleInterface *childFromLogical(int logicalIndex) const;
+ /**
+ * Create an QAccessibleTable2CellInterface representing the table
+ * cell at the @index. Index is 0-based.
+ */
+ inline QAccessibleTable2CellInterface* cell(int index) const;
+ inline QAccessible::Role cellRole() const;
};
-class KItemListWidgetAccessible: public QAccessibleTable2CellInterface
+class KItemListAccessibleCell: public QAccessibleTable2CellInterface
{
public:
- KItemListWidgetAccessible(KItemListView *view, int m_index);
+ KItemListAccessibleCell(KItemListView* view, int m_index);
- QObject *object() const { return 0; }
- Role role(int child) const;
- State state(int child) const;
- QRect rect(int child) const;
+ QObject* object() const;
+ Role role(int) const;
+ State state(int) const;
+ QRect rect(int) const;
bool isValid() const;
-
- int childAt(int, int) const { return 0; }
- int childCount() const { return 0; }
- int indexOfChild(const QAccessibleInterface *) const { return -1; }
-
+ int childAt(int, int) const;
+ int childCount() const;
+ int indexOfChild(const QAccessibleInterface*) const;
QString text(Text t, int child) const;
- void setText(Text t, int child, const QString &text);
-
- int navigate(RelationFlag relation, int m_index, QAccessibleInterface **iface) const;
- Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const;
-
+ void setText(Text t, int child, const QString& text);
+ int navigate(RelationFlag relation, int m_index, QAccessibleInterface** interface) const;
+ Relation relationTo(int child, const QAccessibleInterface* other, int otherChild) const;
bool isExpandable() const;
#ifndef QT_NO_ACTION
int userActionCount(int child) const;
QString actionText(int action, Text t, int child) const;
- bool doAction(int action, int child, const QVariantList ¶ms);
+ bool doAction(int action, int child, const QVariantList& params);
#endif
- // cell interface
+ // Cell Interface
virtual int columnExtent() const;
virtual QList<QAccessibleInterface*> columnHeaderCells() const;
virtual int columnIndex() const;
virtual QList<QAccessibleInterface*> rowHeaderCells() const;
virtual int rowIndex() const;
virtual bool isSelected() const;
- virtual void rowColumnExtents(int *row, int *column, int *rowExtents, int *columnExtents, bool *selected) const;
+ virtual void rowColumnExtents(int* row, int* column, int* rowExtents, int* columnExtents, bool* selected) const;
virtual QAccessibleTable2Interface* table() const;
- inline int getIndex() const
- { return index; }
+ inline int index() const;
private:
- QPointer<KItemListView > view;
- int index;
- KItemListWidget *widget;
-
-friend class KItemListViewAccessible;
-//friend class QAccessibleTree;
+ QPointer<KItemListView> m_view;
+ int m_index;
};
class KItemListContainerAccessible : public QAccessibleWidgetEx
{
Q_ACCESSIBLE_OBJECT
+
public:
- explicit KItemListContainerAccessible(KItemListContainer*);
- virtual ~KItemListContainerAccessible();
- int childCount () const;
- int indexOfChild ( const QAccessibleInterface * child ) const;
- int navigate ( RelationFlag relation, int entry, QAccessibleInterface ** target ) const;
+ explicit KItemListContainerAccessible(KItemListContainer* container);
+ virtual ~KItemListContainerAccessible();
+
+ int childCount() const;
+ int indexOfChild(const QAccessibleInterface* child) const;
+ int navigate(RelationFlag relation, int entry, QAccessibleInterface** target) const;
private:
- inline KItemListContainer *container() const {
- return static_cast<KItemListContainer *>(object());
- }
+ const KItemListContainer* container() const;
};
-#endif // QT_NO_ITEMVIEWS
-
#endif // QT_NO_ACCESSIBILITY
-#endif // ACCESSIBLE_ITEMVIEWS_H
+#endif