Tree view class with possibility to display columns popup menu. More...
#include <QtxTreeView.h>

Data Structures | |
| class | Header |
| Custom tree view header class. More... | |
Signals | |
| void | sortingEnabled (bool) |
| Emitted when "Sorting" commans is enabled/disabled from the popup menu. | |
| void | selectionChanged () |
| Emitted when selection is changed in the tree view. | |
Public Member Functions | |
| QtxTreeView (QWidget *=0) | |
| Constructor. | |
| QtxTreeView (const bool, QWidget *=0) | |
| Constructor. | |
| virtual | ~QtxTreeView () |
| Destructor. | |
| void | expandLevels (const int) |
| Expand all branches for specified number of levels. | |
| void | collapseLevels (const int) |
| Collapse all branches for specified number of levels. | |
| void | expandAll (const QModelIndex &) |
| Expand the branch specifed by the and all its children recursively. | |
| void | collapseAll (const QModelIndex &) |
| Collapse the branch specifed by the and all its children recursively. | |
| void | setSortMenuEnabled (const bool) |
| bool | sortMenuEnabled () const |
| void | resizeColumnToEncloseContents (int) |
| Resizes the given column in order to enclose its contents. The size will be changed only if it is smaller than the size of contents. | |
| virtual void | setModel (QAbstractItemModel *) |
Protected Slots | |
| void | onHeaderClicked (int) |
| void | rowsAboutToBeRemoved (const QModelIndex &, int, int) |
| Called when rows are about to be removed. | |
| void | selectionChanged (const QItemSelection &, const QItemSelection &) |
| Called when the selection is changed. | |
| void | onAppropriate (Qt::Orientation, int, int) |
Protected Member Functions | |
| void | setOpened (const QModelIndex &, const int, bool) |
| Expand/collapse the specified item (recursively). | |
Private Member Functions | |
| void | emitSortingEnabled (bool) |
| Emit sortingEnabled(bool) signal. | |
Friends | |
| class | QtxTreeView::Header |
The QtxTreeView class represents a customized tree view class. In addition to the base functionality inherited from the QTreeView class, clicking at the tree view header with the right mouse button displays the popup menu allowing the user to show/hide specified columns.
By default the popup menu contains items corresponding to all the tree view columns. In order to disable some columns from being shown in the popup menu one may customize the data model (see QAbstractItemModel class). The custom model should implement headerData() method and return true for the Qtx.AppropriateRole role for those columns which should be available in the popup menu and false for the columns which should not be added to it.
| QtxTreeView::QtxTreeView | ( | QWidget * | parent = 0 | ) |
| parent | parent widget |
| QtxTreeView::QtxTreeView | ( | const bool | enableSortMenu, |
| QWidget * | parent = 0 |
||
| ) |
| enableSortMenu | show "Sorting" header menu command if true |
| parent | parent widget |
| QtxTreeView::~QtxTreeView | ( | ) | [virtual] |
| void QtxTreeView::expandLevels | ( | const int | levels | ) |
If levels < 0, all branches are expanded (the same results can be achieved with expandAll() method).
| levels | number of levels to be opened |
References setOpened().
| void QtxTreeView::collapseLevels | ( | const int | levels | ) |
If levels < 0, all branches are collapsed (the same results can be achieved with collapseAll() method).
| levels | number of levels to be collapsed |
References setOpened().
| void QtxTreeView::expandAll | ( | const QModelIndex & | index | ) |
| void QtxTreeView::collapseAll | ( | const QModelIndex & | index | ) |
| void QtxTreeView::setSortMenuEnabled | ( | const bool | enableSortMenu | ) |
References QtxTreeView.Header.setSortMenuEnabled().
| bool QtxTreeView::sortMenuEnabled | ( | ) | const |
References QtxTreeView.Header.sortMenuEnabled().
| void QtxTreeView::resizeColumnToEncloseContents | ( | int | column | ) |
| column | number of column |
| void QtxTreeView::setModel | ( | QAbstractItemModel * | m | ) | [virtual] |
References onAppropriate().
| void QtxTreeView::onHeaderClicked | ( | int | column | ) | [protected, slot] |
| void QtxTreeView::rowsAboutToBeRemoved | ( | const QModelIndex & | parent, |
| int | start, | ||
| int | end | ||
| ) | [protected, slot] |
| parent | model index |
| start | first row to remove |
| end | last row to remove |
| void QtxTreeView::selectionChanged | ( | const QItemSelection & | selected, |
| const QItemSelection & | deselected | ||
| ) | [protected, slot] |
Emits selectionChanged() signal.
| selected | new selection |
| deselected | previous selection |
References selectionChanged().
| void QtxTreeView::onAppropriate | ( | Qt::Orientation | orient, |
| int | first, | ||
| int | last | ||
| ) | [protected, slot] |
References Qtx.AppropriateRole, Qtx.Hidden, and Horizontal.
| void QtxTreeView::setOpened | ( | const QModelIndex & | index, |
| const int | levels, | ||
| bool | open | ||
| ) | [protected] |
| index | model index |
| levels | number of levels to be expanded/collapsed |
| open | if true, item is expanded, otherwise it is collapsed |
| QtxTreeView::sortingEnabled | ( | bool | on | ) | [signal] |
| on | true if sorting is enabled and false otherwise |
| QtxTreeView::selectionChanged | ( | ) | [signal] |
| void QtxTreeView::emitSortingEnabled | ( | bool | enabled | ) | [private] |
| enabled | "enable sorting" flag state |
References sortingEnabled().
friend class QtxTreeView::Header [friend] |