| 1435 | } |
| 1436 | |
| 1437 | QModelIndex UBDocumentTreeModel::addNode(UBDocumentTreeNode *pFreeNode, const QModelIndex &pParent, eAddItemMode pMode) |
| 1438 | { |
| 1439 | UBDocumentTreeNode *tstParent = nodeFromIndex(pParent); |
| 1440 | |
| 1441 | if (!pParent.isValid() || tstParent->nodeType() != UBDocumentTreeNode::Catalog) { |
| 1442 | return QModelIndex(); |
| 1443 | } |
| 1444 | int newIndex = pMode == aDetectPosition ? positionForParent(pFreeNode, tstParent): tstParent->children().size(); |
| 1445 | beginInsertRows(pParent, newIndex, newIndex); |
| 1446 | tstParent->insertChild(newIndex, pFreeNode); |
| 1447 | endInsertRows(); |
| 1448 | |
| 1449 | return createIndex(newIndex, 0, pFreeNode); |
| 1450 | } |
| 1451 | |
| 1452 | int UBDocumentTreeModel::positionForParent(UBDocumentTreeNode *pFreeNode, UBDocumentTreeNode *pParentNode) |
| 1453 | { |
no test coverage detected