| 1034 | } |
| 1035 | |
| 1036 | void 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 |
no test coverage detected