summaryrefslogtreecommitdiffstats
path: root/application/groupview/AccessibleGroupView.cpp
blob: 9a1bb82166a05007203753a1d7cfa8fd5e739a30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
#include "GroupView.h"
#include "AccessibleGroupView.h"
#include "AccessibleGroupView_p.h"

#include <qvariant.h>
#include <qaccessible.h>
#include <qheaderview.h>

QAccessibleInterface *groupViewAccessibleFactory(const QString &classname, QObject *object)
{
    QAccessibleInterface *iface = 0;
    if (!object || !object->isWidgetType())
        return iface;

    QWidget *widget = static_cast<QWidget*>(object);

    if (classname == QLatin1String("GroupView")) {
        iface = new AccessibleGroupView((GroupView *)widget);
    }
    return iface;
}


QAbstractItemView *AccessibleGroupView::view() const
{
    return qobject_cast<QAbstractItemView*>(object());
}

int AccessibleGroupView::logicalIndex(const QModelIndex &index) const
{
    if (!view()->model() || !index.isValid())
        return -1;
    return index.row() * (index.model()->columnCount()) + index.column();
}

AccessibleGroupView::AccessibleGroupView(QWidget *w)
    : QAccessibleObject(w)
{
    Q_ASSERT(view());
}

bool AccessibleGroupView::isValid() const
{
    return view();
}

AccessibleGroupView::~AccessibleGroupView()
{
    for (QAccessible::Id id : childToId) {
        QAccessible::deleteAccessibleInterface(id);
    }
}

QAccessibleInterface *AccessibleGroupView::cellAt(int row, int column) const
{
    if (!view()->model()) {
        return 0;
    }

    QModelIndex index = view()->model()->index(row, column, view()->rootIndex());
    if (Q_UNLIKELY(!index.isValid())) {
        qWarning() << "AccessibleGroupView::cellAt: invalid index: " << index << " for " << view();
        return 0;
    }

    return child(logicalIndex(index));
}

QAccessibleInterface *AccessibleGroupView::caption() const
{
    return 0;
}

QString AccessibleGroupView::columnDescription(int column) const
{
    if (!view()->model())
        return QString();

    return view()->model()->headerData(column, Qt::Horizontal).toString();
}

int AccessibleGroupView::columnCount() const
{
    if (!view()->model())
        return 0;
    return 1;
}

int AccessibleGroupView::rowCount() const
{
    if (!view()->model())
        return 0;
    return view()->model()->rowCount();
}

int AccessibleGroupView::selectedCellCount() const
{
    if (!view()->selectionModel())
        return 0;
    return view()->selectionModel()->selectedIndexes().count();
}

int AccessibleGroupView::selectedColumnCount() const
{
    if (!view()->selectionModel())
        return 0;
    return view()->selectionModel()->selectedColumns().count();
}

int AccessibleGroupView::selectedRowCount() const
{
    if (!view()->selectionModel())
        return 0;
    return view()->selectionModel()->selectedRows().count();
}

QString AccessibleGroupView::rowDescription(int row) const
{
    if (!view()->model())
        return QString();
    return view()->model()->headerData(row, Qt::Vertical).toString();
}

QList<QAccessibleInterface *> AccessibleGroupView::selectedCells() const
{
    QList<QAccessibleInterface*> cells;
    if (!view()->selectionModel())
        return cells;
    const QModelIndexList selectedIndexes = view()->selectionModel()->selectedIndexes();
    cells.reserve(selectedIndexes.size());
    for (const QModelIndex &index : selectedIndexes)
        cells.append(child(logicalIndex(index)));
    return cells;
}

QList<int> AccessibleGroupView::selectedColumns() const
{
    if (!view()->selectionModel()) {
        return QList<int>();
    }

    const QModelIndexList selectedColumns = view()->selectionModel()->selectedColumns();

    QList<int> columns;
    columns.reserve(selectedColumns.size());
    for (const QModelIndex &index : selectedColumns) {
        columns.append(index.column());
    }

    return columns;
}

QList<int> AccessibleGroupView::selectedRows() const
{
    if (!view()->selectionModel()) {
        return QList<int>();
    }

    QList<int> rows;

    const QModelIndexList selectedRows = view()->selectionModel()->selectedRows();

    rows.reserve(selectedRows.size());
    for (const QModelIndex &index : selectedRows) {
        rows.append(index.row());
    }

    return rows;
}

QAccessibleInterface *AccessibleGroupView::summary() const
{
    return 0;
}

bool AccessibleGroupView::isColumnSelected(int column) const
{
    if (!view()->selectionModel()) {
        return false;
    }

    return view()->selectionModel()->isColumnSelected(column, QModelIndex());
}

bool AccessibleGroupView::isRowSelected(int row) const
{
    if (!view()->selectionModel()) {
        return false;
    }

    return view()->selectionModel()->isRowSelected(row, QModelIndex());
}

bool AccessibleGroupView::selectRow(int row)
{
    if (!view()->model() || !view()->selectionModel()) {
        return false;
    }
    QModelIndex index = view()->model()->index(row, 0, view()->rootIndex());

    if (!index.isValid() || view()->selectionBehavior() == QAbstractItemView::SelectColumns) {
        return false;
    }

    switch (view()->selectionMode()) {
        case QAbstractItemView::NoSelection: {
            return false;
        }
        case QAbstractItemView::SingleSelection: {
            if (view()->selectionBehavior() != QAbstractItemView::SelectRows && columnCount() > 1 )
                return false;
            view()->clearSelection();
            break;
        }
        case QAbstractItemView::ContiguousSelection: {
            if ((!row || !view()->selectionModel()->isRowSelected(row - 1, view()->rootIndex())) && !view()->selectionModel()->isRowSelected(row + 1, view()->rootIndex())) {
                view()->clearSelection();
            }
        break;
        }
        default: {
            break;
        }
    }

    view()->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Rows);
    return true;
}

bool AccessibleGroupView::selectColumn(int column)
{
    if (!view()->model() || !view()->selectionModel()) {
        return false;
    }
    QModelIndex index = view()->model()->index(0, column, view()->rootIndex());

    if (!index.isValid() || view()->selectionBehavior() == QAbstractItemView::SelectRows) {
        return false;
    }

    switch (view()->selectionMode()) {
        case QAbstractItemView::NoSelection: {
            return false;
        }
        case QAbstractItemView::SingleSelection: {
            if (view()->selectionBehavior() != QAbstractItemView::SelectColumns && rowCount() > 1) {
                return false;
            }
            // fallthrough intentional
        }
        case QAbstractItemView::ContiguousSelection: {
            if ((!column || !view()->selectionModel()->isColumnSelected(column - 1, view()->rootIndex())) && !view()->selectionModel()->isColumnSelected(column + 1, view()->rootIndex())) {
                view()->clearSelection();
            }
            break;
        }
        default: {
            break;
        }
    }

    view()->selectionModel()->select(index, QItemSelectionModel::Select | QItemSelectionModel::Columns);
    return true;
}

bool AccessibleGroupView::unselectRow(int row)
{
    if (!view()->model() || !view()->selectionModel()) {
        return false;
    }

    QModelIndex index = view()->model()->index(row, 0, view()->rootIndex());
    if (!index.isValid()) {
        return false;
    }

    QItemSelection selection(index, index);
    auto selectionModel = view()->selectionModel();

    switch (view()->selectionMode()) {
        case QAbstractItemView::SingleSelection:
            // no unselect
            if (selectedRowCount() == 1) {
                return false;
            }
            break;
        case QAbstractItemView::ContiguousSelection: {
            // no unselect
            if (selectedRowCount() == 1) {
                return false;
            }


            if ((!row || selectionModel->isRowSelected(row - 1, view()->rootIndex())) && selectionModel->isRowSelected(row + 1, view()->rootIndex())) {
                //If there are rows selected both up the current row and down the current rown,
                //the ones which are down the current row will be deselected
                selection = QItemSelection(index, view()->model()->index(rowCount() - 1, 0, view()->rootIndex()));
            }
        }
        default: {
            break;
        }
    }

    selectionModel->select(selection, QItemSelectionModel::Deselect | QItemSelectionModel::Rows);
    return true;
}

bool AccessibleGroupView::unselectColumn(int column)
{
    auto model = view()->model();
    if (!model || !view()->selectionModel()) {
        return false;
    }

    QModelIndex index = model->index(0, column, view()->rootIndex());
    if (!index.isValid()) {
        return false;
    }

    QItemSelection selection(index, index);

    switch (view()->selectionMode()) {
        case QAbstractItemView::SingleSelection: {
            //In SingleSelection and ContiguousSelection once an item
            //is selected, there's no way for the user to unselect all items
            if (selectedColumnCount() == 1) {
                return false;
            }
            break;
        }
        case QAbstractItemView::ContiguousSelection:
            if (selectedColumnCount() == 1) {
                return false;
            }

            if ((!column || view()->selectionModel()->isColumnSelected(column - 1, view()->rootIndex()))
                && view()->selectionModel()->isColumnSelected(column + 1, view()->rootIndex())) {
                //If there are columns selected both at the left of the current row and at the right
                //of the current row, the ones which are at the right will be deselected
                selection = QItemSelection(index, model->index(0, columnCount() - 1, view()->rootIndex()));
            }
        default:
            break;
    }

    view()->selectionModel()->select(selection, QItemSelectionModel::Deselect | QItemSelectionModel::Columns);
    return true;
}

QAccessible::Role AccessibleGroupView::role() const
{
    return QAccessible::List;
}

QAccessible::State AccessibleGroupView::state() const
{
    return QAccessible::State();
}

QAccessibleInterface *AccessibleGroupView::childAt(int x, int y) const
{
    QPoint viewportOffset = view()->viewport()->mapTo(view(), QPoint(0,0));
    QPoint indexPosition = view()->mapFromGlobal(QPoint(x, y) - viewportOffset);
    // FIXME: if indexPosition < 0 in one coordinate, return header

    QModelIndex index = view()->indexAt(indexPosition);
    if (index.isValid()) {
        return child(logicalIndex(index));
    }
    return 0;
}

int AccessibleGroupView::childCount() const
{
    if (!view()->model()) {
        return 0;
    }
    return (view()->model()->rowCount()) * (view()->model()->columnCount());
}

int AccessibleGroupView::indexOfChild(const QAccessibleInterface *iface) const
{
    if (!view()->model())
        return -1;
    QAccessibleInterface *parent = iface->parent();
    if (parent->object() != view())
        return -1;

    Q_ASSERT(iface->role() != QAccessible::TreeItem); // should be handled by tree class
    if (iface->role() == QAccessible::Cell || iface->role() == QAccessible::ListItem) {
        const AccessibleGroupViewItem* cell = static_cast<const AccessibleGroupViewItem*>(iface);
        return logicalIndex(cell->m_index);
    } else if (iface->role() == QAccessible::Pane) {
        return 0; // corner button
    } else {
        qWarning() << "AccessibleGroupView::indexOfChild has a child with unknown role..." << iface->role() << iface->text(QAccessible::Name);
    }
    // FIXME: we are in denial of our children. this should stop.
    return -1;
}

QString AccessibleGroupView::text(QAccessible::Text t) const
{
    if (t == QAccessible::Description)
        return view()->accessibleDescription();
    return view()->accessibleName();
}

QRect AccessibleGroupView::rect() const
{
    if (!view()->isVisible())
        return QRect();
    QPoint pos = view()->mapToGlobal(QPoint(0, 0));
    return QRect(pos.x(), pos.y(), view()->width(), view()->height());
}

QAccessibleInterface *AccessibleGroupView::parent() const
{
    if (view() && view()->parent()) {
        if (qstrcmp("QComboBoxPrivateContainer", view()->parent()->metaObject()->className()) == 0) {
            return QAccessible::queryAccessibleInterface(view()->parent()->parent());
        }
        return QAccessible::queryAccessibleInterface(view()->parent());
    }
    return 0;
}

QAccessibleInterface *AccessibleGroupView::child(int logicalIndex) const
{
    if (!view()->model())
        return 0;

    auto id = childToId.constFind(logicalIndex);
    if (id != childToId.constEnd())
        return QAccessible::accessibleInterface(id.value());

    int columns = view()->model()->columnCount();

    int row = logicalIndex / columns;
    int column = logicalIndex % columns;

    QAccessibleInterface *iface = 0;

    QModelIndex index = view()->model()->index(row, column, view()->rootIndex());
    if (Q_UNLIKELY(!index.isValid())) {
        qWarning("AccessibleGroupView::child: Invalid index at: %d %d", row, column);
        return 0;
    }
    iface = new AccessibleGroupViewItem(view(), index);

    QAccessible::registerAccessibleInterface(iface);
    childToId.insert(logicalIndex, QAccessible::uniqueId(iface));
    return iface;
}

void *AccessibleGroupView::interface_cast(QAccessible::InterfaceType t)
{
    if (t == QAccessible::TableInterface)
       return static_cast<QAccessibleTableInterface*>(this);
   return 0;
}

void AccessibleGroupView::modelChange(QAccessibleTableModelChangeEvent *event)
{
    // if there is no cache yet, we don't update anything
    if (childToId.isEmpty())
        return;

    switch (event->modelChangeType()) {
        case QAccessibleTableModelChangeEvent::ModelReset:
            for (QAccessible::Id id : childToId)
                QAccessible::deleteAccessibleInterface(id);
            childToId.clear();
            break;

        // rows are inserted: move every row after that
        case QAccessibleTableModelChangeEvent::RowsInserted:
        case QAccessibleTableModelChangeEvent::ColumnsInserted: {

            ChildCache newCache;
            ChildCache::ConstIterator iter = childToId.constBegin();

            while (iter != childToId.constEnd()) {
                QAccessible::Id id = iter.value();
                QAccessibleInterface *iface = QAccessible::accessibleInterface(id);
                Q_ASSERT(iface);
                if (indexOfChild(iface) >= 0) {
                    newCache.insert(indexOfChild(iface), id);
                } else {
                    // ### This should really not happen,
                    // but it might if the view has a root index set.
                    // This needs to be fixed.
                    QAccessible::deleteAccessibleInterface(id);
                }
                ++iter;
            }
            childToId = newCache;
            break;
        }

        case QAccessibleTableModelChangeEvent::ColumnsRemoved:
        case QAccessibleTableModelChangeEvent::RowsRemoved: {
            ChildCache newCache;
            ChildCache::ConstIterator iter = childToId.constBegin();
            while (iter != childToId.constEnd()) {
                QAccessible::Id id = iter.value();
                QAccessibleInterface *iface = QAccessible::accessibleInterface(id);
                Q_ASSERT(iface);
                if (iface->role() == QAccessible::Cell || iface->role() == QAccessible::ListItem) {
                    Q_ASSERT(iface->tableCellInterface());
                    AccessibleGroupViewItem *cell = static_cast<AccessibleGroupViewItem*>(iface->tableCellInterface());
                    // Since it is a QPersistentModelIndex, we only need to check if it is valid
                    if (cell->m_index.isValid())
                        newCache.insert(indexOfChild(cell), id);
                    else
                        QAccessible::deleteAccessibleInterface(id);
                }
                ++iter;
            }
            childToId = newCache;
            break;
        }

        case QAccessibleTableModelChangeEvent::DataChanged:
            // nothing to do in this case
            break;
    }
}

// TABLE CELL

AccessibleGroupViewItem::AccessibleGroupViewItem(QAbstractItemView *view_, const QModelIndex &index_)
    : view(view_), m_index(index_)
{
    if (Q_UNLIKELY(!index_.isValid()))
        qWarning() << "AccessibleGroupViewItem::AccessibleGroupViewItem with invalid index: " << index_;
}

void *AccessibleGroupViewItem::interface_cast(QAccessible::InterfaceType t)
{
    if (t == QAccessible::TableCellInterface)
        return static_cast<QAccessibleTableCellInterface*>(this);
    if (t == QAccessible::ActionInterface)
        return static_cast<QAccessibleActionInterface*>(this);
    return 0;
}

int AccessibleGroupViewItem::columnExtent() const { return 1; }
int AccessibleGroupViewItem::rowExtent() const { return 1; }

QList<QAccessibleInterface*> AccessibleGroupViewItem::rowHeaderCells() const
{
    return {};
}

QList<QAccessibleInterface*> AccessibleGroupViewItem::columnHeaderCells() const
{
    return {};
}

int AccessibleGroupViewItem::columnIndex() const
{
    if (!isValid()) {
        return -1;
    }

    return m_index.column();
}

int AccessibleGroupViewItem::rowIndex() const
{
    if (!isValid()) {
        return -1;
    }

    return m_index.row();
}

bool AccessibleGroupViewItem::isSelected() const
{
    if (!isValid()) {
        return false;
    }

    return view->selectionModel()->isSelected(m_index);
}

QStringList AccessibleGroupViewItem::actionNames() const
{
    QStringList names;
    names << toggleAction();
    return names;
}

void AccessibleGroupViewItem::doAction(const QString& actionName)
{
    if (actionName == toggleAction()) {
        if (isSelected()) {
            unselectCell();
        }
        else {
            selectCell();
        }
    }
}

QStringList AccessibleGroupViewItem::keyBindingsForAction(const QString &) const
{
    return QStringList();
}


void AccessibleGroupViewItem::selectCell()
{
    if (!isValid()) {
        return;
    }
    QAbstractItemView::SelectionMode selectionMode = view->selectionMode();
    if (selectionMode == QAbstractItemView::NoSelection) {
        return;
    }

    Q_ASSERT(table());
    QAccessibleTableInterface *cellTable = table()->tableInterface();

    switch (view->selectionBehavior()) {
        case QAbstractItemView::SelectItems:
            break;
        case QAbstractItemView::SelectColumns:
            if (cellTable)
                cellTable->selectColumn(m_index.column());
            return;
        case QAbstractItemView::SelectRows:
            if (cellTable)
                cellTable->selectRow(m_index.row());
            return;
    }

    if (selectionMode == QAbstractItemView::SingleSelection) {
        view->clearSelection();
    }

    view->selectionModel()->select(m_index, QItemSelectionModel::Select);
}

void AccessibleGroupViewItem::unselectCell()
{
    if (!isValid())
        return;
    QAbstractItemView::SelectionMode selectionMode = view->selectionMode();
    if (selectionMode == QAbstractItemView::NoSelection)
        return;

    QAccessibleTableInterface *cellTable = table()->tableInterface();

    switch (view->selectionBehavior()) {
        case QAbstractItemView::SelectItems:
            break;
        case QAbstractItemView::SelectColumns:
            if (cellTable)
                cellTable->unselectColumn(m_index.column());
            return;
        case QAbstractItemView::SelectRows:
            if (cellTable)
                cellTable->unselectRow(m_index.row());
            return;
    }

    //If the mode is not MultiSelection or ExtendedSelection and only
    //one cell is selected it cannot be unselected by the user
    if ((selectionMode != QAbstractItemView::MultiSelection) && (selectionMode != QAbstractItemView::ExtendedSelection) && (view->selectionModel()->selectedIndexes().count() <= 1))
        return;

    view->selectionModel()->select(m_index, QItemSelectionModel::Deselect);
}

QAccessibleInterface *AccessibleGroupViewItem::table() const
{
    return QAccessible::queryAccessibleInterface(view);
}

QAccessible::Role AccessibleGroupViewItem::role() const
{
    return QAccessible::ListItem;
}

QAccessible::State AccessibleGroupViewItem::state() const
{
    QAccessible::State st;
    if (!isValid())
        return st;

    QRect globalRect = view->rect();
    globalRect.translate(view->mapToGlobal(QPoint(0,0)));
    if (!globalRect.intersects(rect()))
        st.invisible = true;

    if (view->selectionModel()->isSelected(m_index))
        st.selected = true;
    if (view->selectionModel()->currentIndex() == m_index)
        st.focused = true;
    if (m_index.model()->data(m_index, Qt::CheckStateRole).toInt() == Qt::Checked)
        st.checked = true;

    Qt::ItemFlags flags = m_index.flags();
    if (flags & Qt::ItemIsSelectable) {
        st.selectable = true;
        st.focusable = true;
        if (view->selectionMode() == QAbstractItemView::MultiSelection)
            st.multiSelectable = true;
        if (view->selectionMode() == QAbstractItemView::ExtendedSelection)
            st.extSelectable = true;
    }
    return st;
}


QRect AccessibleGroupViewItem::rect() const
{
    QRect r;
    if (!isValid())
        return r;
    r = view->visualRect(m_index);

    if (!r.isNull()) {
        r.translate(view->viewport()->mapTo(view, QPoint(0,0)));
        r.translate(view->mapToGlobal(QPoint(0, 0)));
    }
    return r;
}

QString AccessibleGroupViewItem::text(QAccessible::Text t) const
{
    QString value;
    if (!isValid())
        return value;
    QAbstractItemModel *model = view->model();
    switch (t) {
        case QAccessible::Name:
            value = model->data(m_index, Qt::AccessibleTextRole).toString();
            if (value.isEmpty())
                value = model->data(m_index, Qt::DisplayRole).toString();
            break;
        case QAccessible::Description:
            value = model->data(m_index, Qt::AccessibleDescriptionRole).toString();
            break;
        default:
            break;
    }
    return value;
}

void AccessibleGroupViewItem::setText(QAccessible::Text /*t*/, const QString &text)
{
    if (!isValid() || !(m_index.flags() & Qt::ItemIsEditable))
        return;
    view->model()->setData(m_index, text);
}

bool AccessibleGroupViewItem::isValid() const
{
    return view && view->model() && m_index.isValid();
}

QAccessibleInterface *AccessibleGroupViewItem::parent() const
{
    return QAccessible::queryAccessibleInterface(view);
}

QAccessibleInterface *AccessibleGroupViewItem::child(int) const
{
    return 0;
}