diff options
author | Jan-Arve Sæther <jan-arve.saether@nokia.com> | 2009-11-13 14:15:53 (GMT) |
---|---|---|
committer | Jan-Arve Sæther <jan-arve.saether@nokia.com> | 2009-11-13 14:15:53 (GMT) |
commit | 2432150f9eabbaa0317eeed038eaf661f8ce507e (patch) | |
tree | e45eaa146aa68f776b7d2f12b9cdaacf37d54095 | |
parent | 3764f6a3109266bf55aed1a18dd992e90fb85221 (diff) | |
parent | aefd76b0052cd36ed7f890dd4b91f38873bec251 (diff) | |
download | Qt-2432150f9eabbaa0317eeed038eaf661f8ce507e.zip Qt-2432150f9eabbaa0317eeed038eaf661f8ce507e.tar.gz Qt-2432150f9eabbaa0317eeed038eaf661f8ce507e.tar.bz2 |
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.6
6 files changed, 90 insertions, 19 deletions
diff --git a/src/gui/itemviews/qitemselectionmodel.cpp b/src/gui/itemviews/qitemselectionmodel.cpp index c6e02a6..2e4a602 100644 --- a/src/gui/itemviews/qitemselectionmodel.cpp +++ b/src/gui/itemviews/qitemselectionmodel.cpp @@ -730,13 +730,14 @@ void QItemSelectionModelPrivate::_q_layoutAboutToBeChanged() savedPersistentIndexes.clear(); savedPersistentCurrentIndexes.clear(); - // special case for when all indexes are selected + // optimisation for when all indexes are selected + // (only if there is lots of items (1000) because this is not entirely correct) if (ranges.isEmpty() && currentSelection.count() == 1) { QItemSelectionRange range = currentSelection.first(); QModelIndex parent = range.parent(); tableRowCount = model->rowCount(parent); tableColCount = model->columnCount(parent); - if (tableRowCount * tableColCount > 100 + if (tableRowCount * tableColCount > 1000 && range.top() == 0 && range.left() == 0 && range.bottom() == tableRowCount - 1 diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp index 1163eba..206104f 100644 --- a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp +++ b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp @@ -61,6 +61,9 @@ void QTriangulatingStroker::endCapOrJoinClosed(const qreal *start, const qreal * } else { endCap(cur); } + int count = m_vertices.size(); + m_vertices.add(m_vertices.at(count-2)); + m_vertices.add(m_vertices.at(count-1)); } diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h b/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h index defa3f1..a0117d5 100644 --- a/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h +++ b/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h @@ -188,10 +188,6 @@ inline void QTriangulatingStroker::endCap(const qreal *pts) break; default: break; // to shut gcc up... } - - int count = m_vertices.size(); - m_vertices.add(m_vertices.at(count-2)); - m_vertices.add(m_vertices.at(count-1)); } diff --git a/tests/auto/qabstractslider/tst_qabstractslider.cpp b/tests/auto/qabstractslider/tst_qabstractslider.cpp index d9574df..ee1ba19 100644 --- a/tests/auto/qabstractslider/tst_qabstractslider.cpp +++ b/tests/auto/qabstractslider/tst_qabstractslider.cpp @@ -742,11 +742,9 @@ void tst_QAbstractSlider::wheelEvent_data() << 1 // delta << int(Qt::Horizontal) // orientation of slider << int(Qt::Vertical) // orientation of wheel - << 0 // expected position after + << 1 // expected position after << QPoint(1,1); - // Scrolling in a slider of a different orientation than the wheel works - // if the mouse pointer is within the widget's rect QTest::newRow("Different orientation2")<< 0 // initial position << 0 // minimum << 100 // maximum diff --git a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp index 77c259c..269afbd 100644 --- a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp +++ b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp @@ -92,6 +92,7 @@ private slots: void task252069_rowIntersectsSelection(); void task232634_childrenDeselectionSignal(); void task260134_layoutChangedWithAllSelected(); + void QTBUG5671_layoutChangedWithAllSelected(); private: QAbstractItemModel *model; @@ -2025,24 +2026,24 @@ void tst_QItemSelectionModel::task220420_selectedIndexes() class QtTestTableModel: public QAbstractTableModel { Q_OBJECT - + public: QtTestTableModel(int rows = 0, int columns = 0, QObject *parent = 0) : QAbstractTableModel(parent), row_count(rows), column_count(columns) {} - + int rowCount(const QModelIndex& = QModelIndex()) const { return row_count; } int columnCount(const QModelIndex& = QModelIndex()) const { return column_count; } bool isEditable(const QModelIndex &) const { return true; } - + QVariant data(const QModelIndex &idx, int role) const { if (role == Qt::DisplayRole || role == Qt::EditRole) return QString("[%1,%2]").arg(idx.row()).arg(idx.column()); return QVariant(); } - + int row_count; int column_count; friend class tst_QItemSelectionModel; @@ -2055,7 +2056,7 @@ void tst_QItemSelectionModel::task240734_layoutChanged() QItemSelectionModel selectionModel(&model); selectionModel.select(model.index(0,0), QItemSelectionModel::Select); QCOMPARE(selectionModel.selectedIndexes().count() , 1); - + emit model.layoutAboutToBeChanged(); model.row_count = 5; emit model.layoutChanged(); @@ -2107,7 +2108,7 @@ void tst_QItemSelectionModel::merge_data() << QItemSelection(model->index(2, 2) , model->index(3, 4)) << int(QItemSelectionModel::Deselect) << QItemSelection(model->index(2, 1) , model->index(3, 1)); - + QItemSelection r1(model->index(2, 1) , model->index(3, 1)); r1.select(model->index(2, 4) , model->index(3, 4)); QTest::newRow("Toggle") @@ -2274,5 +2275,57 @@ void tst_QItemSelectionModel::task260134_layoutChangedWithAllSelected() } +void tst_QItemSelectionModel::QTBUG5671_layoutChangedWithAllSelected() +{ + struct MyFilterModel : public QSortFilterProxyModel + { // Override sort filter proxy to remove even numbered rows. + bool filtering; + virtual bool filterAcceptsRow( int source_row, const QModelIndex& source_parent ) const + { + return !filtering || !( source_row & 1 ); + } + }; + + //same as task260134_layoutChangedWithAllSelected but with a sightly bigger model + + enum { cNumRows=30, cNumCols=20 }; + + QStandardItemModel model(cNumRows, cNumCols); + MyFilterModel proxy; + proxy.filtering = true; + proxy.setSourceModel(&model); + QItemSelectionModel selection(&proxy); + + // Populate the tree view. + for (unsigned int i = 0; i < cNumCols; i++) + model.setHeaderData( i, Qt::Horizontal, QString::fromLatin1("Column %1").arg(i)); + + for (unsigned int r = 0; r < cNumRows; r++) { + for (unsigned int c = 0; c < cNumCols; c++) { + model.setData(model.index(r, c, QModelIndex()), + QString::fromLatin1("r:%1/c:%2").arg(r, c)); + } + } + + + QCOMPARE(model.rowCount(), int(cNumRows)); + QCOMPARE(proxy.rowCount(), int(cNumRows/2)); + + selection.select( QItemSelection(proxy.index(0,0), proxy.index(proxy.rowCount() - 1, proxy.columnCount() - 1)), QItemSelectionModel::Select); + + QList<QPersistentModelIndex> indexList; + foreach(const QModelIndex &id, selection.selectedIndexes()) + indexList << id; + + proxy.filtering = false; + proxy.invalidate(); + QCOMPARE(proxy.rowCount(), int(cNumRows)); + + //let's check the selection hasn't changed + QCOMPARE(selection.selectedIndexes().count(), indexList.count()); + foreach(QPersistentModelIndex index, indexList) + QVERIFY(selection.isSelected(index)); +} + QTEST_MAIN(tst_QItemSelectionModel) #include "tst_qitemselectionmodel.moc" diff --git a/tests/auto/qtreewidget/tst_qtreewidget.cpp b/tests/auto/qtreewidget/tst_qtreewidget.cpp index 6defd7b..621072c 100644 --- a/tests/auto/qtreewidget/tst_qtreewidget.cpp +++ b/tests/auto/qtreewidget/tst_qtreewidget.cpp @@ -167,6 +167,7 @@ private slots: void setCurrentItemExpandsParent(); void task239150_editorWidth(); void setTextUpdate(); + void taskQTBUG2844_visualItemRect(); public slots: void itemSelectionChanged(); @@ -601,9 +602,9 @@ void tst_QTreeWidget::setItemHidden() testWidget->scrollToItem(child); QVERIFY(testWidget->visualItemRect(parent).isValid() - && testWidget->viewport()->rect().contains(testWidget->visualItemRect(parent))); + && testWidget->viewport()->rect().intersects(testWidget->visualItemRect(parent))); QVERIFY(testWidget->visualItemRect(child).isValid() - && testWidget->viewport()->rect().contains(testWidget->visualItemRect(child))); + && testWidget->viewport()->rect().intersects(testWidget->visualItemRect(child))); QVERIFY(!testWidget->isItemHidden(parent)); QVERIFY(!testWidget->isItemHidden(child)); @@ -611,9 +612,9 @@ void tst_QTreeWidget::setItemHidden() testWidget->setItemHidden(parent, true); QVERIFY(!(testWidget->visualItemRect(parent).isValid() - && testWidget->viewport()->rect().contains(testWidget->visualItemRect(parent)))); + && testWidget->viewport()->rect().intersects(testWidget->visualItemRect(parent)))); QVERIFY(!(testWidget->visualItemRect(child).isValid() - && testWidget->viewport()->rect().contains(testWidget->visualItemRect(child)))); + && testWidget->viewport()->rect().intersects(testWidget->visualItemRect(child)))); QVERIFY(testWidget->isItemHidden(parent)); QVERIFY(!testWidget->isItemHidden(child)); @@ -3271,6 +3272,25 @@ void tst_QTreeWidget::setTextUpdate() QTRY_VERIFY(delegate.numPaints > 0); } +void tst_QTreeWidget::taskQTBUG2844_visualItemRect() +{ + CustomTreeWidget tree; + tree.resize(150, 100); + tree.setColumnCount(3); + QTreeWidgetItem item(&tree); + + QRect itemRect = tree.visualItemRect(&item); + + QRect rectCol0 = tree.visualRect(tree.indexFromItem(&item, 0)); + QRect rectCol1 = tree.visualRect(tree.indexFromItem(&item, 1)); + QRect rectCol2 = tree.visualRect(tree.indexFromItem(&item, 2)); + + QCOMPARE(tree.visualItemRect(&item), rectCol0 | rectCol2); + tree.setColumnHidden(2, true); + QCOMPARE(tree.visualItemRect(&item), rectCol0 | rectCol1); +} + + QTEST_MAIN(tst_QTreeWidget) |