打开之前保存的恢复文件
| 5192 | |
| 5193 | //打开之前保存的恢复文件 |
| 5194 | bool CCNotePad::tryRestoreFile(QString filePath) |
| 5195 | { |
| 5196 | getRegularFilePath(filePath); |
| 5197 | |
| 5198 | QFileInfo fi(filePath); |
| 5199 | QString fileName = fi.fileName(); |
| 5200 | |
| 5201 | QString tempDir = getGlboalTempSaveDir(); |
| 5202 | QString restoreTempFile = QString("%1\\%2").arg(tempDir).arg(fi.fileName()); |
| 5203 | |
| 5204 | QFileInfo restoreFi(restoreTempFile); |
| 5205 | |
| 5206 | //存在恢复文件,则加载打开 |
| 5207 | if (restoreFi.exists()) |
| 5208 | { |
| 5209 | ScintillaEditView* pEdit = FileManager::getInstance().newEmptyDocument(); |
| 5210 | pEdit->setNoteWidget(this); |
| 5211 | |
| 5212 | //使用上次的swap文件恢复当前文件 |
| 5213 | CODE_ID code; |
| 5214 | RC_LINE_FORM lineEnd; |
| 5215 | |
| 5216 | if (0 != FileManager::getInstance().loadFileDataInText(pEdit, restoreTempFile, code, lineEnd, nullptr,false)) |
| 5217 | { |
| 5218 | ui.statusBar->showMessage(tr("File %1 Open Failed").arg(restoreTempFile)); |
| 5219 | delete pEdit; |
| 5220 | QFile::remove(restoreTempFile); |
| 5221 | return openFile(filePath); |
| 5222 | } |
| 5223 | else |
| 5224 | { |
| 5225 | //打开成功 |
| 5226 | setNormalTextEditInitPro(pEdit, filePath, code, lineEnd, false,true); |
| 5227 | //删除临时备份文件 |
| 5228 | QFile::remove(restoreTempFile); |
| 5229 | return true; |
| 5230 | } |
| 5231 | } |
| 5232 | return openFile(filePath); |
| 5233 | } |
| 5234 | bool CCNotePad::openFile(QString filePath, int lineNum) |
| 5235 | { |
| 5236 | s_padTimes++; |
no test coverage detected