diff options
6 files changed, 16 insertions, 0 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index af22e08..e66bcf6 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -1807,6 +1807,7 @@ void QDeclarativeGridView::itemsInserted(int modelIndex, int count) d->currentIndex += count; if (d->currentItem) d->currentItem->index = d->currentIndex; + emit currentIndexChanged(); } d->scheduleLayout(); emit countChanged(); @@ -1889,6 +1890,7 @@ void QDeclarativeGridView::itemsInserted(int modelIndex, int count) d->currentItem->index = d->currentIndex; d->currentItem->setPosition(d->colPosAt(d->currentIndex), d->rowPosAt(d->currentIndex)); } + emit currentIndexChanged(); } // everything is in order now - emit add() signal diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 007b31b..b988e6e 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -2332,6 +2332,7 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count) d->currentIndex += count; if (d->currentItem) d->currentItem->index = d->currentIndex; + emit currentIndexChanged(); } d->scheduleLayout(); emit countChanged(); @@ -2412,6 +2413,7 @@ void QDeclarativeListView::itemsInserted(int modelIndex, int count) d->currentItem->index = d->currentIndex; d->currentItem->setPosition(d->currentItem->position() + diff); } + emit currentIndexChanged(); } // Update the indexes of the following visible items. for (; index < d->visibleItems.count(); ++index) { diff --git a/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml b/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml index 32833d2..cc3e549 100644 --- a/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml +++ b/tests/auto/declarative/qdeclarativegridview/data/gridview-initCurrent.qml @@ -1,6 +1,7 @@ import Qt 4.6 Rectangle { + property int current: grid.currentIndex width: 240 height: 320 color: "#ffffff" diff --git a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp index a1edc53..aaf8291 100644 --- a/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp +++ b/tests/auto/declarative/qdeclarativegridview/tst_qdeclarativegridview.cpp @@ -703,6 +703,11 @@ void tst_QDeclarativeGridView::currentIndex() QCOMPARE(gridview->highlightItem()->x(), hlPosX); QCOMPARE(gridview->highlightItem()->y(), hlPosY); + // insert item before currentIndex + gridview->setCurrentIndex(28); + model.insertItem(0, "Foo", "1111"); + QCOMPARE(canvas->rootObject()->property("current").toInt(), 29); + delete canvas; } diff --git a/tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml b/tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml index 74f5ef4..a6d7610 100644 --- a/tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml +++ b/tests/auto/declarative/qdeclarativelistview/data/listview-initCurrent.qml @@ -1,6 +1,7 @@ import Qt 4.6 Rectangle { + property int current: list.currentIndex width: 240 height: 320 color: "#ffffff" diff --git a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp index 17257ae..e5542c2 100644 --- a/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp +++ b/tests/auto/declarative/qdeclarativelistview/tst_qdeclarativelistview.cpp @@ -1059,6 +1059,11 @@ void tst_QDeclarativeListView::currentIndex() QTest::qWait(500); QCOMPARE(listview->highlightItem()->y(), hlPos); + // insert item before currentIndex + listview->setCurrentIndex(28); + model.insertItem(0, "Foo", "1111"); + QCOMPARE(canvas->rootObject()->property("current").toInt(), 29); + delete canvas; } |