Public Member Functions

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)
 Creates a new empty string list model.
 WStringListModel (const std::vector< WString > &strings, WObject *parent=0)
 Creates a new string list model.
 ~WStringListModel ()
 Destructor.
void setStringList (const std::vector< WString > &strings)
 Sets a new string list.
void insertString (int row, const WString &string)
 Inserts a string.
void addString (const WString &string)
 Adds a string.
const std::vector< WString > & stringList () const
 Returns the string list.
virtual WFlags< ItemFlagflags (const WModelIndex &index) const
 Returns the flags for an item.
virtual bool setData (const WModelIndex &index, const boost::any &value, int role=EditRole)
 Sets 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())
 Inserts one or more rows.
virtual bool removeRows (int row, int count, const WModelIndex &parent=WModelIndex())
 Removes rows.
virtual void sort (int column, SortOrder order=AscendingOrder)
 Sorts 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::addString ( const WString string )

Adds a string.

See also:
setStringList()
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.

WFlags< ItemFlag > 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::insertRows ( int  row,
int  count,
const WModelIndex parent = WModelIndex() 
) [virtual]

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(), removeRows(), beginInsertRows(), endInsertRows()

Reimplemented from Wt::WAbstractItemModel.

void Wt::WStringListModel::insertString ( int  row,
const WString string 
)

Inserts a string.

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

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(), insertRows(), beginRemoveRows(), endRemoveRows()

Reimplemented from 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::setData ( const WModelIndex index,
const boost::any &  value,
int  role = EditRole 
) [virtual]

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:
data()

Reimplemented from Wt::WAbstractItemModel.

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

Sets a new string list.

Replaces the current string list with a new list.

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

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()

Reimplemented from Wt::WAbstractItemModel.

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

Returns the string list.

See also:
setStringList()
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator

Generated on Fri Feb 4 2011 for the C++ Web Toolkit (Wt) by doxygen 1.7.2