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 (QAbstractItemModel *model, QObject *parent=0)
 
 ctkModelTester (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() [1/2]

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

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

◆ ctkModelTester() [2/2]

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.

◆ ~ctkModelTester()

virtual ctkModelTester::~ctkModelTester ( )
virtual

Destructor.

Member Function Documentation

◆ model()

QAbstractItemModel* ctkModelTester::model ( ) const

◆ nestedInserts()

bool ctkModelTester::nestedInserts ( ) const

◆ onColumnsAboutToBeInserted

void ctkModelTester::onColumnsAboutToBeInserted ( const QModelIndex &  parent,
int  start,
int  end 
)
protectedslot

◆ onColumnsAboutToBeRemoved

void ctkModelTester::onColumnsAboutToBeRemoved ( const QModelIndex &  parent,
int  start,
int  end 
)
protectedslot

◆ onColumnsInserted

void ctkModelTester::onColumnsInserted ( const QModelIndex &  parent,
int  start,
int  end 
)
protectedslot

◆ onColumnsRemoved

void ctkModelTester::onColumnsRemoved ( const QModelIndex &  parent,
int  start,
int  end 
)
protectedslot

◆ onDataChanged

void ctkModelTester::onDataChanged ( const QModelIndex &  topLeft,
const QModelIndex &  bottomRight 
)
protectedslot

◆ onHeaderDataChanged

void ctkModelTester::onHeaderDataChanged ( Qt::Orientation  orientation,
int  first,
int  last 
)
protectedslot

◆ onItemsAboutToBeInserted()

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

The logic of onColumnsAboutToBeInserted and onRowsAboutToBeInserted is gathered in onItemsAboutToBeInserted

◆ onItemsAboutToBeRemoved()

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

The logic of onColumnsAboutToBeRemoved and onRowsAboutToBeRemoved is gathered in onItemsAboutToBeRemoved

◆ onItemsInserted()

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

The logic of onColumnsInserted and onRowsInserted is gathered in onItemsInserted

◆ onItemsRemoved()

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

The logic of onColumnsRemoved and onRowsRemoved is gathered in onItemsRemoved

◆ onLayoutAboutToBeChanged

void ctkModelTester::onLayoutAboutToBeChanged ( )
protectedslot

◆ onLayoutChanged

void ctkModelTester::onLayoutChanged ( )
protectedslot

◆ onModelAboutToBeReset

void ctkModelTester::onModelAboutToBeReset ( )
protectedslot

◆ onModelReset

void ctkModelTester::onModelReset ( )
protectedslot

◆ onRowsAboutToBeInserted

void ctkModelTester::onRowsAboutToBeInserted ( const QModelIndex &  parent,
int  start,
int  end 
)
protectedslot

◆ onRowsAboutToBeRemoved

void ctkModelTester::onRowsAboutToBeRemoved ( const QModelIndex &  parent,
int  start,
int  end 
)
protectedslot

◆ onRowsInserted

void ctkModelTester::onRowsInserted ( const QModelIndex &  parent,
int  start,
int  end 
)
protectedslot

◆ onRowsRemoved

void ctkModelTester::onRowsRemoved ( const QModelIndex &  parent,
int  start,
int  end 
)
protectedslot

◆ persistentModelIndexes()

QList<QPersistentModelIndex> ctkModelTester::persistentModelIndexes ( const QModelIndex &  index) const
protected

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

◆ setModel()

void ctkModelTester::setModel ( QAbstractItemModel *  model)

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

◆ setNestedInserts()

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.

◆ setTestDataEnabled()

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.

◆ setThrowOnError()

void ctkModelTester::setThrowOnError ( bool  throwException)

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

◆ setVerbose()

void ctkModelTester::setVerbose ( bool  enable)

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

◆ test()

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

Utility function that process the result of a test.

◆ testData()

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

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

◆ testDataEnabled()

bool ctkModelTester::testDataEnabled ( ) const

◆ testModel()

virtual void ctkModelTester::testModel ( ) const
virtual

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

◆ testModelIndex()

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

Run a collection of tests on a QModelIndex.

◆ testParent()

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

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

◆ testPersistentModelIndex()

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

Test a persistent model index

◆ throwOnError()

bool ctkModelTester::throwOnError ( ) const

◆ verbose()

bool ctkModelTester::verbose ( ) const

Member Data Documentation

◆ d_ptr

QScopedPointer<ctkModelTesterPrivate> ctkModelTester::d_ptr
protected

Definition at line 172 of file ctkModelTester.h.

Property Documentation

◆ nestedInserts

bool ctkModelTester::nestedInserts
readwrite

Definition at line 1 of file ctkModelTester.h.

◆ testDataEnabled

bool ctkModelTester::testDataEnabled
readwrite

Definition at line 1 of file ctkModelTester.h.

◆ throwOnError

bool ctkModelTester::throwOnError
readwrite

Definition at line 1 of file ctkModelTester.h.

◆ verbose

bool ctkModelTester::verbose
readwrite

Definition at line 1 of file ctkModelTester.h.


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