summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp')
-rw-r--r--tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp89
1 files changed, 53 insertions, 36 deletions
diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
index e5abd6bc46..a4ff7e1c60 100644
--- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
+++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp
@@ -65,17 +65,9 @@ class tst_QTableView : public QObject
{
Q_OBJECT
-public:
- tst_QTableView();
- virtual ~tst_QTableView();
-
-public slots:
+private slots:
void initTestCase();
- void cleanupTestCase();
- void init();
- void cleanup();
-private slots:
void getSetCheck();
void noDelegate();
@@ -214,6 +206,8 @@ private slots:
void changeHeaderData();
void viewOptions();
+
+ void taskQTBUG_7232_AllowUserToControlSingleStep();
};
// Testing get/set functions
@@ -325,8 +319,10 @@ public:
return QVariant();
}
- if (role == Qt::DisplayRole || role == Qt::EditRole)
- return QString("[%1,%2,%3]").arg(idx.row()).arg(idx.column()).arg(0);
+ if (role == Qt::DisplayRole || role == Qt::EditRole) {
+ return QLatin1Char('[') + QString::number(idx.row()) + QLatin1Char(',')
+ + QString::number(idx.column()) + QLatin1String(",0]");
+ }
return QVariant();
}
@@ -415,7 +411,8 @@ public:
void reset()
{
- QAbstractTableModel::reset();
+ beginResetModel();
+ endResetModel();
}
int row_count;
@@ -527,14 +524,6 @@ public:
QSize hint;
};
-tst_QTableView::tst_QTableView()
-{
-}
-
-tst_QTableView::~tst_QTableView()
-{
-}
-
void tst_QTableView::initTestCase()
{
#ifdef Q_OS_WINCE //disable magic for WindowsCE
@@ -542,18 +531,6 @@ void tst_QTableView::initTestCase()
#endif
}
-void tst_QTableView::cleanupTestCase()
-{
-}
-
-void tst_QTableView::init()
-{
-}
-
-void tst_QTableView::cleanup()
-{
-}
-
void tst_QTableView::noDelegate()
{
QtTestTableModel model(3, 3);
@@ -3606,7 +3583,11 @@ public:
{
return QVariant();
}
- void res() { reset(); }
+ void res()
+ {
+ beginResetModel();
+ endResetModel();
+ }
int rows;
int columns;
@@ -3797,7 +3778,7 @@ public:
int role = Qt::DisplayRole) const
{
if (role == Qt::DisplayRole)
- return QString("%1 - %2").arg(index.column()).arg(index.row());
+ return QString::number(index.column()) + QLatin1String(" - ") + QString::number(index.row());
return QVariant();
}
@@ -3919,12 +3900,12 @@ void tst_QTableView::task227953_setRootIndex()
//setup the first table as a child of the first item
for ( int row = 0; row < 40; ++row ) {
- item1.appendRow(QList<QStandardItem*>() << new QStandardItem(QString("row %0").arg(row)));
+ item1.appendRow(QList<QStandardItem*>() << new QStandardItem(QLatin1String("row ") + QString::number(row)));
}
//setup the second table as a child of the second item
for ( int row = 0; row < 10; ++row ) {
- item2.appendRow(QList<QStandardItem*>() << new QStandardItem(QString("row %0").arg(row)));
+ item2.appendRow(QList<QStandardItem*>() << new QStandardItem(QLatin1String("row ") + QString::number(row)));
}
tableView.setModel(&model);
@@ -4476,5 +4457,41 @@ void tst_QTableView::taskQTBUG_30653_doItemsLayout()
QCOMPARE(scrollToBottomOffset, doItemsLayoutOffset);
}
+void tst_QTableView::taskQTBUG_7232_AllowUserToControlSingleStep()
+{
+ // When we set the scrollMode to ScrollPerPixel it will adjust the scrollbars singleStep automatically
+ // Setting a singlestep on a scrollbar should however imply that the user takes control (and it is not changed by geometry updates).
+ // Setting a singlestep to -1 return to an automatic control of the singleStep.
+ QTableView t;
+ t.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
+ t.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
+ QStandardItemModel model(200, 200);
+ t.setModel(&model);
+ t.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&t));
+ t.setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
+ t.setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
+
+ t.setGeometry(200, 200, 200, 200);
+ int vStep1 = t.verticalScrollBar()->singleStep();
+ int hStep1 = t.horizontalScrollBar()->singleStep();
+ QVERIFY(vStep1 > 1);
+ QVERIFY(hStep1 > 1);
+
+ t.verticalScrollBar()->setSingleStep(1);
+ t.setGeometry(300, 300, 300, 300);
+ QCOMPARE(t.verticalScrollBar()->singleStep(), 1);
+
+ t.horizontalScrollBar()->setSingleStep(1);
+ t.setGeometry(400, 400, 400, 400);
+ QCOMPARE(t.horizontalScrollBar()->singleStep(), 1);
+
+ t.setGeometry(200, 200, 200, 200);
+ t.verticalScrollBar()->setSingleStep(-1);
+ t.horizontalScrollBar()->setSingleStep(-1);
+ QCOMPARE(vStep1, t.verticalScrollBar()->singleStep());
+ QCOMPARE(hStep1, t.horizontalScrollBar()->singleStep());
+}
+
QTEST_MAIN(tst_QTableView)
#include "tst_qtableview.moc"