CTK  0.1.0
The Common Toolkit is a community effort to provide support code for medical image analysis, surgical navigation, and related projects.
Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | Properties | List of all members
ctkModelTester Class Reference

#include <Libs/Core/ctkModelTester.h>

Inheritance diagram for ctkModelTester:
Inheritance graph
[legend]
Collaboration diagram for ctkModelTester:
Collaboration graph
[legend]

Public Member Functions

 ctkModelTester (QObject *parent=0)
 
 ctkModelTester (QAbstractItemModel *model, QObject *parent=0)
 
QAbstractItemModel * model () const
 
bool nestedInserts () const
 
void setModel (QAbstractItemModel *model)
 
void setNestedInserts (bool enable)
 
void setTestDataEnabled (bool enable)
 
void setThrowOnError (bool throwException)
 
void setVerbose (bool enable)
 When Verbose is enabled, message will be printed to standard or error output. More...
 
virtual void testData (const QModelIndex &index) const
 
bool testDataEnabled () const
 
virtual void testModel () const
 Run all the tests on the model previously set in setModel(...) More...
 
virtual void testModelIndex (const QModelIndex &index) const
 Run a collection of tests on a QModelIndex. More...
 
virtual void testParent (const QModelIndex &parent) const
 
virtual void testPersistentModelIndex (const QPersistentModelIndex &index) const
 
bool throwOnError () const
 
bool verbose () const
 
virtual ~ctkModelTester ()
 Destructor. More...
 

Protected Slots

void onColumnsAboutToBeInserted (const QModelIndex &parent, int start, int end)
 
void onColumnsAboutToBeRemoved (const QModelIndex &parent, int start, int end)
 
void onColumnsInserted (const QModelIndex &parent, int start, int end)
 
void onColumnsRemoved (const QModelIndex &parent, int start, int end)
 
void onDataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight)
 
void onHeaderDataChanged (Qt::Orientation orientation, int first, int last)
 
void onLayoutAboutToBeChanged ()
 
void onLayoutChanged ()
 
void onModelAboutToBeReset ()
 
void onModelReset ()
 
void onRowsAboutToBeInserted (const QModelIndex &parent, int start, int end)
 
void onRowsAboutToBeRemoved (const QModelIndex &parent, int start, int end)
 
void onRowsInserted (const QModelIndex &parent, int start, int end)
 
void onRowsRemoved (const QModelIndex &parent, int start, int end)
 

Protected Member Functions

virtual void onItemsAboutToBeInserted (const QModelIndex &parent, Qt::Orientation, int start, int end)
 
virtual void onItemsAboutToBeRemoved (const QModelIndex &parent, Qt::Orientation, int start, int end)
 
virtual void onItemsInserted (const QModelIndex &parent, Qt::Orientation, int start, int end)
 
virtual void onItemsRemoved (const QModelIndex &parent, Qt::Orientation, int start, int end)
 
QList< QPersistentModelIndex > persistentModelIndexes (const QModelIndex &index) const
 Create a list of persistent index of all the index's children. More...
 
virtual void test (bool result, const QString &errorString) const
 Utility function that process the result of a test. More...
 

Protected Attributes

QScopedPointer< ctkModelTesterPrivate > d_ptr
 

Properties

bool nestedInserts
 
bool testDataEnabled
 
bool throwOnError
 
bool verbose
 

Detailed Description

ctkModelTester is a tool that tests any QAbstractItemModel Most of the signals fired by the model set (ctkModelTester::setModel()) are connected to the tester that check their consistency with the model contents. ctkModelTester is typically used when developing a new QAbstractItemModel or during unit tests.

Definition at line 44 of file ctkModelTester.h.

Constructor & Destructor Documentation

ctkModelTester::ctkModelTester ( QObject *  parent = 0)
explicit

Constructor No model is set by default. To be tested, a model must be set using setModel(...)

ctkModelTester::ctkModelTester ( QAbstractItemModel *  model,
QObject *  parent = 0 
)

Constructor that set the model to test. A new model can later be set using setModel(...) by default, throwOnError is true, nestedInsert is false, testDataEnabled is true, verbose is true.

virtual ctkModelTester::~ctkModelTester ( )
virtual

Destructor.

Member Function Documentation

QAbstractItemModel* ctkModelTester::model ( ) const
bool ctkModelTester::nestedInserts ( ) const
void ctkModelTester::onColumnsAboutToBeInserted ( const QModelIndex &  parent,
int  start,
int  end 
)
protectedslot
void ctkModelTester::onColumnsAboutToBeRemoved ( const QModelIndex &  parent,
int  start,
int  end 
)
protectedslot
void ctkModelTester::onColumnsInserted ( const QModelIndex &  parent,
int  start,
int  end 
)
protectedslot
void ctkModelTester::onColumnsRemoved ( const QModelIndex &  parent,
int  start,
int  end 
)
protectedslot
void ctkModelTester::onDataChanged ( const QModelIndex &  topLeft,
const QModelIndex &  bottomRight 
)
protectedslot
void ctkModelTester::onHeaderDataChanged ( Qt::Orientation  orientation,
int  first,
int  last 
)
protectedslot
virtual void ctkModelTester::onItemsAboutToBeInserted ( const QModelIndex &  parent,
Qt::Orientation  ,
int  start,
int  end 
)
protectedvirtual

The logic of onColumnsAboutToBeInserted and onRowsAboutToBeInserted is gathered in onItemsAboutToBeInserted

virtual void ctkModelTester::onItemsAboutToBeRemoved ( const QModelIndex &  parent,
Qt::Orientation  ,
int  start,
int  end 
)
protectedvirtual

The logic of onColumnsAboutToBeRemoved and onRowsAboutToBeRemoved is gathered in onItemsAboutToBeRemoved

virtual void ctkModelTester::onItemsInserted ( const QModelIndex &  parent,
Qt::Orientation  ,
int  start,
int  end 
)
protectedvirtual

The logic of onColumnsInserted and onRowsInserted is gathered in onItemsInserted

virtual void ctkModelTester::onItemsRemoved ( const QModelIndex &  parent,
Qt::Orientation  ,
int  start,
int  end 
)
protectedvirtual

The logic of onColumnsRemoved and onRowsRemoved is gathered in onItemsRemoved

void ctkModelTester::onLayoutAboutToBeChanged ( )
protectedslot
void ctkModelTester::onLayoutChanged ( )
protectedslot
void ctkModelTester::onModelAboutToBeReset ( )
protectedslot
void ctkModelTester::onModelReset ( )
protectedslot
void ctkModelTester::onRowsAboutToBeInserted ( const QModelIndex &  parent,
int  start,
int  end 
)
protectedslot
void ctkModelTester::onRowsAboutToBeRemoved ( const QModelIndex &  parent,
int  start,
int  end 
)
protectedslot
void ctkModelTester::onRowsInserted ( const QModelIndex &  parent,
int  start,
int  end 
)
protectedslot
void ctkModelTester::onRowsRemoved ( const QModelIndex &  parent,
int  start,
int  end 
)
protectedslot
QList<QPersistentModelIndex> ctkModelTester::persistentModelIndexes ( const QModelIndex &  index) const
protected

Create a list of persistent index of all the index's children.

void ctkModelTester::setModel ( QAbstractItemModel *  model)

Set the model to be tested, the model must remain valid during the life ctkModelTester.

void ctkModelTester::setNestedInserts ( bool  enable)

nestedInserts controls wether the model is allowed to make nested row/column insertions ( an insertion signal is fired when an insertion a previous insertion was not finished). A row insertion consists of 2 signals: rowsAboutToBeInserted and rowsInserted It also applies for row/column suppressions.

void ctkModelTester::setTestDataEnabled ( bool  enable)

When TestData is enabled, it checks if the display role of a valid model index is valid too. You can disable the test if you are ok with temporary invalid display roles.

void ctkModelTester::setThrowOnError ( bool  throwException)

Throw an exception when an error is found in the model. True by default

void ctkModelTester::setVerbose ( bool  enable)

When Verbose is enabled, message will be printed to standard or error output.

virtual void ctkModelTester::test ( bool  result,
const QString &  errorString 
) const
protectedvirtual

Utility function that process the result of a test.

virtual void ctkModelTester::testData ( const QModelIndex &  index) const
virtual

Test the data consistency of a QModelIndex. Note: Only DisplayRole is checked.

bool ctkModelTester::testDataEnabled ( ) const
virtual void ctkModelTester::testModel ( ) const
virtual

Run all the tests on the model previously set in setModel(...)

virtual void ctkModelTester::testModelIndex ( const QModelIndex &  index) const
virtual

Run a collection of tests on a QModelIndex.

virtual void ctkModelTester::testParent ( const QModelIndex &  parent) const
virtual

Check the hierarchy consistency of a QModelIndex child/parent/siblings relationships

virtual void ctkModelTester::testPersistentModelIndex ( const QPersistentModelIndex &  index) const
virtual

Test a persistent model index

bool ctkModelTester::throwOnError ( ) const
bool ctkModelTester::verbose ( ) const

Member Data Documentation

QScopedPointer<ctkModelTesterPrivate> ctkModelTester::d_ptr
protected

Definition at line 172 of file ctkModelTester.h.

Property Documentation

bool ctkModelTester::nestedInserts
readwrite

Definition at line 47 of file ctkModelTester.h.

bool ctkModelTester::testDataEnabled
readwrite

Definition at line 47 of file ctkModelTester.h.

bool ctkModelTester::throwOnError
readwrite

Definition at line 48 of file ctkModelTester.h.

bool ctkModelTester::verbose
readwrite

Definition at line 49 of file ctkModelTester.h.


The documentation for this class was generated from the following file: