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

Method loadSession

src/SessionManager.cpp:180–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

178}
179
180void SessionManager::loadSession(MainWindow *window)
181{
182 qInfo(Q_FUNC_INFO);
183
184 ApplicationSettings settings;;
185
186 settings.beginGroup("CurrentSession");
187
188 ScintillaNext *currentEditor = Q_NULLPTR;
189 const int currentEditorIndex = settings.value("CurrentEditorIndex").toInt();
190 const int size = settings.beginReadArray("OpenedFiles");
191
192 // NOTE: In theory the fileTypes should determine what is loaded, however if the session fileTypes
193 // change from the last time it was saved then it means the settings were manually altered outside of the app,
194 // which is non-standard behavior, so just load anything in the file
195
196 for (int index = 0; index < size; ++index) {
197 settings.setArrayIndex(index);
198
199 ScintillaNext *editor = Q_NULLPTR;
200
201 if (settings.contains("Type")) {
202 const QString type = settings.value("Type").toString();
203
204 if (type == QStringLiteral("File")) {
205 editor = loadFileDetails(settings);
206 }
207 else if (type == QStringLiteral("UnsavedFile")) {
208 editor = loadUnsavedFileDetails(settings);
209 }
210 else if (type == QStringLiteral("Temp")) {
211 editor = loadTempFile(settings);
212 }
213 else {
214 qDebug("Unknown session entry type: %s", qUtf8Printable(type));
215 }
216
217 if (editor) {
218 if (currentEditorIndex == index) {
219 currentEditor = editor;
220 }
221 }
222 }
223 else {
224 qDebug("Unknown session entry type for index %d", index);
225 }
226 }
227
228 settings.endArray();
229
230 settings.endGroup();
231
232 if (currentEditor) {
233 window->switchToEditor(currentEditor);
234 }
235}
236
237bool SessionManager::willFileGetStoredInSession(ScintillaNext *editor) const

Callers 1

initMethod · 0.80

Calls 2

toStringMethod · 0.80
switchToEditorMethod · 0.45

Tested by

no test coverage detected