| 34 | } |
| 35 | |
| 36 | void TreeItem::appendChild(TreeItem *item, bool initial) |
| 37 | { |
| 38 | QModelIndex index = model_->indexForItem(this, 0); |
| 39 | |
| 40 | // Note that we need emit beginRemoveRows, even if we're replacing |
| 41 | // ellipsis item with the real one. The number of rows does not change |
| 42 | // with the result, but the last item is different. The address of the |
| 43 | // item is stored inside QModelIndex, so just replacing the item, and |
| 44 | // deleting the old one, will lead to crash. |
| 45 | if (more_) |
| 46 | { |
| 47 | if (!initial) |
| 48 | model_->beginRemoveRows(index, childItems.size(), childItems.size()); |
| 49 | more_ = false; |
| 50 | delete ellipsis_; |
| 51 | ellipsis_ = nullptr; |
| 52 | if (!initial) |
| 53 | model_->endRemoveRows(); |
| 54 | } |
| 55 | |
| 56 | if (!initial) |
| 57 | model_->beginInsertRows(index, childItems.size(), childItems.size()); |
| 58 | childItems.append(item); |
| 59 | if (!initial) |
| 60 | model_->endInsertRows(); |
| 61 | } |
| 62 | |
| 63 | void TreeItem::insertChild(int position, TreeItem *child, bool initial) |
| 64 | { |
nothing calls this directly
no test coverage detected