From 8c3e5700a14ff52c2dfff5ab1b1fb47d7240aa02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lund=20Martsum?= Date: Sat, 10 Mar 2012 14:31:15 +0100 Subject: Add two (forgotten) since 5.0 SHA for QWidget::hasHeightForWidth change: 466107107a85e7211c4b7f77b36ec50625657061 SHA for QAbstractItemDelegate::destoryeditor change 15f253a46aa45e2a9fa1055799fa2768ba49b9a3 Change-Id: Ic7e38c15f62eef22ab95414fad6e7b6c9c7d4f59 Reviewed-by: Girish Ramakrishnan Reviewed-by: Stephen Kelly --- src/widgets/itemviews/qabstractitemdelegate.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/widgets/itemviews') diff --git a/src/widgets/itemviews/qabstractitemdelegate.cpp b/src/widgets/itemviews/qabstractitemdelegate.cpp index 6184a5845a..ecba3e238f 100644 --- a/src/widgets/itemviews/qabstractitemdelegate.cpp +++ b/src/widgets/itemviews/qabstractitemdelegate.cpp @@ -243,6 +243,8 @@ QWidget *QAbstractItemDelegate::createEditor(QWidget *, /*! + \since 5.0 + A function called when the editor is no longer needed and should be destroyed. The default behavior is a call to deleteLater on the editor. It possible e.g. to avoid this delete by reimplementing this function. -- cgit v1.2.3 From b64426248d2212eb59535b2ca383d30fdb5e1c7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lund=20Martsum?= Date: Sat, 3 Mar 2012 06:05:54 +0100 Subject: QHeaderView - renaming functions in Qt5 This patch renames the functions in Qt5 according to the notes. It also renames resizeMode to be consistent. The old functions are both marked with both QT_DEPRECATED and '### Qt 6 - remove' All usage of the function within the qtbase are also changed to use the new functions. Change-Id: I9e05fa41d232e9ca43b945fcc949987017f3aedd Reviewed-by: Stephen Kelly --- src/widgets/itemviews/qheaderview.cpp | 124 ++++++++++++++++++++++++---------- src/widgets/itemviews/qheaderview.h | 27 ++++++-- src/widgets/itemviews/qtableview.cpp | 4 +- src/widgets/itemviews/qtreeview.cpp | 4 +- src/widgets/itemviews/qtreewidget.cpp | 2 +- 5 files changed, 115 insertions(+), 46 deletions(-) (limited to 'src/widgets/itemviews') diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index eac543d37d..766d7ce6b6 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -120,9 +120,9 @@ QDataStream &operator>>(QDataStream &in, QHeaderViewPrivate::SectionSpan &span) \section1 Moving Header Sections - A header can be fixed in place, or made movable with setMovable(). It can - be made clickable with setClickable(), and has resizing behavior in - accordance with setResizeMode(). + A header can be fixed in place, or made movable with setSectionsMovable(). It can + be made clickable with setSectionsClickable(), and has resizing behavior in + accordance with setResizeMode() and setSectionResizeMode() \note Double-clicking on a header to resize a section only applies for visible rows. @@ -185,7 +185,7 @@ QDataStream &operator>>(QDataStream &in, QHeaderViewPrivate::SectionSpan &span) The following values are obsolete: \value Custom Use Fixed instead. - \sa setResizeMode() stretchLastSection minimumSectionSize + \sa setResizeMode() setSectionResizeMode() stretchLastSection minimumSectionSize */ /*! @@ -216,7 +216,7 @@ QDataStream &operator>>(QDataStream &in, QHeaderViewPrivate::SectionSpan &span) This signal is emitted when a section is pressed. The section's logical index is specified by \a logicalIndex. - \sa setClickable() + \sa setSectionsClickable() */ /*! @@ -227,7 +227,7 @@ QDataStream &operator>>(QDataStream &in, QHeaderViewPrivate::SectionSpan &span) Note that the sectionPressed signal will also be emitted. - \sa setClickable(), sectionPressed() + \sa setSectionsClickable(), sectionPressed() */ /*! @@ -238,7 +238,7 @@ QDataStream &operator>>(QDataStream &in, QHeaderViewPrivate::SectionSpan &span) mouse button is pressed. The section's logical index is specified by \a logicalIndex. - \sa setClickable(), sectionPressed() + \sa setSectionsClickable(), sectionPressed() */ /*! @@ -247,7 +247,7 @@ QDataStream &operator>>(QDataStream &in, QHeaderViewPrivate::SectionSpan &span) This signal is emitted when a section is double-clicked. The section's logical index is specified by \a logicalIndex. - \sa setClickable() + \sa setSectionsClickable() */ /*! @@ -266,7 +266,7 @@ QDataStream &operator>>(QDataStream &in, QHeaderViewPrivate::SectionSpan &span) This signal is emitted when a section is double-clicked. The section's logical index is specified by \a logicalIndex. - \sa setClickable() + \sa setSectionsClickable() */ /*! @@ -1085,62 +1085,98 @@ int QHeaderView::logicalIndex(int visualIndex) const } /*! - If \a movable is true, the header may be moved by the user; otherwise it + If \a sectionsMovable is true, the header may be moved by the user; otherwise it is fixed in place. - \sa isMovable(), sectionMoved() + \sa sectionsMovable(), sectionMoved() */ -// ### Qt 5: change to setSectionsMovable() -void QHeaderView::setMovable(bool movable) +void QHeaderView::setSectionsMovable(bool movable) { Q_D(QHeaderView); d->movableSections = movable; } +// ### Qt 6 - remove this obsolete function +/*! + \obsolete + \fn void QHeaderView::setMovable(bool movable) + + Use setSectionsMovable instead. + + \sa setSectionsMovable() +*/ + /*! Returns true if the header can be moved by the user; otherwise returns false. - \sa setMovable() + \sa setSectionsMovable() */ -// ### Qt 5: change to sectionsMovable() -bool QHeaderView::isMovable() const +bool QHeaderView::sectionsMovable() const { Q_D(const QHeaderView); return d->movableSections; } +// ### Qt 6 - remove this obsolete function +/*! + \obsolete + \fn bool QHeaderView::isMovable(bool movable) + + Use sectionsMovable instead. + + \sa sectionsMovable() +*/ + /*! If \a clickable is true, the header will respond to single clicks. - \sa isClickable(), sectionClicked(), sectionPressed(), + \sa sectionsClickable(), sectionClicked(), sectionPressed(), setSortIndicatorShown() */ -// ### Qt 5: change to setSectionsClickable() -void QHeaderView::setClickable(bool clickable) +void QHeaderView::setSectionsClickable(bool clickable) { Q_D(QHeaderView); d->clickableSections = clickable; } +// ### Qt 6 - remove this obsolete function +/*! + \obsolete + \fn void QHeaderView::setClickable(bool clickable) + + Use setSectionsClickable instead. + + \sa setSectionsClickable() +*/ + /*! Returns true if the header is clickable; otherwise returns false. A clickable header could be set up to allow the user to change the representation of the data in the view related to the header. - \sa setClickable() + \sa setSectionsClickable() */ -// ### Qt 5: change to sectionsClickable() -bool QHeaderView::isClickable() const +bool QHeaderView::sectionsClickable() const { Q_D(const QHeaderView); return d->clickableSections; } +// ### Qt 6 - remove this obsolete function +/*! + \obsolete + \fn bool QHeaderView::isClickable() const + + Use sectionsClickable instead. + + \sa sectionsClickable() +*/ + void QHeaderView::setHighlightSections(bool highlight) { Q_D(QHeaderView); @@ -1172,8 +1208,6 @@ void QHeaderView::setResizeMode(ResizeMode mode) } /*! - \overload - Sets the constraints on how the section specified by \a logicalIndex in the header can be resized to those described by the given \a mode. The logical index should exist at the time this function is called. @@ -1185,8 +1219,7 @@ void QHeaderView::setResizeMode(ResizeMode mode) \sa setStretchLastSection() */ -// ### Qt 5: change to setSectionResizeMode() -void QHeaderView::setResizeMode(int logicalIndex, ResizeMode mode) +void QHeaderView::setSectionResizeMode(int logicalIndex, ResizeMode mode) { Q_D(QHeaderView); int visual = visualIndex(logicalIndex); @@ -1208,6 +1241,17 @@ void QHeaderView::setResizeMode(int logicalIndex, ResizeMode mode) d->doDelayedResizeSections(); // section sizes may change as a result of the new mode } +// ### Qt 6 - remove this obsolete function +/*! + \overload + \obsolete + \fn void QHeaderView::setResizeMode(int logicalIndex, ResizeMode mode) + + Use setSectionResizeMode instead. + + \sa setSectionResizeMode() +*/ + /*! Returns the resize mode that applies to the section specified by the given \a logicalIndex. @@ -1215,7 +1259,7 @@ void QHeaderView::setResizeMode(int logicalIndex, ResizeMode mode) \sa setResizeMode() */ -QHeaderView::ResizeMode QHeaderView::resizeMode(int logicalIndex) const +QHeaderView::ResizeMode QHeaderView::sectionResizeMode(int logicalIndex) const { Q_D(const QHeaderView); int visual = visualIndex(logicalIndex); @@ -1224,6 +1268,16 @@ QHeaderView::ResizeMode QHeaderView::resizeMode(int logicalIndex) const return d->headerSectionResizeMode(visual); } +// ### Qt 6 - remove this obsolete function +/*! + \obsolete + \fn QHeaderView::ResizeMode QHeaderView::resizeMode(int logicalIndex) const + + Use sectionResizeMode instead. + + \sa sectionResizeMode() +*/ + /*! \since 4.1 @@ -1246,7 +1300,7 @@ int QHeaderView::stretchSectionCount() const By default, this property is false. - \sa setClickable() + \sa setSectionsClickable() */ void QHeaderView::setSortIndicatorShown(bool show) @@ -1299,8 +1353,8 @@ void QHeaderView::setSortIndicator(int logicalIndex, Qt::SortOrder order) } if (old != logicalIndex - && ((logicalIndex >= 0 && resizeMode(logicalIndex) == ResizeToContents) - || old >= d->sectionCount() || (old >= 0 && resizeMode(old) == ResizeToContents))) { + && ((logicalIndex >= 0 && sectionResizeMode(logicalIndex) == ResizeToContents) + || old >= d->sectionCount() || (old >= 0 && sectionResizeMode(old) == ResizeToContents))) { resizeSections(); d->viewport->update(); } else { @@ -2207,7 +2261,7 @@ void QHeaderView::mousePressEvent(QMouseEvent *e) updateSection(d->pressed); d->state = QHeaderViewPrivate::SelectSections; } - } else if (resizeMode(handle) == Interactive) { + } else if (sectionResizeMode(handle) == Interactive) { d->originalSize = sectionSize(handle); d->state = QHeaderViewPrivate::ResizeSection; d->section = handle; @@ -2289,7 +2343,7 @@ void QHeaderView::mouseMoveEvent(QMouseEvent *e) #ifndef QT_NO_CURSOR int handle = d->sectionHandleAt(pos); bool hasCursor = testAttribute(Qt::WA_SetCursor); - if (handle != -1 && (resizeMode(handle) == Interactive)) { + if (handle != -1 && (sectionResizeMode(handle) == Interactive)) { if (!hasCursor) setCursor(d->orientation == Qt::Horizontal ? Qt::SplitHCursor : Qt::SplitVCursor); } else if (hasCursor) { @@ -2360,7 +2414,7 @@ void QHeaderView::mouseDoubleClickEvent(QMouseEvent *e) Q_D(QHeaderView); int pos = d->orientation == Qt::Horizontal ? e->x() : e->y(); int handle = d->sectionHandleAt(pos); - if (handle > -1 && resizeMode(handle) == Interactive) { + if (handle > -1 && sectionResizeMode(handle) == Interactive) { emit sectionHandleDoubleClicked(handle); #ifndef QT_NO_CURSOR Qt::CursorShape splitCursor = (d->orientation == Qt::Horizontal) @@ -2368,7 +2422,7 @@ void QHeaderView::mouseDoubleClickEvent(QMouseEvent *e) if (cursor().shape() == splitCursor) { // signal handlers may have changed the section size handle = d->sectionHandleAt(pos); - if (!(handle > -1 && resizeMode(handle) == Interactive)) + if (!(handle > -1 && sectionResizeMode(handle) == Interactive)) setCursor(Qt::ArrowCursor); } #endif @@ -2673,7 +2727,7 @@ void QHeaderView::dataChanged(const QModelIndex &topLeft, const QModelIndex &bot int first = orientation() == Qt::Horizontal ? topLeft.column() : topLeft.row(); int last = orientation() == Qt::Horizontal ? bottomRight.column() : bottomRight.row(); for (int i = first; i <= last && !resizeRequired; ++i) - resizeRequired = (resizeMode(i) == ResizeToContents); + resizeRequired = (sectionResizeMode(i) == ResizeToContents); if (resizeRequired) d->doDelayedResizeSections(); } diff --git a/src/widgets/itemviews/qheaderview.h b/src/widgets/itemviews/qheaderview.h index d72b8cd735..bf686e2925 100644 --- a/src/widgets/itemviews/qheaderview.h +++ b/src/widgets/itemviews/qheaderview.h @@ -114,18 +114,33 @@ public: int visualIndex(int logicalIndex) const; int logicalIndex(int visualIndex) const; - void setMovable(bool movable); - bool isMovable() const; + void setSectionsMovable(bool movable); + bool sectionsMovable() const; +#if QT_DEPRECATED_SINCE(5, 0) + inline QT_DEPRECATED void setMovable(bool movable) { setSectionsMovable(movable); } + inline QT_DEPRECATED bool isMovable() const { return sectionsMovable(); } +#endif - void setClickable(bool clickable); - bool isClickable() const; + void setSectionsClickable(bool clickable); + bool sectionsClickable() const; +#if QT_DEPRECATED_SINCE(5, 0) + inline QT_DEPRECATED void setClickable(bool clickable) { setSectionsClickable(clickable); } + inline QT_DEPRECATED bool isClickable() const { return sectionsClickable(); } +#endif void setHighlightSections(bool highlight); bool highlightSections() const; void setResizeMode(ResizeMode mode); - void setResizeMode(int logicalIndex, ResizeMode mode); - ResizeMode resizeMode(int logicalIndex) const; + ResizeMode sectionResizeMode(int logicalIndex) const; + void setSectionResizeMode(int logicalIndex, ResizeMode mode); +#if QT_DEPRECATED_SINCE(5, 0) + inline QT_DEPRECATED void setResizeMode(int logicalindex, ResizeMode mode) + { setSectionResizeMode(logicalindex, mode); } + inline QT_DEPRECATED ResizeMode resizeMode(int logicalindex) const + { return sectionResizeMode(logicalindex); } +#endif + int stretchSectionCount() const; void setSortIndicatorShown(bool show); diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index d3bc826750..57f29641de 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -616,12 +616,12 @@ void QTableViewPrivate::init() q->setEditTriggers(editTriggers|QAbstractItemView::AnyKeyPressed); QHeaderView *vertical = new QHeaderView(Qt::Vertical, q); - vertical->setClickable(true); + vertical->setSectionsClickable(true); vertical->setHighlightSections(true); q->setVerticalHeader(vertical); QHeaderView *horizontal = new QHeaderView(Qt::Horizontal, q); - horizontal->setClickable(true); + horizontal->setSectionsClickable(true); horizontal->setHighlightSections(true); q->setHorizontalHeader(horizontal); diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index c54c11d0f5..e2be4990d9 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -848,7 +848,7 @@ void QTreeView::setSortingEnabled(bool enable) { Q_D(QTreeView); header()->setSortIndicatorShown(enable); - header()->setClickable(enable); + header()->setSectionsClickable(enable); if (enable) { //sortByColumn has to be called before we connect or set the sortingEnabled flag // because otherwise it will not call sort on the model. @@ -2886,7 +2886,7 @@ void QTreeViewPrivate::initialize() q->setAttribute(Qt::WA_MacShowFocusRect); QHeaderView *header = new QHeaderView(Qt::Horizontal, q); - header->setMovable(true); + header->setSectionsMovable(true); header->setStretchLastSection(true); header->setDefaultAlignment(Qt::AlignLeft|Qt::AlignVCenter); q->setHeader(header); diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index 156121a533..f8e3a375a4 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -2535,7 +2535,7 @@ QTreeWidget::QTreeWidget(QWidget *parent) this, SLOT(_q_sort())); connect(selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(_q_selectionChanged(QItemSelection,QItemSelection))); - header()->setClickable(false); + header()->setSectionsClickable(false); } /*! -- cgit v1.2.3 From 39e0d35fe9acb2b2b539cc96170be2d227936b74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lund=20Martsum?= Date: Sun, 11 Mar 2012 10:52:25 +0100 Subject: QHeaderView - documentation update. Prefer hideSection over 0-resize. There is a different behavior on 0 sections and hidden sections e.g with scrollbars. Normally people want to use hideSection. Change-Id: Id99de30ea46906bb4ef7720ed12d4ac9615c9743 Reviewed-by: Stephen Kelly --- src/widgets/itemviews/qheaderview.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/widgets/itemviews') diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 766d7ce6b6..425eb4cd95 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -866,9 +866,11 @@ void QHeaderView::swapSections(int first, int second) \fn void QHeaderView::resizeSection(int logicalIndex, int size) Resizes the section specified by \a logicalIndex to \a size measured in - pixels. + pixels. The size parameter must be a value larger or equal to zero. A + size equal to zero is however not recommended. In that situation hideSection + should be used instead. - \sa sectionResized(), resizeMode(), sectionSize() + \sa sectionResized(), resizeMode(), sectionSize(), hideSection() */ void QHeaderView::resizeSection(int logical, int size) -- cgit v1.2.3 From 9e87104295b019a1afa49f856ddcef07249d1afb Mon Sep 17 00:00:00 2001 From: Mark Brand Date: Tue, 13 Mar 2012 11:40:25 +0100 Subject: QTableView: call model->submit() on row change QTreeView already does this in the exact same way. It's necessary to call submit() so edit strategy OnRowChange in QSqlTableModel will work as expected. Change-Id: Ib430143e8a71f3b0bcd842fcc772cc7ee4525f0a Reviewed-by: Olivier Goffart --- src/widgets/itemviews/qtableview.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/widgets/itemviews') diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index 57f29641de..a5e03ca9e4 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -1071,6 +1071,10 @@ void QTableView::setModel(QAbstractItemModel *model) disconnect(d->model, SIGNAL(columnsRemoved(QModelIndex,int,int)), this, SLOT(_q_updateSpanRemovedColumns(QModelIndex,int,int))); } + if (d->selectionModel) { // support row editing + disconnect(d->selectionModel, SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), + d->model, SLOT(submit())); + } if (model) { //and connect to the new one connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(_q_updateSpanInsertedRows(QModelIndex,int,int))); @@ -1123,9 +1127,21 @@ void QTableView::setSelectionModel(QItemSelectionModel *selectionModel) { Q_D(QTableView); Q_ASSERT(selectionModel); + if (d->selectionModel) { + // support row editing + disconnect(d->selectionModel, SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), + d->model, SLOT(submit())); + } + d->verticalHeader->setSelectionModel(selectionModel); d->horizontalHeader->setSelectionModel(selectionModel); QAbstractItemView::setSelectionModel(selectionModel); + + if (d->selectionModel) { + // support row editing + connect(d->selectionModel, SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), + d->model, SLOT(submit())); + } } /*! -- cgit v1.2.3 From a17907829e6b180f2bb4af9a8594996b2a0e531a Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Thu, 8 Mar 2012 16:10:10 +0100 Subject: Use pointers for QAccessibleEvent. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit At least on mac g++ badly wants to copy the event and cannot use the copy ctor. The sensible solution is thus to use pointers. This is in line with QCoreApplication::sendEvent. Change-Id: Icb58852be351ab04ffa17069989d7a07d4b377da Reviewed-by: Jan-Arve Sæther --- src/widgets/itemviews/qabstractitemview.cpp | 18 +++++++++++------ src/widgets/itemviews/qlistview.cpp | 9 ++++++--- src/widgets/itemviews/qtableview.cpp | 30 ++++++----------------------- src/widgets/itemviews/qtreeview.cpp | 15 ++++++++++----- 4 files changed, 34 insertions(+), 38 deletions(-) (limited to 'src/widgets/itemviews') diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index 8530e2c23e..8992a3bdfe 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -1112,7 +1112,8 @@ void QAbstractItemView::reset() #ifdef Q_WS_X11 if (QAccessible::isActive()) { QAccessible::queryAccessibleInterface(this)->table2Interface()->modelReset(); - QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::TableModelChanged, this, 0)); + QAccessibleEvent event(QAccessible::TableModelChanged, this, 0); + QAccessible::updateAccessibility(&event); } #endif #endif @@ -3342,7 +3343,8 @@ void QAbstractItemViewPrivate::_q_rowsRemoved(const QModelIndex &index, int star #ifdef Q_WS_X11 if (QAccessible::isActive()) { QAccessible::queryAccessibleInterface(q)->table2Interface()->rowsRemoved(index, start, end); - QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::TableModelChanged, q, 0)); + QAccessibleEvent event(QAccessible::TableModelChanged, q, 0); + QAccessible::updateAccessibility(&event); } #endif #endif @@ -3422,7 +3424,8 @@ void QAbstractItemViewPrivate::_q_columnsRemoved(const QModelIndex &index, int s #ifdef Q_WS_X11 if (QAccessible::isActive()) { QAccessible::queryAccessibleInterface(q)->table2Interface()->columnsRemoved(index, start, end); - QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::TableModelChanged, q, 0)); + QAccessibleEvent event(QAccessible::TableModelChanged, q, 0); + QAccessible::updateAccessibility(&event); } #endif #endif @@ -3445,7 +3448,8 @@ void QAbstractItemViewPrivate::_q_rowsInserted(const QModelIndex &index, int sta Q_Q(QAbstractItemView); if (QAccessible::isActive()) { QAccessible::queryAccessibleInterface(q)->table2Interface()->rowsInserted(index, start, end); - QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::TableModelChanged, q, 0)); + QAccessibleEvent event(QAccessible::TableModelChanged, q, 0); + QAccessible::updateAccessibility(&event); } #endif #endif @@ -3469,7 +3473,8 @@ void QAbstractItemViewPrivate::_q_columnsInserted(const QModelIndex &index, int #ifdef Q_WS_X11 if (QAccessible::isActive()) { QAccessible::queryAccessibleInterface(q)->table2Interface()->columnsInserted(index, start, end); - QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::TableModelChanged, q, 0)); + QAccessibleEvent event(QAccessible::TableModelChanged, q, 0); + QAccessible::updateAccessibility(&event); } #endif #endif @@ -3497,7 +3502,8 @@ void QAbstractItemViewPrivate::_q_layoutChanged() Q_Q(QAbstractItemView); if (QAccessible::isActive()) { QAccessible::queryAccessibleInterface(q)->table2Interface()->modelReset(); - QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::TableModelChanged, q, 0)); + QAccessibleEvent event(QAccessible::TableModelChanged, q, 0); + QAccessible::updateAccessibility(&event); } #endif #endif diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index b00b1073a3..872798a8e9 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -3169,7 +3169,8 @@ void QListView::currentChanged(const QModelIndex ¤t, const QModelIndex &pr if (QAccessible::isActive()) { if (current.isValid()) { int entry = visualIndex(current) + 1; - QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::Focus, this, entry)); + QAccessibleEvent event(QAccessible::Focus, this, entry); + QAccessible::updateAccessibility(&event); } } #endif @@ -3188,12 +3189,14 @@ void QListView::selectionChanged(const QItemSelection &selected, QModelIndex sel = selected.indexes().value(0); if (sel.isValid()) { int entry = visualIndex(sel) + 1; - QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::Selection, this, entry)); + QAccessibleEvent event(QAccessible::Selection, this, entry); + QAccessible::updateAccessibility(&event); } QModelIndex desel = deselected.indexes().value(0); if (desel.isValid()) { int entry = visualIndex(desel) + 1; - QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::SelectionRemove, this, entry)); + QAccessibleEvent event(QAccessible::SelectionRemove, this, entry); + QAccessible::updateAccessibility(&event); } } #endif diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index a5e03ca9e4..55cf18d78c 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -3180,16 +3180,10 @@ void QTableView::currentChanged(const QModelIndex ¤t, const QModelIndex &p #ifndef QT_NO_ACCESSIBILITY if (QAccessible::isActive()) { if (current.isValid()) { -#ifdef Q_OS_UNIX Q_D(QTableView); int entry = d->accessibleTable2Index(current); - QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::Focus, this, entry)); -#else - int entry = visualIndex(current) + 1; - if (horizontalHeader()) - ++entry; - QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::Focus, viewport(), entry)); -#endif + QAccessibleEvent event(QAccessible::Focus, this, entry); + QAccessible::updateAccessibility(&event); } } #endif @@ -3209,27 +3203,15 @@ void QTableView::selectionChanged(const QItemSelection &selected, // ### does not work properly for selection ranges. QModelIndex sel = selected.indexes().value(0); if (sel.isValid()) { -#ifdef Q_OS_UNIX int entry = d->accessibleTable2Index(sel); - QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::Selection, this, entry)); -#else - int entry = visualIndex(sel); - if (horizontalHeader()) - ++entry; - QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::Selection, viewport(), entry)); -#endif + QAccessibleEvent event(QAccessible::Selection, this, entry); + QAccessible::updateAccessibility(&event); } QModelIndex desel = deselected.indexes().value(0); if (desel.isValid()) { -#ifdef Q_OS_UNIX int entry = d->accessibleTable2Index(desel); - QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::SelectionRemove, this, entry)); -#else - int entry = visualIndex(sel); - if (horizontalHeader()) - ++entry; - QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::SelectionRemove, viewport(), entry)); -#endif + QAccessibleEvent event(QAccessible::SelectionRemove, this, entry); + QAccessible::updateAccessibility(&event); } } #endif diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index e2be4990d9..6166823754 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -2937,7 +2937,8 @@ void QTreeViewPrivate::insertViewItems(int pos, int count, const QTreeViewItem & #ifndef QT_NO_ACCESSIBILITY #ifdef Q_OS_UNIX if (QAccessible::isActive()) { - QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::TableModelChanged, q, 0)); + QAccessibleEvent event(QAccessible::TableModelChanged, q, 0); + QAccessible::updateAccessibility(&event); } #endif #endif @@ -2955,7 +2956,8 @@ void QTreeViewPrivate::removeViewItems(int pos, int count) #ifndef QT_NO_ACCESSIBILITY #ifdef Q_OS_UNIX if (QAccessible::isActive()) { - QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::TableModelChanged, q, 0)); + QAccessibleEvent event(QAccessible::TableModelChanged, q, 0); + QAccessible::updateAccessibility(&event); } #endif #endif @@ -3769,7 +3771,8 @@ void QTreeView::currentChanged(const QModelIndex ¤t, const QModelIndex &pr if (QAccessible::isActive() && current.isValid()) { #ifdef Q_OS_UNIX int entry = (visualIndex(current) + (header()?1:0))*current.model()->columnCount()+current.column() + 1; - QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::Focus, this, entry)); + QAccessibleEvent event(QAccessible::Focus, this, entry); + QAccessible::updateAccessibility(&event); #else int entry = visualIndex(current) + 1; if (header()) @@ -3794,13 +3797,15 @@ void QTreeView::selectionChanged(const QItemSelection &selected, if (sel.isValid()) { int entry = (visualIndex(sel) + (header()?1:0))*sel.model()->columnCount()+sel.column() + 1; Q_ASSERT(entry > 0); - QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::Selection, this, entry)); + QAccessibleEvent event(QAccessible::Selection, this, entry); + QAccessible::updateAccessibility(&event); } QModelIndex desel = deselected.indexes().value(0); if (desel.isValid()) { int entry = (visualIndex(desel) + (header()?1:0))*desel.model()->columnCount()+desel.column() + 1; Q_ASSERT(entry > 0); - QAccessible::updateAccessibility(QAccessibleEvent(QAccessible::SelectionRemove, this, entry)); + QAccessibleEvent event(QAccessible::SelectionRemove, this, entry); + QAccessible::updateAccessibility(&event); } } #endif -- cgit v1.2.3