MCPcopy Create free account
hub / github.com/codestation/qcma / updateObjectPath

Method updateObjectPath

common/sqlitedb.cpp:1042–1096  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1040}
1041
1042bool SQLiteDB::updateObjectPath(int ohfi, const QString &name)
1043{
1044 int parent_ohfi = getParentId(ohfi);
1045 QString parent_path, file;
1046
1047 if(name.isNull()) {
1048 QSqlQuery name_query("SELECT title FROM object_node WHERE object_id = :object_id");
1049 name_query.bindValue(0, ohfi);
1050 if(!name_query.exec() || !name_query.next()) {
1051 return false;
1052 }
1053 file = name_query.value(0).toString();
1054 } else {
1055 file = name;
1056 }
1057
1058 if(parent_ohfi >= OHFI_BASE_VALUE) {
1059 parent_path = getRelativePath(parent_ohfi);
1060 if(parent_path.isNull()) {
1061 parent_path = file;
1062 } else {
1063 parent_path += "/" + file;
1064 }
1065 } else {
1066 parent_path = file;
1067 }
1068
1069 QSqlQuery query("UPDATE sources SET path = :path WHERE object_id = :object_id");
1070 query.bindValue(0, parent_path);
1071 query.bindValue(1, ohfi);
1072
1073 if(!query.exec()) {
1074 return false;
1075 }
1076
1077 DataType type = (DataType)getObjectType(ohfi);
1078
1079 if(type & Folder) {
1080 QSqlQuery child_query("SELECT child_id, data_type FROM adjacent_objects "
1081 "JOIN object_node ON object_id = child_id"
1082 "WHERE parent_id = :parent_id");
1083 child_query.bindValue(0, ohfi);
1084
1085 if(query.exec()) {
1086 while(query.next()) {
1087 int child_ohfi = query.value(0).toInt();
1088 if(!updateObjectPath(child_ohfi, NULL)) {
1089 return false;
1090 }
1091 }
1092 }
1093 }
1094
1095 return true;
1096}
1097
1098bool SQLiteDB::renameObject(int ohfi, const QString &name)
1099{

Callers

nothing calls this directly

Calls 1

valueMethod · 0.80

Tested by

no test coverage detected