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 and all its children recursively. More... | |
void | collapseAll (const QModelIndex &) |
Collapse the branch specifed by the 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 *) |
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 |
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 |
enableSortMenu | show "Sorting" header menu command if true |
parent | parent widget |
|
virtual |
void QtxTreeView::collapseAll | ( | const QModelIndex & | index | ) |
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().
|
private |
enabled | "enable sorting" flag state |
References sortingEnabled().
void QtxTreeView::expandAll | ( | const QModelIndex & | index | ) |
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().
|
protectedslot |
References Qtx::AppropriateRole, Qtx::Hidden, and Horizontal.
|
protectedslot |
void QtxTreeView::resizeColumnToEncloseContents | ( | int | column | ) |
column | number of column |
|
protectedslot |
parent | model index |
start | first row to remove |
end | last row to remove |
|
protectedslot |
Emits selectionChanged() signal.
selected | new selection |
deselected | previous selection |
References selectionChanged().
|
signal |
|
virtual |
References onAppropriate().
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 |
on | true if sorting is enabled and false otherwise |
bool QtxTreeView::sortMenuEnabled | ( | ) | const |
References QtxTreeView::Header::sortMenuEnabled().
|
friend |