#include <Wt/WAbstractItemView>
Public Member Functions | |
virtual void | setModel (WAbstractItemModel *model) |
Sets the model. | |
WAbstractItemModel * | model () const |
Returns the model. | |
virtual void | setColumnAlignment (int column, AlignmentFlag alignment)=0 |
Sets the content alignment for a column. | |
virtual void | setHeaderAlignment (int column, AlignmentFlag alignment)=0 |
Sets the header alignment for a column. | |
virtual AlignmentFlag | columnAlignment (int column) const =0 |
Returns the content alignment for a column. | |
virtual AlignmentFlag | headerAlignment (int column) const =0 |
Returns the header alignment for a column. | |
virtual void | setAlternatingRowColors (bool enable)=0 |
Sets if alternating row colors are to be used. | |
virtual bool | alternatingRowColors () const =0 |
Returns whether alternating row colors are used. | |
void | sortByColumn (int column, SortOrder order) |
Sorts the data according to a column. | |
void | setSortingEnabled (bool enabled) |
Enables or disables sorting for all columns. | |
void | setSortingEnabled (int column, bool enabled) |
Enables or disables sorting for a single column. | |
bool | isSortingEnabled () const |
Returns whether sorting is enabled. | |
void | setColumnResizeEnabled (bool enabled) |
Enables interactive column resizing. | |
bool | isColumnResizeEnabled () const |
Returns whether column resizing is enabled. | |
void | setSelectionBehavior (SelectionBehavior behavior) |
Changes the selection behaviour. | |
SelectionBehavior | selectionBehavior () const |
Returns the selection behaviour. | |
void | setSelectionMode (SelectionMode mode) |
Sets the selection mode. | |
SelectionMode | selectionMode () const |
Returns the selection mode. | |
WItemSelectionModel * | selectionModel () const |
Returns the selection model. | |
void | setSelectedIndexes (const WModelIndexSet &indexes) |
Sets the selected items. | |
void | select (const WModelIndex &index, SelectionFlag option=Select) |
Selects a single item. | |
bool | isSelected (const WModelIndex &index) const |
Returns wheter an item is selected. | |
WModelIndexSet | selectedIndexes () const |
Returns the set of selected items. | |
void | setDragEnabled (bool enable) |
Enables the selection to be dragged (drag & drop). | |
void | setDropsEnabled (bool enable) |
Enables drop operations (drag & drop). | |
Signal< WModelIndex, WMouseEvent > & | clicked () |
Signal emitted when an item is clicked. | |
Signal< WModelIndex, WMouseEvent > & | doubleClicked () |
Signal emitted when an item is double clicked. | |
Signal< WModelIndex, WMouseEvent > & | mouseWentDown () |
Signal emitted when a mouse button is pressed down. | |
Signal< WModelIndex, WMouseEvent > & | mouseWentUp () |
Signal emitted when the mouse button is released. | |
Signal< void > & | selectionChanged () |
Signal emitted when the selection is changed. | |
void | setItemDelegate (WAbstractItemDelegate *delegate) |
Sets the default item delegate. | |
WAbstractItemDelegate * | itemDelegate () const |
Returns the default item delegate. | |
void | setItemDelegateForColumn (int column, WAbstractItemDelegate *delegate) |
Sets the delegate for a column. | |
WAbstractItemDelegate * | itemDelegateForColumn (int column) const |
Returns the delegate that was set for a column. | |
WAbstractItemDelegate * | itemDelegate (const WModelIndex &index) const |
Returns the delegate for rendering an item. | |
WAbstractItemDelegate * | itemDelegate (int column) const |
Returns the delegate for a column. | |
virtual void | setRowHeight (const WLength &rowHeight)=0 |
Sets the row height. | |
const WLength & | rowHeight () const |
Returns the row height. | |
virtual void | setColumnWidth (int column, const WLength &width)=0 |
Sets the column width. | |
virtual WLength | columnWidth (int column) const =0 |
Returns the column width. | |
virtual void | setColumnBorder (const WColor &color)=0 |
Sets the column border color. | |
virtual void | setHeaderHeight (const WLength &height, bool multiLine=false)=0 |
Sets the header height. | |
const WLength & | headerHeight () const |
Returns the header height. | |
Protected Member Functions | |
WAbstractItemView (WContainerWidget *parent=0) | |
Creates a new item view. | |
virtual void | dropEvent (const WDropEvent &event, const WModelIndex &target) |
Handles a drop event (drag & drop). | |
virtual WWidget * | createExtraHeaderWidget (int column) |
Create an extra widget in the header. | |
WWidget * | extraHeaderWidget (int column) |
Returns the extra header widget. |
void Wt::WAbstractItemView::setModel | ( | WAbstractItemModel * | model | ) | [virtual] |
Sets the model.
The view will render the data in the given model
. Changes to the model are reflected in the view.
The initial model is 0
.
Ownership of the model is not transferred (and thus the previously set model is not deleted).
Reimplemented in Wt::WTreeView.
WAbstractItemModel* Wt::WAbstractItemView::model | ( | ) | const [inline] |
virtual void Wt::WAbstractItemView::setColumnAlignment | ( | int | column, | |
AlignmentFlag | alignment | |||
) | [pure virtual] |
Sets the content alignment for a column.
The default value is AlignLeft.
Implemented in Wt::WTreeView.
virtual void Wt::WAbstractItemView::setHeaderAlignment | ( | int | column, | |
AlignmentFlag | alignment | |||
) | [pure virtual] |
Sets the header alignment for a column.
The default value is AlignLeft.
Implemented in Wt::WTreeView.
virtual AlignmentFlag Wt::WAbstractItemView::columnAlignment | ( | int | column | ) | const [pure virtual] |
Returns the content alignment for a column.
Implemented in Wt::WTreeView.
virtual AlignmentFlag Wt::WAbstractItemView::headerAlignment | ( | int | column | ) | const [pure virtual] |
Returns the header alignment for a column.
Implemented in Wt::WTreeView.
virtual bool Wt::WAbstractItemView::alternatingRowColors | ( | ) | const [pure virtual] |
Returns whether alternating row colors are used.
Implemented in Wt::WTreeView.
void Wt::WAbstractItemView::sortByColumn | ( | int | column, | |
SortOrder | order | |||
) |
Sorts the data according to a column.
Sorts the data according to data in column column
and sort order order
.
void Wt::WAbstractItemView::setSortingEnabled | ( | bool | enabled | ) |
Enables or disables sorting for all columns.
Enable or disable sorting by the user on all columns.
Sorting is enabled by default.
void Wt::WAbstractItemView::setSortingEnabled | ( | int | column, | |
bool | enabled | |||
) |
Enables or disables sorting for a single column.
Enable or disable sorting by the user for a specific column.
Sorting is enabled by default.
bool Wt::WAbstractItemView::isSortingEnabled | ( | ) | const [inline] |
void Wt::WAbstractItemView::setColumnResizeEnabled | ( | bool | enabled | ) |
Enables interactive column resizing.
Enable or disable column resize handles for interactive resizing of the columns.
bool Wt::WAbstractItemView::isColumnResizeEnabled | ( | ) | const [inline] |
void Wt::WAbstractItemView::setSelectionBehavior | ( | SelectionBehavior | behavior | ) |
Changes the selection behaviour.
The selection behavior indicates whether whole rows or individual items can be selected. It is a property of the selectionModel().
By default, selection operates on rows (SelectRows), in which case model indexes will always be in the first column (column 0
).
Alternatively, you can allow selection for individual items (SelectItems).
SelectionBehavior Wt::WAbstractItemView::selectionBehavior | ( | ) | const |
void Wt::WAbstractItemView::setSelectionMode | ( | SelectionMode | mode | ) |
Sets the selection mode.
By default selection is disabled (NoSelection ).
SelectionMode Wt::WAbstractItemView::selectionMode | ( | ) | const [inline] |
WItemSelectionModel* Wt::WAbstractItemView::selectionModel | ( | ) | const [inline] |
Returns the selection model.
The selection model keeps track of the currently selected items.
void Wt::WAbstractItemView::setSelectedIndexes | ( | const WModelIndexSet & | indexes | ) |
Sets the selected items.
Replaces the current selection with indexes
.
void Wt::WAbstractItemView::select | ( | const WModelIndex & | index, | |
SelectionFlag | option = Select | |||
) |
bool Wt::WAbstractItemView::isSelected | ( | const WModelIndex & | index | ) | const |
Returns wheter an item is selected.
This is a convenience method for:
selectionModel()->isSelected(index)
WModelIndexSet Wt::WAbstractItemView::selectedIndexes | ( | ) | const |
Returns the set of selected items.
The model indexes are returned as a set, topologically ordered (in the order they appear in the view).
This is a convenience method for:
selectionModel()->selectedIndexes()
void Wt::WAbstractItemView::setDragEnabled | ( | bool | enable | ) |
Enables the selection to be dragged (drag & drop).
To enable dragging of the selection, you first need to enable selection using setSelectionMode().
Whether an individual item may be dragged is controlled by the item's ItemIsDragEnabled flag. The selection can be dragged only if all items currently selected can be dragged.
void Wt::WAbstractItemView::setDropsEnabled | ( | bool | enable | ) |
Enables drop operations (drag & drop).
When drop is enabled, the tree view will indicate that something may be dropped when the mime-type of the dragged object is compatible with one of the model's accepted drop mime-types (see WAbstractItemModel::acceptDropMimeTypes()) or this widget's accepted drop mime-types (see WWidget::acceptDrops()), and the target item has drop enabled (which is controlled by the item's ItemIsDropEnabled flag).
Drop events must be handled in dropEvent().
Signal<WModelIndex, WMouseEvent>& Wt::WAbstractItemView::clicked | ( | ) | [inline] |
Signal<WModelIndex, WMouseEvent>& Wt::WAbstractItemView::doubleClicked | ( | ) | [inline] |
Signal<WModelIndex, WMouseEvent>& Wt::WAbstractItemView::mouseWentDown | ( | ) | [inline] |
Signal<WModelIndex, WMouseEvent>& Wt::WAbstractItemView::mouseWentUp | ( | ) | [inline] |
Signal<void>& Wt::WAbstractItemView::selectionChanged | ( | ) | [inline] |
Signal emitted when the selection is changed.
void Wt::WAbstractItemView::setItemDelegate | ( | WAbstractItemDelegate * | delegate | ) |
Sets the default item delegate.
The previous delegate is removed but not deleted.
The default item delegate is a WItemDelegate.
WAbstractItemDelegate* Wt::WAbstractItemView::itemDelegate | ( | ) | const [inline] |
void Wt::WAbstractItemView::setItemDelegateForColumn | ( | int | column, | |
WAbstractItemDelegate * | delegate | |||
) |
Sets the delegate for a column.
The previous delegate is removed but not deleted.
WAbstractItemDelegate * Wt::WAbstractItemView::itemDelegateForColumn | ( | int | column | ) | const |
Returns the delegate that was set for a column.
Returns 0
if no delegate was set for the column.
WAbstractItemDelegate * Wt::WAbstractItemView::itemDelegate | ( | const WModelIndex & | index | ) | const |
WAbstractItemDelegate * Wt::WAbstractItemView::itemDelegate | ( | int | column | ) | const |
Returns the delegate for a column.
Returns either the delegate that was set for the column, or the default delegate.
virtual void Wt::WAbstractItemView::setRowHeight | ( | const WLength & | rowHeight | ) | [pure virtual] |
Sets the row height.
The view assumes that all rows are of the same height. Use this method to set the height.
The default value is 20 pixels.
Implemented in Wt::WTreeView.
virtual WLength Wt::WAbstractItemView::columnWidth | ( | int | column | ) | const [pure virtual] |
virtual void Wt::WAbstractItemView::setColumnBorder | ( | const WColor & | color | ) | [pure virtual] |
virtual void Wt::WAbstractItemView::setHeaderHeight | ( | const WLength & | height, | |
bool | multiLine = false | |||
) | [pure virtual] |
Sets the header height.
Use this method to change the header height. You may also enable the use of multi-line headers. By default, the header text is a single line, that is centered vertically.
The default value is 20 pixels.
Implemented in Wt::WTreeView.
const WLength& Wt::WAbstractItemView::headerHeight | ( | ) | const [inline] |
void Wt::WAbstractItemView::dropEvent | ( | const WDropEvent & | event, | |
const WModelIndex & | target | |||
) | [protected, virtual] |
Handles a drop event (drag & drop).
The event
object contains details about the drop operation, identifying the source (which provides the data) and the mime-type of the data. The drop was received on the target
item.
The drop event can be handled either by the view itself, or by the model. The default implementation checks if the mime-type is accepted by the model, and if so passes the drop event to the model. If the source is the view's own selection model, then the drop event will be handled as a MoveAction, otherwise the drop event will be handled as a CopyAction.
WWidget * Wt::WAbstractItemView::createExtraHeaderWidget | ( | int | column | ) | [protected, virtual] |
Create an extra widget in the header.
You may reimplement this method to provide an extra widget to be placed below the header label. The extra widget will be visible only if a multi-line header is configured using setHeaderHeight().
The widget is created only once, but this method may be called repeatedly for a column for which prior calls returned 0
(i.e. each time the header is rerendered).
The default implementation returns 0
.
WWidget * Wt::WAbstractItemView::extraHeaderWidget | ( | int | column | ) | [protected] |
Returns the extra header widget.
Returns the widget previously created using createExtraHeaderWidget()