Version: 6.3.1
Data Structures | Signals | Public Member Functions | Protected Slots | Protected Member Functions | Private Member Functions | Friends

QtxTreeView Class Reference

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

#include <QtxTreeView.h>

Inheritance diagram for QtxTreeView:
Inheritance graph

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

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::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::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::expandAll ( const QModelIndex &  index)
Parameters:
indexmodel index to be expanded
See also:
collapseAll()

References setOpened().

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

References setOpened().

void QtxTreeView::setSortMenuEnabled ( const bool  enableSortMenu)
bool QtxTreeView::sortMenuEnabled ( ) const
void QtxTreeView::resizeColumnToEncloseContents ( int  column)
Parameters:
columnnumber 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]
Parameters:
parentmodel index
startfirst row to remove
endlast row to remove
void QtxTreeView::selectionChanged ( const QItemSelection &  selected,
const QItemSelection &  deselected 
) [protected, slot]

Emits selectionChanged() signal.

Parameters:
selectednew selection
deselectedprevious selection

References selectionChanged().

void QtxTreeView::onAppropriate ( Qt::Orientation  orient,
int  first,
int  last 
) [protected, slot]
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()
QtxTreeView::sortingEnabled ( bool  on) [signal]
Parameters:
ontrue if sorting is enabled and false otherwise
QtxTreeView::selectionChanged ( ) [signal]
void QtxTreeView::emitSortingEnabled ( bool  enabled) [private]
Parameters:
enabled"enable sorting" flag state

References sortingEnabled().


Friends And Related Function Documentation

friend class QtxTreeView::Header [friend]
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS