From f6b36eaafec24b4c67efff621d380a4ca4257d0b Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 22 May 2017 20:01:04 +0200 Subject: QHeaderView: fix visual/logical index corruption when restoring state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a followup to 77a8e90cddcfa1c34518ef846a4838874a7bc0c7 which didn't handle the case where no columns had been moved. visualIndices and logicalIndices are empty until initializeIndexMapping() is called, in which case appending is wrong. As a result, visualIndex(i) would return -1 for the values over those added by read(), and an assert would happen at painting time. The fix is to leave visualIndices and logicalIndices empty if they are empty already, leaving it to initializeIndexMapping() to fill them later if necessary (e.g. when moving a column). Task-number: QTBUG-60837 Change-Id: Ia7e4b9d3122647984acd434dfaa0400df319d065 Reviewed-by: Marc Mutz Reviewed-by: Thorbjørn Lund Martsum --- src/widgets/itemviews/qheaderview.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/widgets/itemviews') diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index e0e993ce77..76f80c680e 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -3876,9 +3876,11 @@ bool QHeaderViewPrivate::read(QDataStream &in) const int currentCount = (orient == Qt::Horizontal ? model->columnCount(root) : model->rowCount(root)); if (newSectionItems.count() < currentCount) { // we have sections not in the saved state, give them default settings - for (int i = newSectionItems.count(); i < currentCount; ++i) { - visualIndicesIn.append(i); - logicalIndicesIn.append(i); + if (!visualIndicesIn.isEmpty() && !logicalIndicesIn.isEmpty()) { + for (int i = newSectionItems.count(); i < currentCount; ++i) { + visualIndicesIn.append(i); + logicalIndicesIn.append(i); + } } const int insertCount = currentCount - newSectionItems.count(); const int insertLength = defaultSectionSizeIn * insertCount; -- cgit v1.2.3 From 22a52d1d640f4ee6c68e8ef5da4573770efdb90a Mon Sep 17 00:00:00 2001 From: Leena Miettinen Date: Wed, 31 May 2017 10:32:39 +0200 Subject: Doc: Remove references to screenshots illustrating different styles ... from widget class descriptions. Use one screenshot from Windows instead. The styles change and the screenshots become outdated very fast, so it is easier to update just one screenshot now and then. The styles can still be seen in the style gallery topics. The image files will be removed in a follow-up commit after all references to them have been removed. Change-Id: Id326c141f4884a2e4f67a4fe8681d8c65f8b24ba Reviewed-by: Martin Smith --- src/widgets/itemviews/qlistview.cpp | 11 ++--------- src/widgets/itemviews/qlistwidget.cpp | 11 ++--------- src/widgets/itemviews/qtableview.cpp | 17 ++--------------- src/widgets/itemviews/qtablewidget.cpp | 11 ++--------- src/widgets/itemviews/qtreeview.cpp | 11 ++--------- src/widgets/itemviews/qtreewidget.cpp | 11 ++--------- 6 files changed, 12 insertions(+), 60 deletions(-) (limited to 'src/widgets/itemviews') diff --git a/src/widgets/itemviews/qlistview.cpp b/src/widgets/itemviews/qlistview.cpp index 3ef5b788c6..e7a3c11b44 100644 --- a/src/widgets/itemviews/qlistview.cpp +++ b/src/widgets/itemviews/qlistview.cpp @@ -73,6 +73,8 @@ extern bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event); \ingroup advanced \inmodule QtWidgets + \image windows-listview.png + A QListView presents items stored in a model, either as a simple non-hierarchical list, or as a collection of icons. This class is used to provide lists and icon views that were previously provided by the @@ -111,15 +113,6 @@ extern bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event); within a notional grid of size specified by gridSize(). The items can be rendered as large or small icons depending on their iconSize(). - \table 100% - \row \li \inlineimage windowsvista-listview.png Screenshot of a Windows Vista style list view - \li \inlineimage macintosh-listview.png Screenshot of a Macintosh style table view - \li \inlineimage fusion-listview.png Screenshot of a Fusion style table view - \row \li A \l{Windows Vista Style Widget Gallery}{Windows Vista style} list view. - \li A \l{Macintosh Style Widget Gallery}{Macintosh style} list view. - \li A \l{Fusion Style Widget Gallery}{Fusion style} list view. - \endtable - \section1 Improving Performance It is possible to give the view hints about the data it is handling in order diff --git a/src/widgets/itemviews/qlistwidget.cpp b/src/widgets/itemviews/qlistwidget.cpp index 9b34e89ef0..0a1f85facb 100644 --- a/src/widgets/itemviews/qlistwidget.cpp +++ b/src/widgets/itemviews/qlistwidget.cpp @@ -1149,6 +1149,8 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft, \ingroup model-view \inmodule QtWidgets + \image windows-listview.png + QListWidget is a convenience class that provides a list view similar to the one supplied by QListView, but with a classic item-based interface for adding and removing items. QListWidget uses an internal model to manage @@ -1191,15 +1193,6 @@ void QListWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft, current item changes, the currentItemChanged() signal is emitted with the new current item and the item that was previously current. - \table 100% - \row \li \inlineimage windowsvista-listview.png Screenshot of a Windows Vista style list widget - \li \inlineimage macintosh-listview.png Screenshot of a Macintosh style table widget - \li \inlineimage fusion-listview.png Screenshot of a Fusion style table widget - \row \li A \l{Windows Vista Style Widget Gallery}{Windows Vista style} list widget. - \li A \l{Macintosh Style Widget Gallery}{Macintosh style} list widget. - \li A \l{Fusion Style Widget Gallery}{Fusion style} list widget. - \endtable - \sa QListWidgetItem, QListView, QTreeView, {Model/View Programming}, {Config Dialog Example} */ diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp index ed6482a8bc..b79932327b 100644 --- a/src/widgets/itemviews/qtableview.cpp +++ b/src/widgets/itemviews/qtableview.cpp @@ -988,6 +988,8 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS \ingroup advanced \inmodule QtWidgets + \image windows-tableview.png + A QTableView implements a table view that displays items from a model. This class is used to provide standard tables that were previously provided by the QTable class, but using the more @@ -1052,21 +1054,6 @@ int QTableViewPrivate::heightHintForIndex(const QModelIndex &index, int hint, QS columnViewportPosition() functions provide the equivalent conversion operations between x-coordinates and column indexes. - \section1 Styles - - QTableView is styled appropriately for each platform. The following images show - how it looks on three different platforms. Go to the \l{Qt Widget Gallery} to see - its appearance in other styles. - - \table 100% - \row \li \inlineimage windowsvista-tableview.png Screenshot of a Windows Vista style table view - \li \inlineimage macintosh-tableview.png Screenshot of a Macintosh style table view - \li \inlineimage fusion-tableview.png Screenshot of a Fusion style table view - \row \li A \l{Windows Vista Style Widget Gallery}{Windows Vista style} table view. - \li A \l{Macintosh Style Widget Gallery}{Macintosh style} table view. - \li A \l{Fusion Style Widget Gallery}{Fusion style} table view. - \endtable - \sa QTableWidget, {View Classes}, QAbstractItemModel, QAbstractItemView, {Chart Example}, {Pixelator Example}, {Table Model Example} */ diff --git a/src/widgets/itemviews/qtablewidget.cpp b/src/widgets/itemviews/qtablewidget.cpp index ed83ef7b85..663cd4adc6 100644 --- a/src/widgets/itemviews/qtablewidget.cpp +++ b/src/widgets/itemviews/qtablewidget.cpp @@ -1504,6 +1504,8 @@ QTableWidgetItem &QTableWidgetItem::operator=(const QTableWidgetItem &other) \ingroup model-view \inmodule QtWidgets + \image windows-tableview.png + Table widgets provide standard table display facilities for applications. The items in a QTableWidget are provided by QTableWidgetItem. @@ -1545,15 +1547,6 @@ QTableWidgetItem &QTableWidgetItem::operator=(const QTableWidgetItem &other) number of columns with columnCount(). The table can be cleared with the clear() function. - \table 100% - \row \li \inlineimage windowsvista-tableview.png Screenshot of a Windows Vista style table widget - \li \inlineimage macintosh-tableview.png Screenshot of a Macintosh style table widget - \li \inlineimage fusion-tableview.png Screenshot of a Fusion style table widget - \row \li A \l{Windows Vista Style Widget Gallery}{Windows Vista style} table widget. - \li A \l{Macintosh Style Widget Gallery}{Macintosh style} table widget. - \li A \l{Fusion Style Widget Gallery}{Fusion style} table widget. - \endtable - \sa QTableWidgetItem, QTableView, {Model/View Programming} */ diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index f139fb2d5b..c1647cc2f1 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -71,6 +71,8 @@ QT_BEGIN_NAMESPACE \ingroup advanced \inmodule QtWidgets + \image windows-treeview.png + A QTreeView implements a tree representation of items from a model. This class is used to provide standard hierarchical lists that were previously provided by the \c QListView class, but using the more @@ -150,15 +152,6 @@ QT_BEGIN_NAMESPACE Describe the expanding/collapsing concept if not covered elsewhere. \endomit - \table 100% - \row \li \inlineimage windowsvista-treeview.png Screenshot of a Windows Vista style tree view - \li \inlineimage macintosh-treeview.png Screenshot of a Macintosh style tree view - \li \inlineimage fusion-treeview.png Screenshot of a Fusion style tree view - \row \li A \l{Windows Vista Style Widget Gallery}{Windows Vista style} tree view. - \li A \l{Macintosh Style Widget Gallery}{Macintosh style} tree view. - \li A \l{Fusion Style Widget Gallery}{Fusion style} tree view. - \endtable - \section1 Improving Performance It is possible to give the view hints about the data it is handling in order diff --git a/src/widgets/itemviews/qtreewidget.cpp b/src/widgets/itemviews/qtreewidget.cpp index 1338ce4585..8ce36ab47e 100644 --- a/src/widgets/itemviews/qtreewidget.cpp +++ b/src/widgets/itemviews/qtreewidget.cpp @@ -2354,6 +2354,8 @@ void QTreeWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft, \ingroup model-view \inmodule QtWidgets + \image windows-treeview.png + The QTreeWidget class is a convenience class that provides a standard tree widget with a classic item-based interface similar to that used by the QListView class in Qt 3. @@ -2387,15 +2389,6 @@ void QTreeWidgetPrivate::_q_dataChanged(const QModelIndex &topLeft, \l{QTreeView::isSortingEnabled()}{isSortingEnabled()} function indicates whether sorting is enabled. - \table 100% - \row \li \inlineimage windowsvista-treeview.png Screenshot of a Windows Vista style tree widget - \li \inlineimage macintosh-treeview.png Screenshot of a Macintosh style tree widget - \li \inlineimage fusion-treeview.png Screenshot of a Fusion style tree widget - \row \li A \l{Windows Vista Style Widget Gallery}{Windows Vista style} tree widget. - \li A \l{Macintosh Style Widget Gallery}{Macintosh style} tree widget. - \li A \l{Fusion Style Widget Gallery}{Fusion style} tree widget. - \endtable - \sa QTreeWidgetItem, QTreeWidgetItemIterator, QTreeView, {Model/View Programming}, {Settings Editor Example} */ -- cgit v1.2.3