16 : QAbstractListModel(pobj)
24 if (!index.isValid()) {
30 return (nRole == Qt::DisplayRole || nRole == Qt::EditRole)
31 ? m_list.at(index.row())
37 const QVariant& value,
41 if (index.isValid() && nRole == Qt::EditRole) {
42 m_list.replace(index.row(), value.value<
int>());
43 emit dataChanged(index, index);
53 if (parent.isValid()) {
62 Qt::Orientation orientation,
66 if (nRole != Qt::DisplayRole) {
69 return (orientation == Qt::Horizontal) ? QString(
"Number")
70 : QString::number(nSection);
76 Qt::ItemFlags
flags = QAbstractListModel::flags(index);
77 return index.isValid() ? (
flags | Qt::ItemIsEditable)
84 const QModelIndex& parent
87 if (parent.isValid()) {
91 beginInsertRows(QModelIndex(), nRow, nRow + nCount - 1);
92 for (
int i = 0; i < nCount; ++i) {
93 m_list.insert(nRow, 0);
103 const QModelIndex& parent
106 if (parent.isValid()) {
110 beginRemoveRows(QModelIndex(), nRow, nRow + nCount - 1);
111 for (
int i = 0; i < nCount; ++i) {
112 m_list.removeAt(nRow);
Qt::ItemFlags flags(const QModelIndex &index) const
bool insertRows(int nRow, int nCount, const QModelIndex &parent=QModelIndex())
bool setData(const QModelIndex &index, const QVariant &value, int nRole)
QVariant data(const QModelIndex &index, int nRole) const
IntListModel(const QList< int > &list, QObject *pobj=0)
bool removeRows(int nRow, int nCount, const QModelIndex &parent=QModelIndex())
QVariant headerData(int nSection, Qt::Orientation orientation, int nRole=Qt::DisplayRole) const
int rowCount(const QModelIndex &parent=QModelIndex()) const