• QSListModel
  • QSListModel Class

    Header: #include <QSListModel>
    Inherits: QSPatchable and

    Properties

    Public Functions

    QSListModel(QObject * parent = 0)
    int count() const
    QVariant data(const QModelIndex & index, int role) const
    QHash<int, QByteArray> roleNames() const
    int rowCount(const QModelIndex & parent) const
    void setRoleNames(const QVariantMap & value)
    void setRoleNames(const QStringList & list)
    void setStorage(const QVariantList & value)
    QVariantList storage() const

    Reimplemented Public Functions

    virtual void insert(int index, const QVariantList & value)

    Public Slots

    void append(const QVariantMap & value)
    void clear()
    QVariantMap get(int i) const
    int indexOf(QString field, QVariant value) const
    void insert(int index, const QVariantMap & value)
    virtual void move(int from, int to, int n = 1)
    virtual void remove(int i, int count = 1)
    virtual void set(int index, QVariantMap data)
    void setProperty(int idx, QString property, QVariant value)

    Signals

    void countChanged()

    Detailed Description

    QSListModel is an implementation of QAbstactItemModel. It stores data in a list of QVariantMap. Moreover, it has implemented the QSPatchable interface. You may use QSDiffRunner to patch QSListModel, and it will emit insert, remove, move and data changed signals according to the patch applied.

    Property Documentation

    count : const int

    No. of items in this list model.

    Access functions:

    int count() const

    Notifier signal:

    void countChanged()

    Member Function Documentation

    QSListModel::QSListModel(QObject * parent = 0)

    [slot] void QSListModel::append(const QVariantMap & value)

    Append an items at the end of list

    [slot] void QSListModel::clear()

    Clear the content of list model.

    QVariant QSListModel::data(const QModelIndex & index, int role) const

    Returns the data stored under the given role for the item referred to by the index.

    Note: If you do not have a value to return, return an invalid QVariant instead of returning 0.

    [slot] QVariantMap QSListModel::get(int i) const

    Returns the item at index in the list model.

    [slot] int QSListModel::indexOf(QString field, QVariant value) const

    Returns the index position of the first occurrence of the item with field equal to value

    [virtual] void QSListModel::insert(int index, const QVariantList & value)

    Reimplemented from QSPatchable::insert().

    Returns the index position of the first occurrence of the byte array ba in this byte array,

    [slot] void QSListModel::insert(int index, const QVariantMap & value)

    Inserts an item at index position.

    [virtual slot] void QSListModel::move(int from, int to, int n = 1)

    Reimplemented from QSPatchable::move().

    Moves n items from one position to another.

    [virtual slot] void QSListModel::remove(int i, int count = 1)

    Reimplemented from QSPatchable::remove().

    Deletes the content at index from the model. You may specific the no. of items to be removed by count argument.

    QHash<int, QByteArray> QSListModel::roleNames() const

    Returns the model's role names.

    See also setRoleNames().

    int QSListModel::rowCount(const QModelIndex & parent) const

    Returns no. of items in this list model

    [virtual slot] void QSListModel::set(int index, QVariantMap data)

    [slot] void QSListModel::setProperty(int idx, QString property, QVariant value)

    Apply the changes to a record at index. Only modified value will be set.

    void QSListModel::setRoleNames(const QVariantMap & value)

    Sets the model's role names to roleNames.

    This function allows mapping of role identifiers to role property names in scripting languages.

    See also roleNames().

    void QSListModel::setRoleNames(const QStringList & list)

    Sets the model's role names to roleNames.

    This function allows mapping of role identifiers to role property names in scripting languages.

    void QSListModel::setStorage(const QVariantList & value)

    Replace the content of this list model by input value.

    See also storage().

    QVariantList QSListModel::storage() const

    Get the content ot this list model

    See also setStorage().