summaryrefslogtreecommitdiffstats
path: root/src/testlib/qabstractitemmodeltester.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/testlib/qabstractitemmodeltester.cpp')
-rw-r--r--src/testlib/qabstractitemmodeltester.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/testlib/qabstractitemmodeltester.cpp b/src/testlib/qabstractitemmodeltester.cpp
index 4c86d65e77..1cd18b98bb 100644
--- a/src/testlib/qabstractitemmodeltester.cpp
+++ b/src/testlib/qabstractitemmodeltester.cpp
@@ -438,7 +438,7 @@ void QAbstractItemModelTesterPrivate::parent()
// when asked for the parent of an invalid index.
MODELTESTER_VERIFY(!model->parent(QModelIndex()).isValid());
- if (!model->hasChildren())
+ if (model->rowCount() == 0 || model->columnCount() == 0)
return;
// Column 0 | Column 1 |
@@ -449,11 +449,12 @@ void QAbstractItemModelTesterPrivate::parent()
// Common error test #1, make sure that a top level index has a parent
// that is a invalid QModelIndex.
QModelIndex topIndex = model->index(0, 0, QModelIndex());
+ MODELTESTER_VERIFY(topIndex.isValid());
MODELTESTER_VERIFY(!model->parent(topIndex).isValid());
// Common error test #2, make sure that a second level index has a parent
// that is the first level index.
- if (model->hasChildren(topIndex)) {
+ if (model->rowCount(topIndex) > 0) {
QModelIndex childIndex = model->index(0, 0, topIndex);
MODELTESTER_VERIFY(childIndex.isValid());
MODELTESTER_COMPARE(model->parent(childIndex), topIndex);
@@ -465,7 +466,7 @@ void QAbstractItemModelTesterPrivate::parent()
if (model->hasIndex(0, 1)) {
QModelIndex topIndex1 = model->index(0, 1, QModelIndex());
MODELTESTER_VERIFY(topIndex1.isValid());
- if (model->hasChildren(topIndex) && model->hasChildren(topIndex1)) {
+ if (model->rowCount(topIndex) > 0 && model->rowCount(topIndex1) > 0) {
QModelIndex childIndex = model->index(0, 0, topIndex);
MODELTESTER_VERIFY(childIndex.isValid());
QModelIndex childIndex1 = model->index(0, 0, topIndex1);
@@ -569,7 +570,7 @@ void QAbstractItemModelTesterPrivate::checkChildren(const QModelIndex &parent, i
// recursively go down the children
if (model->hasChildren(index) && currentDepth < 10)
- checkChildren(index, ++currentDepth);
+ checkChildren(index, currentDepth + 1);
// make sure that after testing the children that the index doesn't change.
QModelIndex newerIndex = model->index(r, c, parent);
@@ -583,7 +584,7 @@ void QAbstractItemModelTesterPrivate::checkChildren(const QModelIndex &parent, i
*/
void QAbstractItemModelTesterPrivate::data()
{
- if (!model->hasChildren())
+ if (model->rowCount() == 0 || model->columnCount() == 0)
return;
MODELTESTER_VERIFY(model->index(0, 0).isValid());
@@ -719,12 +720,12 @@ void QAbstractItemModelTesterPrivate::rowsAboutToBeRemoved(const QModelIndex &pa
Changing c;
c.parent = parent;
c.oldSize = model->rowCount(parent);
- if (start > 0) {
+ if (start > 0 && model->columnCount(parent) > 0) {
const QModelIndex startIndex = model->index(start - 1, 0, parent);
MODELTESTER_VERIFY(startIndex.isValid());
c.last = model->data(startIndex);
}
- if (end < c.oldSize - 1) {
+ if (end < c.oldSize - 1 && model->columnCount(parent) > 0) {
const QModelIndex endIndex = model->index(end + 1, 0, parent);
MODELTESTER_VERIFY(endIndex.isValid());
c.next = model->data(endIndex);
@@ -844,3 +845,5 @@ bool QAbstractItemModelTesterPrivate::compare(const T1 &t1, const T2 &t2,
QT_END_NAMESPACE
+
+#include "moc_qabstractitemmodeltester.cpp"