Little optimization.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-12-17 21:01:06 +02:00
parent 949f4be2c6
commit 6ba9bb8b28

View File

@ -88,6 +88,8 @@ Q_LOGGING_CATEGORY(vMainWindow, "v.mainwindow")
#pragma warning( pop ) #pragma warning( pop )
#endif #endif
const QString autosavePrefix = QStringLiteral(".autosave");
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief MainWindow constructor. * @brief MainWindow constructor.
@ -2092,7 +2094,7 @@ bool MainWindow::Save()
bool result = SavePattern(curFile, error); bool result = SavePattern(curFile, error);
if (result) if (result)
{ {
QString autofile = curFile +".autosave"; QString autofile = curFile + autosavePrefix;
QFile file(autofile); QFile file(autofile);
file.remove(); file.remove();
} }
@ -2237,7 +2239,7 @@ void MainWindow::FileClosedCorrect()
qApp->ValentinaSettings()->SetRestoreFileList(restoreFiles); qApp->ValentinaSettings()->SetRestoreFileList(restoreFiles);
// Remove autosave file // Remove autosave file
QFile autofile(curFile +".autosave"); QFile autofile(curFile + autosavePrefix);
if (autofile.exists()) if (autofile.exists())
{ {
autofile.remove(); autofile.remove();
@ -2907,7 +2909,7 @@ void MainWindow::AutoSavePattern()
if (curFile.isEmpty() == false && this->isWindowModified() == true) if (curFile.isEmpty() == false && this->isWindowModified() == true)
{ {
QString autofile = curFile +".autosave"; QString autofile = curFile + autosavePrefix;
QString error; QString error;
SavePattern(autofile, error); SavePattern(autofile, error);
} }
@ -3636,7 +3638,7 @@ void MainWindow::ReopenFilesAfterCrash(QStringList &args)
QStringList restoreFiles; QStringList restoreFiles;
for (int i = 0; i < files.size(); ++i) for (int i = 0; i < files.size(); ++i)
{ {
QFile file(files.at(i) +".autosave"); QFile file(files.at(i) + autosavePrefix);
if (file.exists()) if (file.exists())
{ {
restoreFiles.append(files.at(i)); restoreFiles.append(files.at(i));
@ -3657,18 +3659,18 @@ void MainWindow::ReopenFilesAfterCrash(QStringList &args)
for (int i = 0; i < restoreFiles.size(); ++i) for (int i = 0; i < restoreFiles.size(); ++i)
{ {
QString error; QString error;
if (VDomDocument::SafeCopy(restoreFiles.at(i) +".autosave", restoreFiles.at(i), error)) if (VDomDocument::SafeCopy(restoreFiles.at(i) + autosavePrefix, restoreFiles.at(i), error))
{ {
QFile autoFile(restoreFiles.at(i) +".autosave"); QFile autoFile(restoreFiles.at(i) + autosavePrefix);
autoFile.remove(); autoFile.remove();
LoadPattern(restoreFiles.at(i)); LoadPattern(restoreFiles.at(i));
args.removeAll(restoreFiles.at(i));// Do not open file twice after we restore him. args.removeAll(restoreFiles.at(i));// Do not open file twice after we restore him.
} }
else else
{ {
qCDebug(vMainWindow, "Could not copy %s.autosave to %s %s", qCDebug(vMainWindow, "Could not copy %s%s to %s %s",
qUtf8Printable(restoreFiles.at(i)), qUtf8Printable(restoreFiles.at(i)), qUtf8Printable(restoreFiles.at(i)), qUtf8Printable(autosavePrefix),
qUtf8Printable(error)); qUtf8Printable(restoreFiles.at(i)), qUtf8Printable(error));
} }
} }
} }