MCPcopy Create free account
hub / github.com/OpenBoard-org/OpenBoard / deleteIndexAndAssociatedData

Method deleteIndexAndAssociatedData

src/document/UBDocumentController.cpp:3122–3167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3120}
3121
3122void UBDocumentController::deleteIndexAndAssociatedData(const QModelIndex &pIndex)
3123{
3124 UBDocumentTreeModel *docModel = UBPersistenceManager::persistenceManager()->mDocumentTreeStructureModel;
3125 while (docModel->rowCount(pIndex)) {
3126 QModelIndex subIndex = docModel->index(0, 0, pIndex);
3127 deleteIndexAndAssociatedData(subIndex);
3128 }
3129
3130 //N/C - NNE - 20140408
3131 std::shared_ptr<UBDocumentProxy> proxyData = nullptr;
3132 if(pIndex.column() == 0)
3133 {
3134 if (docModel->isDocument(pIndex)) {
3135 proxyData = docModel->proxyData(pIndex);
3136
3137 if (selectedDocument() == proxyData)
3138 {
3139 setDocument(nullptr);
3140 }
3141
3142 if (proxyData) {
3143 UBPersistenceManager::persistenceManager()->deleteDocument(proxyData);
3144 }
3145 }
3146 }
3147
3148 if (proxyData)
3149 {
3150 // need to recall indexForProxy as rows could have changed when performing a multiple deletion
3151 QModelIndex indexForProxy = docModel->indexForProxy(proxyData);
3152 if (!docModel->removeRow(indexForProxy.row(), indexForProxy.parent()))
3153 {
3154 qDebug() << "could not remove row (r:" << indexForProxy.row() << "p:" << indexForProxy.parent() << ")";
3155 }
3156 }
3157 else
3158 {
3159 if (docModel->isCatalog(pIndex))
3160 {
3161 if (!docModel->removeRow(pIndex.row(), pIndex.parent()))
3162 {
3163 qDebug() << "could not remove row (r:" << pIndex.row() << "p:" << pIndex.parent() << ")";
3164 }
3165 }
3166 }
3167}
3168
3169
3170void UBDocumentController::exportDocument()

Callers

nothing calls this directly

Calls 11

columnMethod · 0.80
isDocumentMethod · 0.80
deleteDocumentMethod · 0.80
indexForProxyMethod · 0.80
removeRowMethod · 0.80
rowMethod · 0.80
isCatalogMethod · 0.80
rowCountMethod · 0.45
indexMethod · 0.45
proxyDataMethod · 0.45
parentMethod · 0.45

Tested by

no test coverage detected