eu.webtoolkit.jwt
Class WAbstractItemModel

java.lang.Object
  extended by eu.webtoolkit.jwt.WObject
      extended by eu.webtoolkit.jwt.WAbstractItemModel
Direct Known Subclasses:
WAbstractListModel, WAbstractProxyModel, WAbstractTableModel, WItemModel, WStandardItemModel

public abstract class WAbstractItemModel
extends WObject

An abstract model for use with Wt's view classes.

This abstract model is used by several JWt view widgets as data models.

It may model data for both tree-like and table-like view widgets. Data is therefore organized in a hierarchical structure of tables, where every item stores data and items in column 0 can be the parent of a nested table of data. Every data item is uniquely identified by their row, column and parent index, and items may be referenced using the helper class WModelIndex.

Each item may provide data for one or more roles, and indicate options using flags. The different roles can be used to model different aspects of an item (its text value, an icon, style class), or to hold auxiliary custom information. The flags provide information to the View on possible interactivity.

Top level data have a null parent WModelIndex.

The data itself is of type Object, which can either be null, or be any type of data. Depending on the role however, view classes may expect certain types of data (e.g. numerical types for charts) or will convert the data to a string (e.g. for ItemDataRole.DisplayRole).

To implement a custom model, you need to reimplement the following methods:

A crucial point in implementing a hierarchical model is to decide how to reference an index in terms of an internal pointer ( WModelIndex#getInternalPointer()). Other than the top-level index, which is special since it is referenced using an invalid index, every index with children must be identifiable using this object. For example, in the WStandardItemModel, the internal pointer points to the parent WStandardItem. For table models, the internal pointer plays no role, since only the toplevel index has children.

If you want to support editing of the model, then you need to indicate this support using a ItemFlag.ItemIsEditable flag, and reimplement setData(). View classes will use the EditRole to read and update the data for the editor.

When the model's data has been changed, the model must emit the dataChanged() signal.

Finally, there is a generic interface for insertion of new data or removal of data (changing the geometry), although this interface is not yet used by any View class:

Alternatively, you can provide your own API for changing the model. In either case it is important that you call the corresponding protected member functions which will emit the relevant signals so that views can adapt themselves to the new geometry.


Constructor Summary
WAbstractItemModel()
          Creates a new data model.
WAbstractItemModel(WObject parent)
          Creates a new data model.
 
Method Summary
protected  void beginInsertColumns(WModelIndex parent, int first, int last)
          Method to be called before inserting columns.
protected  void beginInsertRows(WModelIndex parent, int first, int last)
          Method to be called before inserting rows.
protected  void beginRemoveColumns(WModelIndex parent, int first, int last)
          Method to be called before removing columns.
protected  void beginRemoveRows(WModelIndex parent, int first, int last)
          Method to be called before removing rows.
 void collapseColumn(int column)
          Collapses a column.
 Signal3<WModelIndex,java.lang.Integer,java.lang.Integer> columnsAboutToBeInserted()
          Signal emitted before a number of columns will be inserted.
 Signal3<WModelIndex,java.lang.Integer,java.lang.Integer> columnsAboutToBeRemoved()
          Signal emitted before a number of columns will be removed.
 Signal3<WModelIndex,java.lang.Integer,java.lang.Integer> columnsInserted()
          Signal emitted after a number of columns were inserted.
 Signal3<WModelIndex,java.lang.Integer,java.lang.Integer> columnsRemoved()
          Signal emitted after a number of columns were removed.
protected  WModelIndex createIndex(int row, int column, java.lang.Object ptr)
          Creates a model index for the given row and column.
 Signal2<WModelIndex,WModelIndex> dataChanged()
          Signal emitted when some data was changed.
 void dropEvent(WDropEvent e, DropAction action, int row, int column, WModelIndex parent)
          Handles a drop event.
protected  void endInsertColumns()
          Method to be called after inserting columns.
protected  void endInsertRows()
          Method to be called after inserting rows.
protected  void endRemoveColumns()
          Method to be called after removing columns.
protected  void endRemoveRows()
          Method to be called after removing rows.
 void expandColumn(int column)
          Expands a column.
 WModelIndex fromRawIndex(java.lang.Object rawIndex)
          Converts a raw pointer to a model index.
 java.util.List<java.lang.String> getAcceptDropMimeTypes()
          Returns a list of mime-types that could be accepted for a drop event.
 int getColumnCount()
          Returns the number of columns.
abstract  int getColumnCount(WModelIndex parent)
          Returns the number of columns.
 java.lang.Object getData(int row, int column)
          Returns the data item at the given column and row.
 java.lang.Object getData(int row, int column, int role)
          Returns the data item at the given column and row.
 java.lang.Object getData(int row, int column, int role, WModelIndex parent)
          Returns the data item at the given column and row.
 java.lang.Object getData(WModelIndex index)
          Returns data at a specific model index.
abstract  java.lang.Object getData(WModelIndex index, int role)
          Returns data at a specific model index.
 java.util.EnumSet<ItemFlag> getFlags(WModelIndex index)
          Returns the flags for an item.
 java.lang.Object getHeaderData(int section)
          Returns the row or column header data.
 java.lang.Object getHeaderData(int section, Orientation orientation)
          Returns the row or column header data.
 java.lang.Object getHeaderData(int section, Orientation orientation, int role)
          Returns the row or column header data.
 java.util.EnumSet<HeaderFlag> getHeaderFlags(int section)
          Returns the flags for a header.
 java.util.EnumSet<HeaderFlag> getHeaderFlags(int section, Orientation orientation)
          Returns the flags for a header.
 WModelIndex getIndex(int row, int column)
          Returns the child index for the given row and column.
abstract  WModelIndex getIndex(int row, int column, WModelIndex parent)
          Returns the child index for the given row and column.
 java.util.SortedMap<java.lang.Integer,java.lang.Object> getItemData(WModelIndex index)
          Returns all data at a specific index.
 java.lang.String getMimeType()
          Returns a mime-type for dragging a set of indexes.
abstract  WModelIndex getParent(WModelIndex index)
          Returns the parent for a model index.
 int getRowCount()
          Returns the number of rows.
abstract  int getRowCount(WModelIndex parent)
          Returns the number of rows.
 boolean hasChildren(WModelIndex index)
          Returns if there are children at an index.
 boolean hasIndex(int row, int column)
          Returns if an index at the given position is valid (i.e.
 boolean hasIndex(int row, int column, WModelIndex parent)
          Returns if an index at the given position is valid (i.e.
 Signal3<Orientation,java.lang.Integer,java.lang.Integer> headerDataChanged()
          Signal emitted when some header data was changed.
 boolean insertColumn(int column)
          Inserts one column.
 boolean insertColumn(int column, WModelIndex parent)
          Inserts one column.
 boolean insertColumns(int column, int count)
          Inserts one or more columns.
 boolean insertColumns(int column, int count, WModelIndex parent)
          Inserts one or more columns.
 boolean insertRow(int row)
          Inserts one row.
 boolean insertRow(int row, WModelIndex parent)
          Inserts one row.
 boolean insertRows(int row, int count)
          Inserts one or more rows.
 boolean insertRows(int row, int count, WModelIndex parent)
          Inserts one or more rows.
 Signal layoutAboutToBeChanged()
          Signal emitted when the layout is about to be changed.
 Signal layoutChanged()
          Signal emitted when the layout is changed.
 java.util.List<WModelIndex> match(WModelIndex start, int role, java.lang.Object value, int hits, MatchOptions flags)
          Returns an index list for data items that match.
 Signal modelReset()
          Signal emitted when the model was reset.
 boolean removeColumn(int column)
          Removes one column.
 boolean removeColumn(int column, WModelIndex parent)
          Removes one column.
 boolean removeColumns(int column, int count)
          Removes columns.
 boolean removeColumns(int column, int count, WModelIndex parent)
          Removes columns.
 boolean removeRow(int row)
          Removes one row.
 boolean removeRow(int row, WModelIndex parent)
          Removes one row.
 boolean removeRows(int row, int count)
          Removes rows.
 boolean removeRows(int row, int count, WModelIndex parent)
          Removes rows.
protected  void reset()
          Resets the model and invalidate any data.
 Signal3<WModelIndex,java.lang.Integer,java.lang.Integer> rowsAboutToBeInserted()
          Signal emitted before a number of rows will be inserted.
 Signal3<WModelIndex,java.lang.Integer,java.lang.Integer> rowsAboutToBeRemoved()
          Signal emitted before a number of rows will be removed.
 Signal3<WModelIndex,java.lang.Integer,java.lang.Integer> rowsInserted()
          Signal emitted after a number of rows were inserted.
 Signal3<WModelIndex,java.lang.Integer,java.lang.Integer> rowsRemoved()
          Signal emitted after a number of rows were removed.
 boolean setData(int row, int column, java.lang.Object value)
          Sets data at the given row and column.
 boolean setData(int row, int column, java.lang.Object value, int role)
          Sets data at the given row and column.
 boolean setData(int row, int column, java.lang.Object value, int role, WModelIndex parent)
          Sets data at the given row and column.
 boolean setData(WModelIndex index, java.lang.Object value)
          Sets data at the given model index.
 boolean setData(WModelIndex index, java.lang.Object value, int role)
          Sets data at the given model index.
 boolean setHeaderData(int section, java.lang.Object value)
          Sets column header data.
 boolean setHeaderData(int section, Orientation orientation, java.lang.Object value)
          Sets header data for a column or row.
 boolean setHeaderData(int section, Orientation orientation, java.lang.Object value, int role)
          Sets header data for a column or row.
 boolean setItemData(WModelIndex index, java.util.SortedMap<java.lang.Integer,java.lang.Object> values)
          Sets data at the given model index.
 void sort(int column)
          Sorts the model according to a particular column.
 void sort(int column, SortOrder order)
          Sorts the model according to a particular column.
 java.lang.Object toRawIndex(WModelIndex index)
          Converts a model index to a raw pointer that remains valid while the model's layout is changed.
 
Methods inherited from class eu.webtoolkit.jwt.WObject
getId, getObjectName, remove, setObjectName, tr
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WAbstractItemModel

public WAbstractItemModel(WObject parent)
Creates a new data model.


WAbstractItemModel

public WAbstractItemModel()
Creates a new data model.

Calls this((WObject)null)

Method Detail

getColumnCount

public abstract int getColumnCount(WModelIndex parent)
Returns the number of columns.

This returns the number of columns at index parent.

See Also:
getRowCount(WModelIndex parent)

getColumnCount

public final int getColumnCount()
Returns the number of columns.

Returns getColumnCount(null)


getRowCount

public abstract int getRowCount(WModelIndex parent)
Returns the number of rows.

This returns the number of rows at index parent.

See Also:
getColumnCount(WModelIndex parent)

getRowCount

public final int getRowCount()
Returns the number of rows.

Returns getRowCount(null)


getFlags

public java.util.EnumSet<ItemFlag> getFlags(WModelIndex index)
Returns the flags for an item.

The default implementation returns ItemIsSelectable.

See Also:
ItemFlag

getHeaderFlags

public java.util.EnumSet<HeaderFlag> getHeaderFlags(int section,
                                                    Orientation orientation)
Returns the flags for a header.

The default implementation returns no flags set.

See Also:
HeaderFlag

getHeaderFlags

public final java.util.EnumSet<HeaderFlag> getHeaderFlags(int section)
Returns the flags for a header.

Returns getHeaderFlags(section, Orientation.Horizontal)


hasChildren

public boolean hasChildren(WModelIndex index)
Returns if there are children at an index.

Returns true when rowCount(index) > 0 and columnCount(index) > 0.

See Also:
getRowCount(WModelIndex parent), getColumnCount(WModelIndex parent)

getParent

public abstract WModelIndex getParent(WModelIndex index)
Returns the parent for a model index.

An implementation should use createIndex() to create a model index that corresponds to the parent of a given index.

Note that the index itself may be stale (referencing a row/column within the parent that is outside the model geometry), but its parent (identified by the WModelIndex#getInternalPointer()) is referencing an existing parent. A stale index can only be used while the model geometry is being updated, i.e. during the emission of the corresponding [rows/columns](Being)[Removed/Inserted]() signals.

See Also:
getIndex(int row, int column, WModelIndex parent)

getData

public abstract java.lang.Object getData(WModelIndex index,
                                         int role)
Returns data at a specific model index.

Return data for a given role at a given index.

You should check the role to decide what data to return. Usually a View class will ask for data for several roles which affect not only the contents (ItemDataRole.DisplayRole) but also icons ( ItemDataRole.DecorationRole), URLs (ItemDataRole.LinkRole ), and other visual aspects. If your item does not specify data for a particular role, it should simply return a boost::any().

See Also:
getFlags(WModelIndex index), getHeaderData(int section, Orientation orientation, int role), setData(WModelIndex index, Object value, int role)

getData

public final java.lang.Object getData(WModelIndex index)
Returns data at a specific model index.

Returns getData(index, ItemDataRole.DisplayRole)


getItemData

public java.util.SortedMap<java.lang.Integer,java.lang.Object> getItemData(WModelIndex index)
Returns all data at a specific index.

This is a convenience function that returns a map with data corresponding to all standard roles.

See Also:
getData(WModelIndex index, int role)

getHeaderData

public java.lang.Object getHeaderData(int section,
                                      Orientation orientation,
                                      int role)
Returns the row or column header data.

When orientation is Horizontal, section is a column number, when orientation is Vertical, section is a row number.

See Also:
getData(WModelIndex index, int role), setHeaderData(int section, Orientation orientation, Object value, int role)

getHeaderData

public final java.lang.Object getHeaderData(int section)
Returns the row or column header data.

Returns getHeaderData(section, Orientation.Horizontal, ItemDataRole.DisplayRole)


getHeaderData

public final java.lang.Object getHeaderData(int section,
                                            Orientation orientation)
Returns the row or column header data.

Returns getHeaderData(section, orientation, ItemDataRole.DisplayRole)


getIndex

public abstract WModelIndex getIndex(int row,
                                     int column,
                                     WModelIndex parent)
Returns the child index for the given row and column.

When implementing this method, you can use createIndex() to create an index that corresponds to the item at row and column within parent.

If the location is invalid (out of bounds at the parent), then an invalid index must be returned.

See Also:
getParent(WModelIndex index)

getIndex

public final WModelIndex getIndex(int row,
                                  int column)
Returns the child index for the given row and column.

Returns getIndex(row, column, null)


match

public java.util.List<WModelIndex> match(WModelIndex start,
                                         int role,
                                         java.lang.Object value,
                                         int hits,
                                         MatchOptions flags)
Returns an index list for data items that match.

Returns an index list of data items that match, starting at start, and searching further in that column. If flags specifies MatchWrap then the search wraps around from the start. If hits is not -1, then at most that number of hits are returned.


getData

public java.lang.Object getData(int row,
                                int column,
                                int role,
                                WModelIndex parent)
Returns the data item at the given column and row.

This is a convenience method, and is equivalent to:

 index(row, column, parent).data(role)
 

See Also:
getIndex(int row, int column, WModelIndex parent), getData(WModelIndex index, int role)

getData

public final java.lang.Object getData(int row,
                                      int column)
Returns the data item at the given column and row.

Returns getData(row, column, ItemDataRole.DisplayRole, null)


getData

public final java.lang.Object getData(int row,
                                      int column,
                                      int role)
Returns the data item at the given column and row.

Returns getData(row, column, role, null)


hasIndex

public boolean hasIndex(int row,
                        int column,
                        WModelIndex parent)
Returns if an index at the given position is valid (i.e. falls within the column-row bounds).

Equivalent to:

 return row >= 0 && column >= 0 && row < rowCount(parent)
                && column < columnCount(parent);
 

See Also:
getRowCount(WModelIndex parent), getColumnCount(WModelIndex parent)

hasIndex

public final boolean hasIndex(int row,
                              int column)
Returns if an index at the given position is valid (i.e. falls within the column-row bounds).

Returns hasIndex(row, column, null)


insertColumns

public boolean insertColumns(int column,
                             int count,
                             WModelIndex parent)
Inserts one or more columns.

In models that support column insertion, this inserts count columns, starting at column, and returns true if the operation was successful. The new columns are inserted under parent.

The default implementation returns false.

The model implementation must call beginInsertColumns() and endInsertColumns() before and after the operation whenever its geometry is changed by inserting columns. This emits signals for views to properly react to these changes.

See Also:
insertRows(int row, int count, WModelIndex parent), removeColumns(int column, int count, WModelIndex parent), beginInsertColumns(WModelIndex parent, int first, int last), endInsertColumns()

insertColumns

public final boolean insertColumns(int column,
                                   int count)
Inserts one or more columns.

Returns insertColumns(column, count, null)


insertRows

public boolean insertRows(int row,
                          int count,
                          WModelIndex parent)
Inserts one or more rows.

In models that support row insertion, this inserts count rows, starting at row, and returns true if the operation was successful. The new rows are inserted under parent.

If parent had no children, then a single column is added with count rows.

The default implementation returns false.

The model implementation must call beginInsertRows() and endInsertRows() before and after the operation whenever its geometry is changed by inserting rows. This emits signals for views to properly react to these changes.

See Also:
insertColumns(int column, int count, WModelIndex parent), removeRows(int row, int count, WModelIndex parent), beginInsertRows(WModelIndex parent, int first, int last), endInsertRows()

insertRows

public final boolean insertRows(int row,
                                int count)
Inserts one or more rows.

Returns insertRows(row, count, null)


removeColumns

public boolean removeColumns(int column,
                             int count,
                             WModelIndex parent)
Removes columns.

Returns true if the operation was successful.

The default implementation returns false.

The model implementation must call beginRemoveColumns() and endRemoveColumns() before and after the operation whenever its geometry is changed by removing columns. This emits signals for views to properly react to these changes.

See Also:
removeRows(int row, int count, WModelIndex parent), insertColumns(int column, int count, WModelIndex parent), beginRemoveColumns(WModelIndex parent, int first, int last), endRemoveColumns()

removeColumns

public final boolean removeColumns(int column,
                                   int count)
Removes columns.

Returns removeColumns(column, count, null)


removeRows

public boolean removeRows(int row,
                          int count,
                          WModelIndex parent)
Removes rows.

Returns true if the operation was successful.

The default implementation returns false.

The model implementation must call beginRemoveRows() and endRemoveRows() before and after the operation whenever its geometry is changed by removing rows. This emits signals for views to properly react to these changes.

See Also:
removeColumns(int column, int count, WModelIndex parent), insertRows(int row, int count, WModelIndex parent), beginRemoveRows(WModelIndex parent, int first, int last), endRemoveRows()

removeRows

public final boolean removeRows(int row,
                                int count)
Removes rows.

Returns removeRows(row, count, null)


setData

public boolean setData(WModelIndex index,
                       java.lang.Object value,
                       int role)
Sets data at the given model index.

Returns true if the operation was successful.

The default implementation returns false.

The model implementation must emit the dataChanged() signal after data was changed.

See Also:
getData(WModelIndex index, int role)

setData

public final boolean setData(WModelIndex index,
                             java.lang.Object value)
Sets data at the given model index.

Returns setData(index, value, ItemDataRole.EditRole)


setItemData

public boolean setItemData(WModelIndex index,
                           java.util.SortedMap<java.lang.Integer,java.lang.Object> values)
Sets data at the given model index.

This is a convenience function that sets data for all roles at once.

See Also:
setData(WModelIndex index, Object value, int role)

setHeaderData

public boolean setHeaderData(int section,
                             Orientation orientation,
                             java.lang.Object value,
                             int role)
Sets header data for a column or row.

Returns true if the operation was successful.

See Also:
getHeaderData(int section, Orientation orientation, int role)

setHeaderData

public final boolean setHeaderData(int section,
                                   Orientation orientation,
                                   java.lang.Object value)
Sets header data for a column or row.

Returns setHeaderData(section, orientation, value, ItemDataRole.EditRole)


setHeaderData

public boolean setHeaderData(int section,
                             java.lang.Object value)
Sets column header data.

Returns true if the operation was successful.

See Also:
setHeaderData(int section, Orientation orientation, Object value, int role)

sort

public void sort(int column,
                 SortOrder order)
Sorts the model according to a particular column.

If the model supports sorting, then it should emit the layoutAboutToBeChanged() signal, rearrange its items, and afterwards emit the layoutChanged() signal.

See Also:
layoutAboutToBeChanged(), layoutChanged()

sort

public final void sort(int column)
Sorts the model according to a particular column.

Calls sort(column, SortOrder.AscendingOrder)


expandColumn

public void expandColumn(int column)
Expands a column.

Expands a column. This may only be called by a view when the HeaderFlag.ColumnIsCollapsed flag is set.

The default implementation does nothing.

See Also:
WAggregateProxyModel

collapseColumn

public void collapseColumn(int column)
Collapses a column.

Collapses a column. This may only be called by a view when the HeaderFlag.ColumnIsExpandedLeft or HeaderFlag.ColumnIsExpandedRight flag is set.

The default implementation does nothing.

See Also:
WAggregateProxyModel

toRawIndex

public java.lang.Object toRawIndex(WModelIndex index)
Converts a model index to a raw pointer that remains valid while the model's layout is changed.

Use this method to temporarily save model indexes while the model's layout is changed by for example a sorting operation.

The default implementation returns null, which indicates that the index cannot be converted to a raw pointer. If you reimplement this method, you also need to reimplemnt fromRawIndex().

See Also:
layoutAboutToBeChanged(), sort(int column, SortOrder order), fromRawIndex(Object rawIndex)

fromRawIndex

public WModelIndex fromRawIndex(java.lang.Object rawIndex)
Converts a raw pointer to a model index.

Use this method to create model index from temporary raw pointers. It is the reciproce method of toRawIndex().

You can return an invalid modelindex if the rawIndex no longer points to a valid item because of the layout change.

See Also:
toRawIndex(WModelIndex index)

getMimeType

public java.lang.String getMimeType()
Returns a mime-type for dragging a set of indexes.

This method returns a mime-type that describes dragging of a selection of items.

The drop event will indicate a selection model for this abstract item model as source.

The default implementation returns a mime-type for generic drag&drop support between abstract item models.

See Also:
getAcceptDropMimeTypes()

getAcceptDropMimeTypes

public java.util.List<java.lang.String> getAcceptDropMimeTypes()
Returns a list of mime-types that could be accepted for a drop event.

The default implementation only accepts drag&drop support between abstract item models.

See Also:
getMimeType()

dropEvent

public void dropEvent(WDropEvent e,
                      DropAction action,
                      int row,
                      int column,
                      WModelIndex parent)
Handles a drop event.

The default implementation only handles generic drag&drop between abstract item models. Source item data is copied (but not the source item's flags).

The location in the model is indicated by the row and column within the parent index. If row is -1, then the item is appended to the parent. Otherwise, the item is inserted at or copied over the indicated item (and subsequent rows). When action is a MoveAction, the original items are deleted from the source model.

You may want to reimplement this method if you want to handle other mime-type data, or if you want to refine how the drop event of an item selection must be interpreted.

Note: Currently, only row selections are handled by the default implementation.

See Also:
getMimeType(), WItemSelectionModel

insertColumn

public boolean insertColumn(int column,
                            WModelIndex parent)
Inserts one column.

This is a convenience method that adds a single column, and is equivalent to:

 insertColumns(column, 1, parent);
 

Returns true if the operation was successful.

See Also:
insertColumns(int column, int count, WModelIndex parent)

insertColumn

public final boolean insertColumn(int column)
Inserts one column.

Returns insertColumn(column, null)


insertRow

public boolean insertRow(int row,
                         WModelIndex parent)
Inserts one row.

This is a convenience method that adds a single row, and is equivalent to:

 insertRows(row, 1, parent);
 

Returns true if the operation was successful.

See Also:
insertRows(int row, int count, WModelIndex parent)

insertRow

public final boolean insertRow(int row)
Inserts one row.

Returns insertRow(row, null)


removeColumn

public boolean removeColumn(int column,
                            WModelIndex parent)
Removes one column.

This is a convenience method that removes a single column, and is equivalent to:

 removeColumns(column, 1, parent);
 

Returns true if the operation was successful.

See Also:
removeColumns(int column, int count, WModelIndex parent)

removeColumn

public final boolean removeColumn(int column)
Removes one column.

Returns removeColumn(column, null)


removeRow

public boolean removeRow(int row,
                         WModelIndex parent)
Removes one row.

This is a convenience method that removes a single row, and is equivalent to:

 removeRows(row, 1, parent);
 

Returns true if the operation was successful.

See Also:
removeRows(int row, int count, WModelIndex parent)

removeRow

public final boolean removeRow(int row)
Removes one row.

Returns removeRow(row, null)


setData

public boolean setData(int row,
                       int column,
                       java.lang.Object value,
                       int role,
                       WModelIndex parent)
Sets data at the given row and column.

This is a convience method, and is equivalent to:

 setData(index(row, column, parent), value, role);
 

Returns true if the operation was successful.

See Also:
setData(WModelIndex index, Object value, int role), getIndex(int row, int column, WModelIndex parent)

setData

public final boolean setData(int row,
                             int column,
                             java.lang.Object value)
Sets data at the given row and column.

Returns setData(row, column, value, ItemDataRole.EditRole, null)


setData

public final boolean setData(int row,
                             int column,
                             java.lang.Object value,
                             int role)
Sets data at the given row and column.

Returns setData(row, column, value, role, null)


columnsAboutToBeInserted

public Signal3<WModelIndex,java.lang.Integer,java.lang.Integer> columnsAboutToBeInserted()
Signal emitted before a number of columns will be inserted.

The first argument is the parent index. The two integer arguments are the column numbers that the first and last column will have when inserted.

See Also:
columnsInserted(), beginInsertColumns(WModelIndex parent, int first, int last)

columnsAboutToBeRemoved

public Signal3<WModelIndex,java.lang.Integer,java.lang.Integer> columnsAboutToBeRemoved()
Signal emitted before a number of columns will be removed.

The first argument is the parent index. The two integer arguments are the column numbers of the first and last column that will be removed.

See Also:
columnsRemoved(), beginRemoveColumns(WModelIndex parent, int first, int last)

columnsInserted

public Signal3<WModelIndex,java.lang.Integer,java.lang.Integer> columnsInserted()
Signal emitted after a number of columns were inserted.

The first argument is the parent index. The two integer arguments are the column numbers of the first and last column that were inserted.

See Also:
columnsAboutToBeInserted(), endInsertColumns()

columnsRemoved

public Signal3<WModelIndex,java.lang.Integer,java.lang.Integer> columnsRemoved()
Signal emitted after a number of columns were removed.

The first argument is the parent index. The two integer arguments are the column numbers of the first and last column that were removed.

See Also:
columnsAboutToBeRemoved(), endRemoveColumns()

rowsAboutToBeInserted

public Signal3<WModelIndex,java.lang.Integer,java.lang.Integer> rowsAboutToBeInserted()
Signal emitted before a number of rows will be inserted.

The first argument is the parent index. The two integer arguments are the row numbers that the first and last row will have when inserted.

See Also:
rowsInserted(), beginInsertRows(WModelIndex parent, int first, int last)

rowsAboutToBeRemoved

public Signal3<WModelIndex,java.lang.Integer,java.lang.Integer> rowsAboutToBeRemoved()
Signal emitted before a number of rows will be removed.

The first argument is the parent index. The two integer arguments are the row numbers of the first and last row that will be removed.

See Also:
rowsRemoved(), beginRemoveRows(WModelIndex parent, int first, int last)

rowsInserted

public Signal3<WModelIndex,java.lang.Integer,java.lang.Integer> rowsInserted()
Signal emitted after a number of rows were inserted.

The first argument is the parent index. The two integer arguments are the row numbers of the first and last row that were inserted.

See Also:
rowsAboutToBeInserted(), endInsertRows()

rowsRemoved

public Signal3<WModelIndex,java.lang.Integer,java.lang.Integer> rowsRemoved()
Signal emitted after a number of rows were removed.

The first argument is the parent index. The two integer arguments are the row numbers of the first and last row that were removed.

See Also:
rowsAboutToBeRemoved(), endRemoveRows()

dataChanged

public Signal2<WModelIndex,WModelIndex> dataChanged()
Signal emitted when some data was changed.

The two arguments are the model indexes of the top-left and bottom-right data items that span the rectangle of changed data items.

See Also:
setData(WModelIndex index, Object value, int role)

headerDataChanged

public Signal3<Orientation,java.lang.Integer,java.lang.Integer> headerDataChanged()
Signal emitted when some header data was changed.

The first argument indicates the orientation of the header, and the two integer arguments are the row or column numbers of the first and last header item of which the value was changed.

See Also:
setHeaderData(int section, Orientation orientation, Object value, int role)

layoutAboutToBeChanged

public Signal layoutAboutToBeChanged()
Signal emitted when the layout is about to be changed.

A layout change reorders the data in the model, but columns are preserved. Model indexes are invalidated by a layout change, but indexes may be ported across a layout change by using the toRawIndex() and fromRawIndex() methods.

See Also:
layoutChanged(), toRawIndex(WModelIndex index), fromRawIndex(Object rawIndex)

layoutChanged

public Signal layoutChanged()
Signal emitted when the layout is changed.

See Also:
layoutAboutToBeChanged()

modelReset

public Signal modelReset()
Signal emitted when the model was reset.

A model reset invalidates all existing data, and the model may change its entire geometry (column count, row count).

See Also:
reset()

reset

protected void reset()
Resets the model and invalidate any data.

Informs any attached view that all data in the model was invalidated, and the model's data should be reread.

This causes the modelReset() signal to be emitted.


createIndex

protected WModelIndex createIndex(int row,
                                  int column,
                                  java.lang.Object ptr)
Creates a model index for the given row and column.

Use this method to create a model index. ptr is an internal pointer that may be used to identify the parent of the corresponding item. For a flat table model, ptr can thus always be 0.

See Also:
WModelIndex.getInternalPointer()

beginInsertColumns

protected void beginInsertColumns(WModelIndex parent,
                                  int first,
                                  int last)
Method to be called before inserting columns.

If your model supports insertion of columns, then you should call this method before inserting one or more columns, and endInsertColumns() afterwards. These methods emit the necessary signals to allow view classes to update themselves.

See Also:
endInsertColumns(), insertColumns(int column, int count, WModelIndex parent), columnsAboutToBeInserted()

beginInsertRows

protected void beginInsertRows(WModelIndex parent,
                               int first,
                               int last)
Method to be called before inserting rows.

If your model supports insertion of rows, then you should call this method before inserting one or more rows, and endInsertRows() afterwards. These methods emit the necessary signals to allow view classes to update themselves.

See Also:
endInsertRows(), insertRows(int row, int count, WModelIndex parent), rowsAboutToBeInserted()

beginRemoveColumns

protected void beginRemoveColumns(WModelIndex parent,
                                  int first,
                                  int last)
Method to be called before removing columns.

If your model supports removal of columns, then you should call this method before removing one or more columns, and endRemoveColumns() afterwards. These methods emit the necessary signals to allow view classes to update themselves.

See Also:
endRemoveColumns(), removeColumns(int column, int count, WModelIndex parent), columnsAboutToBeRemoved()

beginRemoveRows

protected void beginRemoveRows(WModelIndex parent,
                               int first,
                               int last)
Method to be called before removing rows.

If your model supports removal of rows, then you should call this method before removing one or more rows, and endRemoveRows() afterwards. These methods emit the necessary signals to allow view classes to update themselves.

See Also:
endRemoveRows(), removeRows(int row, int count, WModelIndex parent), rowsAboutToBeRemoved()

endInsertColumns

protected void endInsertColumns()
Method to be called after inserting columns.

See Also:
beginInsertColumns(WModelIndex parent, int first, int last)

endInsertRows

protected void endInsertRows()
Method to be called after inserting rows.

See Also:
beginInsertRows(WModelIndex parent, int first, int last)

endRemoveColumns

protected void endRemoveColumns()
Method to be called after removing columns.

See Also:
beginRemoveColumns(WModelIndex parent, int first, int last)

endRemoveRows

protected void endRemoveRows()
Method to be called after removing rows.

See Also:
beginRemoveRows(WModelIndex parent, int first, int last)