MCPcopy Create free account
hub / github.com/KangLin/RabbitRemoteControl / DeleteNode

Method DeleteNode

Src/Database/DatabaseTree.cpp:291–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

289}
290
291bool CDatabaseNode::DeleteNode(
292 int id, std::function<bool (int)> cbDeleteLeaf, bool checkReturn)
293{
294 bool bRet = false;
295 // 删除子目录
296 auto folders = GetSubNodes(id);
297 foreach(auto f, folders) {
298 bRet = DeleteNode(f.GetId(), cbDeleteLeaf, checkReturn);
299 if(checkReturn && !bRet)
300 return false;
301 }
302
303 // 删除其下面的所有条目
304 if(cbDeleteLeaf) {
305 bRet = cbDeleteLeaf(id);
306 if(checkReturn && !bRet) {
307 SetError("Failed to call cbDeleteLeaf");
308 qCritical(log) << GetError();
309 return false;
310 }
311 }
312
313 bRet = OnDeleteLeafs(id);
314 if(checkReturn && !bRet) {
315 SetError("Failed to call OnDeleteLeafs");
316 qCritical(log) << GetError();
317 return false;
318 }
319
320 // 删除文件夹
321 QSqlQuery query(GetDatabase());
322 query.prepare("DELETE FROM `" + m_szTableName + "` WHERE `id` = :id");
323 query.bindValue(":id", id);
324 bRet = query.exec();
325 if (bRet)
326 emit sigChanged();
327 else {
328 SetError("Failed to delete folders: " + query.lastError().text()
329 + "; Sql: " + query.executedQuery());
330 qCritical(log) << GetError();
331 }
332
333 return bRet;
334}
335
336bool CDatabaseNode::OnDeleteLeafs(int id)
337{

Callers 2

removeRowsMethod · 0.80
deleteFolderMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected