Changeset View
Changeset View
Standalone View
Standalone View
tests/test_tree_rust.cpp
Show First 20 Lines • Show All 157 Lines • ▼ Show 20 Line(s) | 155 | { | |||
---|---|---|---|---|---|
158 | return s; | 158 | return s; | ||
159 | } | 159 | } | ||
160 | 160 | | |||
161 | bool Persons::setUserName(const QModelIndex& index, const QString& value) | 161 | bool Persons::setUserName(const QModelIndex& index, const QString& value) | ||
162 | { | 162 | { | ||
163 | bool set = false; | 163 | bool set = false; | ||
164 | set = persons_set_data_user_name(m_d, index.internalId(), value.utf16(), value.length()); | 164 | set = persons_set_data_user_name(m_d, index.internalId(), value.utf16(), value.length()); | ||
165 | if (set) { | 165 | if (set) { | ||
166 | emit dataChanged(index, index); | 166 | Q_EMIT dataChanged(index, index); | ||
167 | } | 167 | } | ||
168 | return set; | 168 | return set; | ||
169 | } | 169 | } | ||
170 | 170 | | |||
171 | QVariant Persons::data(const QModelIndex &index, int role) const | 171 | QVariant Persons::data(const QModelIndex &index, int role) const | ||
172 | { | 172 | { | ||
173 | Q_ASSERT(rowCount(index.parent()) > index.row()); | 173 | Q_ASSERT(rowCount(index.parent()) > index.row()); | ||
174 | switch (index.column()) { | 174 | switch (index.column()) { | ||
▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Line(s) | |||||
255 | } | 255 | } | ||
256 | 256 | | |||
257 | Persons::Persons(QObject *parent): | 257 | Persons::Persons(QObject *parent): | ||
258 | QAbstractItemModel(parent), | 258 | QAbstractItemModel(parent), | ||
259 | m_d(persons_new(this, | 259 | m_d(persons_new(this, | ||
260 | [](const Persons* o, option_quintptr id) { | 260 | [](const Persons* o, option_quintptr id) { | ||
261 | if (id.some) { | 261 | if (id.some) { | ||
262 | int row = persons_row(o->m_d, id.value); | 262 | int row = persons_row(o->m_d, id.value); | ||
263 | emit o->newDataReady(o->createIndex(row, 0, id.value)); | 263 | Q_EMIT o->newDataReady(o->createIndex(row, 0, id.value)); | ||
264 | } else { | 264 | } else { | ||
265 | emit o->newDataReady(QModelIndex()); | 265 | Q_EMIT o->newDataReady(QModelIndex()); | ||
266 | } | 266 | } | ||
267 | }, | 267 | }, | ||
268 | [](Persons* o) { | 268 | [](Persons* o) { | ||
269 | emit o->layoutAboutToBeChanged(); | 269 | Q_EMIT o->layoutAboutToBeChanged(); | ||
270 | }, | 270 | }, | ||
271 | [](Persons* o) { | 271 | [](Persons* o) { | ||
272 | o->updatePersistentIndexes(); | 272 | o->updatePersistentIndexes(); | ||
273 | emit o->layoutChanged(); | 273 | Q_EMIT o->layoutChanged(); | ||
274 | }, | 274 | }, | ||
275 | [](Persons* o, quintptr first, quintptr last) { | 275 | [](Persons* o, quintptr first, quintptr last) { | ||
276 | quintptr frow = persons_row(o->m_d, first); | 276 | quintptr frow = persons_row(o->m_d, first); | ||
277 | quintptr lrow = persons_row(o->m_d, first); | 277 | quintptr lrow = persons_row(o->m_d, first); | ||
278 | o->dataChanged(o->createIndex(frow, 0, first), | 278 | o->dataChanged(o->createIndex(frow, 0, first), | ||
279 | o->createIndex(lrow, 0, last)); | 279 | o->createIndex(lrow, 0, last)); | ||
280 | }, | 280 | }, | ||
281 | [](Persons* o) { | 281 | [](Persons* o) { | ||
▲ Show 20 Lines • Show All 60 Lines • Show Last 20 Lines |