Wt
3.3.8
|
Standard delegate class for rendering a view item. More...
#include <Wt/WItemDelegate>
Public Member Functions | |
WItemDelegate (WObject *parent=0) | |
Create an item delegate. | |
virtual WWidget * | update (WWidget *widget, const WModelIndex &index, WFlags< ViewItemRenderFlag > flags) |
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... | |
void | setTextFormat (const WString &format) |
Sets the text format string. More... | |
const WString & | textFormat () const |
Returns the text format string. More... | |
virtual void | setModelData (const boost::any &editState, WAbstractItemModel *model, const WModelIndex &index) const |
Saves the edited data to the model. More... | |
virtual boost::any | editState (WWidget *editor) const |
Returns the current edit state. More... | |
virtual void | setEditState (WWidget *editor, const boost::any &value) const |
Sets the editor data from the editor state. More... | |
Public Member Functions inherited from Wt::WAbstractItemDelegate | |
WAbstractItemDelegate (WObject *parent=0) | |
Constructor. | |
virtual | ~WAbstractItemDelegate () |
Destructor. | |
virtual WValidator::State | validate (const WModelIndex &index, const boost::any &editState) const |
Returns whether the edited value is valid. 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. | |
Protected Member Functions | |
virtual WWidget * | createEditor (const WModelIndex &index, WFlags< ViewItemRenderFlag > flags) const |
Creates an editor for a data item. More... | |
Protected Member Functions inherited from Wt::WObject | |
virtual WStatelessSlot * | getStateless (Method method) |
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 Protected Member Functions inherited from Wt::WObject | |
static WObject * | sender () |
Returns the sender of the current slot call. More... | |
Standard delegate class for rendering a view item.
This class provides the standard implementation for rendering an item (as in a WAbstractItemView), and renders data provided by the standard data roles (see ItemDataRole). It also provides default editing support using a line edit.
You may provide special editing support for an item by specializing the widget and reimplement createEditor(), setModelData(), editState(), and setEditState().
|
protectedvirtual |
Creates an editor for a data item.
The default implementation returns a WLineEdit which edits the item's Wt::EditRole value.
You may reimplement this method to provide a suitable editor, or to attach a custom validator. In that case, you will probably also want to reimplement editState(), setEditState(), and setModelData().
The editor should not keep a reference to the model index (it does not need to since setModelData() will provide the proper model index to save the data to the model). Otherwise, because model indexes may shift because of row or column insertions, you should reimplement updateModelIndex().
As an example of how to provide a specialized editor, consider the default implementation, which returns a WLineEdit:
|
virtual |
Returns the current edit state.
The default implementation returns the current text in the line edit. You will need to reimplement this method for a custom editor.
As an example of how to deal with a specialized editor, consider the default implementation:
Reimplemented from Wt::WAbstractItemDelegate.
|
virtual |
Sets the editor data from the editor state.
The default implementation resets the text in the line edit. You will need to reimplement this method if for a custom editor.
As an example of how to deal with a specialized editor, consider the default implementation:
Reimplemented from Wt::WAbstractItemDelegate.
|
virtual |
Saves the edited data to the model.
The default implementation saves the current edit value to the model. You will need to reimplement this method for a custom editor.
As an example of how to deal with a specialized editor, consider the default implementation:
Reimplemented from Wt::WAbstractItemDelegate.
void Wt::WItemDelegate::setTextFormat | ( | const WString & | format | ) |
Sets the text format string.
The DisplayRole data is converted to a string using asString() by passing the given format.
The default value is "".
const WString& Wt::WItemDelegate::textFormat | ( | ) | const |
Returns the text format string.
|
virtual |
Creates or updates a widget that renders an item.
The following properties of an item are rendered:
When the flags indicates Wt::RenderEditing, then createEditor() is called to create a suitable editor for editing the item.
Implements Wt::WAbstractItemDelegate.
|
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 from Wt::WAbstractItemDelegate.