Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

Classes

class  ToolTip
 

Public Types

typedef QMap< QString, bool > MapOfOpenStates
 

Signals

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

Public Member Functions

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

Protected Member Functions

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

Private Slots

void onExpandAll ()
 Called when "Expand all" popup menu command is activated. More...
 
void onCollapseAll ()
 Called when "Collapse all" popup menu command is activated. More...
 
virtual void onExpanded (const QModelIndex &)
 

Private Member Functions

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

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.

Member Typedef Documentation

typedef QMap<QString, bool> OB_Browser::MapOfOpenStates

Constructor & Destructor Documentation

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

Member Function Documentation

void OB_Browser::adjustColumnsWidth ( )
void OB_Browser::adjustFirstColumnWidth ( )
void OB_Browser::adjustWidth ( )
int OB_Browser::autoOpenLevel ( ) const
Returns
number of levels to be auto-opened on tree updating
See Also
setAutoOpenLevel()

References myAutoOpenLevel.

void OB_Browser::contextMenuEvent ( QContextMenuEvent *  e)
protectedvirtual
Parameters
econtext menu event

Reimplemented in SUIT_DataBrowser.

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

void OB_Browser::createPopupMenu ( QMenu menu)
protectedvirtual

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

unsigned long OB_Browser::getModifiedTime ( ) const
Returns
latest updating time

References myModifiedTime.

QByteArray OB_Browser::getOpenStates ( int  theColumn) const

References openStates().

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.

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.

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

References mySearchTool.

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

References myView.

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

References 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.

void OB_Browser::onCollapseAll ( )
privateslot

Collapse all selected items recursively.

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

void OB_Browser::onExpandAll ( )
privateslot

Expands all selected items recursively.

References QtxTreeView::expandAll(), myView, onExpanded(), selectedIndexes(), and treeView().

virtual void OB_Browser::onExpanded ( const QModelIndex &  )
inlineprivatevirtualslot
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.

void OB_Browser::openStates ( bool  isGet,
MapOfOpenStates theMap,
const QModelIndex &  theIndex,
int  theColumn 
)

References isOpen(), model(), and treeView().

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

References myView.

QtxSearchTool * OB_Browser::searchTool ( ) const
Returns
search tool widget
See Also
isSearchToolEnabled(), setSearchToolEnabled()

References mySearchTool.

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

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::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::setAutoOpenLevel ( const int  levels)
Parameters
levelsnumber of levels to be auto-opened on tree updating
See Also
autoOpenLevel()

References myAutoOpenLevel.

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

References myView.

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

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

void OB_Browser::setModified ( )

References myModifiedTime.

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::setOpenStates ( const QByteArray &  theData,
int  theColumn 
)

References isOpen(), and openStates().

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

References myView, and rootIsDecorated().

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

References mySearchTool.

void OB_Browser::setSortMenuEnabled ( const bool  enabled)
bool OB_Browser::sortMenuEnabled ( ) const
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.

Member Data Documentation

int OB_Browser::myAutoOpenLevel
private
unsigned long OB_Browser::myModifiedTime
private
QtxSearchTool* OB_Browser::mySearchTool
private
QtxTreeView* OB_Browser::myView
private

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