summaryrefslogtreecommitdiffstats
path: root/tests/auto/qlistview
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-06-08 12:47:33 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-06-08 12:48:58 (GMT)
commit9281ea186212591e636437d30747e7efd6138af6 (patch)
tree2c40bc3b0b4be1e7cb66c1e3202affd61d5f80f7 /tests/auto/qlistview
parenteda070eb1f0e65366eaece43e5d86baf9fb8cd89 (diff)
downloadQt-9281ea186212591e636437d30747e7efd6138af6.zip
Qt-9281ea186212591e636437d30747e7efd6138af6.tar.gz
Qt-9281ea186212591e636437d30747e7efd6138af6.tar.bz2
Fixed ListView so that it is able to move items in negative space and
still paint them. The autotest is included. Task-number: 254449 Reviewed-by: ogoffart
Diffstat (limited to 'tests/auto/qlistview')
-rw-r--r--tests/auto/qlistview/tst_qlistview.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp
index f70db14..8338ffa 100644
--- a/tests/auto/qlistview/tst_qlistview.cpp
+++ b/tests/auto/qlistview/tst_qlistview.cpp
@@ -52,6 +52,7 @@
#include <math.h>
#include <QtGui/QScrollBar>
#include <QtGui/QDialog>
+#include <QtGui/QStyledItemDelegate>
#if defined(Q_OS_WIN) || defined(Q_OS_WINCE)
#include <windows.h>
#endif
@@ -107,6 +108,7 @@ private slots:
void task248430_crashWith0SizedItem();
void task250446_scrollChanged();
void task196118_visualRegionForSelection();
+ void task254449_draggingItemToNegativeCoordinates();
void keyboardSearch();
};
@@ -1580,6 +1582,55 @@ void tst_QListView::task196118_visualRegionForSelection()
QVERIFY(view.visualRegionForSelection().isEmpty());
}
+void tst_QListView::task254449_draggingItemToNegativeCoordinates()
+{
+ //we'll check that the items are painted correctly
+ class MyListView : public QListView
+ {
+ public:
+ void setPositionForIndex(const QPoint &position, const QModelIndex &index)
+ { QListView::setPositionForIndex(position, index); }
+
+ } list;
+
+ QStandardItemModel model(1,1);
+ QModelIndex index = model.index(0,0);
+ model.setData(index, QLatin1String("foo"));
+ list.setModel(&model);
+ list.setViewMode(QListView::IconMode);
+ list.show();
+ QTest::qWait(200); //makes sure the layout is done
+
+ const QPoint topLeft(-6, 0);
+
+
+ list.setPositionForIndex(topLeft, index);
+
+ class MyItemDelegate : public QStyledItemDelegate
+ {
+ public:
+ MyItemDelegate() : numPaints(0) { }
+ void paint(QPainter *painter,
+ const QStyleOptionViewItem &option, const QModelIndex &index) const
+ {
+ numPaints++;
+ QStyledItemDelegate::paint(painter, option, index);
+ }
+
+ mutable int numPaints;
+ } delegate;
+
+ list.setItemDelegate(&delegate);
+
+ //we'll make sure the item is repainted
+ delegate.numPaints = 0;
+ list.viewport()->repaint();
+
+ QCOMPARE(list.visualRect(index).topLeft(), topLeft);
+ QCOMPARE(delegate.numPaints, 1);
+}
+
+
void tst_QListView::keyboardSearch()
{
QStringList items;