Wt
3.3.8
|
Abstract delegate class for rendering an item in an item view. More...
#include <Wt/WAbstractItemDelegate>
Public Member Functions | |
WAbstractItemDelegate (WObject *parent=0) | |
Constructor. | |
virtual | ~WAbstractItemDelegate () |
Destructor. | |
virtual WWidget * | update (WWidget *widget, const WModelIndex &index, WFlags< ViewItemRenderFlag > flags)=0 |
Creates or updates a widget that renders an item. More... | |
virtual void | updateModelIndex (WWidget *widget, const WModelIndex &index) |
Updates the model index of a widget. More... | |
virtual boost::any | editState (WWidget *widget) const |
Returns the current edit state. More... | |
virtual void | setEditState (WWidget *widget, const boost::any &value) const |
Sets the editor data from the editor state. More... | |
virtual WValidator::State | validate (const WModelIndex &index, const boost::any &editState) const |
Returns whether the edited value is valid. More... | |
virtual void | setModelData (const boost::any &editState, WAbstractItemModel *model, const WModelIndex &index) const |
Saves the edited data to the model. More... | |
Signal< WWidget *, bool > & | closeEditor () |
Signal which indicates that an editor needs to be closed. More... | |
const Signal< WWidget *, bool > & | closeEditor () const |
Signal which indicates that an editor needs to be closed. 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... | |
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... | |
void | addChild (WObject *child) |
Adds a child object. More... | |
virtual void | removeChild (WObject *child) |
Removes a child object. More... | |
const std::vector< WObject * > & | children () const |
Returns the children. | |
WObject * | parent () const |
Returns the parent object. | |
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... | |
Static Protected Member Functions inherited from Wt::WObject | |
static WObject * | sender () |
Returns the sender of the current slot call. More... | |
Abstract delegate class for rendering an item in an item view.
Rendering of an item in a WAbstractItemView is delegated to an implementation of this delegate class. The default implementation used by Wt's item views is WItemDelegate. To provide specialized rendering support, you can reimplement this class (or specialize WItemDelegate).
As a delegate is used for rendering multiple items, the class should not keep state about one specific item.
A delegate may provide editing support by instantiating an editor when update() is called with the Wt::RenderEditing flag. In that case, you will also need to implement editState() and setEditState() to support virtual scrolling and setModelData() to save the edited value to the model. For an example, see the WItemDelegate.
Signal which indicates that an editor needs to be closed.
The delegate should emit this signal when it decides for itself that it should be closed (e.g. because the user confirmed the edited value or cancelled the editing). The View will then rerender the item if needed.
The second boolean argument passed to the signal is a flag which indicates whether the editor feels that the value should be saved or cancelled.
Signal which indicates that an editor needs to be closed.
|
virtual |
Returns the current edit state.
Because a View may support virtual scrolling in combination with editing, it may happen that the view decides to delete the editor widget while the user is editing. To allow to reconstruct the editor in its original state, the View will therefore ask for the editor to serialize its state in a boost::any.
When the view decides to close an editor and save its value back to the model, he will first call editState() and then setModelData().
The default implementation assumes a read-only delegate, and returns a boost::any().
Reimplemented in Wt::WItemDelegate.
|
virtual |
Sets the editor data from the editor state.
When the View scrolls back into view an item that was being edited, he will use setEditState() to allow the editor to restore its current editor state.
The default implementation assumes a read-only delegate and does nothing.
Reimplemented in Wt::WItemDelegate.
|
virtual |
Saves the edited data to the model.
The View will use this method to save the edited value to the model. The editState
is first fetched from the editor using editState().
The default implementation assumes a read-only delegate does nothing.
Reimplemented in Wt::WItemDelegate.
|
pure virtual |
Creates or updates a widget that renders an item.
The item is specified by its model index
, which also indicates the model. If an existing widget already renders the item, but needs to be updated, it is passed as the widget
parameter. You may decide to create a new widget, in which case you are responsible to delete the previous widget
if it is not reused.
When widget
is 0
, a new widget needs to be created.
The returned widget should be a widget that responds properly to be given a height, width and style class. In practice, that means it cannot have a border or margin, and thus cannot be a WFormWidget since those widgets typically have built-in borders and margins. If you want to return a form widget (for editing the item), you should wrap it in a container widget.
The flags
parameter indicates options for rendering the item.
Implemented in Wt::WItemDelegate.
|
virtual |
Updates the model index of a widget.
This method is invoked by the view when due to row/column insertions or removals, the index has shifted.
You should reimplement this method only if you are storing the model index in the widget
, to update the stored model index.
The default implementation does nothing.
Reimplemented in Wt::WItemDelegate.
|
virtual |
Returns whether the edited value is valid.
The default implementation does nothing and returns Valid.