Class to test all basic stuff of QAbstractItemModels.
More...
#include <modeltest.h>
Detailed Description
Class to test all basic stuff of QAbstractItemModels.
This class is from QtLabs. It is designed to watch a given model and run some checks after events like inserting or remove items. So use it like this:
YourModel *
model =
new YourModel(
this);
- Todo:
- Give more useful output with verbose > 0
Constructor & Destructor Documentation
ModelTest::ModelTest |
( |
QAbstractItemModel * |
_model, |
|
|
QObject * |
parent = NULL , |
|
|
int |
verbose = 1 |
|
) |
| |
Connect to all of the models signals. Whenever anything happens recheck everything.
Member Function Documentation
void ModelTest::checkChildren |
( |
const QModelIndex & |
parent, |
|
|
int |
currentDepth = 0 |
|
) |
| |
|
private |
Called from the parent() test.
A model that returns an index of parent X should also return X when asking for the parent of the index.
This recursive function does pretty extensive testing on the whole model in an effort to catch edge cases.
This function assumes that rowCount(), columnCount() and index() already work. If they have a bug it will point it out, but the above tests should have already found the basic bugs because it is easier to figure out the problem in those tests then this one.
void ModelTest::columnCount |
( |
| ) |
|
|
privateslot |
Tests model's implementation of QAbstractItemModel::columnCount() and hasChildren()
Tests model's implementation of QAbstractItemModel::data()
void ModelTest::hasIndex |
( |
| ) |
|
|
privateslot |
Tests model's implementation of QAbstractItemModel::hasIndex()
void ModelTest::index |
( |
| ) |
|
|
privateslot |
Tests model's implementation of QAbstractItemModel::index()
void ModelTest::layoutAboutToBeChanged |
( |
| ) |
|
|
protectedslot |
void ModelTest::layoutChanged |
( |
| ) |
|
|
protectedslot |
void ModelTest::nonDestructiveBasicTest |
( |
| ) |
|
|
privateslot |
nonDestructiveBasicTest tries to call a number of the basic functions (not all) to make sure the model doesn't outright segfault, testing the functions that makes sense.
void ModelTest::parent |
( |
| ) |
|
|
privateslot |
Tests model's implementation of QAbstractItemModel::parent()
void ModelTest::rowCount |
( |
| ) |
|
|
privateslot |
Tests model's implementation of QAbstractItemModel::rowCount() and hasChildren()
Models that are dynamically populated are not as fully tested here.
void ModelTest::rowsAboutToBeInserted |
( |
const QModelIndex & |
parent, |
|
|
int |
start, |
|
|
int |
|
|
) |
| |
|
protectedslot |
Store what is about to be inserted to make sure it actually happens
- See Also
- rowsInserted()
void ModelTest::rowsAboutToBeRemoved |
( |
const QModelIndex & |
parent, |
|
|
int |
start, |
|
|
int |
end |
|
) |
| |
|
protectedslot |
Store what is about to be inserted to make sure it actually happens
- See Also
- rowsRemoved()
void ModelTest::rowsInserted |
( |
const QModelIndex & |
parent, |
|
|
int |
start, |
|
|
int |
end |
|
) |
| |
|
protectedslot |
void ModelTest::rowsRemoved |
( |
const QModelIndex & |
parent, |
|
|
int |
start, |
|
|
int |
end |
|
) |
| |
|
protectedslot |
void ModelTest::runAllTests |
( |
| ) |
|
|
protectedslot |
Member Data Documentation
QList<QPersistentModelIndex> ModelTest::changing |
|
private |
bool ModelTest::fetchingMore |
|
private |
QAbstractItemModel* ModelTest::model |
|
private |
int ModelTest::verboseLevel |
|
private |
The documentation for this class was generated from the following files: