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

Method Move

App/Client/Favorite/FavoriteModel.cpp:272–298  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

270}
271
272bool 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!!!
301bool CFavoriteModel::Copy(QModelIndex index, QModelIndex parentIndex)

Callers 2

foreachFunction · 0.45
AddFavoriteMethod · 0.45

Calls 5

isValidMethod · 0.80
isFavoriteMethod · 0.80
FindRecursiveMethod · 0.80
MoveNodeMethod · 0.80
isEmptyMethod · 0.45

Tested by

no test coverage detected