* @brief Persists the notes string for a session. */
| 221 | * @brief Persists the notes string for a session. |
| 222 | */ |
| 223 | void 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 |