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

An model that manages a list of strings. More...

#include <Wt/WStringListModel>

Inheritance diagram for Wt::WStringListModel:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 WStringListModel (WObject *parent=0)
 Create a new empty string list model.
 WStringListModel (const std::vector< WString > &strings, WObject *parent=0)
 Create a new string list model.
 ~WStringListModel ()
 Destructor.
void setStringList (const std::vector< WString > &strings)
 Set a new string list.
const std::vector< WString > & stringList () const
 Returns the string list.
virtual int flags (const WModelIndex &index) const
 Returns the flags for an item.
virtual bool setData (const WModelIndex &index, const boost::any &value, int role=EditRole)
 Set data at the given model index.
virtual boost::any data (const WModelIndex &index, int role=DisplayRole) const
 Returns data at a specific model index.
virtual int rowCount (const WModelIndex &parent=WModelIndex()) const
 Returns the number of rows.
virtual bool insertRows (int row, int count, const WModelIndex &parent=WModelIndex())
 Insert one or more rows.
virtual bool removeRows (int row, int count, const WModelIndex &parent=WModelIndex())
 Remove rows.
virtual void sort (int column, SortOrder order=AscendingOrder)
 Sort the model according to a particular column.


Detailed Description

An model that manages a list of strings.

This model only manages a unidimensional list of strings. It is used as the default model for view classes that show a list.

The model only presents DisplayRole data of a single column of data, but otherwise provides support for all standard features of a model, including editing and addition and removal of data rows.

You can populate the model by passing a list of strings to its consructor, or by using the setStringList() method. You can set or retrieve data using the setData() and data() methods, and add or remove data using the insertRows() and removeRows() methods.

See also:
WComboBox, WSelectionBox, Ext::ComboBox

Member Function Documentation

void Wt::WStringListModel::setStringList ( const std::vector< WString > &  strings  ) 

Set a new string list.

Replaces the current string list with a new list.

See also:
dataChanged

const std::vector<WString>& Wt::WStringListModel::stringList (  )  const [inline]

Returns the string list.

See also:
setStringList()

int Wt::WStringListModel::flags ( const WModelIndex index  )  const [virtual]

Returns the flags for an item.

This method is reimplemented to return ItemIsSelectable | ItemIsEditable.

See also:
Wt::ItemFlag

Reimplemented from Wt::WAbstractItemModel.

bool Wt::WStringListModel::setData ( const WModelIndex index,
const boost::any &  value,
int  role = EditRole 
) [virtual]

Set data at the given model index.

Returns true if the operation was successful.

The default implementation returns false. If you reimplement this method, you must emit the the dataChanged signal after data was changed.

See also:
data()

Reimplemented from Wt::WAbstractItemModel.

boost::any Wt::WStringListModel::data ( const WModelIndex index,
int  role = DisplayRole 
) const [virtual]

Returns data at a specific model index.

Return data for a given role at a given index.

See also:
flags(), headerData(), setData()

Implements Wt::WAbstractItemModel.

int Wt::WStringListModel::rowCount ( const WModelIndex parent = WModelIndex()  )  const [virtual]

Returns the number of rows.

This returns the number of rows at index parent.

See also:
columnCount()

Implements Wt::WAbstractItemModel.

bool Wt::WStringListModel::insertRows ( int  row,
int  count,
const WModelIndex parent = WModelIndex() 
) [virtual]

Insert one or more rows.

Returns true if the operation was successful. If you reimplement this method, then you must call beginInsertRows() and endInsertRows() before and after the operation.

The default implementation returns false.

See also:
insertColumns(), removeRows(), beginInsertRows(), endInsertRows()

Reimplemented from Wt::WAbstractItemModel.

bool Wt::WStringListModel::removeRows ( int  row,
int  count,
const WModelIndex parent = WModelIndex() 
) [virtual]

Remove rows.

Returns true if the operation was successful.

The default implementation returns false. If you reimplement this method, then you must call beginRemoveRows() and endRemoveRows() before and after the operation.

See also:
removeColumns(), insertRows(), beginRemoveRows(), endRemoveRows()

Reimplemented from Wt::WAbstractItemModel.

void Wt::WStringListModel::sort ( int  column,
SortOrder  order = AscendingOrder 
) [virtual]

Sort 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

Reimplemented from Wt::WAbstractItemModel.


Generated on Fri Apr 24 16:26:00 2009 for Wt by doxygen 1.5.6