MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / updatePaths

Method updatePaths

src/Mod/Material/App/MaterialLibrary.cpp:263–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

261}
262
263void MaterialLibraryLocal::updatePaths(const QString& oldPath, const QString& newPath)
264{
265 // Update the path map
266 QString op = getRelativePath(oldPath);
267 QString np = getRelativePath(newPath);
268 std::unique_ptr<std::map<QString, std::shared_ptr<Material>>> pathMap =
269 std::make_unique<std::map<QString, std::shared_ptr<Material>>>();
270 for (auto& itp : *_materialPathMap) {
271 QString path = itp.first;
272 if (path.startsWith(op)) {
273 path = np + path.remove(0, op.size());
274 }
275 itp.second->setDirectory(path);
276 (*pathMap)[path] = itp.second;
277 }
278
279 _materialPathMap = std::move(pathMap);
280}
281
282std::shared_ptr<Material>
283MaterialLibraryLocal::saveMaterial(const std::shared_ptr<Material>& material,

Callers

nothing calls this directly

Calls 5

startsWithMethod · 0.80
moveFunction · 0.50
removeMethod · 0.45
sizeMethod · 0.45
setDirectoryMethod · 0.45

Tested by

no test coverage detected