itom  4.1.0
CheckableModelHelper Class Reference

#include <checkableModelHelper.h>

Inheritance diagram for CheckableModelHelper:

Public Slots

void setCheckState (const QModelIndex &modelIndex, Qt::CheckState checkState)
 
void setHeaderCheckState (int section, Qt::CheckState checkState)
 
void toggleCheckState (const QModelIndex &modelIndex)
 Utility function to toggle the checkstate of an index.
 
void toggleHeaderCheckState (int section)
 

Public Member Functions

 CheckableModelHelper (Qt::Orientation orientation, QObject *parent=0)
 
Qt::Orientation orientation () const
 
QAbstractItemModel * model () const
 
virtual void setModel (QAbstractItemModel *model)
 
QModelIndex rootIndex () const
 Reimplemented for internal reasons.
 
virtual void setRootIndex (const QModelIndex &index)
 
bool isHeaderCheckable (int section) const
 
bool isCheckable (const QModelIndex &index) const
 
Qt::CheckState headerCheckState (int section) const
 
Qt::CheckState checkState (const QModelIndex &) const
 
bool headerCheckState (int section, Qt::CheckState &checkState) const
 
bool checkState (const QModelIndex &, Qt::CheckState &checkState) const
 
void setPropagateDepth (int depth)
 
int propagateDepth () const
 
void setForceCheckability (bool force)
 When true, the new items are automatically set to checkable.
 
bool forceCheckability () const
 
Qt::CheckState defaultCheckState () const
 
void setDefaultCheckState (Qt::CheckState)
 

Protected Attributes

QScopedPointer< CheckableModelHelperPrivated_ptr
 

Properties

bool forceCheckability
 
int propagateDepth
 
Qt::CheckState defaultCheckState
 

Private Slots

void onHeaderDataChanged (Qt::Orientation orient, int first, int last)
 
void onDataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight)
 
void updateHeadersFromItems ()
 
void onColumnsInserted (const QModelIndex &parent, int start, int end)
 
void onRowsInserted (const QModelIndex &parent, int start, int end)
 

Private Member Functions

 Q_DECLARE_PRIVATE (CheckableModelHelper)
 
 Q_DISABLE_COPY (CheckableModelHelper)
 

Detailed Description

CheckableModelHelper expose functions to handle checkable models

Member Function Documentation

Qt::CheckState CheckableModelHelper::headerCheckState ( int  section) const

Utility function that returns the checkState of the section. One can access the same value through the model: model->headerData(orientation, section, Qt::CheckStateRole)

bool CheckableModelHelper::headerCheckState ( int  section,
Qt::CheckState &  checkState 
) const

Utility function that returns the checkState of the section. One can access the same value through the model: model->headerData(orientation, section, Qt::CheckStateRole)

bool CheckableModelHelper::isHeaderCheckable ( int  section) const

A section is checkable if its CheckStateRole data is non null. One can access the same value through the model: model->headerData(orientation, section, Qt::CheckStateRole).isEmpty()

QAbstractItemModel * CheckableModelHelper::model ( ) const

When setting the model, if PropagateToItems is true (by default), the check state of the checkable headers is updated from the check state of the items If you want to make sure of the check state of a header, after setting the (done by myView.setHeader(myCheckableModelHelper)), you can call myModel.setHeaderData(0, Qt::Horizontal, Qt::Checked, Qt::CheckStateRole) or myCheckableModelHelper->setCheckState(0, Qt::Checked)

void CheckableModelHelper::setHeaderCheckState ( int  section,
Qt::CheckState  checkState 
)
slot

Warning, setting the check state automatically set the header section checkable

void CheckableModelHelper::setPropagateDepth ( int  depth)

How deep in the model(tree) do you want the check state to be propagated A value of -1 correspond to the deepest level of the model. -1 by default


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