MCPcopy Create free account
hub / github.com/KDE/kdevelop / removeRows

Method removeRows

kdevplatform/project/projectmodel.cpp:220–260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

218}
219
220void ProjectBaseItem::removeRows(int row, int count)
221{
222 if (!count) {
223 return;
224 }
225
226 Q_D(ProjectBaseItem);
227 Q_ASSERT(row >= 0 && row + count <= d->children.size());
228
229 if( model() ) {
230 model()->beginRemoveRows(index(), row, row + count - 1);
231 }
232
233 //NOTE: we unset parent, row and model manually to speed up the deletion
234 if (row == 0 && count == d->children.size()) {
235 // optimize if we want to delete all
236 for (ProjectBaseItem* item : std::as_const(d->children)) {
237 item->d_func()->parent = nullptr;
238 item->d_func()->row = -1;
239 item->setModel( nullptr );
240 delete item;
241 }
242 d->children.clear();
243 } else {
244 for (int i = row; i < count; ++i) {
245 ProjectBaseItem* item = d->children.at(i);
246 item->d_func()->parent = nullptr;
247 item->d_func()->row = -1;
248 item->setModel( nullptr );
249 delete d->children.takeAt( row );
250 }
251 for(int i = row; i < d->children.size(); ++i) {
252 d->children.at(i)->d_func()->row--;
253 Q_ASSERT(child(i)->d_func()->row==i);
254 }
255 }
256
257 if( model() ) {
258 model()->endRemoveRows();
259 }
260}
261
262QModelIndex ProjectBaseItem::index() const
263{

Callers 4

deleteButtonPressedMethod · 0.45
clearMethod · 0.45
eventViewClickedMethod · 0.45

Calls 8

modelFunction · 0.85
childFunction · 0.85
d_funcMethod · 0.80
indexFunction · 0.50
sizeMethod · 0.45
setModelMethod · 0.45
clearMethod · 0.45
atMethod · 0.45

Tested by 1