| 270 | } |
| 271 | |
| 272 | bool CFavoriteModel::Move(QModelIndex index, QModelIndex parentIndex) |
| 273 | { |
| 274 | if(!index.isValid()) return false; |
| 275 | tree* ip = GetTree(index); |
| 276 | if(!ip) return false; |
| 277 | tree* ipParent = GetTree(parentIndex); |
| 278 | if(!ipParent || ipParent->item.isFavorite()) return false; |
| 279 | int nParentId = ipParent->item.id; |
| 280 | auto& item = ip->item; |
| 281 | bool bRet = false; |
| 282 | if(item.isFavorite()) |
| 283 | bRet = m_pDatabase->Move(item.id, nParentId); |
| 284 | else { |
| 285 | if(item.id != nParentId && ip->FindRecursive(ipParent->item).isEmpty()) |
| 286 | bRet = m_pDatabase->MoveNode(item.id, nParentId); |
| 287 | else { |
| 288 | if(item.id == nParentId) |
| 289 | qWarning(log) << "The same node:" << item.id; |
| 290 | else |
| 291 | qWarning(log) << "The destination node is a child node of this node." |
| 292 | << item.id << ipParent->item.id; |
| 293 | } |
| 294 | } |
| 295 | if(bRet) |
| 296 | bRet = MoveTree(ip->item, ipParent->item.id); |
| 297 | return bRet; |
| 298 | } |
| 299 | |
| 300 | // TODO: not test!!! |
| 301 | bool CFavoriteModel::Copy(QModelIndex index, QModelIndex parentIndex) |
no test coverage detected