Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SUIT_ProxyModel Class Reference

Proxy model which can be used above the SUIT_TreeModel class to enable custom sorting/filtering of the data. More...

#include <SUIT_TreeModel.h>

Inheritance diagram for SUIT_ProxyModel:
Inheritance graph

Public Slots

virtual void updateTree (const QModelIndex &)
 Update tree model. More...
 
virtual void updateTree (SUIT_DataObject *=0)
 Update tree model. More...
 
void setSortingEnabled (bool)
 Enable/disable sorting. More...
 

Signals

void modelUpdated ()
 
void clicked (SUIT_DataObject *, int)
 
void dropped (const QList< SUIT_DataObject * > &, SUIT_DataObject *, int, Qt::DropAction)
 
void renamed (SUIT_DataObject *)
 

Public Member Functions

 SUIT_ProxyModel (QObject *=0)
 Constructor. More...
 
 SUIT_ProxyModel (SUIT_DataObject *, QObject *=0)
 Constructor. More...
 
 SUIT_ProxyModel (SUIT_AbstractModel *, QObject *=0)
 Constructor. More...
 
 ~SUIT_ProxyModel ()
 Destructor. More...
 
SUIT_DataObjectroot () const
 Get data tree root object. More...
 
void setRoot (SUIT_DataObject *)
 Set data tree root object. More...
 
SUIT_DataObjectobject (const QModelIndex &=QModelIndex()) const
 Get data object by the specified model index. More...
 
QModelIndex index (const SUIT_DataObject *, int=0) const
 Get model index by the specified data object. More...
 
bool autoDeleteTree () const
 Get 'auto-delete data tree' flag value. More...
 
void setAutoDeleteTree (const bool)
 Set 'auto-delete data tree' flag value. More...
 
bool autoUpdate () const
 Get 'auto-update tree' flag value. More...
 
void setAutoUpdate (const bool)
 Set 'auto-update tree' flag value. More...
 
bool updateModified () const
 Get 'updateModified' flag value. More...
 
void setUpdateModified (const bool)
 Set 'updateModified' flag value. More...
 
bool isSortingEnabled () const
 Check if sorting is enabled. More...
 
bool customSorting (const int) const
 Check if the specified column supports custom sorting. More...
 
virtual void forgetObject (const SUIT_DataObject *)
 
virtual bool lessThan (const QModelIndex &, const QModelIndex &) const
 Compares two model indexes for the sorting purposes. More...
 
virtual void registerColumn (const int group_id, const QString &name, const int custom_id)
 Register new column in the model. More...
 
virtual void unregisterColumn (const int group_id, const QString &name)
 Remove column from the model. More...
 
virtual void setColumnIcon (const QString &name, const QPixmap &icon)
 Change column icon. More...
 
virtual QPixmap columnIcon (const QString &name) const
 Get column icon. More...
 
virtual void setAppropriate (const QString &name, const Qtx::Appropriate appr)
 Change appropriate status. More...
 
virtual Qtx::Appropriate appropriate (const QString &name) const
 Check if the column should appear in the tree view header popup menu (to show/hide the column). More...
 
virtual void setVisibilityState (const QString &id, Qtx::VisibilityState state, bool emitChanged=true)
 Set visibility state of the object. More...
 
virtual void setVisibilityStateForAll (Qtx::VisibilityState state)
 Set visibility state for all objects. More...
 
virtual Qtx::VisibilityState visibilityState (const QString &id) const
 Get visibility state of the object. More...
 
virtual void setHeaderFlags (const QString &name, const Qtx::HeaderViewFlags flags)
 Set header flags. More...
 
virtual Qtx::HeaderViewFlags headerFlags (const QString &name) const
 Get the header flags. More...
 
virtual void emitClicked (SUIT_DataObject *obj, const QModelIndex &index)
 
virtual SUIT_DataSearchersearcher () const
 
virtual void setSearcher (SUIT_DataSearcher *)
 
QAbstractItemDelegate * delegate () const
 Get item delegate for the model. More...
 
- Public Member Functions inherited from SUIT_AbstractModel
 SUIT_AbstractModel ()
 
 operator const QAbstractItemModel * () const
 
 operator QAbstractItemModel * ()
 
 operator const QObject * () const
 
virtual void updateTree (const QModelIndex &)=0
 
virtual void updateTree (SUIT_DataObject *=0)=0
 

Protected Member Functions

SUIT_AbstractModeltreeModel () const
 
virtual bool filterAcceptsRow (int, const QModelIndex &) const
 Filter rows. More...
 

Private Attributes

bool mySortingEnabled
 

Detailed Description

The SUIT_TreeModel class does not support custom sorting/filtering of the data. To use these features, the SUIT_ProxyModel class can be used as top-level wrapper for the SUIT_DataObject-based data tree model.

Constructor & Destructor Documentation

SUIT_ProxyModel::SUIT_ProxyModel ( QObject parent = 0)
Parameters
parentparent object

References clicked(), dropped(), modelUpdated(), and renamed().

SUIT_ProxyModel::SUIT_ProxyModel ( SUIT_DataObject root,
QObject parent = 0 
)
Parameters
rootroot data object
parentparent object

References clicked(), dropped(), modelUpdated(), and renamed().

SUIT_ProxyModel::SUIT_ProxyModel ( SUIT_AbstractModel model,
QObject parent = 0 
)
Parameters
modeltree model
parentparent object

References clicked(), dropped(), modelUpdated(), and renamed().

SUIT_ProxyModel::~SUIT_ProxyModel ( )

Member Function Documentation

Qtx::Appropriate SUIT_ProxyModel::appropriate ( const QString &  name) const
virtual

Default implementation (if appropriate status is not specified yet) returns Shown, it means that column should be always visible.

Parameters
name- column name
Returns
appropriate status

Implements SUIT_AbstractModel.

References SUIT_AbstractModel::appropriate(), Qtx::Shown, and treeModel().

bool SUIT_ProxyModel::autoDeleteTree ( ) const
virtual
Returns
'auto-delete data tree' flag value
See Also
setAutoDeleteTree()

Implements SUIT_AbstractModel.

References SUIT_AbstractModel::autoDeleteTree(), and treeModel().

bool SUIT_ProxyModel::autoUpdate ( ) const
virtual
Returns
'auto-update tree' flag value
See Also
setAutoUpdate(), updateTree()

Implements SUIT_AbstractModel.

References SUIT_AbstractModel::autoUpdate(), and treeModel().

void SUIT_ProxyModel::clicked ( SUIT_DataObject ,
int   
)
signal
QPixmap SUIT_ProxyModel::columnIcon ( const QString &  name) const
virtual
Parameters
name- column name
Returns
icon of the specified column

Implements SUIT_AbstractModel.

References SUIT_AbstractModel::columnIcon(), and treeModel().

bool SUIT_ProxyModel::customSorting ( const int  column) const
virtual
Parameters
columncolumn index on which data is being sorted
Returns
true if column requires custom sorting
See Also
lessThan()

Implements SUIT_AbstractModel.

References SUIT_AbstractModel::customSorting(), and treeModel().

QAbstractItemDelegate * SUIT_ProxyModel::delegate ( ) const
virtual
Returns
new item delegate

Implements SUIT_AbstractModel.

References SUIT_AbstractModel::delegate(), and treeModel().

void SUIT_ProxyModel::dropped ( const QList< SUIT_DataObject * > &  ,
SUIT_DataObject ,
int  ,
Qt::DropAction   
)
signal
void SUIT_ProxyModel::emitClicked ( SUIT_DataObject obj,
const QModelIndex &  index 
)
virtual
bool SUIT_ProxyModel::filterAcceptsRow ( int  sourceRow,
const QModelIndex &  sourceParent 
) const
protectedvirtual
Parameters
sourceRowrow index of the source data model
sourceParentparent model index of the source data model
Returns
true if the specified row should be filtered out (i.e. not displayed) or false otherwise

References SUIT_DataObject::expandable(), index(), SUIT_DataObject::isVisible(), SUIT_AbstractModel::object(), SUIT_DataObject::parent(), and treeModel().

void SUIT_ProxyModel::forgetObject ( const SUIT_DataObject obj)
virtual
Qtx::HeaderViewFlags SUIT_ProxyModel::headerFlags ( const QString &  name) const
virtual

These flags allow show in the header of the column text (name of the column), icon or both text and icon.

Parameters
name- column name
Returns
header flags

Implements SUIT_AbstractModel.

References SUIT_AbstractModel::headerFlags(), Qtx::ShowAll, and treeModel().

QModelIndex SUIT_ProxyModel::index ( const SUIT_DataObject obj,
int  column = 0 
) const
virtual
Parameters
objdata object
columndata object column
Returns
model index

Implements SUIT_AbstractModel.

References treeModel().

bool SUIT_ProxyModel::isSortingEnabled ( ) const
Returns
true if sorting is enabled
See Also
setSortingEnabled()

References mySortingEnabled.

bool SUIT_ProxyModel::lessThan ( const QModelIndex &  left,
const QModelIndex &  right 
) const
virtual
Parameters
leftfirst index to compare
rightsecond index to compare
Returns
result of the comparison

Implements SUIT_AbstractModel.

References customSorting(), isSortingEnabled(), SUIT_AbstractModel::lessThan(), and treeModel().

void SUIT_ProxyModel::modelUpdated ( )
signal
SUIT_DataObject * SUIT_ProxyModel::object ( const QModelIndex &  index = QModelIndex()) const
virtual
Parameters
indexmodel index
Returns
data object corresponding to the model index

Implements SUIT_AbstractModel.

References SUIT_AbstractModel::object(), and treeModel().

void SUIT_ProxyModel::registerColumn ( const int  group_id,
const QString &  name,
const int  custom_id 
)
virtual
Parameters
group_id- unique data object identificator allowing the classification of objects
name- translated column name
custom_id- custom column id that should be passed into method SUIT_DataObject::data()

Implements SUIT_AbstractModel.

References SUIT_AbstractModel::registerColumn(), and treeModel().

void SUIT_ProxyModel::renamed ( SUIT_DataObject )
signal
SUIT_DataObject * SUIT_ProxyModel::root ( ) const
virtual
Returns
data tree root
See Also
setRoot()

Implements SUIT_AbstractModel.

References SUIT_AbstractModel::root(), and treeModel().

SUIT_DataSearcher * SUIT_ProxyModel::searcher ( ) const
virtual

Reimplemented from SUIT_AbstractModel.

References SUIT_AbstractModel::searcher(), and treeModel().

void SUIT_ProxyModel::setAppropriate ( const QString &  name,
const Qtx::Appropriate  appr 
)
virtual

Appropriate status determines if the column should appear in the tree view header popup menu (to show/hide the column).

If appropriate status is not specified yet, the Shown value is taken, it means that column should be always visible.

Parameters
name- column name
appr- new appropriate status

Implements SUIT_AbstractModel.

References SUIT_AbstractModel::setAppropriate(), and treeModel().

void SUIT_ProxyModel::setAutoDeleteTree ( const bool  on)
virtual

If this flag is set to true, the data tree is deleted when the tree model is destroyed. Default value for this flag is false.

Parameters
on'auto-delete data tree' flag value
See Also
autoDeleteTree()

Implements SUIT_AbstractModel.

References SUIT_AbstractModel::setAutoDeleteTree(), and treeModel().

void SUIT_ProxyModel::setAutoUpdate ( const bool  on)
virtual

If this flag is set to true (by default), the model is updated automatically when data tree is changed.

Parameters
on'auto-update tree' flag value
See Also
autoUpdate(), updateTree()

Implements SUIT_AbstractModel.

References SUIT_AbstractModel::setAutoUpdate(), and treeModel().

void SUIT_ProxyModel::setColumnIcon ( const QString &  name,
const QPixmap &  icon 
)
virtual
Parameters
name- column name
icon- new icon of the specified column

Implements SUIT_AbstractModel.

References SUIT_AbstractModel::setColumnIcon(), and treeModel().

void SUIT_ProxyModel::setHeaderFlags ( const QString &  name,
const Qtx::HeaderViewFlags  flags 
)
virtual

These flags allow show in the header of the column text (name of the column), icon or both text and icon.

Parameters
name- column name
flags- header flags

Implements SUIT_AbstractModel.

References SUIT_AbstractModel::setHeaderFlags(), and treeModel().

void SUIT_ProxyModel::setRoot ( SUIT_DataObject r)
virtual
Parameters
rnew data tree root
See Also
root()

Implements SUIT_AbstractModel.

References SUIT_AbstractModel::setRoot(), and treeModel().

void SUIT_ProxyModel::setSearcher ( SUIT_DataSearcher s)
virtual
void SUIT_ProxyModel::setSortingEnabled ( bool  enabled)
slot
Parameters
enablednew flag state
See Also
isSortingEnabled()

References mySortingEnabled.

void SUIT_ProxyModel::setUpdateModified ( const bool  on)
virtual

If this flag is set to true (default=false), the model is updated by updateTreeModel that uses the isModified flag to update only modified objects

Parameters
on'updateModified' flag value

Implements SUIT_AbstractModel.

References SUIT_AbstractModel::setUpdateModified(), and treeModel().

void SUIT_ProxyModel::setVisibilityState ( const QString &  id,
Qtx::VisibilityState  state,
bool  emitChanged = true 
)
virtual
Parameters
id- column name
state- visible state
emitChanged- if set to false, blocks dataChanged() signal, this can be used to prevent emitting dataChanged() several times for the same data object

Implements SUIT_AbstractModel.

References SUIT_AbstractModel::setVisibilityState(), and treeModel().

void SUIT_ProxyModel::setVisibilityStateForAll ( Qtx::VisibilityState  state)
virtual
Parameters
id- column name
state- visible state

Implements SUIT_AbstractModel.

References SUIT_AbstractModel::setVisibilityStateForAll(), and treeModel().

SUIT_AbstractModel * SUIT_ProxyModel::treeModel ( ) const
protected
void SUIT_ProxyModel::unregisterColumn ( const int  group_id,
const QString &  name 
)
virtual

Please take into account that column is removed only for given group_id, it means that information of data objects with such group_id won't be shown. If there is not any registered group_id for this column after removing, the column will be hidden otherwise it continue to be shown

Parameters
group_id- unique data object identificator allowing the classification of objects
name- translated column name

Implements SUIT_AbstractModel.

References treeModel(), and SUIT_AbstractModel::unregisterColumn().

bool SUIT_ProxyModel::updateModified ( ) const
virtual
Returns
'updateModified' flag value

Implements SUIT_AbstractModel.

References treeModel(), and SUIT_AbstractModel::updateModified().

void SUIT_ProxyModel::updateTree ( const QModelIndex &  index)
virtualslot

Call this method when data tree is changed outside the model. If the 'auto-update' flag is set to true, the model is updated automatically when the data tree is changed.

Parameters
indexstarting index for the updating
See Also
setAutoUpdate()

References treeModel(), and SUIT_AbstractModel::updateTree().

void SUIT_ProxyModel::updateTree ( SUIT_DataObject obj = 0)
virtualslot

Call this method when data tree is changed outside the model. If the 'auto-update' flag is set to true, the model is updated automatically when the data tree is changed.

Parameters
objstarting data object for the updating
See Also
setAutoUpdate()

References treeModel(), and SUIT_AbstractModel::updateTree().

Qtx::VisibilityState SUIT_ProxyModel::visibilityState ( const QString &  id) const
virtual
Parameters
id- column name
Returns
visible state

Implements SUIT_AbstractModel.

References treeModel(), Qtx::UnpresentableState, and SUIT_AbstractModel::visibilityState().

Member Data Documentation

bool SUIT_ProxyModel::mySortingEnabled
private

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