* @brief Loads the distinct frame timestamps for the session, with periodic cancel checks. */
| 124 | * @brief Loads the distinct frame timestamps for the session, with periodic cancel checks. |
| 125 | */ |
| 126 | bool Sessions::PlayerLoaderWorker::loadTimestampIndex(QSqlDatabase& db, |
| 127 | int sessionId, |
| 128 | PlayerSessionPayload& payload, |
| 129 | QString& errorOut) |
| 130 | { |
| 131 | QSqlQuery q(db); |
| 132 | q.setForwardOnly(true); |
| 133 | q.prepare("SELECT DISTINCT timestamp_ns FROM readings " |
| 134 | "WHERE session_id = ? ORDER BY timestamp_ns ASC"); |
| 135 | q.bindValue(0, sessionId); |
| 136 | if (!q.exec()) { |
| 137 | errorOut = q.lastError().text(); |
| 138 | return false; |
| 139 | } |
| 140 | |
| 141 | qint64 row = 0; |
| 142 | while (q.next()) { |
| 143 | if ((row & 0xFFFF) == 0 && m_cancelRequested.load(std::memory_order_acquire)) { |
| 144 | errorOut = tr("Cancelled"); |
| 145 | return false; |
| 146 | } |
| 147 | |
| 148 | payload.timestampsNs.push_back(q.value(0).toLongLong()); |
| 149 | ++row; |
| 150 | } |
| 151 | |
| 152 | return true; |
| 153 | } |
| 154 | |
| 155 | /** |
| 156 | * @brief Opens the file, fetches column order + project JSON + timestamp index, ships it back. |