+ issue #0000175: Auto save function
This commit is contained in:
parent
9cb63295e9
commit
16f813281c
|
@ -109,6 +109,7 @@ void AutoSaver::saveDocument(const std::string& name)
|
||||||
<< "<AutoRecovery SchemaVersion=\"1\">" << endl;
|
<< "<AutoRecovery SchemaVersion=\"1\">" << endl;
|
||||||
str << " <Status>Created</Status>" << endl;
|
str << " <Status>Created</Status>" << endl;
|
||||||
str << " <Label>" << doc->Label.getValue() << "</Label>" << endl; // store the document's current label
|
str << " <Label>" << doc->Label.getValue() << "</Label>" << endl; // store the document's current label
|
||||||
|
str << " <FileName>" << doc->FileName.getValue() << "</FileName>" << endl; // store the document's current filename
|
||||||
str << "</AutoRecovery>" << endl;
|
str << "</AutoRecovery>" << endl;
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,6 +200,22 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
|
<widget class="Gui::PrefCheckBox" name="prefRecovery">
|
||||||
|
<property name="text">
|
||||||
|
<string>Run AutoRecovery at startup</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="prefEntry" stdset="0">
|
||||||
|
<cstring>RecoveryEnabled</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="prefPath" stdset="0">
|
||||||
|
<cstring>Document</cstring>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="Gui::PrefCheckBox" name="prefAutoSaveEnabled">
|
<widget class="Gui::PrefCheckBox" name="prefAutoSaveEnabled">
|
||||||
|
@ -244,7 +260,7 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="4" column="0">
|
||||||
<widget class="Line" name="line1_2_3">
|
<widget class="Line" name="line1_2_3">
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::HLine</enum>
|
<enum>QFrame::HLine</enum>
|
||||||
|
@ -257,7 +273,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0">
|
<item row="5" column="0">
|
||||||
<widget class="Gui::PrefCheckBox" name="prefSaveThumbnail">
|
<widget class="Gui::PrefCheckBox" name="prefSaveThumbnail">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Save thumbnail into project file when saving document</string>
|
<string>Save thumbnail into project file when saving document</string>
|
||||||
|
@ -270,7 +286,7 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="6" column="0">
|
||||||
<layout class="QHBoxLayout">
|
<layout class="QHBoxLayout">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
|
|
|
@ -77,6 +77,7 @@ void DlgSettingsDocumentImp::saveSettings()
|
||||||
prefAuthor->onSave();
|
prefAuthor->onSave();
|
||||||
prefSetAuthorOnSave->onSave();
|
prefSetAuthorOnSave->onSave();
|
||||||
prefCompany->onSave();
|
prefCompany->onSave();
|
||||||
|
prefRecovery->onSave();
|
||||||
prefAutoSaveEnabled->onSave();
|
prefAutoSaveEnabled->onSave();
|
||||||
prefAutoSaveTimeout->onSave();
|
prefAutoSaveTimeout->onSave();
|
||||||
|
|
||||||
|
@ -104,6 +105,7 @@ void DlgSettingsDocumentImp::loadSettings()
|
||||||
prefAuthor->onRestore();
|
prefAuthor->onRestore();
|
||||||
prefSetAuthorOnSave->onRestore();
|
prefSetAuthorOnSave->onRestore();
|
||||||
prefCompany->onRestore();
|
prefCompany->onRestore();
|
||||||
|
prefRecovery->onRestore();
|
||||||
prefAutoSaveEnabled->onRestore();
|
prefAutoSaveEnabled->onRestore();
|
||||||
prefAutoSaveTimeout->onRestore();
|
prefAutoSaveTimeout->onRestore();
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,6 +75,7 @@ public:
|
||||||
QString projectFile;
|
QString projectFile;
|
||||||
QString xmlFile;
|
QString xmlFile;
|
||||||
QString label;
|
QString label;
|
||||||
|
QString fileName;
|
||||||
QString tooltip;
|
QString tooltip;
|
||||||
Status status;
|
Status status;
|
||||||
};
|
};
|
||||||
|
@ -154,7 +155,8 @@ void DocumentRecovery::accept()
|
||||||
// If something goes wrong an exception will be thrown here
|
// If something goes wrong an exception will be thrown here
|
||||||
document->restore();
|
document->restore();
|
||||||
|
|
||||||
document->FileName.setValue(std::string());
|
file = it->fileName;
|
||||||
|
document->FileName.setValue(file.toUtf8().constData());
|
||||||
document->Label.setValue(it->label.toUtf8().constData());
|
document->Label.setValue(it->label.toUtf8().constData());
|
||||||
|
|
||||||
// Set the modified flag so that the user cannot close by accident
|
// Set the modified flag so that the user cannot close by accident
|
||||||
|
@ -233,6 +235,7 @@ void DocumentRecoveryPrivate::writeRecoveryInfo(const DocumentRecoveryPrivate::I
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
str << " <Label>" << info.label << "</Label>" << endl;
|
str << " <Label>" << info.label << "</Label>" << endl;
|
||||||
|
str << " <FileName>" << info.fileName << "</FileName>" << endl;
|
||||||
str << "</AutoRecovery>" << endl;
|
str << "</AutoRecovery>" << endl;
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
@ -260,6 +263,10 @@ DocumentRecoveryPrivate::Info DocumentRecoveryPrivate::getRecoveryInfo(const QFi
|
||||||
info.label = cfg[QString::fromLatin1("Label")];
|
info.label = cfg[QString::fromLatin1("Label")];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cfg.contains(QString::fromLatin1("FileName"))) {
|
||||||
|
info.fileName = cfg[QString::fromLatin1("FileName")];
|
||||||
|
}
|
||||||
|
|
||||||
if (cfg.contains(QString::fromLatin1("Status"))) {
|
if (cfg.contains(QString::fromLatin1("Status"))) {
|
||||||
QString status = cfg[QString::fromLatin1("Status")];
|
QString status = cfg[QString::fromLatin1("Status")];
|
||||||
if (status == QLatin1String("Success"))
|
if (status == QLatin1String("Success"))
|
||||||
|
@ -299,6 +306,7 @@ DocumentRecoveryPrivate::XmlConfig DocumentRecoveryPrivate::readXmlFile(const QS
|
||||||
|
|
||||||
QVector<QString> filter;
|
QVector<QString> filter;
|
||||||
filter << QString::fromLatin1("Label");
|
filter << QString::fromLatin1("Label");
|
||||||
|
filter << QString::fromLatin1("FileName");
|
||||||
filter << QString::fromLatin1("Status");
|
filter << QString::fromLatin1("Status");
|
||||||
|
|
||||||
QDomElement child;
|
QDomElement child;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user