Version: 9.12.0
QtxTreeView Class Reference

Tree view class with possibility to display columns popup menu. More...

#include <QtxTreeView.h>

Inheritance diagram for QtxTreeView:
Inheritance graph

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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ QtxTreeView() [1/2]

QtxTreeView::QtxTreeView ( QWidget parent = 0)

Constructor.

Parameters
parentparent widget

◆ QtxTreeView() [2/2]

QtxTreeView::QtxTreeView ( const bool  enableSortMenu,
QWidget parent = 0 
)

Constructor.

Parameters
enableSortMenushow "Sorting" header menu command if true
parentparent widget

◆ ~QtxTreeView()

QtxTreeView::~QtxTreeView ( )
virtual

Destructor.

Member Function Documentation

◆ collapseAll()

void QtxTreeView::collapseAll ( const QModelIndex &  index)

Collapse the branch specifed by the \index and all its children recursively.

Parameters
indexmodel index to be collapsed
See also
expandAll()

References setOpened().

◆ collapseLevels()

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

Parameters
levelsnumber of levels to be collapsed
See also
expandLevels(), setOpened()

References setOpened().

◆ emitSortingEnabled()

void QtxTreeView::emitSortingEnabled ( bool  enabled)
private

Emit sortingEnabled(bool) signal.

Parameters
enabled"enable sorting" flag state

References sortingEnabled().

◆ expandAll()

void QtxTreeView::expandAll ( const QModelIndex &  index)

Expand the branch specifed by the \index and all its children recursively.

Parameters
indexmodel index to be expanded
See also
collapseAll()

References setOpened().

◆ expandLevels()

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

Parameters
levelsnumber of levels to be opened
See also
collapseLevels(), setOpened()

References setOpened().

◆ onAppropriate

void QtxTreeView::onAppropriate ( Qt::Orientation  orient,
int  first,
int  last 
)
protectedslot

◆ onHeaderClicked

void QtxTreeView::onHeaderClicked ( int  column)
protectedslot

◆ resizeColumnToEncloseContents()

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.

Parameters
columnnumber of column

◆ rowsAboutToBeRemoved

void QtxTreeView::rowsAboutToBeRemoved ( const QModelIndex &  parent,
int  start,
int  end 
)
protectedslot

Called when rows are about to be removed.

Parameters
parentmodel index
startfirst row to remove
endlast row to remove

◆ scrollTo()

void QtxTreeView::scrollTo ( const QModelIndex &  index,
QAbstractItemView::ScrollHint  hint = QAbstractItemView::EnsureVisible 
)
virtual

◆ selectionChanged [1/2]

QtxTreeView::selectionChanged ( )
signal

Emitted when selection is changed in the tree view.

◆ selectionChanged [2/2]

void QtxTreeView::selectionChanged ( const QItemSelection &  selected,
const QItemSelection &  deselected 
)
protectedslot

Called when the selection is changed.

Emits selectionChanged() signal.

Parameters
selectednew selection
deselectedprevious selection

References selectionChanged().

◆ setModel()

void QtxTreeView::setModel ( QAbstractItemModel m)
virtual

References onAppropriate().

◆ setOpened()

void QtxTreeView::setOpened ( const QModelIndex &  index,
const int  levels,
bool  open 
)
protected

Expand/collapse the specified item (recursively).

Parameters
indexmodel index
levelsnumber of levels to be expanded/collapsed
openif true, item is expanded, otherwise it is collapsed
See also
expandLevels(), collapseLevels()

◆ setSortMenuEnabled()

void QtxTreeView::setSortMenuEnabled ( const bool  enableSortMenu)

◆ sortingEnabled

QtxTreeView::sortingEnabled ( bool  on)
signal

Emitted when "Sorting" commans is enabled/disabled from the popup menu.

Parameters
ontrue if sorting is enabled and false otherwise

◆ sortMenuEnabled()

bool QtxTreeView::sortMenuEnabled ( ) const

Friends And Related Function Documentation

◆ QtxTreeView::Header

friend class QtxTreeView::Header
friend

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