Wt  4.0.2
Public Member Functions | List of all members
Wt::WItemSelectionModel Class Reference

A class that represents a selection for a WAbstractItemView. More...

#include <Wt/WItemSelectionModel.h>

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

Public Member Functions

std::shared_ptr< WAbstractItemModelmodel () const
 Returns the WAbstractItemModel.
 
WModelIndexSet selectedIndexes () const
 Returns the set of selected items. More...
 
bool isSelected (const WModelIndex &index) const
 Returns wheter an item is selected. More...
 
void setSelectionBehavior (SelectionBehavior behavior)
 Sets the selection behaviour. More...
 
SelectionBehavior selectionBehavior () const
 Returns the selection behaviour. More...
 
virtual std::string mimeType ()
 Returns the selection mime type. 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< WObjectremoveChild (WObject *child)
 Remove a child WObject, so its lifetime is no longer determined by this WObject.
 
virtual const std::string id () const
 Returns the (unique) identifier for this object. More...
 
virtual void setObjectName (const std::string &name)
 Sets an object name. More...
 
virtual std::string objectName () const
 Returns the object name. 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...
 

Additional Inherited Members

- Public Types inherited from Wt::WObject
typedef void(WObject::* Method) ()
 Typedef for a WObject method without arguments.
 
- Protected Member Functions inherited from Wt::WObject
virtual WStatelessSlot * getStateless (Method method)
 On-demand stateless slot implementation. More...
 

Detailed Description

A class that represents a selection for a WAbstractItemView.

This model is currently only used by WTreeView, and plays only a role in drag & drop of an item selection.

When an item selection is dragged from a view widget, the generated drop events will have as source object (see WDropEvent::source()) this selection model.

Although this class does not (yet) allow you to modify the selection, note that manipulations to the model may modify the selection (row insertions and removals may shift the selection, and row deletions may shrink the selection).

Note
Currently this class cannot be shared between multiple views.
See also
WTreeView, WTableView, WAbstractItemModel

Member Function Documentation

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

Returns wheter an item is selected.

When selection operates on rows (SelectionBehavior::Rows), this method returns true for each element in a selected row.

See also
selectedIndexes()
std::string Wt::WItemSelectionModel::mimeType ( )
virtual

Returns the selection mime type.

This should return the mime type for the current selection, or an emtpy string if the selection cannot be dragged.

The default implementation returns the mime type based on ItemDataRole::MimeType data if all selected items indicate the same mime type, or the model mimeType() otherwise.

If one or more items indicate that they cannot be dragged, then an empty string is returned.

WModelIndexSet Wt::WItemSelectionModel::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).

When selection operates on rows (SelectionBehavior::Rows), this method only returns the model index of first column's element of the selected rows.

SelectionBehavior Wt::WItemSelectionModel::selectionBehavior ( ) const

Returns the selection behaviour.

See also
setSelectionBehavior()
void Wt::WItemSelectionModel::setSelectionBehavior ( SelectionBehavior  behavior)

Sets the selection behaviour.

By default, the selection contains rows (SelectionBehavior::Rows), in which case model indexes will always be have column 0, but represent the whole row.

Alternatively, you can allow selection for individual items (SelectionBehavior::Items).


Generated on Fri Nov 24 2017 for the C++ Web Toolkit (Wt) by doxygen 1.8.11