| 340 | } |
| 341 | |
| 342 | bool CFavoriteModel::AddNode(const QString& szName, int parentId) |
| 343 | { |
| 344 | if(!m_pDatabase || !m_Folders.contains(parentId)) return false; |
| 345 | |
| 346 | int id = m_pDatabase->AddNode(szName, parentId); |
| 347 | |
| 348 | auto item = m_pDatabase->GetGroup(id); |
| 349 | auto parent = GetTree(parentId); |
| 350 | if(!parent) return false; |
| 351 | |
| 352 | auto t = new tree(); |
| 353 | if(!t) return false; |
| 354 | |
| 355 | QModelIndex index = CreateIndex(parent); |
| 356 | t->item = item; |
| 357 | int pos = parent->GetInserIndex(t); |
| 358 | beginInsertRows(index, pos, pos); |
| 359 | parent->InsertChild(pos, t); |
| 360 | m_Folders[id] = t; |
| 361 | endInsertRows(); |
| 362 | emit dataChanged(index, index); |
| 363 | |
| 364 | return true; |
| 365 | } |
| 366 | |
| 367 | void CFavoriteModel::ClearTree(tree* node) |
| 368 | { |
no test coverage detected