Wt::WAbstractItemView Class Reference
[Model/view system]

An abstract base class for item Views. More...

#include <Wt/WAbstractItemView>

Inheritance diagram for Wt::WAbstractItemView:

Inheritance graph
[legend]

List of all members.

Public Types

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...

Public Member Functions

virtual void setModel (WAbstractItemModel *model)
 Sets the model.
WAbstractItemModelmodel () const
 Returns the model.
void setRootIndex (const WModelIndex &rootIndex)
 Sets the root index.
const WModelIndexrootIndex () const
 Returns the root index.
void setItemDelegate (WAbstractItemDelegate *delegate)
 Sets the default item delegate.
WAbstractItemDelegateitemDelegate () const
 Returns the default item delegate.
void setItemDelegateForColumn (int column, WAbstractItemDelegate *delegate)
 Sets the delegate for a column.
WAbstractItemDelegateitemDelegateForColumn (int column) const
 Returns the delegate that was set for a column.
WAbstractItemDelegateitemDelegate (const WModelIndex &index) const
 Returns the delegate for rendering an item.
WAbstractItemDelegateitemDelegate (int column) const
 Returns the delegate for a column.
virtual void setColumnAlignment (int column, AlignmentFlag alignment)
 Sets the content alignment for a column.
virtual void setHeaderAlignment (int column, AlignmentFlag alignment)
 Sets the header alignment for a column.
virtual AlignmentFlag columnAlignment (int column) const
 Returns the content alignment for a column.
virtual AlignmentFlag headerAlignment (int column) const
 Returns the header alignment for a column.
virtual void setAlternatingRowColors (bool enable)
 Sets if alternating row colors are to be used.
virtual bool alternatingRowColors () const
 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.
bool isSortingEnabled (int column) const
 Returns whether sorting is enabled for a single column.
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.
WItemSelectionModelselectionModel () 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).
virtual void setRowHeight (const WLength &rowHeight)
 Sets the row height.
const WLengthrowHeight () const
 Returns the row height.
virtual void setColumnWidth (int column, const WLength &width)=0
 Sets the column width.
WLength columnWidth (int column) const
 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)
 Sets the header height.
const WLengthheaderHeight () const
 Returns the header height.
virtual int pageCount () const =0
 Returns the number of pages.
virtual int pageSize () const =0
 Returns the page size.
virtual int currentPage () const =0
 Returns the current page.
virtual void setCurrentPage (int page)=0
 Sets the current page.
void setEditTriggers (WFlags< EditTrigger > editTriggers)
 Configures what actions should trigger editing.
WFlags< EditTriggereditTriggers () const
 Returns the editing triggers.
void setEditOptions (WFlags< EditOption > options)
 Configures editing options.
WFlags< EditOptioneditOptions () const
 Returns the editing options.
void edit (const WModelIndex &index)
 Opens an editor for the given index.
void closeEditor (const WModelIndex &index, bool saveData=true)
 Closes the editor for the given index.
bool isEditing (const WModelIndex &index) const
 Returns whether an editor is open for a given index.
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.
SignalselectionChanged ()
 Signal emitted when the selection is changed.
SignalpageChanged ()
 Signal emitted when page information was updated.
Signal< int, WLength > & columnResized ()
 Returns the signal emitted when a column is resized by the user.

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 WWidgetcreateExtraHeaderWidget (int column)
 Create an extra widget in the header.
WWidgetextraHeaderWidget (int column)
 Returns the extra header widget.
virtual WWidgetcreatePageNavigationBar ()
 Returns a page navigation widget.


Detailed Description

An abstract base class for item Views.

See WTableView or WTreeView for a description.


Member Enumeration Documentation

Enumeration that specifies the user action that triggers editing.

See also:
setEditTriggers(), edit()
Enumerator:
NoEditTrigger  Do not allow user to initiate editing.
SingleClicked  Edit an item when clicked.
DoubleClicked  Edit an item when double clicked.
SelectedClicked  Edit a selected item that is clicked again.

Enumeration that specifies editing options.

See also:
setEditOptions()
Enumerator:
SingleEditor  Never show more than one active editor.
MultipleEditors  Allow multiple editors at the same time.
SaveWhenClosed  Always save the current edit value when closing.
LeaveEditorsOpen  Editors can only be closed using closeEditor().


Member Function Documentation

void Wt::WAbstractItemView::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 in Wt::WTableView, and Wt::WTreeView.

WAbstractItemModel* Wt::WAbstractItemView::model (  )  const [inline]

Returns the model.

See also:
setModel()

void Wt::WAbstractItemView::setRootIndex ( const WModelIndex rootIndex  ) 

Sets the root index.

The root index is the model index that is considered the root node. This node itself is not rendered, but its children are.

The default value is an invalid model index, corresponding to the model's root node.

See also:
setModel()

const WModelIndex& Wt::WAbstractItemView::rootIndex (  )  const [inline]

Returns the root index.

See also:
setRootIndex()

void Wt::WAbstractItemView::setItemDelegate ( WAbstractItemDelegate delegate  ) 

Sets the default item delegate.

The previous delegate is removed but not deleted. This item delegate is for all columns for which no specific item delegate is set.

The default item delegate is a WItemDelegate.

See also:
setItemDelegateForColumn()

WAbstractItemDelegate* Wt::WAbstractItemView::itemDelegate (  )  const [inline]

Returns the default item delegate.

See also:
setItemDelegate()

void Wt::WAbstractItemView::setItemDelegateForColumn ( int  column,
WAbstractItemDelegate delegate 
)

Sets the delegate for a column.

The previous delegate is removed but not deleted.

See also:
setItemDelegate()

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.

See also:
setItemDelegateForColumn()

WAbstractItemDelegate * Wt::WAbstractItemView::itemDelegate ( const WModelIndex index  )  const

Returns the delegate for rendering an item.

See also:
setItemDelegateForColumn(), setItemDelegate()

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.

void Wt::WAbstractItemView::setColumnAlignment ( int  column,
AlignmentFlag  alignment 
) [virtual]

Sets the content alignment for a column.

The default value is AlignLeft.

See also:
setHeaderAlignment()

void Wt::WAbstractItemView::setHeaderAlignment ( int  column,
AlignmentFlag  alignment 
) [virtual]

Sets the header alignment for a column.

The default value is AlignLeft.

See also:
setColumnAlignment()

AlignmentFlag Wt::WAbstractItemView::columnAlignment ( int  column  )  const [virtual]

Returns the content alignment for a column.

See also:
setColumnAlignment()

AlignmentFlag Wt::WAbstractItemView::headerAlignment ( int  column  )  const [virtual]

Returns the header alignment for a column.

See also:
setHeaderAlignment()

void Wt::WAbstractItemView::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 in Wt::WTableView, and Wt::WTreeView.

virtual bool Wt::WAbstractItemView::alternatingRowColors (  )  const [inline, virtual]

Returns whether alternating row colors are used.

When enabled, rows are displayed in alternating row colors, according to the current theme's definition.

See also:
setAlternatingRowColors()

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.

See also:
WAbstractItemModel::sort()

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.

See also:
WAbstractItemModel::sort()

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.

See also:
WAbstractItemModel::sort()

bool Wt::WAbstractItemView::isSortingEnabled (  )  const [inline]

Returns whether sorting is enabled.

See also:
setSortingEnabled()

bool Wt::WAbstractItemView::isSortingEnabled ( int  column  )  const

Returns whether sorting is enabled for a single column.

See also:
setSortingEnabled()

void Wt::WAbstractItemView::setColumnResizeEnabled ( bool  enabled  ) 

Enables interactive column resizing.

Enable or disable column resize handles for interactive resizing of the columns.

Column resizing is enabled by default when JavaScript is available.

See also:
setColumnResizeEnabled()

bool Wt::WAbstractItemView::isColumnResizeEnabled (  )  const [inline]

Returns whether column resizing is enabled.

See also:
setColumnResizeEnabled()

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).

See also:
WItemSelectionModel::setSelectionBehavior(), setSelectionMode()

SelectionBehavior Wt::WAbstractItemView::selectionBehavior (  )  const

Returns the selection behaviour.

See also:
setSelectionBehavior()

void Wt::WAbstractItemView::setSelectionMode ( SelectionMode  mode  ) 

Sets the selection mode.

By default selection is disabled (NoSelection ).

See also:
setSelectionBehavior()

SelectionMode Wt::WAbstractItemView::selectionMode (  )  const [inline]

Returns the selection mode.

See also:
setSelectionMode()

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.

See also:
select(), selectionModel()

void Wt::WAbstractItemView::select ( const WModelIndex index,
SelectionFlag  option = Select 
)

Selects a single item.

See also:
setSelectedIndexes(), selectionModel()

bool Wt::WAbstractItemView::isSelected ( const WModelIndex index  )  const

Returns wheter an item is selected.

This is a convenience method for:

 selectionModel()->isSelected(index)

See also:
selectedIndexes(), select(), selectionModel()

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()

See also:
setSelectedIndexes()

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.

See also:
setDropsEnabled()

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().

See also:
setDragEnabled(), dropEvent()

void Wt::WAbstractItemView::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 in Wt::WTableView, and Wt::WTreeView.

virtual void Wt::WAbstractItemView::setColumnWidth ( int  column,
const WLength width 
) [pure virtual]

Sets the column width.

The default column width is 150 pixels.

Note:
The actual space occupied by each column is the column width augmented by 7 pixels for internal padding and a border.

Implemented in Wt::WTableView, and Wt::WTreeView.

WLength Wt::WAbstractItemView::columnWidth ( int  column  )  const

Returns the column width.

See also:
setColumnWidth()

virtual void Wt::WAbstractItemView::setColumnBorder ( const WColor color  )  [pure virtual]

Sets the column border color.

The default border color is defined by the CSS theme.

Implemented in Wt::WTableView, and Wt::WTreeView.

void Wt::WAbstractItemView::setHeaderHeight ( const WLength height,
bool  multiLine = false 
) [virtual]

Sets the header height.

Use this method to change the header height. By default, the header text is a single line that is centered vertically.

By enabling multi-line headers, the header text will be aligned to the top and wrap as needed. In that case, additional contents may be displayed in the header, provided by createExtraHeaderWidget().

The default value is a single line of 20 pixels.

Reimplemented in Wt::WTableView, and Wt::WTreeView.

const WLength& Wt::WAbstractItemView::headerHeight (  )  const [inline]

Returns the header height.

See also:
setHeaderHeight()

virtual int Wt::WAbstractItemView::pageCount (  )  const [pure 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()

Implemented in Wt::WTableView, and Wt::WTreeView.

virtual int Wt::WAbstractItemView::pageSize (  )  const [pure 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()

Implemented in Wt::WTableView, and Wt::WTreeView.

virtual int Wt::WAbstractItemView::currentPage (  )  const [pure 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()

Implemented in Wt::WTableView, and Wt::WTreeView.

virtual void Wt::WAbstractItemView::setCurrentPage ( int  page  )  [pure 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()

Implemented in Wt::WTableView, and Wt::WTreeView.

void Wt::WAbstractItemView::setEditTriggers ( WFlags< EditTrigger editTriggers  ) 

Configures what actions should trigger editing.

See also:
edit()

WFlags<EditTrigger> Wt::WAbstractItemView::editTriggers (  )  const [inline]

Returns the editing triggers.

See also:
setEditTriggers()

WFlags<EditOption> Wt::WAbstractItemView::editOptions (  )  const [inline]

Returns the editing options.

See also:
setEditOptions()

void Wt::WAbstractItemView::edit ( const WModelIndex index  ) 

Opens an editor for the given index.

Unless multiple editors are enabled, any other open editor is closed first.

See also:
setEditTriggers(), setEditOptions(), closeEditor()

void Wt::WAbstractItemView::closeEditor ( const WModelIndex index,
bool  saveData = true 
)

Closes the editor for the given index.

If saveData is true, then the currently edited value is saved first to the model.

See also:
edit()

bool Wt::WAbstractItemView::isEditing ( const WModelIndex index  )  const

Returns whether an editor is open for a given index.

See also:
edit()

Signal<WModelIndex, WMouseEvent>& Wt::WAbstractItemView::clicked (  )  [inline]

Signal emitted when an item is clicked.

See also:
doubleClicked()

Signal<WModelIndex, WMouseEvent>& Wt::WAbstractItemView::doubleClicked (  )  [inline]

Signal emitted when an item is double clicked.

See also:
clicked()

Signal<WModelIndex, WMouseEvent>& Wt::WAbstractItemView::mouseWentDown (  )  [inline]

Signal emitted when a mouse button is pressed down.

See also:
mouseWentUp()

Signal<WModelIndex, WMouseEvent>& Wt::WAbstractItemView::mouseWentUp (  )  [inline]

Signal emitted when the mouse button is released.

See also:
mouseWentDown()

Signal& Wt::WAbstractItemView::selectionChanged (  )  [inline]

Signal emitted when the selection is changed.

See also:
select(), setSelectionMode(), setSelectionBehavior()

Signal& Wt::WAbstractItemView::pageChanged (  )  [inline]

Signal emitted when page information was updated.

When Ajax/JavaScript is not available, the view will use a paging navigation bar to allow scrolling through the data. This signal is emitted when page-related information changed (e.g. the current page was changed, or the number of rows was changed).

See also:
createPageNavigationBar()

Signal<int, WLength>& Wt::WAbstractItemView::columnResized (  )  [inline]

Returns the signal emitted when a column is resized by the user.

The arguments of the signal are: the column index and the new width of the column.

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.

See also:
WAbstractItemModel::dropEvent()

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.

See also:
setHeaderHeight(), extraHeaderWidget()

WWidget * Wt::WAbstractItemView::extraHeaderWidget ( int  column  )  [protected]

Returns the extra header widget.

Returns the widget previously created using createExtraHeaderWidget()

See also:
createExtraHeaderWidget()

WWidget * Wt::WAbstractItemView::createPageNavigationBar (  )  [protected, virtual]

Returns a page navigation widget.

When Ajax/JavaScript is not available, the view will use a paging navigation bar to allow scrolling through the data, created by this method. The default implementation displays a simple navigation bar with (First, Prevous, Next, Last) buttons and a page counter.

You may want to reimplement this method to provide a custom page navigation bar. You can use the currentPage(), pageCount(), and setCurrentPage() methods to set or get the page information, and listen to the pageChanged() signal to react to changes.


Generated on Thu May 20 18:14:40 2010 for Wt by doxygen 1.5.6