#include <Wt/WModelIndex>
Public Member Functions | |
WModelIndex () | |
Create an invalid WModelIndex. | |
WModelIndex (const WModelIndex &other) | |
Copy constructor. | |
int | column () const |
Returns the column for this model index. | |
int | row () const |
Returns the row for this model index. | |
void * | internalPointer () const |
Returns the internal pointer. | |
uint64_t | internalId () const |
Returns the internal id. | |
Sha1::Digest | internalHashId () const |
Returns a long internal id. | |
WModelIndex | child (int row, int column) const |
Returns a model index for a child item. | |
WModelIndex | parent () const |
Returns an index to the parent. | |
boost::any | data (int role=DisplayRole) const |
Returns data in the model at this index. | |
int | flags () const |
Returns the flags for this item. | |
bool | isValid () const |
Returns whether the index is a real valid index. | |
const WAbstractItemModel * | model () const |
Returns the model to which this (valid) index is bound. | |
bool | operator== (const WModelIndex &other) const |
Comparison operator. | |
bool | operator!= (const WModelIndex &other) const |
Comparison operator. | |
bool | operator< (const WModelIndex &other) const |
Comparison operator. |
Indexes are used to indicate a particular item in a WAbstractItemModel. It points to the item at a given row and column, within a parent model index.
An index is immutable. The default constructor creates an invalid index, which by convention indicates the parent of top level indexes.
Valid indexes are created by the model, within the protected WAbstractItemModel::createIndex() methods. In this way, models can define the internal pointer or id suitable for identifying items in the model.
Upon the model's choice, model indexes for hierarchical models may have an internal Id represented by a int64_t (internalId()), a pointer (internalPointer()), or an internal hash (internalHashId()). The former are convenient for in-memory models, while the latter is useful for models that keep data out of memory (on disk or in a database).
Wt::WModelIndex::WModelIndex | ( | ) |
Create an invalid WModelIndex.
Returns a model index for which isValid() return false.
int Wt::WModelIndex::column | ( | ) | const [inline] |
int Wt::WModelIndex::row | ( | ) | const [inline] |
void* Wt::WModelIndex::internalPointer | ( | ) | const [inline] |
Returns the internal pointer.
The internal pointer is used by the model to retrieve the corresponding data.
This is only defined when the model created the index using WAbstractItemModel::createIndex(int, int, void *) const.
uint64_t Wt::WModelIndex::internalId | ( | ) | const [inline] |
Returns the internal id.
The internal id is used by the model to retrieve the corresponding data.
This is only defined when the model created the index using WAbstractItemModel::createIndex(int, int, uint64_t) const.
Sha1::Digest Wt::WModelIndex::internalHashId | ( | ) | const [inline] |
Returns a long internal id.
A long internal id (20 bytes) may be used by models that do not keep data in memory.
The 20 bytes length has been chosen to be able store SHA-1 hash ids.
WModelIndex Wt::WModelIndex::child | ( | int | row, | |
int | column | |||
) | const |
Returns a model index for a child item.
This is a convenience method, and is only defined for indexes that are valid().
It has the same function as WAbstractItemModel::index() but is less general because the latter expression may also be used to retrieve top level children, i.e. when index is invalid.
WModelIndex Wt::WModelIndex::parent | ( | ) | const |
Returns an index to the parent.
This is a convenience method for WAbstractItemModel::parent().
For a top level data item, the parent() is an invalid index (see WModelIndex()).
boost::any Wt::WModelIndex::data | ( | int | role = DisplayRole |
) | const |
Returns data in the model at this index.
This is a convenience method. It is less general than using WAbstractItemModel::data(), because the latter expression may also be used to retrieve top level children, i.e. when index is invalid.
int Wt::WModelIndex::flags | ( | ) | const |
Returns the flags for this item.
This is a convenience method for WAbstractItemModel::flags().
bool Wt::WModelIndex::isValid | ( | ) | const [inline] |
Returns whether the index is a real valid index.
Returns true when the index points to a valid data item, i.e. at a valid row() and column().
An index may be invalid for two reasons:
bool Wt::WModelIndex::operator== | ( | const WModelIndex & | other | ) | const |
Comparison operator.
Returns true only if the indexes point at the same data, in the same model.
bool Wt::WModelIndex::operator!= | ( | const WModelIndex & | other | ) | const |
bool Wt::WModelIndex::operator< | ( | const WModelIndex & | other | ) | const |
Comparison operator.
Returns true if the index comes topologically before other.