Wt
4.11.1
|
A view class that displays a model as a tree or tree table. More...
#include <Wt/WTreeView.h>
Public Member Functions | |
WTreeView () | |
Creates a new tree view. | |
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 | collapseAll () |
Collapse all expanded nodes. 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) override |
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 WWidget * | itemWidget (const WModelIndex &index) const override |
Returns the widget that renders an item. More... | |
virtual void | setModel (const std::shared_ptr< WAbstractItemModel > &model) override |
Sets the model. More... | |
virtual void | setColumnWidth (int column, const WLength &width) override |
Sets the column width. More... | |
virtual void | setAlternatingRowColors (bool enable) override |
Sets if alternating row colors are to be used. More... | |
virtual void | setRowHeight (const WLength &rowHeight) override |
Sets the row height. More... | |
virtual void | setHeaderHeight (const WLength &height) override |
Sets the header height. More... | |
virtual void | setColumnHidden (int column, bool hidden) override |
Changes the visibility of a column. More... | |
virtual void | setRowHeaderCount (int count) override |
Configures the number of columns that are used as row headers. More... | |
virtual int | pageCount () const override |
Returns the number of pages. More... | |
virtual int | pageSize () const override |
Returns the page size. More... | |
virtual int | currentPage () const override |
Returns the current page. More... | |
virtual void | setCurrentPage (int page) override |
Sets the current page. More... | |
virtual void | scrollTo (const WModelIndex &index, ScrollHint hint=ScrollHint::EnsureVisible) override |
Scrolls the view to an item. More... | |
virtual EventSignal< WScrollEvent > & | scrolled () override |
Signal emitted when scrolling. More... | |
virtual void | setId (const std::string &id) override |
Sets the CSS Id. More... | |
virtual void | setHeaderHeight (const WLength &height) |
Sets the header height. More... | |
Public Member Functions inherited from Wt::WAbstractItemView | |
std::shared_ptr< WAbstractItemModel > | model () const |
Returns the model. More... | |
void | setRootIndex (const WModelIndex &rootIndex) |
Sets the root index. More... | |
const WModelIndex & | rootIndex () const |
Returns the root index. More... | |
void | setItemDelegate (const std::shared_ptr< WAbstractItemDelegate > &delegate) |
Sets the default item delegate. More... | |
std::shared_ptr< WAbstractItemDelegate > | itemDelegate () const |
Returns the default item delegate. More... | |
void | setItemDelegateForColumn (int column, const std::shared_ptr< WAbstractItemDelegate > &delegate) |
Sets the delegate for a column. More... | |
std::shared_ptr< WAbstractItemDelegate > | itemDelegateForColumn (int column) const |
Returns the delegate that was set for a column. More... | |
std::shared_ptr< WAbstractItemDelegate > | itemDelegate (const WModelIndex &index) const |
Returns the delegate for rendering an item. More... | |
std::shared_ptr< WAbstractItemDelegate > | itemDelegate (int column) const |
Returns the delegate for a column. More... | |
void | setHeaderItemDelegate (const std::shared_ptr< WAbstractItemDelegate > &delegate) |
Sets the header item delegate. More... | |
std::shared_ptr< WAbstractItemDelegate > | headerItemDelegate () 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 | 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... | |
void | setColumnResizeEnabled (bool enabled, int column) |
Enables interactive column resizing. More... | |
bool | isColumnResizeEnabled () const |
Returns whether column resizing is enabled for new columns. More... | |
bool | isColumnResizeEnabled (int column) const |
Returns whether column resizing is enabled for a single column. 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... | |
WItemSelectionModel * | selectionModel () 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=SelectionFlag::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... | |
void | setEnabledDropLocations (WFlags< DropLocation > droplocation) |
Enables drop operations (drag & drop). More... | |
WFlags< DropLocation > | enabledDropLocations () const |
Returns the enabled drop locations. | |
const WLength & | rowHeight () 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... | |
const WLength & | headerHeight () const |
Returns the header height. More... | |
void | setEditTriggers (WFlags< EditTrigger > editTriggers) |
Configures what actions should trigger editing. More... | |
WFlags< EditTrigger > | editTriggers () const |
Returns the editing triggers. More... | |
void | setEditOptions (WFlags< EditOption > options) |
Configures editing options. More... | |
WFlags< EditOption > | editOptions () 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... | |
ValidationState | validateEditor (const WModelIndex &index) |
Validates the editor for the given index. More... | |
ValidationState | 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... | |
Signal< WModelIndex, WTouchEvent > & | touchStart () |
Signal emitted when a finger is placed on the screen. More... | |
Signal< std::vector< WModelIndex >, WTouchEvent > & | touchStarted () |
Signal emitted when one or more fingers are placed on the screen. More... | |
Signal< std::vector< WModelIndex >, WTouchEvent > & | touchMoved () |
Signal emitted when one or more fingers are moved on the screen. More... | |
Signal< std::vector< WModelIndex >, WTouchEvent > & | touchEnded () |
Signal emitted when one or more fingers are removed from the screen. More... | |
Signal & | selectionChanged () |
Signal emitted when the selection is changed. More... | |
Signal & | pageChanged () |
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... | |
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 () | |
Creates a WCompositeWidget. More... | |
WCompositeWidget (std::unique_ptr< WWidget > implementation) | |
Creates a WCompositeWidget with given implementation. More... | |
virtual std::vector< WWidget * > | children () const override |
Returns child widgets. More... | |
virtual std::unique_ptr< WWidget > | removeWidget (WWidget *widget) override |
Removes a child widget. | |
virtual void | setObjectName (const std::string &name) override |
Sets an object name. More... | |
virtual std::string | objectName () const override |
Returns the object name. More... | |
virtual const std::string | id () const override |
Returns the (unique) identifier for this object. More... | |
virtual void | setPositionScheme (PositionScheme scheme) override |
Sets the CSS position scheme. More... | |
virtual PositionScheme | positionScheme () const override |
Returns the CSS position scheme. More... | |
virtual void | setOffsets (const WLength &offset, WFlags< Side > sides=AllSides) override |
Sets CSS offsets for a non-statically positioned widget. More... | |
virtual WLength | offset (Side s) const override |
Returns a CSS offset. More... | |
virtual WLength | width () const override |
Returns the width. More... | |
virtual WLength | height () const override |
Returns the height. More... | |
virtual void | setMinimumSize (const WLength &width, const WLength &height) override |
Sets a minimum size. More... | |
virtual WLength | minimumWidth () const override |
Returns the minimum width. More... | |
virtual WLength | minimumHeight () const override |
Returns the minimum height. More... | |
virtual void | setMaximumSize (const WLength &width, const WLength &height) override |
Sets a maximum size. More... | |
virtual WLength | maximumWidth () const override |
Returns the maximum width. More... | |
virtual WLength | maximumHeight () const override |
Returns the maximum height. More... | |
virtual void | setLineHeight (const WLength &height) override |
Sets the CSS line height for contained text. | |
virtual WLength | lineHeight () const override |
Returns the CSS line height for contained text. More... | |
virtual void | setFloatSide (Side s) override |
Specifies a CSS float side. More... | |
virtual Side | floatSide () const override |
Returns the CSS float side. More... | |
virtual void | setClearSides (WFlags< Side > sides) override |
Sets the sides that should be cleared of floats. More... | |
virtual WFlags< Side > | clearSides () const override |
Returns the sides that should remain empty. More... | |
virtual void | setMargin (const WLength &margin, WFlags< Side > sides=AllSides) override |
Sets CSS margins around the widget. More... | |
virtual WLength | margin (Side side) const override |
Returns a CSS margin set. More... | |
virtual void | setHiddenKeepsGeometry (bool enabled) override |
Sets whether the widget keeps its geometry when hidden. More... | |
virtual bool | hiddenKeepsGeometry () const override |
Returns whether the widget keeps its geometry when hidden. More... | |
virtual void | setHidden (bool hidden, const WAnimation &animation=WAnimation()) override |
Hides or shows the widget. More... | |
virtual bool | isHidden () const override |
Returns whether the widget is set hidden. More... | |
virtual bool | isVisible () const override |
Returns whether the widget is visible. More... | |
virtual void | setDisabled (bool disabled) override |
Sets whether the widget is disabled. More... | |
virtual bool | isDisabled () const override |
Returns whether the widget is set disabled. More... | |
virtual bool | isEnabled () const override |
Returns whether the widget is enabled. More... | |
virtual void | setPopup (bool popup) override |
Lets the widget overlay over other sibling widgets. More... | |
virtual bool | isPopup () const override |
Returns whether the widget is overlayed. More... | |
virtual void | setInline (bool isInline) override |
Sets whether the widget is displayed inline or as a block. More... | |
virtual bool | isInline () const override |
Returns whether the widget is displayed inline or as block. More... | |
virtual void | setDecorationStyle (const WCssDecorationStyle &style) override |
Sets a CSS decoration style. More... | |
virtual WCssDecorationStyle & | decorationStyle () override |
Returns the decoration style of this widget. More... | |
virtual void | setStyleClass (const WString &styleClass) override |
Sets (one or more) CSS style classes. More... | |
virtual WString | styleClass () const override |
Returns the CSS style class. More... | |
virtual void | addStyleClass (const WString &styleClass, bool force=false) override |
Adds a CSS style class. More... | |
virtual void | removeStyleClass (const WString &styleClass, bool force=false) override |
Removes a CSS style class. More... | |
virtual bool | hasStyleClass (const WString &styleClass) const override |
Returns whether the widget has a style class. | |
virtual void | setVerticalAlignment (AlignmentFlag alignment, const WLength &length=WLength::Auto) override |
Sets the vertical alignment. More... | |
virtual AlignmentFlag | verticalAlignment () const override |
Returns the vertical alignment. More... | |
virtual WLength | verticalAlignmentLength () const override |
Returns the fixed vertical alignment that was set. More... | |
virtual void | setToolTip (const WString &text, TextFormat textFormat=TextFormat::Plain) override |
Sets a tooltip. More... | |
virtual WString | toolTip () const override |
Returns the tooltip. | |
virtual void | setDeferredToolTip (bool enable, TextFormat textFormat=TextFormat::Plain) override |
Enable deferred tooltip. More... | |
virtual void | refresh () override |
Refresh the widget. More... | |
virtual void | setAttributeValue (const std::string &name, const WString &value) override |
Sets an attribute value. More... | |
virtual WString | attributeValue (const std::string &name) const override |
Returns an attribute value. More... | |
virtual void | setJavaScriptMember (const std::string &name, const std::string &value) override |
Sets a JavaScript member. More... | |
virtual std::string | javaScriptMember (const std::string &name) const override |
Returns the value of a JavaScript member. More... | |
virtual void | callJavaScriptMember (const std::string &name, const std::string &args) override |
Calls a JavaScript member. More... | |
virtual void | load () override |
Loads content just before the widget is used. More... | |
virtual bool | loaded () const override |
Returns whether this widget has been loaded. More... | |
virtual void | setCanReceiveFocus (bool enabled) override |
Sets whether the widget can receive focus. More... | |
virtual bool | canReceiveFocus () const override |
Returns whether the widget can receive focus. More... | |
virtual void | setFocus (bool focus) override |
Sets focus. More... | |
virtual bool | setFirstFocus () override |
Set focus on the widget's first descendant. More... | |
virtual bool | hasFocus () const override |
Returns whether the widget currently has the focus. | |
virtual void | setTabIndex (int index) override |
Sets the tab index. More... | |
virtual int | tabIndex () const override |
Returns the tab index. More... | |
virtual WWidget * | find (const std::string &name) override |
Finds a descendent widget by name. More... | |
virtual WWidget * | findById (const std::string &name) override |
Finds a descendent widget by id. | |
virtual void | setSelectable (bool selectable) override |
Sets as selectable. More... | |
virtual void | doJavaScript (const std::string &js) override |
Executes the given JavaScript statements when the widget is rendered or updated. More... | |
virtual void | propagateSetEnabled (bool enabled) override |
Propagates that a widget was enabled or disabled through children. More... | |
virtual bool | scrollVisibilityEnabled () const final override |
Returns whether scroll visibility detection is enabled for this widget. More... | |
virtual void | setScrollVisibilityEnabled (bool enabled) final override |
Sets whether scroll visibility detection is enabled for this widget. More... | |
virtual int | scrollVisibilityMargin () const final override |
Returns the margin around the viewport within which the widget is considered visible. More... | |
virtual void | setScrollVisibilityMargin (int margin) final override |
Sets the margin around the viewport within which the widget is considered visible. More... | |
virtual Signal< bool > & | scrollVisibilityChanged () final override |
Signal triggered when the scroll visibility of this widget changes. More... | |
virtual bool | isScrollVisible () const final override |
Returns whether this widget is currently considered scroll visible. More... | |
virtual void | setThemeStyleEnabled (bool enabled) final override |
Sets whether theme styling for a widget is enabled or disabled. More... | |
virtual bool | isThemeStyleEnabled () const final override |
Returns whether this widget is currently styled by the chosen theme. More... | |
virtual std::unique_ptr< WWidget > | removeWidget (WWidget *widget) |
Removes a child widget. | |
template<typename Widget > | |
std::unique_ptr< Widget > | removeWidget (Widget *widget) |
Removes a child widget. More... | |
void | setFocus () |
Sets focus. More... | |
virtual void | setFocus (bool focus)=0 |
Sets focus. More... | |
Public Member Functions inherited from Wt::WWidget | |
virtual | ~WWidget () |
Destructor. More... | |
WWidget * | parent () const |
Returns the parent widget. | |
template<typename Widget > | |
std::unique_ptr< Widget > | removeWidget (Widget *widget) |
Removes a child widget. More... | |
std::unique_ptr< WWidget > | removeFromParent () |
Removes the widget from its parent. 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=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 | |
void | addChild (std::unique_ptr< WObject > child) |
Add a child WObject whose lifetime is determined by this WObject. | |
template<typename Child > | |
Child * | addChild (std::unique_ptr< Child > child) |
Add a child WObject, returning a raw pointer. More... | |
std::unique_ptr< WObject > | removeChild (WObject *child) |
Remove a child WObject, so its lifetime is no longer determined by this WObject. | |
template<typename Child > | |
std::unique_ptr< Child > | removeChild (Child *child) |
Remove a child WObject, so its lifetime is no longer determined by this WObject. 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... | |
Public Member Functions inherited from Wt::Core::observable | |
observable () noexcept | |
Default constructor. | |
virtual | ~observable () |
Destructor. More... | |
template<typename... Args, typename C > | |
auto | bindSafe (void(C::*method)(Args...)) noexcept |
Protects a method call against object destruction. More... | |
template<typename... Args, typename C > | |
auto | bindSafe (void(C::*method)(Args...) const) const noexcept |
Protects a const method call against object destruction. More... | |
template<typename Function > | |
auto | bindSafe (const Function &function) noexcept |
Protects a function against object destruction. More... | |
Protected Member Functions | |
virtual void | render (WFlags< RenderFlag > flags) override |
Renders the widget. More... | |
virtual void | enableAjax () override |
Progresses to an Ajax-enabled widget. More... | |
Protected Member Functions inherited from Wt::WAbstractItemView | |
WAbstractItemView () | |
Creates a new item view. | |
virtual void | dropEvent (const WDropEvent &event, const WModelIndex &target) |
Handles a drop event (drag & drop). More... | |
virtual void | dropEvent (const WDropEvent &event, const WModelIndex &index, Wt::Side side) |
Handles a drop event (drag & drop). More... | |
virtual std::unique_ptr< WWidget > | createExtraHeaderWidget (int column) |
Create an extra widget in the header. More... | |
WWidget * | extraHeaderWidget (int column) |
Returns the extra header widget. More... | |
virtual std::unique_ptr< WWidget > | createPageNavigationBar () |
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... | |
virtual void | handleTouchSelect (const std::vector< WModelIndex > &indices, const WTouchEvent &event) |
Handles a touch select event. | |
virtual void | handleTouchStart (const std::vector< WModelIndex > &indices, const WTouchEvent &event) |
Handles a touch started event. | |
virtual void | handleTouchMove (const std::vector< WModelIndex > &indices, const WTouchEvent &event) |
Handles a touch moved event. | |
virtual void | handleTouchEnd (const std::vector< WModelIndex > &indices, const WTouchEvent &event) |
Handles a touch ended event. | |
virtual void | dropEvent (WDropEvent dropEvent) |
Handles a drop event. More... | |
Protected Member Functions inherited from Wt::WCompositeWidget | |
void | setImplementation (std::unique_ptr< WWidget > widget) |
Set the implementation widget. More... | |
template<typename Widget > | |
Widget * | setImplementation (std::unique_ptr< Widget > widget) |
Sets the implementation widget, returning a raw pointer. More... | |
template<typename W , typename... Args> | |
W * | setNewImplementation (Args &&... args) |
Creates the implementation widget and sets it, returning a raw pointer. More... | |
WWidget * | implementation () |
Get the implementation widget. More... | |
virtual int | boxPadding (Orientation orientation) const override |
Returns the widget's built-in padding. More... | |
virtual int | boxBorder (Orientation orientation) const override |
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 () | |
Creates a widget. | |
virtual void | dropEvent (WDropEvent dropEvent) |
Handles a drop event. More... | |
void | scheduleRender (WFlags< RepaintFlag > flags=None) |
Schedules rerendering of the widget. More... | |
virtual WStatelessSlot * | getStateless (Method method) override |
On-demand stateless slot implementation. More... | |
Additional Inherited Members | |
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... | |
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::ItemFlag::Editable 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, with 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 ItemFlag::DragEnabled 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 ItemFlag::DropEnabled flag).
You may also react to mouse click events on any item, by connecting to one of the clicked() or doubleClicked() signals.
Usage example:
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:
void Wt::WTreeView::collapse | ( | const WModelIndex & | index | ) |
Collapses a node.
void Wt::WTreeView::collapseAll | ( | ) |
Collapse all expanded nodes.
Signal<WModelIndex>& Wt::WTreeView::collapsed | ( | ) |
Signal emitted when a node is collapsed.
|
overridevirtual |
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).
Implements Wt::WAbstractItemView.
|
overrideprotectedvirtual |
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.
Reimplemented from Wt::WAbstractItemView.
void Wt::WTreeView::expand | ( | const WModelIndex & | index | ) |
Expands a node.
Signal<WModelIndex>& Wt::WTreeView::expanded | ( | ) |
Signal emitted when a node is expanded.
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.
bool Wt::WTreeView::isExpanded | ( | const WModelIndex & | index | ) | const |
Returns whether a node is expanded.
|
overridevirtual |
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.
|
overridevirtual |
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.
Implements Wt::WAbstractItemView.
|
overridevirtual |
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.
Implements Wt::WAbstractItemView.
|
overrideprotectedvirtual |
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.
|
overridevirtual |
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:
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.
Reimplemented from Wt::WCompositeWidget.
bool Wt::WTreeView::rootIsDecorated | ( | ) | const |
Returns whether toplevel items are decorated.
|
overridevirtual |
Signal emitted when scrolling.
Implements Wt::WAbstractItemView.
|
overridevirtual |
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).
Implements Wt::WAbstractItemView.
|
overridevirtual |
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.
|
overridevirtual |
Changes the visibility of a column.
Reimplemented from Wt::WAbstractItemView.
|
overridevirtual |
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.
Implements Wt::WAbstractItemView.
|
overridevirtual |
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.
Implements Wt::WAbstractItemView.
void Wt::WTreeView::setExpanded | ( | const WModelIndex & | , |
bool | expanded | ||
) |
Expands or collapses a node.
void Wt::WAbstractItemView::setHeaderHeight |
Sets the header height.
The default value is 20 pixels.
|
overridevirtual |
Sets the header height.
The default value is 20 pixels.
Reimplemented from Wt::WAbstractItemView.
|
overridevirtual |
Sets the CSS Id.
Sets a custom Id. Note that the Id must be unique across the whole widget tree, can only be set right after construction and cannot be changed. This is mostly useful for in tests using a test plan that manipulates DOM elements by Id.
By default, auto-generated id's are used.
Reimplemented from Wt::WCompositeWidget.
|
overridevirtual |
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
.
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.
|
overridevirtual |
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.
Reimplemented from Wt::WAbstractItemView.
|
overridevirtual |
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.
Reimplemented from Wt::WAbstractItemView.