MCPcopy Create free account
hub / github.com/dail8859/NotepadNext / newFile

Method newFile

src/dialogs/MainWindow.cpp:1036–1062  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1034}
1035
1036void MainWindow::newFile()
1037{
1038 qInfo(Q_FUNC_INFO);
1039
1040 static int count = 1;
1041
1042 // NOTE: in theory need to check all editors in the editorManager to future proof this.
1043 // If there is another window it would need to check those too to see if New X exists. The editor
1044 // manager would encompass all editors
1045
1046 forever {
1047 QString newFileName = tr("New %1").arg(count++);
1048 bool canUseName = true;
1049
1050 for (const ScintillaNext *editor : editors()) {
1051 if (!editor->isFile() && editor->getName() == newFileName) {
1052 canUseName = false;
1053 break;
1054 }
1055 }
1056
1057 if (canUseName) {
1058 ScintillaNext *editor = app->getEditorManager()->createEditor(newFileName);
1059 editor->grabFocus();
1060 break;
1061 }
1062 }
1063}
1064
1065// One unedited, new blank document

Callers 1

initMethod · 0.80

Calls 4

isFileMethod · 0.80
getEditorManagerMethod · 0.80
getNameMethod · 0.45
createEditorMethod · 0.45

Tested by

no test coverage detected