Version: 8.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 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
 

Detailed Description

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::QtxTreeView ( QWidget parent = 0)
Parameters
parentparent widget
QtxTreeView::QtxTreeView ( const bool  enableSortMenu,
QWidget parent = 0 
)
Parameters
enableSortMenushow "Sorting" header menu command if true
parentparent widget
QtxTreeView::~QtxTreeView ( )
virtual

Member Function Documentation

void QtxTreeView::collapseAll ( const QModelIndex &  index)
Parameters
indexmodel index to be collapsed
See Also
expandAll()

References setOpened().

void QtxTreeView::collapseLevels ( const int  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().

void QtxTreeView::emitSortingEnabled ( bool  enabled)
private
Parameters
enabled"enable sorting" flag state

References sortingEnabled().

void QtxTreeView::expandAll ( const QModelIndex &  index)
Parameters
indexmodel index to be expanded
See Also
collapseAll()

References setOpened().

void QtxTreeView::expandLevels ( const int  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().

void QtxTreeView::onAppropriate ( Qt::Orientation  orient,
int  first,
int  last 
)
protectedslot
void QtxTreeView::onHeaderClicked ( int  column)
protectedslot
void QtxTreeView::resizeColumnToEncloseContents ( int  column)
Parameters
columnnumber of column
void QtxTreeView::rowsAboutToBeRemoved ( const QModelIndex &  parent,
int  start,
int  end 
)
protectedslot
Parameters
parentmodel index
startfirst row to remove
endlast row to remove
void QtxTreeView::selectionChanged ( const QItemSelection &  selected,
const QItemSelection &  deselected 
)
protectedslot

Emits selectionChanged() signal.

Parameters
selectednew selection
deselectedprevious selection

References selectionChanged().

QtxTreeView::selectionChanged ( )
signal
void QtxTreeView::setModel ( QAbstractItemModel m)
virtual

References onAppropriate().

void QtxTreeView::setOpened ( const QModelIndex &  index,
const int  levels,
bool  open 
)
protected
Parameters
indexmodel index
levelsnumber of levels to be expanded/collapsed
openif true, item is expanded, otherwise it is collapsed
See Also
expandLevels(), collapseLevels()
void QtxTreeView::setSortMenuEnabled ( const bool  enableSortMenu)
QtxTreeView::sortingEnabled ( bool  on)
signal
Parameters
ontrue if sorting is enabled and false otherwise
bool QtxTreeView::sortMenuEnabled ( ) const

Friends And Related Function Documentation

friend class QtxTreeView::Header
friend

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