Qt 4.8
itemviews.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the plugins of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef ACCESSIBLE_ITEMVIEWS_H
43 #define ACCESSIBLE_ITEMVIEWS_H
44 
45 #include "QtCore/qpointer.h"
46 
47 #include <QtGui/qabstractitemview.h>
48 #include <QtGui/qheaderview.h>
49 #include <QtGui/qaccessible.h>
50 #include <QtGui/qaccessible2.h>
51 #include <QtGui/qaccessiblewidget.h>
52 
53 
55 
56 #ifndef QT_NO_ACCESSIBILITY
57 
58 #ifndef QT_NO_ITEMVIEWS
59 
62 
64 {
66 public:
67  explicit QAccessibleTable2(QWidget *w);
68 
69  virtual ~QAccessibleTable2();
70 
71  Role role(int child) const;
72  State state(int child) const;
73  QString text(Text t, int child) const;
74  QRect rect(int child) const;
75 
76  int childAt(int x, int y) const;
77  int childCount() const;
78  int indexOfChild(const QAccessibleInterface *) const;
79 
80  int navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const;
81  Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const;
82 
83 #ifndef QT_NO_ACTION
84  int userActionCount(int child) const;
85  QString actionText(int action, Text t, int child) const;
86  bool doAction(int action, int child, const QVariantList &params);
87 #endif
88  QVariant invokeMethodEx(Method, int, const QVariantList &) { return QVariant(); }
89 
90  // table2 interface
91  virtual QAccessibleTable2CellInterface *cellAt(int row, int column) const;
92  virtual QAccessibleInterface *caption() const;
93  virtual QAccessibleInterface *summary() const;
94  virtual QString columnDescription(int column) const;
95  virtual QString rowDescription(int row) const;
96  virtual int columnCount() const;
97  virtual int rowCount() const;
99 
100  // selection
101  virtual int selectedCellCount() const;
102  virtual int selectedColumnCount() const;
103  virtual int selectedRowCount() const;
105  virtual QList<int> selectedColumns() const;
106  virtual QList<int> selectedRows() const;
107  virtual bool isColumnSelected(int column) const;
108  virtual bool isRowSelected(int row) const;
109  virtual bool selectRow(int row);
110  virtual bool selectColumn(int column);
111  virtual bool unselectRow(int row);
112  virtual bool unselectColumn(int column);
113 
114  QAbstractItemView *view() const;
115 
116 protected:
117  virtual void modelReset();
118  virtual void rowsInserted(const QModelIndex &parent, int first, int last);
119  virtual void rowsRemoved(const QModelIndex &parent, int first, int last);
120  virtual void columnsInserted(const QModelIndex &parent, int first, int last);
121  virtual void columnsRemoved(const QModelIndex &parent, int first, int last);
122  virtual void rowsMoved( const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row);
123  virtual void columnsMoved( const QModelIndex &parent, int start, int end, const QModelIndex &destination, int column);
124 
125 protected:
127  inline QAccessibleTable2Cell *cell(const QModelIndex &index) const;
128  inline QAccessible::Role cellRole() const {
129  switch (m_role) {
130  case QAccessible::List:
131  return QAccessible::ListItem;
132  case QAccessible::Table:
133  return QAccessible::Cell;
134  case QAccessible::Tree:
135  return QAccessible::TreeItem;
136  default:
137  Q_ASSERT(0);
138  }
139  return QAccessible::NoRole;
140  }
141 
142  QHeaderView *horizontalHeader() const;
143  QHeaderView *verticalHeader() const;
144 private:
145  // the child index for a model index
146  inline int logicalIndex(const QModelIndex &index) const;
147  // the model index from the child index
148  QAccessibleInterface *childFromLogical(int logicalIndex) const;
150 };
151 
153 {
154 public:
156  : QAccessibleTable2(w)
157  {}
158 
159  virtual ~QAccessibleTree() {}
160 
161  int childAt(int x, int y) const;
162  int childCount() const;
163  int indexOfChild(const QAccessibleInterface *) const;
164 
165  int rowCount() const;
166 
167  int navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const;
168  Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const;
169 
170  // table2 interface
171  QAccessibleTable2CellInterface *cellAt(int row, int column) const;
172  QString rowDescription(int row) const;
173  bool isRowSelected(int row) const;
174  bool selectRow(int row);
175 
176 private:
177  QModelIndex indexFromLogical(int row, int column = 0) const;
178 };
179 
180 class QAccessibleTable2Cell: public QAccessibleTable2CellInterface /*), public QAccessibleTextInterface, public QAccessibleSimpleEditableTextInterface*/
181 {
182 public:
184 
185  QObject *object() const { return 0; }
186  Role role(int child) const;
187  State state(int child) const;
188  QRect rect(int child) const;
189  bool isValid() const;
190 
191  int childAt(int, int) const { return 0; }
192  int childCount() const { return 0; }
193  int indexOfChild(const QAccessibleInterface *) const { return -1; }
194 
195  QString text(Text t, int child) const;
196  void setText(Text t, int child, const QString &text);
197 
198  int navigate(RelationFlag relation, int m_index, QAccessibleInterface **iface) const;
199  Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const;
200 
201  bool isExpandable() const;
202 
203 #ifndef QT_NO_ACTION
204  int userActionCount(int child) const;
205  QString actionText(int action, Text t, int child) const;
206  bool doAction(int action, int child, const QVariantList &params);
207 #endif
208 
209  // cell interface
210  virtual int columnExtent() const;
211  virtual QList<QAccessibleInterface*> columnHeaderCells() const;
212  virtual int columnIndex() const;
213  virtual int rowExtent() const;
214  virtual QList<QAccessibleInterface*> rowHeaderCells() const;
215  virtual int rowIndex() const;
216  virtual bool isSelected() const;
217  virtual void rowColumnExtents(int *row, int *column, int *rowExtents, int *columnExtents, bool *selected) const;
218  virtual QAccessibleTable2Interface* table() const;
219 
220 private:
221  QHeaderView *verticalHeader() const;
222  QHeaderView *horizontalHeader() const;
226 
227 friend class QAccessibleTable2;
228 friend class QAccessibleTree;
229 };
230 
231 
232 class QAccessibleTable2HeaderCell: public QAccessibleInterface /*), public QAccessibleTextInterface, public QAccessibleSimpleEditableTextInterface*/
233 {
234 public:
235  // For header cells, pass the header view in addition
237 
238  QObject *object() const { return 0; }
239  Role role(int child) const;
240  State state(int child) const;
241  QRect rect(int child) const;
242  bool isValid() const;
243 
244  int childAt(int, int) const { return 0; }
245  int childCount() const { return 0; }
246  int indexOfChild(const QAccessibleInterface *) const { return -1; }
247 
248  QString text(Text t, int child) const;
249  void setText(Text t, int child, const QString &text);
250 
251  int navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const;
252  Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const;
253 
254 #ifndef QT_NO_ACTION
255  int userActionCount(int child) const;
256  QString actionText(int action, Text t, int child) const;
257  bool doAction(int action, int child, const QVariantList &params);
258 #endif
259 
260 private:
262  int index;
264 
265 friend class QAccessibleTable2;
266 friend class QAccessibleTree;
267 };
268 
269 // This is the corner button on the top left of a table.
270 // It can be used to select all cells or it is not active at all.
271 // For now it is ignored.
273 {
274 public:
276  :view(view_)
277  {}
278 
279  QObject *object() const { return 0; }
280  Role role(int child) const { Q_ASSERT(child == 0); return QAccessible::Pane; }
281  State state(int child) const { Q_ASSERT(child == 0); return QAccessible::Normal; }
282  QRect rect(int child) const { Q_ASSERT(child == 0); return QRect(); }
283  bool isValid() const { return true; }
284 
285  int childAt(int, int) const { return 0; }
286  int childCount() const { return 0; }
287  int indexOfChild(const QAccessibleInterface *) const { return -1; }
288 
289  QString text(Text, int) const { return QString(); }
290  void setText(Text, int, const QString &) {}
291 
292  int navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const
293  {
294  if (relation == QAccessible::Ancestor && index == 1) {
296  return 0;
297  }
298  return -1;
299  }
300  Relation relationTo(int, const QAccessibleInterface *, int) const
301  {
302  return QAccessible::Unrelated;
303  }
304 
305 #ifndef QT_NO_ACTION
306  int userActionCount(int) const { return 0; }
307  QString actionText(int, Text, int) const { return QString(); }
308  bool doAction(int, int, const QVariantList &) { return false; }
309 #endif
310 private:
312 };
313 
314 
315 #endif
316 
317 #endif // QT_NO_ACCESSIBILITY
318 
320 
321 #endif // ACCESSIBLE_ITEMVIEWS_H
virtual void columnsMoved(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int column)
Definition: itemviews.cpp:220
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
virtual void rowsRemoved(const QModelIndex &parent, int first, int last)
Definition: itemviews.cpp:184
Role role(int child) const
Returns the role of the object, or of the object&#39;s child if child is not 0.
Definition: itemviews.cpp:407
QAccessible::Role m_role
Definition: itemviews.h:149
virtual ~QAccessibleTable2()
Definition: itemviews.cpp:140
QAccessible::Role cellRole() const
Definition: itemviews.h:128
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
virtual QList< int > selectedRows() const
Definition: itemviews.cpp:326
int childCount() const
Returns the number of children that belong to this object.
Definition: itemviews.cpp:434
virtual ~QAccessibleTree()
Definition: itemviews.h:159
virtual bool selectColumn(int column)
Definition: itemviews.cpp:367
virtual int rowCount() const
Definition: itemviews.cpp:269
QAbstractItemView * view
Definition: itemviews.h:311
bool doAction(int, int, const QVariantList &)
Asks the object, or the object&#39;s child if child is not 0, to execute action using the parameters...
Definition: itemviews.h:308
virtual int selectedCellCount() const
Definition: itemviews.cpp:276
virtual void rowsMoved(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row)
Definition: itemviews.cpp:211
QAbstractItemView * view() const
Definition: itemviews.cpp:70
Role
This enum defines the role of an accessible object.
Definition: qaccessible.h:188
QAccessibleTable2Cell * cell(const QModelIndex &index) const
Definition: itemviews.cpp:229
QAccessibleTree(QWidget *w)
Definition: itemviews.h:155
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
virtual QAccessible2::TableModelChange modelChange() const
Definition: itemviews.cpp:400
QRect rect(int child) const
Returns the geometry of the object, or of the object&#39;s child if child is not 0.
Definition: itemviews.cpp:475
virtual QList< QAccessibleTable2CellInterface * > selectedCells() const
Definition: itemviews.cpp:304
int userActionCount(int child) const
Returns the number of custom actions of the object, or of the object&#39;s child if child is not 0...
Definition: itemviews.cpp:519
State state(int child) const
Returns the current state of the object, or of the object&#39;s child if child is not 0...
Definition: itemviews.cpp:415
int logicalIndex(const QModelIndex &index) const
Definition: itemviews.cpp:75
int indexOfChild(const QAccessibleInterface *) const
Returns the 1-based index of the object child in this object&#39;s children list, or -1 if child is not a...
Definition: itemviews.h:193
The QString class provides a Unicode character string.
Definition: qstring.h:83
State state(int child) const
Returns the current state of the object, or of the object&#39;s child if child is not 0...
Definition: itemviews.h:281
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
QModelIndex m_index
Definition: itemviews.h:224
int childAt(int, int) const
Returns the 1-based index of the child that contains the screen coordinates (x, y).
Definition: itemviews.h:285
void setText(Text t, int child, const QString &text)
Sets the text property t of the object, or of the object&#39;s child if child is not 0, to text.
QAccessible2::TableModelChange lastChange
Definition: itemviews.h:126
QHeaderView * verticalHeader() const
Definition: itemviews.cpp:160
QString text(Text t, int child) const
Returns the value of the text property t of the object, or of the object&#39;s child if child is not 0...
Definition: itemviews.cpp:467
virtual int columnCount() const
Definition: itemviews.cpp:262
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
int userActionCount(int) const
Returns the number of custom actions of the object, or of the object&#39;s child if child is not 0...
Definition: itemviews.h:306
QAccessible::Role m_role
Definition: itemviews.h:225
int childCount() const
Returns the number of children that belong to this object.
Definition: itemviews.h:286
int childCount() const
Returns the number of children that belong to this object.
Definition: itemviews.h:245
virtual bool unselectColumn(int column)
Definition: itemviews.cpp:389
RelationFlag
This enum type defines bit flags that can be combined to indicate the relationship between two access...
Definition: qaccessible.h:268
Method
This enum describes the possible types of methods that can be invoked on an accessible object...
Definition: qaccessible.h:311
virtual int selectedRowCount() const
Definition: itemviews.cpp:290
#define Q_ACCESSIBLE_OBJECT
Definition: qaccessible2.h:108
virtual QList< int > selectedColumns() const
Definition: itemviews.cpp:315
Qt::Orientation orientation
Definition: itemviews.h:263
virtual bool isRowSelected(int row) const
Definition: itemviews.cpp:349
int navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const
Navigates from this object to an object that has a relationship relation to this object, and returns the respective object in target.
Definition: itemviews.cpp:484
virtual QAccessibleInterface * caption() const
Definition: itemviews.cpp:250
virtual void rowsInserted(const QModelIndex &parent, int first, int last)
Definition: itemviews.cpp:175
The State element defines configurations of objects and properties.
virtual bool selectRow(int row)
Definition: itemviews.cpp:356
Relation relationTo(int, const QAccessibleInterface *, int) const
Returns the relationship between this object&#39;s \a child and the \a other object&#39;s \a otherChild...
Definition: itemviews.h:300
virtual int selectedColumnCount() const
Definition: itemviews.cpp:283
virtual QString columnDescription(int column) const
Definition: itemviews.cpp:255
QObject * object() const
Returns a pointer to the QObject this interface implementation provides information for...
Definition: itemviews.h:238
static QAccessibleInterface * queryAccessibleInterface(QObject *)
If a QAccessibleInterface implementation exists for the given object, this function returns a pointer...
QAbstractItemView * view
Definition: itemviews.h:261
The QAbstractItemView class provides the basic functionality for item view classes.
QObject * object() const
Returns a pointer to the QObject this interface implementation provides information for...
Definition: itemviews.h:185
QObject * object() const
Returns a pointer to the QObject this interface implementation provides information for...
Definition: itemviews.h:279
int navigate(RelationFlag relation, int index, QAccessibleInterface **iface) const
Navigates from this object to an object that has a relationship relation to this object, and returns the respective object in target.
Definition: itemviews.h:292
bool isValid() const
Returns true if all the data necessary to use this interface implementation is valid (e...
Definition: itemviews.h:283
QHeaderView * horizontalHeader() const
Definition: itemviews.cpp:144
int indexOfChild(const QAccessibleInterface *) const
Returns the 1-based index of the object child in this object&#39;s children list, or -1 if child is not a...
Definition: itemviews.h:246
The QAccessibleInterface class defines an interface that exposes information about accessible objects...
Definition: qaccessible.h:370
int childAt(int, int) const
Returns the 1-based index of the child that contains the screen coordinates (x, y).
Definition: itemviews.h:244
int indexOfChild(const QAccessibleInterface *) const
Returns the 1-based index of the object child in this object&#39;s children list, or -1 if child is not a...
Definition: itemviews.h:287
virtual void columnsRemoved(const QModelIndex &parent, int first, int last)
Definition: itemviews.cpp:202
QString text(Text, int) const
Returns the value of the text property t of the object, or of the object&#39;s child if child is not 0...
Definition: itemviews.h:289
QRect rect(int child) const
Returns the geometry of the object, or of the object&#39;s child if child is not 0.
Definition: itemviews.h:282
The QModelIndex class is used to locate data in a data model.
virtual bool unselectRow(int row)
Definition: itemviews.cpp:378
virtual bool isColumnSelected(int column) const
Definition: itemviews.cpp:342
int childCount() const
Returns the number of children that belong to this object.
Definition: itemviews.h:192
QAccessibleTable2CornerButton(QAbstractItemView *view_)
Definition: itemviews.h:275
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
virtual void modelReset()
Definition: itemviews.cpp:172
int childAt(int, int) const
Returns the 1-based index of the child that contains the screen coordinates (x, y).
Definition: itemviews.h:191
Role role(int child) const
Returns the role of the object, or of the object&#39;s child if child is not 0.
Definition: itemviews.h:280
quint16 index
Relation relationTo(int child, const QAccessibleInterface *other, int otherChild) const
Returns the relationship between this object&#39;s \a child and the \a other object&#39;s \a otherChild...
Definition: itemviews.cpp:513
QPointer< QAbstractItemView > view
Definition: itemviews.h:223
bool isValid() const
Returns true if all the data necessary to use this interface implementation is valid (e...
virtual QString rowDescription(int row) const
Definition: itemviews.cpp:297
void setText(Text, int, const QString &)
Sets the text property t of the object, or of the object&#39;s child if child is not 0, to text.
Definition: itemviews.h:290
int childAt(int x, int y) const
Returns the 1-based index of the child that contains the screen coordinates (x, y).
Definition: itemviews.cpp:421
QAccessibleTable2(QWidget *w)
Definition: itemviews.cpp:123
static const KeyPair *const end
Orientation
Definition: qnamespace.h:174
int indexOfChild(const QAccessibleInterface *) const
Returns the 1-based index of the object child in this object&#39;s children list, or -1 if child is not a...
Definition: itemviews.cpp:443
QString actionText(int action, Text t, int child) const
Returns the text property t of the action action supported by the object, or of the object&#39;s child if...
Definition: itemviews.cpp:523
virtual QAccessibleTable2CellInterface * cellAt(int row, int column) const
Definition: itemviews.cpp:236
QString actionText(int, Text, int) const
Returns the text property t of the action action supported by the object, or of the object&#39;s child if...
Definition: itemviews.h:307
QAccessibleInterface * childFromLogical(int logicalIndex) const
Definition: itemviews.cpp:85
bool doAction(int action, int child, const QVariantList &params)
Asks the object, or the object&#39;s child if child is not 0, to execute action using the parameters...
Definition: itemviews.cpp:527
The QHeaderView class provides a header row or header column for item views.
Definition: qheaderview.h:58
QVariant invokeMethodEx(Method, int, const QVariantList &)
Definition: itemviews.h:88
The Text item allows you to add formatted text to a scene.
virtual QAccessibleInterface * summary() const
Definition: itemviews.cpp:337
virtual void columnsInserted(const QModelIndex &parent, int first, int last)
Definition: itemviews.cpp:193