* @brief Assigns one collision-free data-table name per message (the message name, with the * frame id appended when a DBC reuses a name). */
| 385 | * frame id appended when a DBC reuses a name). |
| 386 | */ |
| 387 | void DataModel::DBCImporter::buildTableNames(const QList<QCanMessageDescription>& messages) |
| 388 | { |
| 389 | m_tableNames.clear(); |
| 390 | |
| 391 | QSet<QString> used; |
| 392 | for (const auto& message : messages) { |
| 393 | const auto id = static_cast<quint32>(message.uniqueId()) & 0x1FFFFFFF; |
| 394 | const auto hex = QString::number(id, 16).toUpper(); |
| 395 | |
| 396 | QString name = message.name().simplified(); |
| 397 | if (name.isEmpty()) |
| 398 | name = QStringLiteral("Message 0x%1").arg(hex); |
| 399 | |
| 400 | if (used.contains(name)) |
| 401 | name += QStringLiteral(" @ 0x%1").arg(hex); |
| 402 | |
| 403 | used.insert(name); |
| 404 | m_tableNames.insert(id, name); |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | /** |
| 409 | * @brief Returns the data-table name assigned to the message by buildTableNames(). |