| 398 | } |
| 399 | |
| 400 | void ProjectBaseItem::appendRow( ProjectBaseItem* item ) |
| 401 | { |
| 402 | Q_D(ProjectBaseItem); |
| 403 | if( !item ) { |
| 404 | return; |
| 405 | } |
| 406 | if( item->parent() ) { |
| 407 | // Proper way is to first removeRow() on the original parent, then appendRow on this one |
| 408 | qCWarning(PROJECT) << "Ignoring double insertion of item" << item; |
| 409 | return; |
| 410 | } |
| 411 | // this is too slow... O(n) and thankfully not a problem anyways |
| 412 | // Q_ASSERT(!d->children.contains(item)); |
| 413 | int startrow,endrow; |
| 414 | if( model() ) { |
| 415 | startrow = endrow = d->children.count(); |
| 416 | model()->beginInsertRows(index(), startrow, endrow); |
| 417 | } |
| 418 | d->children.append( item ); |
| 419 | item->setRow( d->children.count() - 1 ); |
| 420 | item->d_func()->parent = this; |
| 421 | item->setModel( model() ); |
| 422 | if( model() ) { |
| 423 | model()->endInsertRows(); |
| 424 | } |
| 425 | } |
| 426 | |
| 427 | Path ProjectBaseItem::path() const |
| 428 | { |