| 124 | } |
| 125 | |
| 126 | void SessionManager::saveSession(MainWindow *window) |
| 127 | { |
| 128 | qInfo(Q_FUNC_INFO); |
| 129 | |
| 130 | clear(); |
| 131 | |
| 132 | // Early out if no flags are set |
| 133 | if (fileTypes == SessionManager::None) { |
| 134 | return; |
| 135 | } |
| 136 | |
| 137 | const ScintillaNext *currentEditor = window->currentEditor(); |
| 138 | int currentEditorIndex = 0; |
| 139 | ApplicationSettings settings;; |
| 140 | |
| 141 | settings.beginGroup("CurrentSession"); |
| 142 | |
| 143 | settings.beginWriteArray("OpenedFiles"); |
| 144 | |
| 145 | int index = 0; |
| 146 | for (const auto &editor : window->editors()) { |
| 147 | SessionFileType editorType = determineType(editor); |
| 148 | |
| 149 | if (fileTypes.testFlag(editorType)) { |
| 150 | settings.setArrayIndex(index); |
| 151 | |
| 152 | if (editorType == SessionManager::SavedFile) { |
| 153 | storeFileDetails(editor, settings); |
| 154 | } |
| 155 | else if (editorType == SessionManager::UnsavedFile) { |
| 156 | storeUnsavedFileDetails(editor, settings); |
| 157 | } |
| 158 | else if (editorType == SessionManager::TempFile) { |
| 159 | storeTempFile(editor, settings); |
| 160 | } |
| 161 | else { |
| 162 | qWarning("Unknown SessionFileType %d", editorType); |
| 163 | } |
| 164 | |
| 165 | if (currentEditor == editor) { |
| 166 | currentEditorIndex = index; |
| 167 | } |
| 168 | |
| 169 | ++index; |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | settings.endArray(); |
| 174 | |
| 175 | settings.setValue("CurrentEditorIndex", currentEditorIndex); |
| 176 | |
| 177 | settings.endGroup(); |
| 178 | } |
| 179 | |
| 180 | void SessionManager::loadSession(MainWindow *window) |
| 181 | { |
nothing calls this directly
no test coverage detected