MCPcopy Create free account
hub / github.com/KDE/ghostwriter / openFileAt

Method openFileAt

src/documentmanager.cpp:370–402  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

368}
369
370void 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
404void DocumentManager::createUntitled()
405{

Callers 2

MainWindowMethod · 0.80
setupActionsMethod · 0.80

Calls 9

LibraryClass · 0.85
checkSaveChangesMethod · 0.80
isValidMethod · 0.80
isReadableMethod · 0.80
loadFileMethod · 0.80
navigateDocumentMethod · 0.80
filePathMethod · 0.45
positionMethod · 0.45
setLastOpenedMethod · 0.45

Tested by

no test coverage detected