5
6
7
8
13
14
15
20 return stringList.count();
30
31
32
33
34
37QVariant StringListModel::data(
const QModelIndex &index,
int role)
const
42 if (index.row() >= stringList.size())
45 if (role == Qt::DisplayRole)
46 return stringList.at(index.row());
55
56
57
58
59
67 if (index.row() >= stringList.size())
70 if (role == Qt::DisplayRole || role == Qt::EditRole)
71 return stringList.at(index.row());
78
79
80
81
87 if (role != Qt::DisplayRole)
90 if (orientation == Qt::Horizontal)
91 return QStringLiteral(
"Column %1").arg(section);
93 return QStringLiteral(
"Row %1").arg(section);
98
99
100
105 if (!index.isValid())
106 return Qt::ItemIsEnabled;
108 return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
113
114
115
116
117
118
119
120
121
125 const QVariant &value,
int role)
127 if (index.isValid() && role == Qt::EditRole) {
129 stringList.replace(index.row(), value.toString());
130 emit dataChanged(index, index, {role});
139
140
145 beginInsertRows(QModelIndex(), position, position+rows-1);
147 for (
int row = 0; row < rows; ++row) {
148 stringList.insert(position,
"");
158
159
164 beginRemoveRows(QModelIndex(), position, position+rows-1);
166 for (
int row = 0; row < rows; ++row) {
167 stringList.removeAt(position);
bool insertRows(int position, int rows, const QModelIndex &index=QModelIndex()) override
[3]
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
[3]
QVariant data(const QModelIndex &index, int role) const override
[0]
Qt::ItemFlags flags(const QModelIndex &index) const override
[1]
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
[1]
bool removeRows(int position, int rows, const QModelIndex &index=QModelIndex()) override
[7]