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

Method AddTree

App/Client/Favorite/FavoriteModel.cpp:413–446  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

411}
412
413bool CFavoriteModel::AddTree(const CFavoriteDatabase::Item &item, int parentId)
414{
415 if (item.id == 0) return false;
416
417 auto parent = GetTree(parentId);
418 if(!parent) {
419 qCritical(log) << QString("m_Folders[%1] is nullptr").arg(parentId);
420 return false;
421 }
422
423 auto t = new tree(item);
424 if (!t) {
425 qCritical(log) << "Failed to allocate memory for tree node";
426 return false;
427 }
428
429 int pos = parent->GetInserIndex(t);
430
431 QModelIndex parentIndex = CreateIndex(parent);
432
433 beginInsertRows(parentIndex, pos, pos);
434
435 parent->InsertChild(pos, t);
436
437 if (item.isFolder()) {
438 m_Folders[item.id] = t;
439 }
440
441 endInsertRows();
442
443 emit dataChanged(parentIndex, parentIndex);
444
445 return true;
446}
447
448bool CFavoriteModel::UpdateTree(const QString &szFile)
449{

Callers

nothing calls this directly

Calls 3

GetInserIndexMethod · 0.80
InsertChildMethod · 0.80
isFolderMethod · 0.45

Tested by

no test coverage detected