Wt  3.3.6
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
Public Member Functions | Protected Member Functions | List of all members
Wt::WTreeView Class Reference

A view class that displays a model as a tree or tree table. More...

#include <Wt/WTreeView>

Inheritance diagram for Wt::WTreeView:
Inheritance graph
[legend]

Public Member Functions

 WTreeView (WContainerWidget *parent=0)
 Creates a new tree view.
 
void setColumnFormat (int column, const WString &format)
 Sets the column format string (deprecated). More...
 
WString columnFormat (int column) const
 Returns the column format string (deprecated). More...
 
void setExpanded (const WModelIndex &, bool expanded)
 Expands or collapses a node. More...
 
bool isExpanded (const WModelIndex &index) const
 Returns whether a node is expanded. More...
 
void collapse (const WModelIndex &index)
 Collapses a node. More...
 
void expand (const WModelIndex &index)
 Expands a node. More...
 
void expandToDepth (int depth)
 Expands all nodes to a depth. More...
 
void setRootIsDecorated (bool show)
 Sets whether toplevel items are decorated. More...
 
bool rootIsDecorated () const
 Returns whether toplevel items are decorated. More...
 
virtual void resize (const WLength &width, const WLength &height)
 Resizes the widget. More...
 
Signal< WModelIndex > & collapsed ()
 Signal emitted when a node is collapsed. More...
 
Signal< WModelIndex > & expanded ()
 Signal emitted when a node is expanded. More...
 
virtual WWidgetitemWidget (const WModelIndex &index) const
 Returns the widget that renders an item. More...
 
virtual void setModel (WAbstractItemModel *model)
 Sets the model. More...
 
virtual void setColumnWidth (int column, const WLength &width)
 Sets the column width. More...
 
virtual void setAlternatingRowColors (bool enable)
 Sets if alternating row colors are to be used. More...
 
virtual void setRowHeight (const WLength &rowHeight)
 Sets the row height. More...
 
virtual void setHeaderHeight (const WLength &height)
 Sets the header height. More...
 
virtual void setColumnBorder (const WColor &color)
 Sets the column border color. More...
 
virtual void setColumnHidden (int column, bool hidden)
 Changes the visibility of a column. More...
 
virtual void setRowHeaderCount (int count)
 Configures the number of columns that are used as row headers. More...
 
virtual int pageCount () const
 Returns the number of pages. More...
 
virtual int pageSize () const
 Returns the page size. More...
 
virtual int currentPage () const
 Returns the current page. More...
 
virtual void setCurrentPage (int page)
 Sets the current page. More...
 
virtual void scrollTo (const WModelIndex &index, ScrollHint hint=EnsureVisible)
 Scrolls the view to an item. More...
 
virtual EventSignal
< WScrollEvent > & 
scrolled ()
 Signal emitted when scrolling. More...
 
- Public Member Functions inherited from Wt::WAbstractItemView
WAbstractItemModelmodel () const
 Returns the model. More...
 
void setRootIndex (const WModelIndex &rootIndex)
 Sets the root index. More...
 
const WModelIndexrootIndex () const
 Returns the root index. More...
 
void setItemDelegate (WAbstractItemDelegate *delegate)
 Sets the default item delegate. More...
 
WAbstractItemDelegateitemDelegate () const
 Returns the default item delegate. More...
 
void setItemDelegateForColumn (int column, WAbstractItemDelegate *delegate)
 Sets the delegate for a column. More...
 
WAbstractItemDelegateitemDelegateForColumn (int column) const
 Returns the delegate that was set for a column. More...
 
WAbstractItemDelegateitemDelegate (const WModelIndex &index) const
 Returns the delegate for rendering an item. More...
 
WAbstractItemDelegateitemDelegate (int column) const
 Returns the delegate for a column. More...
 
void setHeaderItemDelegate (WAbstractItemDelegate *delegate)
 Sets the header item delegate. More...
 
WAbstractItemDelegateheaderItemDelegate () const
 Returns the header item delegate. More...
 
virtual void setColumnAlignment (int column, AlignmentFlag alignment)
 Sets the content alignment for a column. More...
 
virtual AlignmentFlag columnAlignment (int column) const
 Returns the content alignment for a column. More...
 
virtual void setHeaderAlignment (int column, WFlags< AlignmentFlag > alignment)
 Sets the header alignment for a column. More...
 
AlignmentFlag headerAlignment (int column) const
 Returns the horizontal header alignment for a column (deprecated). More...
 
AlignmentFlag horizontalHeaderAlignment (int column) const
 Returns the horizontal header alignment for a column. More...
 
AlignmentFlag verticalHeaderAlignment (int column) const
 Returns the vertical header alignment for a column. More...
 
void setHeaderWordWrap (int column, bool enabled)
 Configures header text wrapping. More...
 
virtual bool alternatingRowColors () const
 Returns whether alternating row colors are used. More...
 
void sortByColumn (int column, SortOrder order)
 Sorts the data according to a column. More...
 
int sortColumn () const
 Returns the current sorting columm. More...
 
SortOrder sortOrder () const
 Returns the current sorting order. More...
 
void setSortingEnabled (bool enabled)
 Enables or disables sorting for all columns. More...
 
void setSortingEnabled (int column, bool enabled)
 Enables or disables sorting for a single column. More...
 
bool isSortingEnabled () const
 Returns whether sorting is enabled. More...
 
bool isSortingEnabled (int column) const
 Returns whether sorting is enabled for a single column. More...
 
void setColumnResizeEnabled (bool enabled)
 Enables interactive column resizing. More...
 
bool isColumnResizeEnabled () const
 Returns whether column resizing is enabled. More...
 
void setSelectionBehavior (SelectionBehavior behavior)
 Changes the selection behaviour. More...
 
SelectionBehavior selectionBehavior () const
 Returns the selection behaviour. More...
 
void setSelectionMode (SelectionMode mode)
 Sets the selection mode. More...
 
SelectionMode selectionMode () const
 Returns the selection mode. More...
 
WItemSelectionModelselectionModel () const
 Returns the selection model. More...
 
void setSelectedIndexes (const WModelIndexSet &indexes)
 Sets the selected items. More...
 
void clearSelection ()
 Clears the selection. More...
 
void select (const WModelIndex &index, SelectionFlag option=Select)
 Selects a single item. More...
 
bool isSelected (const WModelIndex &index) const
 Returns wheter an item is selected. More...
 
WModelIndexSet selectedIndexes () const
 Returns the set of selected items. More...
 
void setDragEnabled (bool enable)
 Enables the selection to be dragged (drag & drop). More...
 
void setDropsEnabled (bool enable)
 Enables drop operations (drag & drop). More...
 
const WLengthrowHeight () const
 Returns the row height.
 
WLength columnWidth (int column) const
 Returns the column width. More...
 
bool isColumnHidden (int column) const
 Returns if a column is hidden. More...
 
void hideColumn (int column)
 Hides a column. More...
 
void showColumn (int column)
 Shows a column. More...
 
void setHeaderHeight (const WLength &height, bool multiLine)
 Sets the header height, and vertical alignment (deprecated). By default, the header text is a single line that is centered vertically. More...
 
const WLengthheaderHeight () const
 Returns the header height. More...
 
void setEditTriggers (WFlags< EditTrigger > editTriggers)
 Configures what actions should trigger editing. More...
 
WFlags< EditTriggereditTriggers () const
 Returns the editing triggers. More...
 
void setEditOptions (WFlags< EditOption > options)
 Configures editing options. More...
 
WFlags< EditOptioneditOptions () const
 Returns the editing options. More...
 
void edit (const WModelIndex &index)
 Opens an editor for the given index. More...
 
void closeEditor (const WModelIndex &index, bool saveData=true)
 Closes the editor for the given index. More...
 
void closeEditors (bool saveData=true)
 Closes all open editors. More...
 
WValidator::State validateEditor (const WModelIndex &index)
 Validates the editor for the given index. More...
 
WValidator::State validateEditors ()
 Validates all editors. More...
 
bool isEditing (const WModelIndex &index) const
 Returns whether an editor is open for a given index. More...
 
bool isValid (const WModelIndex &index) const
 Returns whether an editor's state is valid.
 
Signal< WModelIndex,
WMouseEvent > & 
clicked ()
 Signal emitted when clicked. More...
 
Signal< WModelIndex,
WMouseEvent > & 
doubleClicked ()
 Signal emitted when double clicked. More...
 
Signal< WModelIndex,
WMouseEvent > & 
mouseWentDown ()
 Signal emitted when a mouse button is pressed down. More...
 
Signal< WModelIndex,
WMouseEvent > & 
mouseWentUp ()
 Signal emitted when the mouse button is released. More...
 
SignalselectionChanged ()
 Signal emitted when the selection is changed. More...
 
SignalpageChanged ()
 Signal emitted when page information was updated. More...
 
Signal< int, WLength > & columnResized ()
 Returns the signal emitted when a column is resized by the user. More...
 
bool sortEnabled ()
 Returns whether the view is sortable. More...
 
void setHeaderClickSortEnabled (bool enabled)
 Alow to sort. More...
 
Signal< int, WMouseEvent > & headerClicked ()
 Signal emitted when a header item is clicked. More...
 
Signal< int, WMouseEvent > & headerDoubleClicked ()
 Signal emitted when a header item is double clicked. More...
 
Signal< int, WMouseEvent > & headerMouseWentDown ()
 Signal emitted when a mouse button is pressed on a header item More...
 
Signal< int, WMouseEvent > & headerMouseWentUp ()
 Signal emitted when a mouse button is released on a header item More...
 
int rowHeaderCount () const
 Returns the number of columns that are used as row headers. More...
 
void setColumn1Fixed (bool enable)
 Configures whether horizontal scrolling includes the first column (deprecated) More...
 
bool column1Fixed () const
 Returns whether horizontal scrolling includes the first column. (deprecated) More...
 
virtual void setObjectName (const std::string &name)
 Sets an object name. More...
 
EventSignal< WKeyEvent > & keyWentDown ()
 Event signal emitted when a keyboard key is pushed down. More...
 
EventSignal< WKeyEvent > & keyPressed ()
 Event signal emitted when a "character" was entered. More...
 
EventSignal< WKeyEvent > & keyWentUp ()
 Event signal emitted when a keyboard key is released. More...
 
- Public Member Functions inherited from Wt::WCompositeWidget
 WCompositeWidget (WContainerWidget *parent=0)
 Creates a WCompositeWidget. More...
 
 WCompositeWidget (WWidget *implementation, WContainerWidget *parent)
 Creates a WCompositeWidget with given implementation. More...
 
virtual std::string objectName () const
 Returns the object name. More...
 
virtual const std::string id () const
 Returns the (unique) identifier for this object. More...
 
virtual void setPositionScheme (PositionScheme scheme)
 Sets the CSS position scheme. More...
 
virtual PositionScheme positionScheme () const
 Returns the CSS position scheme. More...
 
virtual void setOffsets (const WLength &offset, WFlags< Side > sides=All)
 Sets CSS offsets for a non-statically positioned widget. More...
 
virtual WLength offset (Side s) const
 Returns a CSS offset. More...
 
virtual WLength width () const
 Returns the width. More...
 
virtual WLength height () const
 Returns the height. More...
 
virtual void setMinimumSize (const WLength &width, const WLength &height)
 Sets a minimum size. More...
 
virtual WLength minimumWidth () const
 Returns the minimum width. More...
 
virtual WLength minimumHeight () const
 Returns the minimum height. More...
 
virtual void setMaximumSize (const WLength &width, const WLength &height)
 Sets a maximum size. More...
 
virtual WLength maximumWidth () const
 Returns the maximum width. More...
 
virtual WLength maximumHeight () const
 Returns the maximum height. More...
 
virtual void setLineHeight (const WLength &height)
 Sets the CSS line height for contained text.
 
virtual WLength lineHeight () const
 Returns the CSS line height for contained text. More...
 
virtual void setFloatSide (Side s)
 Specifies a CSS float side. More...
 
virtual Side floatSide () const
 Returns the CSS float side. More...
 
virtual void setClearSides (WFlags< Side > sides)
 Sets the sides that should be cleared of floats. More...
 
virtual WFlags< SideclearSides () const
 Returns the sides that should remain empty. More...
 
virtual void setMargin (const WLength &margin, WFlags< Side > sides=All)
 Sets CSS margins around the widget. More...
 
virtual WLength margin (Side side) const
 Returns a CSS margin set. More...
 
virtual void setHiddenKeepsGeometry (bool enabled)
 Sets whether the widget keeps its geometry when hidden. More...
 
virtual bool hiddenKeepsGeometry () const
 Returns whether the widget keeps its geometry when hidden. More...
 
virtual void setHidden (bool hidden, const WAnimation &animation=WAnimation())
 Hides or shows the widget. More...
 
virtual bool isHidden () const
 Returns whether the widget is set hidden. More...
 
virtual bool isVisible () const
 Returns whether the widget is visible. More...
 
virtual void setDisabled (bool disabled)
 Sets whether the widget is disabled. More...
 
virtual bool isDisabled () const
 Returns whether the widget is set disabled. More...
 
virtual bool isEnabled () const
 Returns whether the widget is enabled. More...
 
virtual void setPopup (bool popup)
 Lets the widget overlay over other sibling widgets. More...
 
virtual bool isPopup () const
 Returns whether the widget is overlayed. More...
 
virtual void setInline (bool isInline)
 Sets whether the widget is displayed inline or as a block. More...
 
virtual bool isInline () const
 Returns whether the widget is displayed inline or as block. More...
 
virtual void setDecorationStyle (const WCssDecorationStyle &style)
 Sets a CSS decoration style. More...
 
virtual WCssDecorationStyledecorationStyle ()
 Returns the decoration style of this widget. More...
 
virtual void setStyleClass (const WString &styleClass)
 Sets (one or more) CSS style classes. More...
 
virtual WString styleClass () const
 Returns the CSS style class. More...
 
virtual void addStyleClass (const WString &styleClass, bool force=false)
 Adds a CSS style class. More...
 
virtual void removeStyleClass (const WString &styleClass, bool force=false)
 Removes a CSS style class. More...
 
virtual bool hasStyleClass (const WString &styleClass) const
 Returns whether the widget has a style class.
 
virtual void setVerticalAlignment (AlignmentFlag alignment, const WLength &length=WLength::Auto)
 Sets the vertical alignment. More...
 
virtual AlignmentFlag verticalAlignment () const
 Returns the vertical alignment. More...
 
virtual WLength verticalAlignmentLength () const
 Returns the fixed vertical alignment that was set. More...
 
virtual void setToolTip (const WString &text, TextFormat textFormat=PlainText)
 Sets a tooltip. More...
 
virtual WString toolTip () const
 Returns the tooltip.
 
virtual void setDeferredToolTip (bool enable, TextFormat textFormat=PlainText)
 Enable deferred tooltip. More...
 
virtual void refresh ()
 Refresh the widget. More...
 
virtual void setAttributeValue (const std::string &name, const WString &value)
 Sets an attribute value. More...
 
virtual WString attributeValue (const std::string &name) const
 Returns an attribute value. More...
 
virtual void setJavaScriptMember (const std::string &name, const std::string &value)
 Sets a JavaScript member. More...
 
virtual std::string javaScriptMember (const std::string &name) const
 Returns the value of a JavaScript member. More...
 
virtual void callJavaScriptMember (const std::string &name, const std::string &args)
 Calls a JavaScript member. More...
 
virtual void load ()
 Loads content just before the widget is used. More...
 
virtual bool loaded () const
 Returns whether this widget has been loaded. More...
 
virtual void setCanReceiveFocus (bool enabled)
 Sets whether the widget can receive focus. More...
 
virtual bool canReceiveFocus () const
 Returns whether the widget can receive focus. More...
 
virtual void setFocus (bool focus)
 Sets focus. More...
 
virtual bool setFirstFocus ()
 Set focus on the widget's first descendant. More...
 
virtual bool hasFocus () const
 Returns whether the widget currently has the focus.
 
virtual void setTabIndex (int index)
 Sets the tab index. More...
 
virtual int tabIndex () const
 Returns the tab index. More...
 
virtual void setId (const std::string &id)
 Sets the CSS Id. More...
 
virtual WWidgetfind (const std::string &name)
 Finds a descendent widget by name. More...
 
virtual WWidgetfindById (const std::string &name)
 Finds a descendent widget by id.
 
virtual void setSelectable (bool selectable)
 Sets as selectable. More...
 
virtual void doJavaScript (const std::string &js)
 Executes the given JavaScript statements when the widget is rendered or updated. More...
 
virtual void propagateSetEnabled (bool enabled)
 Propagates that a widget was enabled or disabled through children. More...
 
- Public Member Functions inherited from Wt::WWidget
virtual ~WWidget ()
 Destructor. More...
 
WWidgetparent () const
 Returns the parent widget. More...
 
virtual void removeChild (WObject *child)
 Removes a child object. More...
 
void setWidth (const WLength &width)
 Sets the width. More...
 
void setHeight (const WLength &height)
 Sets the height. More...
 
virtual void positionAt (const WWidget *widget, Orientation orientation=Vertical)
 Positions a widget next to another widget. More...
 
virtual void toggleStyleClass (const WString &styleClass, bool add, bool force=false)
 Toggles a CSS style class.
 
std::string jsRef () const
 Returns a JavaScript expression to the corresponding DOM node. More...
 
void setFocus ()
 Sets focus. More...
 
virtual void acceptDrops (const std::string &mimeType, const WString &hoverStyleClass=WString())
 Sets a mime type to be accepted for dropping. More...
 
virtual void stopAcceptDrops (const std::string &mimeType)
 Indicates that a mime type is no longer accepted for dropping. More...
 
virtual void htmlText (std::ostream &out)
 Streams the (X)HTML representation. More...
 
bool isRendered () const
 Returns whether the widget is rendered. More...
 
void hide ()
 Hides the widget. More...
 
void animateHide (const WAnimation &animation)
 Hides the widget using an animation. More...
 
void show ()
 Shows the widget. More...
 
void animateShow (const WAnimation &animation)
 Shows the widget using an animation. More...
 
void enable ()
 Enables the widget. More...
 
void disable ()
 Disable thes widget. More...
 
bool layoutSizeAware () const
 Returns whether the widget is layout size aware. More...
 
- Public Member Functions inherited from Wt::WObject
 WObject (WObject *parent=0)
 Create a WObject with a given parent object. More...
 
virtual ~WObject ()
 Destructor. More...
 
void resetLearnedSlots ()
 Resets learned stateless slot implementations. More...
 
template<class T >
void resetLearnedSlot (void(T::*method)())
 Resets a learned stateless slot implementation. More...
 
template<class T >
WStatelessSlot * implementStateless (void(T::*method)())
 Declares a slot to be stateless and learn client-side behaviour on first invocation. More...
 
template<class T >
WStatelessSlot * implementStateless (void(T::*method)(), void(T::*undoMethod)())
 Declares a slot to be stateless and learn client-side behaviour in advance. More...
 
void isNotStateless ()
 Marks the current function as not stateless. More...
 
template<class T >
WStatelessSlot * implementJavaScript (void(T::*method)(), const std::string &jsCode)
 Provides a JavaScript implementation for a method. More...
 
void addChild (WObject *child)
 Adds a child object. More...
 
const std::vector< WObject * > & children () const
 Returns the children.
 
WObjectparent () const
 Returns the parent object.
 

Protected Member Functions

virtual void render (WFlags< RenderFlag > flags)
 Renders the widget. More...
 
virtual void enableAjax ()
 Progresses to an Ajax-enabled widget. More...
 
- Protected Member Functions inherited from Wt::WAbstractItemView
 WAbstractItemView (WContainerWidget *parent=0)
 Creates a new item view.
 
virtual void dropEvent (const WDropEvent &event, const WModelIndex &target)
 Handles a drop event (drag & drop). More...
 
virtual WWidgetcreateExtraHeaderWidget (int column)
 Create an extra widget in the header. More...
 
WWidgetextraHeaderWidget (int column)
 Returns the extra header widget. More...
 
virtual WWidgetcreatePageNavigationBar ()
 Returns a page navigation widget. More...
 
virtual void handleClick (const WModelIndex &index, const WMouseEvent &event)
 Handles a click event. More...
 
virtual void handleDoubleClick (const WModelIndex &index, const WMouseEvent &event)
 Handles a double click event. More...
 
virtual void handleMouseDown (const WModelIndex &index, const WMouseEvent &event)
 Handles a mouse down event. More...
 
virtual void handleMouseUp (const WModelIndex &index, const WMouseEvent &event)
 Handles a mouse up event. More...
 
- Protected Member Functions inherited from Wt::WCompositeWidget
void setImplementation (WWidget *widget)
 Set the implementation widget. More...
 
WWidgetimplementation ()
 Get the implementation widget. More...
 
virtual int boxPadding (Orientation orientation) const
 Returns the widget's built-in padding. More...
 
virtual int boxBorder (Orientation orientation) const
 Returns the widget's built-in border width. More...
 
- Protected Member Functions inherited from Wt::WWidget
void setLayoutSizeAware (bool sizeAware)
 Sets the widget to be aware of its size set by a layout manager. More...
 
virtual void layoutSizeChanged (int width, int height)
 Virtual method that indicates a size change. More...
 
 WWidget (WContainerWidget *parent=0)
 Creates a widget. More...
 
virtual void dropEvent (WDropEvent dropEvent)
 Handles a drop event. More...
 
void scheduleRender (WFlags< RepaintFlag > flags=0)
 Schedules rerendering of the widget. More...
 
virtual WStatelessSlot * getStateless (Method method)
 On-demand stateless slot implementation. More...
 

Additional Inherited Members

- Public Types inherited from Wt::WAbstractItemView
enum  EditTrigger { NoEditTrigger = 0x0, SingleClicked = 0x1, DoubleClicked = 0x2, SelectedClicked = 0x4 }
 Enumeration that specifies the user action that triggers editing. More...
 
enum  EditOption { SingleEditor = 0x1, MultipleEditors = 0x2, SaveWhenClosed = 0x4, LeaveEditorsOpen = 0x8 }
 Enumeration that specifies editing options. More...
 
enum  ScrollHint { EnsureVisible, PositionAtTop, PositionAtBottom, PositionAtCenter }
 Enumeration that specifies a scrolling option. More...
 
- Public Types inherited from Wt::WObject
typedef void(WObject::* Method )()
 Typedef for a WObject method without arguments.
 
- Static Public Member Functions inherited from Wt::WWidget
static WString tr (const char *key)
 Short hand for WString::tr() More...
 
- Static Protected Member Functions inherited from Wt::WObject
static WObjectsender ()
 Returns the sender of the current slot call. More...
 

Detailed Description

A view class that displays a model as a tree or tree table.

The view displays data from a WAbstractItemModel in a tree or tree table. It provides incremental rendering, allowing the display of data models of any size efficiently, without excessive use of client- or serverside resources.

The rendering (and editing) of items is handled by a WAbstractItemDelegate, by default it uses WItemDelegate which renders data of all predefined roles (see also Wt::ItemDataRole), including text, icons, checkboxes, and tooltips.

The view may support editing of items, if the model indicates support (see the Wt::ItemIsEditable flag). You can define triggers that initiate editing of an item using setEditTriggers(). The actual editing is provided by the item delegate (you can set an appropriate delegate for one column using setItemDelegateForColumn()). Using setEditOptions() you can customize if and how the view deals with multiple editors.

By default, all but the first columns are given a width of 150px, and the first column takes the remaining size. Note that this may have as consequence that the first column's size is reduced to 0. Column widths of all columns, including the first column, can be set through the API method setColumnWidth(), and also by the user using handles provided in the header.

Optionally, the treeview may be configured so that the first column is always visible while scrolling through the other columns, which may be convenient if you wish to display a model with many columns. Use setColumn1Fixed() to enable this behaviour.

If the model supports sorting (WAbstractItemModel::sort()), such as the WStandardItemModel, then you can enable sorting buttons in the header, using setSortingEnabled().

You can allow selection on row or item level (using setSelectionBehavior()), and selection of single or multiple items (using setSelectionMode()), and listen for changes in the selection using the selectionChanged() signal.

You may enable drag & drop support for this view, whith awareness of the items in the model. When enabling dragging (see setDragEnabled()), the current selection may be dragged, but only when all items in the selection indicate support for dragging (controlled by the ItemIsDragEnabled flag), and if the model indicates a mime-type (controlled by WAbstractItemModel::mimeType()). Likewise, by enabling support for dropping (see setDropsEnabled()), the treeview may receive a drop event on a particular item, at least if the item indicates support for drops (controlled by the ItemIsDropEnabled flag).

You may also react to mouse click events on any item, by connecting to one of the clicked() or doubleClicked() signals.

Usage example:

// WTreeView will display the data of a model
// Create the WTreeView
Wt::WTreeView *gitView = new Wt::WTreeView();
gitView->resize(300, Wt::WLength::Auto);
gitView->setSortingEnabled(false);
gitView->setModel(model);
gitView->setSelectionMode(SingleSelection);

Graceful degradation

The view provides a virtual scrolling behavior which relies on Ajax availability. When Ajax is not available, a page navigation bar is used instead, see createPageNavigationBar(). In that case, the widget needs to be given an explicit height using resize() which determines the number of rows that are displayed at a time.

A snapshot of the WTreeView:

WTreeView-default-1.png
WTreeView example (default)
WTreeView-polished-1.png
WTreeView example (polished)

Member Function Documentation

void Wt::WTreeView::collapse ( const WModelIndex index)

Collapses a node.

See Also
setExpanded(), expand()
Note
until 3.3.4, selection was removed from within nodes that were collapsed. This (inconsistent) behavior has been removed in 3.3.4.
Signal<WModelIndex>& Wt::WTreeView::collapsed ( )

Signal emitted when a node is collapsed.

See Also
setExpanded(), expanded()
WString Wt::WTreeView::columnFormat ( int  column) const

Returns the column format string (deprecated).

See Also
setColumnFormat()
Deprecated:
use itemDelegateForColumn() to customize the formatting. This method will try to cast the itemDelegateForColumn() to a WItemDelegate and return the format.
virtual int Wt::WTreeView::currentPage ( ) const
virtual

Returns the current page.

When Ajax/JavaScript is not available, the view will use a paging navigation bar to allow scrolling through the data. This returns the current page (between 0 and pageCount() - 1).

See Also
createPageNavigationBar(), pageChanged()

Implements Wt::WAbstractItemView.

virtual void Wt::WTreeView::enableAjax ( )
protectedvirtual

Progresses to an Ajax-enabled widget.

This method is called when the progressive bootstrap method is used, and support for AJAX has been detected. The default behavior will upgrade the widget's event handling to use AJAX instead of full page reloads, and propagate the call to its children.

You may want to reimplement this method if you want to make changes to widget when AJAX is enabled. You should always call the base implementation.

See Also
WApplication::enableAjax()

Reimplemented from Wt::WCompositeWidget.

void Wt::WTreeView::expand ( const WModelIndex index)

Expands a node.

See Also
setExpanded(), collapse()
Signal<WModelIndex>& Wt::WTreeView::expanded ( )

Signal emitted when a node is expanded.

See Also
setExpanded(), collapsed()
void Wt::WTreeView::expandToDepth ( int  depth)

Expands all nodes to a depth.

Expands all nodes to the given depth. A depth of 1 corresponds to the top level nodes.

See Also
expand()
bool Wt::WTreeView::isExpanded ( const WModelIndex index) const

Returns whether a node is expanded.

See Also
setExpanded()
virtual WWidget* Wt::WTreeView::itemWidget ( const WModelIndex index) const
virtual

Returns the widget that renders an item.

This returns the widget that renders the given item. This may return 0 if the item is currently not rendered.

This widget has been created by an item delegate, and usually an item delegate is involved when updating it.

Implements Wt::WAbstractItemView.

virtual int Wt::WTreeView::pageCount ( ) const
virtual

Returns the number of pages.

When Ajax/JavaScript is not available, the view will use a paging navigation bar to allow scrolling through the data. This returns the number of pages currently shown.

See Also
createPageNavigationBar(), pageChanged()

Implements Wt::WAbstractItemView.

virtual int Wt::WTreeView::pageSize ( ) const
virtual

Returns the page size.

When Ajax/JavaScript is not available, the view will use a paging navigation bar to allow scrolling through the data. This returns the number of items per page.

See Also
createPageNavigationBar(), pageChanged()

Implements Wt::WAbstractItemView.

virtual void Wt::WTreeView::render ( WFlags< RenderFlag flags)
protectedvirtual

Renders the widget.

This function renders the widget (or an update for the widget), after this has been scheduled using scheduleRender().

The default implementation will render the widget by serializing changes to JavaScript and HTML. You may want to reimplement this widget if you have been postponing some of the layout / rendering implementation until the latest moment possible. In that case you should make sure you call the base implementation however.

Reimplemented from Wt::WCompositeWidget.

virtual void Wt::WTreeView::resize ( const WLength width,
const WLength height 
)
virtual

Resizes the widget.

Specifies a fixed size for this widget, setting CSS width and height properties. By default a widget has automatic width and height, which sets a size for the widget following CSS rules.

When the widget is not managed by a layout manager, the automatic (natural) size of a widget depends on whether they widget is a block or inline widget:

  • a block widget takes by default the width of the parent, and the height that it needs based on its contents
  • an inline widget takes the width and height that it needs based on its contents (possibly wrapping over multiple lines). The width and height of an inline widget cannot be changed (by the letter of CSS, although most browsers will react to it in varying ways).

When inserted in a layout manager, the size set will be used as a widget's preferred size, but the widget may be given a different size by the layout manager based on available space and stretch factors. The actual size given by a layout manager may be retrieved by making the widget "layout size aware", using setLayoutSizeAware(). If you have defined a "wtResize()" JavaScript method for the widget, then this method will also be called.

The default width and height of a widget is WLength::Auto.

See Also
width(), height()

Reimplemented from Wt::WCompositeWidget.

bool Wt::WTreeView::rootIsDecorated ( ) const

Returns whether toplevel items are decorated.

See Also
setRootIsDecorated()
virtual EventSignal<WScrollEvent>& Wt::WTreeView::scrolled ( )
virtual

Signal emitted when scrolling.

Note
Works only if ajax is available.

Implements Wt::WAbstractItemView.

virtual void Wt::WTreeView::scrollTo ( const WModelIndex index,
ScrollHint  hint = EnsureVisible 
)
virtual

Scrolls the view to an item.

Scrolls the view to ensure that the item which represents the provided index is visible. A hint may indicate how the item should appear in the viewport (if possible).

Note
Currently only implemented to scroll to the correct row, not taking into account the column.

Implements Wt::WAbstractItemView.

virtual void Wt::WTreeView::setAlternatingRowColors ( bool  enable)
virtual

Sets if alternating row colors are to be used.

Configure whether rows get alternating background colors, defined by the current CSS theme.

The default value is false.

Reimplemented from Wt::WAbstractItemView.

virtual void Wt::WTreeView::setColumnBorder ( const WColor color)
virtual

Sets the column border color.

The default border color is defined by the CSS theme.

Implements Wt::WAbstractItemView.

void Wt::WTreeView::setColumnFormat ( int  column,
const WString format 
)

Sets the column format string (deprecated).

The DisplayRole data for that column is converted to a string using asString(), with the given format.

The default value is "".

Deprecated:
use itemDelegateForColumn() to customize the formatting. This method will create a new WItemDelegate for the column, and configure its format.
virtual void Wt::WTreeView::setColumnHidden ( int  column,
bool  hide 
)
virtual

Changes the visibility of a column.

See Also
isColumnHidden()

Reimplemented from Wt::WAbstractItemView.

virtual void Wt::WTreeView::setColumnWidth ( int  column,
const WLength width 
)
virtual

Sets the column width.

For a model with columnCount() == N, the initial width of columns 1..N is set to 150 pixels, and column 0 will take all remaining space.

Note
The actual space occupied by each column is the column width augmented by 7 pixels for internal padding and a border.
See Also
setRowHeight()

Implements Wt::WAbstractItemView.

virtual void Wt::WTreeView::setCurrentPage ( int  page)
virtual

Sets the current page.

When Ajax/JavaScript is not available, the view will use a paging navigation bar to allow scrolling through the data. This method can be used to change the current page.

See Also
createPageNavigationBar(), pageChanged()

Implements Wt::WAbstractItemView.

void Wt::WTreeView::setExpanded ( const WModelIndex ,
bool  expanded 
)

Expands or collapses a node.

See Also
expand(), collapse()
virtual void Wt::WTreeView::setHeaderHeight ( const WLength height)
virtual

Sets the header height.

The default value is 20 pixels.

Note
The height must be specified in WLength::Pixel units.

Reimplemented from Wt::WAbstractItemView.

virtual void Wt::WTreeView::setModel ( WAbstractItemModel model)
virtual

Sets the model.

The View will display data of the given model and changes in the model are reflected by the View.

The initial model is 0.

Ownership of the model is not transferred (and thus the previously set model is not deleted). A model may not be deleted as long as a view exists for it.

See Also
setRootIndex()

Reimplemented from Wt::WAbstractItemView.

void Wt::WTreeView::setRootIsDecorated ( bool  show)

Sets whether toplevel items are decorated.

By default, top level nodes have expand/collapse and other lines to display their linkage and offspring, like any node.

By setting show to false, you can hide these decorations for root nodes, and in this way mimic a plain list. You could also consider using a WTableView instead.

virtual void Wt::WTreeView::setRowHeaderCount ( int  count)
virtual

Configures the number of columns that are used as row headers.

An item view does not use the vertical header data from the model in any way, but instead you can configure data in the first column(s) to be used as a row headers.

These columns will not scroll horizontally together with the rest of the model.

The default value is 0.

Note
Currently, this property must be set before any other settings of the view and only a value of 0 or 1 is supported.

Reimplemented from Wt::WAbstractItemView.

virtual void Wt::WTreeView::setRowHeight ( const WLength rowHeight)
virtual

Sets the row height.

The view renders all rows with a same height. This method configures this row height.

The default value is 20 pixels.

Note
The height must be specified in WLength::Pixel units.
See Also
setColumnWidth()

Reimplemented from Wt::WAbstractItemView.


Generated on Wed Jul 13 2016 for the C++ Web Toolkit (Wt) by doxygen 1.8.6