Tree view class with possibility to display columns popup menu. More...
#include <QtxTreeView.h>
Classes | |
class | Header |
Custom tree view header class. More... | |
Signals | |
void | sortingEnabled (bool) |
Emitted when "Sorting" commans is enabled/disabled from the popup menu. More... | |
void | selectionChanged () |
Emitted when selection is changed in the tree view. More... | |
Public Member Functions | |
QtxTreeView (QWidget *=0) | |
Constructor. More... | |
QtxTreeView (const bool, QWidget *=0) | |
Constructor. More... | |
virtual | ~QtxTreeView () |
Destructor. More... | |
void | expandLevels (const int) |
Expand all branches for specified number of levels. More... | |
void | collapseLevels (const int) |
Collapse all branches for specified number of levels. More... | |
void | expandAll (const QModelIndex &) |
Expand the branch specifed by the \index and all its children recursively. More... | |
void | collapseAll (const QModelIndex &) |
Collapse the branch specifed by the \index and all its children recursively. More... | |
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. More... | |
virtual void | setModel (QAbstractItemModel *) |
virtual void | scrollTo (const QModelIndex &index, QAbstractItemView::ScrollHint hint=QAbstractItemView::EnsureVisible) |
Protected Slots | |
void | onHeaderClicked (int) |
void | rowsAboutToBeRemoved (const QModelIndex &, int, int) |
Called when rows are about to be removed. More... | |
void | selectionChanged (const QItemSelection &, const QItemSelection &) |
Called when the selection is changed. More... | |
void | onAppropriate (Qt::Orientation, int, int) |
Protected Member Functions | |
void | setOpened (const QModelIndex &, const int, bool) |
Expand/collapse the specified item (recursively). More... | |
Private Member Functions | |
void | emitSortingEnabled (bool) |
Emit sortingEnabled(bool) signal. More... | |
Friends | |
class | QtxTreeView::Header |
Tree view class with possibility to display columns popup menu.
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 | ) |
Constructor.
parent | parent widget |
QtxTreeView::QtxTreeView | ( | const bool | enableSortMenu, |
QWidget * | parent = 0 |
||
) |
Constructor.
enableSortMenu | show "Sorting" header menu command if true |
parent | parent widget |
|
virtual |
Destructor.
void QtxTreeView::collapseAll | ( | const QModelIndex & | index | ) |
Collapse the branch specifed by the \index and all its children recursively.
index | model index to be collapsed |
References setOpened().
void QtxTreeView::collapseLevels | ( | const int | levels | ) |
Collapse all branches for specified number of 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().
|
private |
Emit sortingEnabled(bool) signal.
enabled | "enable sorting" flag state |
References sortingEnabled().
void QtxTreeView::expandAll | ( | const QModelIndex & | index | ) |
Expand the branch specifed by the \index and all its children recursively.
index | model index to be expanded |
References setOpened().
void QtxTreeView::expandLevels | ( | const int | levels | ) |
Expand all branches for specified number of 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().
|
protectedslot |
References Qtx::AppropriateRole, Qtx::Hidden, and Horizontal.
|
protectedslot |
void QtxTreeView::resizeColumnToEncloseContents | ( | int | column | ) |
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.
column | number of column |
|
protectedslot |
Called when rows are about to be removed.
parent | model index |
start | first row to remove |
end | last row to remove |
|
virtual |
|
signal |
Emitted when selection is changed in the tree view.
|
protectedslot |
Called when the selection is changed.
Emits selectionChanged() signal.
selected | new selection |
deselected | previous selection |
References selectionChanged().
|
virtual |
References onAppropriate().
|
protected |
Expand/collapse the specified item (recursively).
index | model index |
levels | number of levels to be expanded/collapsed |
open | if true , item is expanded, otherwise it is collapsed |
void QtxTreeView::setSortMenuEnabled | ( | const bool | enableSortMenu | ) |
References QtxTreeView::Header::setSortMenuEnabled().
|
signal |
Emitted when "Sorting" commans is enabled/disabled from the popup menu.
on | true if sorting is enabled and false otherwise |
bool QtxTreeView::sortMenuEnabled | ( | ) | const |
References QtxTreeView::Header::sortMenuEnabled().
|
friend |