| 368 | } |
| 369 | |
| 370 | void DocumentManager::openFileAt(const Bookmark &location, bool omitFromHistory) |
| 371 | { |
| 372 | Q_D(DocumentManager); |
| 373 | |
| 374 | if (d->checkSaveChanges()) { |
| 375 | if (location.isValid()) { |
| 376 | if (!location.isReadable()) { |
| 377 | MessageBoxHelper::critical(d->editor, tr("Could not open %1").arg(location.filePath()), tr("Permission denied.")); |
| 378 | |
| 379 | return; |
| 380 | } |
| 381 | |
| 382 | QString oldFilePath = d->document->filePath(); |
| 383 | int oldCursorPosition = d->editor->textCursor().position(); |
| 384 | |
| 385 | close(); |
| 386 | |
| 387 | if (!d->loadFile(location)) { |
| 388 | // The error dialog should already have been displayed |
| 389 | // in loadFile(). |
| 390 | // |
| 391 | return; |
| 392 | } else if (oldFilePath == d->document->filePath()) { |
| 393 | d->editor->navigateDocument(oldCursorPosition); |
| 394 | } |
| 395 | |
| 396 | if (d->restoreSessionEnabled) { |
| 397 | Library().setLastOpened(location, d->fileHistoryEnabled && !omitFromHistory); |
| 398 | emit sessionHistoryChanged(); |
| 399 | } |
| 400 | } |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | void DocumentManager::createUntitled() |
| 405 | { |
no test coverage detected