MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / setSessionNotes

Method setSessionNotes

app/src/Sessions/DatabaseWorker.cpp:223–251  ·  view source on GitHub ↗

* @brief Persists the notes string for a session. */

Source from the content-addressed store, hash-verified

221 * @brief Persists the notes string for a session.
222 */
223void Sessions::DatabaseWorker::setSessionNotes(int sessionId, const QString& notes, quint64 token)
224{
225 if (!m_db.isOpen()) {
226 Q_EMIT mutationFinished(token, false, tr("Database not open"));
227 return;
228 }
229
230 QSqlQuery q(m_db);
231 q.prepare("UPDATE sessions SET notes = ? WHERE session_id = ?");
232 q.bindValue(0, notes);
233 q.bindValue(1, sessionId);
234 if (!q.exec()) {
235 Q_EMIT mutationFinished(token, false, q.lastError().text());
236 return;
237 }
238
239 for (auto& v : m_sessionList) {
240 auto m = v.toMap();
241 if (m.value("session_id").toInt() == sessionId) {
242 m["notes"] = notes;
243 v = m;
244 break;
245 }
246 }
247
248 Q_EMIT sessionListRefreshed(m_sessionList);
249 Q_EMIT notesUpdated(sessionId, notes);
250 Q_EMIT mutationFinished(token, true, QString());
251}
252
253//--------------------------------------------------------------------------------------------------
254// Tag mutations

Callers

nothing calls this directly

Calls 5

execMethod · 0.80
isOpenMethod · 0.45
textMethod · 0.45
lastErrorMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected