diff options
Diffstat (limited to 'src/gui/itemviews')
-rw-r--r-- | src/gui/itemviews/qheaderview.cpp | 3 | ||||
-rw-r--r-- | src/gui/itemviews/qitemselectionmodel.cpp | 22 | ||||
-rw-r--r-- | src/gui/itemviews/qlistview.cpp | 4 |
3 files changed, 16 insertions, 13 deletions
diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp index 5d3bb12..60c31ad 100644 --- a/src/gui/itemviews/qheaderview.cpp +++ b/src/gui/itemviews/qheaderview.cpp @@ -1195,7 +1195,8 @@ QHeaderView::ResizeMode QHeaderView::resizeMode(int logicalIndex) const { Q_D(const QHeaderView); int visual = visualIndex(logicalIndex); - Q_ASSERT(visual != -1); + if (visual == -1) + return Fixed; //the default value return d->headerSectionResizeMode(visual); } diff --git a/src/gui/itemviews/qitemselectionmodel.cpp b/src/gui/itemviews/qitemselectionmodel.cpp index 98810a0..8414460 100644 --- a/src/gui/itemviews/qitemselectionmodel.cpp +++ b/src/gui/itemviews/qitemselectionmodel.cpp @@ -573,6 +573,7 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare int start, int end) { Q_Q(QItemSelectionModel); + finalize(); // update current index if (currentIndex.isValid() && parent == currentIndex.parent() @@ -591,8 +592,8 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare } QItemSelection deselected; - QItemSelection::iterator it = currentSelection.begin(); - while (it != currentSelection.end()) { + QItemSelection::iterator it = ranges.begin(); + while (it != ranges.end()) { if (it->topLeft().parent() != parent) { // Check parents until reaching root or contained in range QModelIndex itParent = it->topLeft().parent(); while (itParent.isValid() && itParent.parent() != parent) @@ -600,24 +601,22 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare if (parent.isValid() && start <= itParent.row() && itParent.row() <= end) { deselected.append(*it); - it = currentSelection.erase(it); + it = ranges.erase(it); } else { ++it; } } else if (start <= it->bottom() && it->bottom() <= end // Full inclusion && start <= it->top() && it->top() <= end) { deselected.append(*it); - it = currentSelection.erase(it); + it = ranges.erase(it); } else if (start <= it->top() && it->top() <= end) { // Top intersection deselected.append(QItemSelectionRange(it->topLeft(), model->index(end, it->left(), it->parent()))); - it = currentSelection.insert(it, QItemSelectionRange(model->index(end + 1, it->left(), it->parent()), - it->bottomRight())); - it = currentSelection.erase(++it); + *it = QItemSelectionRange(model->index(end + 1, it->left(), it->parent()), it->bottomRight()); + ++it; } else if (start <= it->bottom() && it->bottom() <= end) { // Bottom intersection deselected.append(QItemSelectionRange(model->index(start, it->right(), it->parent()), it->bottomRight())); - it = currentSelection.insert(it, QItemSelectionRange(it->topLeft(), - model->index(start - 1, it->right(), it->parent()))); - it = currentSelection.erase(++it); + *it = QItemSelectionRange(it->topLeft(), model->index(start - 1, it->right(), it->parent())); + ++it; } else { if (it->top() < start && end < it->bottom()) // Middle intersection (do nothing) deselected.append(QItemSelectionRange(model->index(start, it->right(), it->parent()), @@ -626,7 +625,8 @@ void QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(const QModelIndex &pare } } - emit q->selectionChanged(QItemSelection(), deselected); + if (!deselected.isEmpty()) + emit q->selectionChanged(QItemSelection(), deselected); } /*! diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index ea38f5f..e9e365f 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -458,6 +458,8 @@ QSize QListView::gridSize() const void QListView::setViewMode(ViewMode mode) { Q_D(QListView); + if (d->viewMode == mode) + return; d->viewMode = mode; if (mode == ListMode) { @@ -1963,7 +1965,7 @@ QListViewPrivate::QListViewPrivate() movement(QListView::Static), resizeMode(QListView::Fixed), layoutMode(QListView::SinglePass), - viewMode(QListView::ListMode), + viewMode(QListView::IconMode), //this will ensure the first initialization to ListView modeProperties(0), column(0), uniformItemSizes(false), |