本文整理汇总了C++中app::Document::signalSaveDocument方法的典型用法代码示例。如果您正苦于以下问题:C++ Document::signalSaveDocument方法的具体用法?C++ Document::signalSaveDocument怎么用?C++ Document::signalSaveDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app::Document
的用法示例。
在下文中一共展示了Document::signalSaveDocument方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveDocument
void AutoSaver::saveDocument(const std::string& name, AutoSaveProperty& saver)
{
Gui::WaitCursor wc;
App::Document* doc = App::GetApplication().getDocument(name.c_str());
if (doc) {
// Set the document's current transient directory
std::string dirName = doc->TransientDir.getValue();
dirName += "/fc_recovery_files";
saver.dirName = dirName;
// Write recovery meta file
QFile file(QString::fromLatin1("%1/fc_recovery_file.xml")
.arg(QString::fromUtf8(doc->TransientDir.getValue())));
if (file.open(QFile::WriteOnly)) {
QTextStream str(&file);
str.setCodec("UTF-8");
str << "<?xml version='1.0' encoding='utf-8'?>" << endl
<< "<AutoRecovery SchemaVersion=\"1\">" << endl;
str << " <Status>Created</Status>" << endl;
str << " <Label>" << QString::fromUtf8(doc->Label.getValue()) << "</Label>" << endl; // store the document's current label
str << " <FileName>" << QString::fromUtf8(doc->FileName.getValue()) << "</FileName>" << endl; // store the document's current filename
str << "</AutoRecovery>" << endl;
file.close();
}
// make sure to tmp. disable saving thumbnails because this causes trouble if the
// associated 3d view is not active
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetParameterGroupByPath
("User parameter:BaseApp/Preferences/Document");
bool save = hGrp->GetBool("SaveThumbnail",false);
hGrp->SetBool("SaveThumbnail",false);
getMainWindow()->showMessage(tr("Please wait until the AutoRecovery file has been saved..."), 5000);
//qApp->processEvents();
// open extra scope to close ZipWriter properly
Base::StopWatch watch;
watch.start();
{
if (!this->compressed) {
RecoveryWriter writer(saver);
if (hGrp->GetBool("SaveBinaryBrep", true))
writer.setMode("BinaryBrep");
writer.putNextEntry("Document.xml");
doc->Save(writer);
// Special handling for Gui document.
doc->signalSaveDocument(writer);
// write additional files
writer.writeFiles();
}
else {
std::string fn = doc->TransientDir.getValue();
fn += "/fc_recovery_file.fcstd";
Base::FileInfo tmp(fn);
Base::ofstream file(tmp, std::ios::out | std::ios::binary);
if (file.is_open())
{
Base::ZipWriter writer(file);
if (hGrp->GetBool("SaveBinaryBrep", true))
writer.setMode("BinaryBrep");
writer.setComment("AutoRecovery file");
writer.setLevel(1); // apparently the fastest compression
writer.putNextEntry("Document.xml");
doc->Save(writer);
// Special handling for Gui document.
doc->signalSaveDocument(writer);
// write additional files
writer.writeFiles();
}
}
}
std::string str = watch.toString(watch.elapsed());
Base::Console().Log("Save AutoRecovery file: %s\n", str.c_str());
hGrp->SetBool("SaveThumbnail",save);
}
}