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

Method MoveNode

Src/Database/DatabaseTree.cpp:342–372  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

340}
341
342bool CDatabaseNode::MoveNode(int id, int newParentId)
343{
344 if(id == newParentId) {
345 SetError("Failed to move node. The same node: " + id);
346 qWarning(log) << GetError();
347 return false;
348 }
349 // Check the newParentId is not the child of id
350 bool bRet = InSubNode(id, newParentId);
351 if(bRet) {
352 SetError("The id is the parent of newParentId. "
353 + QString::number(id) + " is the parent of "
354 + QString::number(newParentId));
355 qWarning(log) << GetError();
356 return false;
357 }
358 QSqlQuery query(GetDatabase());
359 query.prepare("UPDATE `" + m_szTableName + "` "
360 " SET `parent_id` = :parent_id WHERE `id` = :id");
361 query.bindValue(":id", id);
362 query.bindValue(":parent_id", newParentId);
363 bRet = query.exec();
364 if (bRet)
365 emit sigChanged();
366 else {
367 SetError("Failed to move folders: " + query.lastError().text()
368 + "; Sql: " + query.executedQuery());
369 qCritical(log) << GetError();
370 }
371 return bRet;
372}
373
374TreeItem CDatabaseNode::GetNode(int id)
375{

Callers 2

MoveMethod · 0.80
moveFolderMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected