summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-12-10 10:35:53 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-12-10 10:38:46 (GMT)
commita2ccf692cdc4113cc90ef12c27ba8c4aa552d81f (patch)
treede44f49f3f6ab166748155c0c04eac7c41afcd54
parentbb0ab1d8cf57dd4a7b69c8478c2a40c1cd1782e9 (diff)
downloadQt-a2ccf692cdc4113cc90ef12c27ba8c4aa552d81f.zip
Qt-a2ccf692cdc4113cc90ef12c27ba8c4aa552d81f.tar.gz
Qt-a2ccf692cdc4113cc90ef12c27ba8c4aa552d81f.tar.bz2
Fixes internal drag and drop in QListWidget while dropping to the end
Task-number: QTBUG-6565 Reviewed-by: Gabriel
-rw-r--r--src/gui/itemviews/qlistwidget.cpp2
-rw-r--r--tests/auto/qlistwidget/tst_qlistwidget.cpp8
2 files changed, 8 insertions, 2 deletions
diff --git a/src/gui/itemviews/qlistwidget.cpp b/src/gui/itemviews/qlistwidget.cpp
index 929d688..0ce0e5e 100644
--- a/src/gui/itemviews/qlistwidget.cpp
+++ b/src/gui/itemviews/qlistwidget.cpp
@@ -173,7 +173,7 @@ void QListModel::move(int srcRow, int dstRow)
{
if (srcRow == dstRow
|| srcRow < 0 || srcRow >= items.count()
- || dstRow < 0 || dstRow >= items.count())
+ || dstRow < 0 || dstRow > items.count())
return;
if (!beginMoveRows(QModelIndex(), srcRow, srcRow, QModelIndex(), dstRow))
diff --git a/tests/auto/qlistwidget/tst_qlistwidget.cpp b/tests/auto/qlistwidget/tst_qlistwidget.cpp
index 863c308..e165190 100644
--- a/tests/auto/qlistwidget/tst_qlistwidget.cpp
+++ b/tests/auto/qlistwidget/tst_qlistwidget.cpp
@@ -862,12 +862,18 @@ void tst_QListWidget::moveItemsPriv_data()
QTest::newRow("Empty") << 0 << 0 << 0 << false;
QTest::newRow("Overflow src") << 5 << 5 << 2 << false;
QTest::newRow("Underflow src") << 5 << -1 << 2 << false;
- QTest::newRow("Overflow dst") << 5 << 2 << 5 << false;
+ QTest::newRow("Overflow dst") << 5 << 2 << 6 << false;
QTest::newRow("Underflow dst") << 5 << 2 << -1 << false;
QTest::newRow("Same place") << 5 << 2 << 2 << false;
QTest::newRow("Up") << 5 << 4 << 2 << true;
QTest::newRow("Down") << 5 << 2 << 4 << true;
QTest::newRow("QTBUG-6532 assert") << 5 << 0 << 1 << false;
+ QTest::newRow("QTBUG-6565 to the end") << 5 << 3 << 5 << true;
+ QTest::newRow("Same place 2") << 2 << 0 << 1 << false;
+ QTest::newRow("swap") << 2 << 0 << 2 << true;
+ QTest::newRow("swap2") << 4 << 1 << 3 << true;
+ QTest::newRow("swap3") << 4 << 3 << 2 << true;
+ QTest::newRow("swap4") << 2 << 1 << 0 << true;
}
void tst_QListWidget::moveItemsPriv()