Added SaveCopy command

This command saves a copy of the current document under a new name,
without modifying the document itself.

Available in menu File -> Save a Copy or from python with
FreeCAD.ActiveDocument.saveCopy(filename)
This commit is contained in:
Yorik van Havre
2015-09-02 13:38:14 -03:00
parent 3b433256e6
commit e122ea8bf7
9 changed files with 113 additions and 2 deletions

View File

@@ -1001,6 +1001,24 @@ bool Document::saveAs(const char* file)
return save();
}
bool Document::saveCopy(const char* file)
{
std::string originalFileName = this->FileName.getStrValue();
std::string originalLabel = this->Label.getStrValue();
Base::FileInfo fi(file);
if (this->FileName.getStrValue() != file) {
this->FileName.setValue(file);
this->Label.setValue(fi.fileNamePure());
this->Uid.touch(); // this forces a rename of the transient directory
bool result = save();
this->FileName.setValue(originalFileName);
this->Label.setValue(originalLabel);
this->Uid.touch();
return result;
}
return false;
}
// Save the document under the name it has been opened
bool Document::save (void)
{