Version: 9.15.0
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

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

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() [1/3]

SUIT_ProxyModel::SUIT_ProxyModel ( QObject parent = 0)

Constructor.

Parameters
parentparent object

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

◆ SUIT_ProxyModel() [2/3]

SUIT_ProxyModel::SUIT_ProxyModel ( SUIT_DataObject root,
QObject parent = 0 
)

Constructor.

Parameters
rootroot data object
parentparent object

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

◆ SUIT_ProxyModel() [3/3]

SUIT_ProxyModel::SUIT_ProxyModel ( SUIT_AbstractModel model,
QObject parent = 0 
)

Constructor.

Parameters
modeltree model
parentparent object

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

◆ ~SUIT_ProxyModel()

SUIT_ProxyModel::~SUIT_ProxyModel ( )

Destructor.

Member Function Documentation

◆ appropriate()

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

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

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().

◆ autoDeleteTree()

bool SUIT_ProxyModel::autoDeleteTree ( ) const
virtual

Get 'auto-delete data tree' flag value.

Returns
'auto-delete data tree' flag value
See also
setAutoDeleteTree()

Implements SUIT_AbstractModel.

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

◆ autoUpdate()

bool SUIT_ProxyModel::autoUpdate ( ) const
virtual

Get 'auto-update tree' flag value.

Returns
'auto-update tree' flag value
See also
setAutoUpdate(), updateTree()

Implements SUIT_AbstractModel.

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

◆ clicked

void SUIT_ProxyModel::clicked ( SUIT_DataObject ,
int   
)
signal

◆ columnIcon()

QPixmap SUIT_ProxyModel::columnIcon ( const QString &  name) const
virtual

Get column icon.

Parameters
name- column name
Returns
icon of the specified column

Implements SUIT_AbstractModel.

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

◆ customSorting()

bool SUIT_ProxyModel::customSorting ( const int  column) const
virtual

Check if the specified column supports custom sorting.

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().

◆ delegate()

QAbstractItemDelegate * SUIT_ProxyModel::delegate ( ) const
virtual

Get item delegate for the model.

Returns
new item delegate

Implements SUIT_AbstractModel.

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

◆ dropped

void SUIT_ProxyModel::dropped ( const QList< SUIT_DataObject * > &  ,
SUIT_DataObject ,
int  ,
Qt::DropAction   
)
signal

◆ emitClicked()

void SUIT_ProxyModel::emitClicked ( SUIT_DataObject obj,
const QModelIndex &  index 
)
virtual

◆ filterAcceptsRow()

bool SUIT_ProxyModel::filterAcceptsRow ( int  sourceRow,
const QModelIndex &  sourceParent 
) const
protectedvirtual

Filter rows.

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().

◆ forgetObject()

void SUIT_ProxyModel::forgetObject ( const SUIT_DataObject obj)
virtual

◆ headerFlags()

Qtx::HeaderViewFlags SUIT_ProxyModel::headerFlags ( const QString &  name) const
virtual

Get the header flags.

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().

◆ index()

QModelIndex SUIT_ProxyModel::index ( const SUIT_DataObject obj,
int  column = 0 
) const
virtual

Get model index by the specified data object.

Parameters
objdata object
columndata object column
Returns
model index

Implements SUIT_AbstractModel.

References treeModel().

◆ isSortingEnabled()

bool SUIT_ProxyModel::isSortingEnabled ( ) const

Check if sorting is enabled.

Returns
true if sorting is enabled
See also
setSortingEnabled()

References mySortingEnabled.

◆ lessThan()

bool SUIT_ProxyModel::lessThan ( const QModelIndex &  left,
const QModelIndex &  right 
) const
virtual

Compares two model indexes for the sorting purposes.

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().

◆ modelUpdated

void SUIT_ProxyModel::modelUpdated ( )
signal

◆ object()

SUIT_DataObject * SUIT_ProxyModel::object ( const QModelIndex &  index = QModelIndex()) const
virtual

Get data object by the specified model index.

Parameters
indexmodel index
Returns
data object corresponding to the model index

Implements SUIT_AbstractModel.

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

◆ registerColumn()

void SUIT_ProxyModel::registerColumn ( const int  group_id,
const QString &  name,
const int  custom_id 
)
virtual

Register new column in the model.

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().

◆ renamed

void SUIT_ProxyModel::renamed ( SUIT_DataObject )
signal

◆ root()

SUIT_DataObject * SUIT_ProxyModel::root ( ) const
virtual

Get data tree root object.

Returns
data tree root
See also
setRoot()

Implements SUIT_AbstractModel.

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

◆ searcher()

SUIT_DataSearcher * SUIT_ProxyModel::searcher ( ) const
virtual

Reimplemented from SUIT_AbstractModel.

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

◆ setAppropriate()

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

Change appropriate status.

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().

◆ setAutoDeleteTree()

void SUIT_ProxyModel::setAutoDeleteTree ( const bool  on)
virtual

Set 'auto-delete data tree' flag value.

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().

◆ setAutoUpdate()

void SUIT_ProxyModel::setAutoUpdate ( const bool  on)
virtual

Set 'auto-update tree' flag value.

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().

◆ setColumnIcon()

void SUIT_ProxyModel::setColumnIcon ( const QString &  name,
const QPixmap &  icon 
)
virtual

Change column icon.

Parameters
name- column name
icon- new icon of the specified column

Implements SUIT_AbstractModel.

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

◆ setHeaderFlags()

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

Set header flags.

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().

◆ setRoot()

void SUIT_ProxyModel::setRoot ( SUIT_DataObject r)
virtual

Set data tree root object.

Parameters
rnew data tree root
See also
root()

Implements SUIT_AbstractModel.

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

◆ setSearcher()

void SUIT_ProxyModel::setSearcher ( SUIT_DataSearcher s)
virtual

◆ setSortingEnabled

void SUIT_ProxyModel::setSortingEnabled ( bool  enabled)
slot

Enable/disable sorting.

Parameters
enablednew flag state
See also
isSortingEnabled()

References mySortingEnabled.

◆ setUpdateModified()

void SUIT_ProxyModel::setUpdateModified ( const bool  on)
virtual

Set 'updateModified' flag value.

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().

◆ setVisibilityState()

void SUIT_ProxyModel::setVisibilityState ( const QString &  id,
Qtx::VisibilityState  state,
bool  emitChanged = true 
)
virtual

Set visibility state of the object.

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().

◆ setVisibilityStateForAll()

void SUIT_ProxyModel::setVisibilityStateForAll ( Qtx::VisibilityState  state)
virtual

Set visibility state for all objects.

Parameters
id- column name
state- visible state

Implements SUIT_AbstractModel.

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

◆ treeModel()

SUIT_AbstractModel * SUIT_ProxyModel::treeModel ( ) const
protected

◆ unregisterColumn()

void SUIT_ProxyModel::unregisterColumn ( const int  group_id,
const QString &  name 
)
virtual

Remove column from the model.

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().

◆ updateModified()

bool SUIT_ProxyModel::updateModified ( ) const
virtual

Get 'updateModified' flag value.

Returns
'updateModified' flag value

Implements SUIT_AbstractModel.

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

◆ updateTree [1/2]

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

Update tree model.

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 index(), treeModel(), and SUIT_AbstractModel::updateTree().

◆ updateTree [2/2]

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

Update tree model.

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().

◆ visibilityState()

Qtx::VisibilityState SUIT_ProxyModel::visibilityState ( const QString &  id) const
virtual

Get visibility state of the object.

Parameters
id- column name
Returns
visible state

Implements SUIT_AbstractModel.

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

Member Data Documentation

◆ mySortingEnabled

bool SUIT_ProxyModel::mySortingEnabled
private

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