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

OB_Browser Class Reference

Object browser widget which can be used to handle tree-like data model. More...

#include <OB_Browser.h>

Inheritance diagram for OB_Browser:
Inheritance graph

Data Structures

class  ToolTip

Signals

void selectionChanged ()
 Emitted when selection is changed in the Object Browser.

Public Member Functions

 OB_Browser (QWidget *=0, QAbstractItemModel *=0)
 Constructor.
virtual ~OB_Browser ()
 Destructor.
QAbstractItemModelmodel () const
 Get data model.
void setModel (QAbstractItemModel *)
 Set data model.
QAbstractItemDelegate * itemDelegate () const
 Get current item delegate (items renderer).
void setItemDelegate (QAbstractItemDelegate *)
 Set item delegate (items renderer).
bool rootIsDecorated () const
 Check if controls for expanding and collapsing top-level items are shown.
void setRootIsDecorated (const bool)
 Show/hide controls for expanding and collapsing top-level items.
bool sortMenuEnabled () const
void setSortMenuEnabled (const bool)
QtxSearchToolsearchTool () const
 Get search tool widget.
bool isSearchToolEnabled () const
 Check if search tool is enabled.
void setSearchToolEnabled (const bool)
 Enable/disable search tool.
int autoOpenLevel () const
 Get number of levels which should be automatically expanded when updating the data tree.
void setAutoOpenLevel (const int)
 Set number of levels which should be automatically expanded when updating the data tree.
void openLevels (const int=-1)
 Expand all branches to the specified number of levels.
int numberOfSelected () const
 Get number of selected items.
QModelIndexList selectedIndexes () const
 Get all selected items.
const QItemSelection selection () const
 Get selection containing information about selected ranges.
virtual void select (const QModelIndex &, const bool, const bool=true)
 Select/deselect specified model index.
virtual void select (const QModelIndexList &, const bool, const bool=true)
 Select/deselect specified model indices.
bool isOpen (const QModelIndex &) const
 Check if specified model index is expanded or collapsed.
virtual void setOpen (const QModelIndex &theObject, const bool theOpen=true)
 Expand/collapse the specified model index.
void adjustWidth ()
 Adjust first column width to its contents.
void adjustFirstColumnWidth ()
 Adjust first column width to its contents.
void adjustColumnsWidth ()
 Adjust all columns width to its contents except the first column.
unsigned long getModifiedTime () const
 Get the time of the latest updating.
void setModified ()
 Update the time of the latest updating.
QtxTreeViewtreeView () const
 Get tree view widget.

Protected Member Functions

virtual void contextMenuEvent (QContextMenuEvent *)
 Process context menu request event.
virtual void createPopupMenu (QMenu *)
 Add custom actions to the popup menu.

Private Slots

void onExpandAll ()
 Called when "Expand all" popup menu command is activated.
void onCollapseAll ()
 Called when "Collapse all" popup menu command is activated.

Private Member Functions

bool hasCollased (const QModelIndex &) const
 Check if model index is collapsed or has collapsed children.
bool hasExpanded (const QModelIndex &) const
 Check if model index is expanded or has expanded children.

Private Attributes

QtxTreeViewmyView
QtxSearchToolmySearchTool
int myAutoOpenLevel
unsigned long myModifiedTime

Detailed Description

Constructor

Destructor

It is called when there is a possibility that a tool tip should be shown and must decide whether there is a tool tip for the point in the widget that this QToolTip object relates to.

Parameters:
pos- point co-ordinates

The class OB_Browser implements public API of an object browser widget that can be used to display arbitrary application data in a hierarchical form. It is based on Qt4 model/view architecture.

Object browser can be used with conjuction of any custom item model inherited from QAbstractItemModel class (see Qt 4 reference manual).

The class provides a functionality get/modify selection, drag-n-drop of the objects, etc.


Constructor & Destructor Documentation

OB_Browser::OB_Browser ( QWidget parent = 0,
QAbstractItemModel model = 0 
)
OB_Browser::~OB_Browser ( ) [virtual]

Member Function Documentation

QAbstractItemModel * OB_Browser::model ( ) const
Returns:
data model
See also:
setModel()

References myView.

void OB_Browser::setModel ( QAbstractItemModel model)
Parameters:
modeldata model
See also:
model()

References myView, QtxTreeView.setModel(), and setModified().

QAbstractItemDelegate * OB_Browser::itemDelegate ( ) const
Returns:
currently used item delegate
See also:
setItemDelegate()

References myView.

void OB_Browser::setItemDelegate ( QAbstractItemDelegate *  d)
Parameters:
dcustom item delegate
See also:
itemDelegate()

References myView.

bool OB_Browser::rootIsDecorated ( ) const
Returns:
true if top-level items are decorated
See also:
setRootIsDecorated()

References myView.

void OB_Browser::setRootIsDecorated ( const bool  decor)
Parameters:
decorif true, top-level items are decorated
See also:
rootIsDecorated()

References myView, and rootIsDecorated().

bool OB_Browser::sortMenuEnabled ( ) const
void OB_Browser::setSortMenuEnabled ( const bool  enabled)
QtxSearchTool * OB_Browser::searchTool ( ) const
Returns:
search tool widget
See also:
isSearchToolEnabled(), setSearchToolEnabled()

References mySearchTool.

bool OB_Browser::isSearchToolEnabled ( ) const
Returns:
true if search tool is enabled
See also:
setSearchToolEnabled(), searchTool()

References mySearchTool.

void OB_Browser::setSearchToolEnabled ( const bool  enable)
Parameters:
enablepass true to enable search tool
See also:
isSearchToolEnabled(), searchTool()

References mySearchTool.

int OB_Browser::autoOpenLevel ( ) const
Returns:
number of levels to be auto-opened on tree updating
See also:
setAutoOpenLevel()

References myAutoOpenLevel.

void OB_Browser::setAutoOpenLevel ( const int  levels)
Parameters:
levelsnumber of levels to be auto-opened on tree updating
See also:
autoOpenLevel()

References myAutoOpenLevel.

void OB_Browser::openLevels ( const int  levels = -1)

If levels value is negative, then autoOpenLevel() value is used instead.

Parameters:
levelsnumber of levels to be expanded
See also:
autoOpenLevel()

References autoOpenLevel(), QtxTreeView.expandLevels(), and myView.

int OB_Browser::numberOfSelected ( ) const
Returns:
state "are tooltips shown"

Sets new value of state "are tooltips shown"

Parameters:
theDisplay- new value
Returns:
number of selected items

References myView.

QModelIndexList OB_Browser::selectedIndexes ( ) const
Returns:
unsorted list of selected indexes with no duplicates

References myView.

const QItemSelection OB_Browser::selection ( ) const
Returns:
QItemSelection instance

References myView.

void OB_Browser::select ( const QModelIndex &  index,
const bool  on,
const bool  keepSelection = true 
) [virtual]
Parameters:
indexmodel index to be selected/deselected
onif true, the index will be selected, otherwise - deselected
keepSelectionif true (default) the previous selection is kept, otherwise it is first cleared

References myView.

void OB_Browser::select ( const QModelIndexList &  indexes,
const bool  on,
const bool  keepSelection = true 
) [virtual]
Parameters:
indexesmodel indices to be selected/deselected
onif true, the indices will be selected, otherwise - deselected
keepSelectionif true (default) the previous selection is kept, otherwise it is first cleared

References myView, and selectionChanged().

bool OB_Browser::isOpen ( const QModelIndex &  index) const
Parameters:
indexmodel index
Returns:
true if model index is expanded
See also:
setOpen()

References model(), and myView.

void OB_Browser::setOpen ( const QModelIndex &  index,
const bool  open = true 
) [virtual]
Parameters:
indexmodel index
openif true, the index will be expanded, otherwse - collapsed
See also:
isOpen()

References myView.

void OB_Browser::adjustWidth ( )
void OB_Browser::adjustFirstColumnWidth ( )
void OB_Browser::adjustColumnsWidth ( )
unsigned long OB_Browser::getModifiedTime ( ) const
Returns:
latest updating time

References myModifiedTime.

void OB_Browser::setModified ( )

References myModifiedTime.

QtxTreeView * OB_Browser::treeView ( ) const
Returns:
SUIT object correspondint to item at position 'pos'
Parameters:
pos- position
Returns:
filter of list view

Changes filter of list view

Parameters:
f- new filter

Sets global width mode

Parameters:
mode- new width mode

Updates tree

Parameters:
obj- start object
autoOpen- to open automatically branches of autoOpenLevel()
See also:
autoOpenLevel()

Replaces part of tree starting at object 'src' by tree starting at object 'trg'

Adjusts width by item

Parameters:
item

all items referencing current (through data objects)

Connects all children to SLOT onDestroyed

Disconnects all children from SLOT onDestroyed

Stores states (opened, selected) of current tree items

Returns:
current item
Parameters:
selObjs,selKeys- maps of selected objects
openObjs,openKeys- maps of opened objects
curKey- map of current objects

Restores states (opened, selected) of current tree items

Parameters:
selObjs,selKeys- maps of selected objects
openObjs,openKeys- maps of opened objects
curKey- map of current objects

Creates object key by tree item

Creates object key by SUIT object

Returns:
tree view widget of the object browser

References myView.

void OB_Browser::selectionChanged ( ) [signal]

Removes SUIT object

Parameters:
obj- SUIT object to be removed
autoUpd- auto tree updating

Opens branches from 1 to autoOpenLevel()

See also:
autoOpenLevel()

Opens branch

Parameters:
item
level

SLOT: called on double click on item, emits signal

void OB_Browser::onExpandAll ( ) [private, slot]

Expands all selected items recursively.

References QtxTreeView.expandAll(), myView, and selectedIndexes().

void OB_Browser::onCollapseAll ( ) [private, slot]

Collapse all selected items recursively.

References QtxTreeView.collapseAll(), myView, and selectedIndexes().

void OB_Browser::contextMenuEvent ( QContextMenuEvent *  e) [protected, virtual]
Parameters:
econtext menu event

Reimplemented in SUIT_DataBrowser.

References createPopupMenu(), and Qtx.simplifySeparators().

void OB_Browser::createPopupMenu ( QMenu menu) [protected, virtual]

SLOT: called if SUIT object is destroyed

SLOT: called on finish of drag-n-drop operation

Parameters:
items- dragged items
item- destination (item on that they were dropped)
action- QDropEvent.Action

Updates texts of items

Returns:
true if item must be updated
Parameters:
item- item to be checked

Updates texts of item

Parameters:
item- item to be updated
menupopup menu

References hasCollased(), hasExpanded(), isSearchToolEnabled(), onCollapseAll(), onExpandAll(), searchTool(), and selectedIndexes().

bool OB_Browser::hasCollased ( const QModelIndex &  index) const [private]

Expands item with all it's children

Returns:
true if item or one of its children is collapsed

References model(), and myView.

bool OB_Browser::hasExpanded ( const QModelIndex &  index) const [private]
Returns:
true if item or one of its children is expanded

References model(), and myView.


Field Documentation

unsigned long OB_Browser.myModifiedTime [private]
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