Version: 6.3.1
Public Slots | Signals | Public Member Functions | Protected Member Functions | Private Attributes

SUIT_ProxyModel Class Reference

Proxy model which can be used above the SUIT_TreeMovel 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.
virtual void updateTree (SUIT_DataObject *=0)
 Update tree model.
void setSortingEnabled (bool)
 Enable/disable sorting.

Signals

void modelUpdated ()
void clicked (SUIT_DataObject *, int)

Public Member Functions

 SUIT_ProxyModel (QObject *=0)
 Constructor.
 SUIT_ProxyModel (SUIT_DataObject *, QObject *=0)
 Constructor.
 SUIT_ProxyModel (SUIT_AbstractModel *, QObject *=0)
 Constructor.
 ~SUIT_ProxyModel ()
 Destructor.
SUIT_DataObjectroot () const
 Get data tree root object.
void setRoot (SUIT_DataObject *)
 Set data tree root object.
SUIT_DataObjectobject (const QModelIndex &=QModelIndex()) const
 Get data object by the specified model index.
QModelIndex index (const SUIT_DataObject *, int=0) const
 Get model index by the specified data object.
bool autoDeleteTree () const
 Get 'auto-delete data tree' flag value.
void setAutoDeleteTree (const bool)
 Set 'auto-delete data tree' flag value.
bool autoUpdate () const
 Get 'auto-update tree' flag value.
void setAutoUpdate (const bool)
 Set 'auto-update tree' flag value.
bool updateModified () const
 Get 'updateModified' flag value.
void setUpdateModified (const bool)
 Set 'updateModified' flag value.
bool isSortingEnabled () const
 Check if sorting is enabled.
bool customSorting (const int) const
 Check if the specified column supports custom sorting.
virtual bool lessThan (const QModelIndex &, const QModelIndex &) const
 Compares two model indexes for the sorting purposes.
virtual void registerColumn (const int group_id, const QString &name, const int custom_id)
 Register new column in the model.
virtual void unregisterColumn (const int group_id, const QString &name)
 Remove column from the model.
virtual void setColumnIcon (const QString &name, const QPixmap &icon)
 Change column icon.
virtual QPixmap columnIcon (const QString &name) const
 Get column icon.
virtual void setAppropriate (const QString &name, const Qtx::Appropriate appr)
 Change appropriate status.
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).
virtual void setVisibilityState (const QString &id, Qtx::VisibilityState state)
 Set visibility state of the object.
virtual void setVisibilityStateForAll (Qtx::VisibilityState state)
 Set visibility state for all objects.
virtual Qtx::VisibilityState visibilityState (const QString &id) const
 Get visibility state of the object.
virtual void setHeaderFlags (const QString &name, const Qtx::HeaderViewFlags flags)
 Set header flags.
virtual Qtx::HeaderViewFlags headerFlags (const QString &name) const
 Get the header flags.
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.
 operator const QAbstractItemModel * () const
 operator QAbstractItemModel * ()
 operator const QObject * () const

Protected Member Functions

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

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(), and modelUpdated().

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

References clicked(), and modelUpdated().

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

References clicked(), and modelUpdated().

SUIT_ProxyModel::~SUIT_ProxyModel ( )

Member Function Documentation

SUIT_DataObject * SUIT_ProxyModel::root ( ) const [virtual]
Returns:
data tree root
See also:
setRoot()

Implements SUIT_AbstractModel.

References SUIT_AbstractModel.root(), 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().

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

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::autoDeleteTree ( ) const [virtual]
Returns:
'auto-delete data tree' flag value
See also:
setAutoDeleteTree()

Implements SUIT_AbstractModel.

References SUIT_AbstractModel.autoDeleteTree(), 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().

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

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

Implements SUIT_AbstractModel.

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

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

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

References mySortingEnabled.

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

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

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

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

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

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

void SUIT_ProxyModel::setVisibilityState ( const QString &  id,
Qtx::VisibilityState  state 
) [virtual]
Parameters:
id- column name
state- visible state

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

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

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

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

void SUIT_ProxyModel::emitClicked ( SUIT_DataObject obj,
const QModelIndex &  index 
) [virtual]
SUIT_DataSearcher * SUIT_ProxyModel::searcher ( ) const [virtual]

Reimplemented from SUIT_AbstractModel.

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

void SUIT_ProxyModel::setSearcher ( SUIT_DataSearcher s) [virtual]

Reimplemented from SUIT_AbstractModel.

References SUIT_AbstractModel.setSearcher(), and treeModel().

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

Implements SUIT_AbstractModel.

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

void SUIT_ProxyModel::updateTree ( const QModelIndex &  index) [virtual, slot]

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

Implements SUIT_AbstractModel.

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

void SUIT_ProxyModel::updateTree ( SUIT_DataObject obj = 0) [virtual, slot]

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

Implements SUIT_AbstractModel.

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

void SUIT_ProxyModel::setSortingEnabled ( bool  enabled) [slot]
Parameters:
enablednew flag state
See also:
isSortingEnabled()

References mySortingEnabled.

void SUIT_ProxyModel.modelUpdated ( ) [signal]
void SUIT_ProxyModel.clicked ( SUIT_DataObject ,
int   
) [signal]
SUIT_AbstractModel * SUIT_ProxyModel::treeModel ( ) const [protected]
bool SUIT_ProxyModel::filterAcceptsRow ( int  sourceRow,
const QModelIndex &  sourceParent 
) const [protected, virtual]
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().

SUIT_AbstractModel::operator const QAbstractItemModel * ( ) const [inherited]
SUIT_AbstractModel::operator QAbstractItemModel * ( ) [inherited]
SUIT_AbstractModel::operator const QObject * ( ) const [inherited]

Field Documentation

Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS