* @brief Primary posting entry point; normalizes inputs and fans out to the bus. */
| 136 | * @brief Primary posting entry point; normalizes inputs and fans out to the bus. |
| 137 | */ |
| 138 | void DataModel::NotificationCenter::post(int level, |
| 139 | const QString& channel, |
| 140 | const QString& title, |
| 141 | const QString& subtitle) |
| 142 | { |
| 143 | Q_ASSERT(thread() == QThread::currentThread()); |
| 144 | |
| 145 | const int clamped = qBound(static_cast<int>(Info), level, static_cast<int>(Critical)); |
| 146 | |
| 147 | const QString chan = channel.trimmed(); |
| 148 | const QString ttl = title.trimmed(); |
| 149 | |
| 150 | if (chan.isEmpty() && ttl.isEmpty()) |
| 151 | return; |
| 152 | |
| 153 | const auto now = QDateTime::currentMSecsSinceEpoch(); |
| 154 | const DedupKey key{clamped, chan, ttl, subtitle}; |
| 155 | if (shouldDropDuplicate(key, now)) |
| 156 | return; |
| 157 | |
| 158 | Event e; |
| 159 | e.timestampMs = now; |
| 160 | e.level = clamped; |
| 161 | e.channel = chan; |
| 162 | e.title = ttl; |
| 163 | e.subtitle = subtitle; |
| 164 | appendEvent(std::move(e)); |
| 165 | } |
| 166 | |
| 167 | /** |
| 168 | * @brief Convenience wrapper that posts an Info-level event. |
no test coverage detected