Object browser widget which can be used to handle tree-like data model. More...
#include <OB_Browser.h>

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... | |
| QAbstractItemModel * | model () 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) |
| QtxSearchTool * | searchTool () 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... | |
| QtxTreeView * | treeView () 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 | |
| QtxTreeView * | myView |
| QtxSearchTool * | mySearchTool |
| int | myAutoOpenLevel |
| unsigned long | myModifiedTime |
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.
| 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.
| typedef QMap<QString, bool> OB_Browser::MapOfOpenStates |
| OB_Browser::OB_Browser | ( | QWidget * | parent = 0, |
| QAbstractItemModel * | model = 0 |
||
| ) |
| parent | paren widget |
| model | data model |
References main(), mySearchTool, myView, selectionChanged(), QtxSearchTool::setActivators(), setModel(), QtxSearchTool::setSearcher(), QtxSearchTool::SlashKey, and QtxSearchTool::StandardKey.
|
virtual |
| void OB_Browser::adjustColumnsWidth | ( | ) |
References myView, and QtxTreeView::resizeColumnToEncloseContents().
| void OB_Browser::adjustFirstColumnWidth | ( | ) |
References myView, and QtxTreeView::resizeColumnToEncloseContents().
| void OB_Browser::adjustWidth | ( | ) |
References myView, and QtxTreeView::resizeColumnToEncloseContents().
| int OB_Browser::autoOpenLevel | ( | ) | const |
References myAutoOpenLevel.
|
protectedvirtual |
| e | context menu event |
Reimplemented in SUIT_DataBrowser.
References createPopupMenu(), and Qtx::simplifySeparators().
|
protectedvirtual |
SLOT: called if SUIT object is destroyed
SLOT: called on finish of drag-n-drop operation
| items | - dragged items |
| item | - destination (item on that they were dropped) |
| action | - QDropEvent::Action |
Updates texts of items
| item | - item to be checked |
Updates texts of item
| item | - item to be updated |
| menu | popup menu |
References hasCollased(), hasExpanded(), isSearchToolEnabled(), onCollapseAll(), onExpandAll(), searchTool(), and selectedIndexes().
| unsigned long OB_Browser::getModifiedTime | ( | ) | const |
References myModifiedTime.
| QByteArray OB_Browser::getOpenStates | ( | int | theColumn | ) | const |
References openStates().
|
private |
|
private |
| bool OB_Browser::isOpen | ( | const QModelIndex & | index | ) | const |
| bool OB_Browser::isSearchToolEnabled | ( | ) | const |
true if search tool is enabled References mySearchTool.
| QAbstractItemDelegate * OB_Browser::itemDelegate | ( | ) | const |
| QAbstractItemModel * OB_Browser::model | ( | ) | const |
| int OB_Browser::numberOfSelected | ( | ) | const |
Sets new value of state "are tooltips shown"
| theDisplay | - new value |
References myView.
|
privateslot |
Collapse all selected items recursively.
References QtxTreeView::collapseAll(), myView, and selectedIndexes().
|
privateslot |
Expands all selected items recursively.
References QtxTreeView::expandAll(), myView, onExpanded(), selectedIndexes(), and treeView().
|
inlineprivatevirtualslot |
| void OB_Browser::openLevels | ( | const int | levels = -1 | ) |
If levels value is negative, then autoOpenLevel() value is used instead.
| levels | number of levels to be expanded |
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 |
| QtxSearchTool * OB_Browser::searchTool | ( | ) | const |
References mySearchTool.
|
virtual |
| index | model index to be selected/deselected |
| on | if true, the index will be selected, otherwise - deselected |
| keepSelection | if true (default) the previous selection is kept, otherwise it is first cleared |
References myView.
|
virtual |
| indexes | model indices to be selected/deselected |
| on | if true, the indices will be selected, otherwise - deselected |
| keepSelection | if true (default) the previous selection is kept, otherwise it is first cleared |
References myView, and selectionChanged().
| QModelIndexList OB_Browser::selectedIndexes | ( | ) | const |
References myView.
| const QItemSelection OB_Browser::selection | ( | ) | const |
References myView.
|
signal |
Removes SUIT object
| obj | - SUIT object to be removed |
| autoUpd | - auto tree updating |
Opens branches from 1 to autoOpenLevel()
Opens branch
| item | |
| level |
SLOT: called on double click on item, emits signal
| void OB_Browser::setAutoOpenLevel | ( | const int | levels | ) |
| levels | number of levels to be auto-opened on tree updating |
References myAutoOpenLevel.
| void OB_Browser::setItemDelegate | ( | QAbstractItemDelegate * | d | ) |
| void OB_Browser::setModel | ( | QAbstractItemModel * | model | ) |
| model | data model |
References myView, QtxTreeView::setModel(), and setModified().
| void OB_Browser::setModified | ( | ) |
References myModifiedTime.
| void OB_Browser::setOpenStates | ( | const QByteArray & | theData, |
| int | theColumn | ||
| ) |
References isOpen(), and openStates().
| void OB_Browser::setRootIsDecorated | ( | const bool | decor | ) |
| decor | if true, top-level items are decorated |
References myView, and rootIsDecorated().
| void OB_Browser::setSearchToolEnabled | ( | const bool | enable | ) |
| enable | pass true to enable search tool |
References mySearchTool.
| void OB_Browser::setSortMenuEnabled | ( | const bool | enabled | ) |
References myView, QtxTreeView::setSortMenuEnabled(), and sortMenuEnabled().
| bool OB_Browser::sortMenuEnabled | ( | ) | const |
References myView, and QtxTreeView::sortMenuEnabled().
| QtxTreeView * OB_Browser::treeView | ( | ) | const |
| pos | - position |
Changes filter of list view
| f | - new filter |
Sets global width mode
| mode | - new width mode |
Updates tree
| obj | - start object |
| autoOpen | - to open automatically branches of autoOpenLevel() |
Replaces part of tree starting at object 'src' by tree starting at object 'trg'
Adjusts width by item
| 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
| 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
| 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
References myView.
|
private |
|
private |
|
private |
|
private |