| 40 | } |
| 41 | |
| 42 | void Model::addFile(FileInterface* file) |
| 43 | { |
| 44 | if (!file) |
| 45 | return; |
| 46 | |
| 47 | const int type = int(file->type()); |
| 48 | |
| 49 | if (mapNode.find(type) == mapNode.end()) { |
| 50 | QModelIndex index = createIndex(0, 0, rootItem); |
| 51 | int rowCount = rootItem->childCount(); |
| 52 | beginInsertRows(index, rowCount, rowCount); |
| 53 | mapNode.emplace(type, Pair { nullptr, type }); |
| 54 | rootItem->addChild(mapNode[type].node = new FolderNode(App::filePlugin(type)->folderName(), new int(mapNode[type].type))); |
| 55 | endInsertRows(); |
| 56 | } |
| 57 | |
| 58 | Node* item(mapNode[type].node); |
| 59 | QModelIndex index = createIndex(0, 0, item); |
| 60 | int rowCount = item->childCount(); |
| 61 | beginInsertRows(index, rowCount, rowCount); |
| 62 | mapNode[type].node->addChild(file->node()); |
| 63 | endInsertRows(); |
| 64 | |
| 65 | App::filePlugin(type)->updateFileModel(file); |
| 66 | emit select(createIndex(rowCount, 0, file->node())); |
| 67 | } |
| 68 | |
| 69 | void Model::addShape(ShapeInterface* shape) |
| 70 | { |
nothing calls this directly
no test coverage detected