| 448 | } |
| 449 | |
| 450 | void CheckMessage(IgnoredMessages& ignored_messages, const SettingMeta& meta, SettingDataSet& data_set) { |
| 451 | for (std::size_t i = 0, n = meta.messages.size(); i < n; ++i) { |
| 452 | const Message& message = meta.messages[i]; |
| 453 | |
| 454 | if (!message.Triggered(data_set)) { |
| 455 | continue; |
| 456 | } |
| 457 | |
| 458 | bool show_message_box = false; |
| 459 | auto it = ignored_messages.find(message.key); |
| 460 | if (it != ignored_messages.end()) { |
| 461 | if (it->second < message.version) { |
| 462 | show_message_box = true; |
| 463 | } |
| 464 | } else { |
| 465 | show_message_box = true; |
| 466 | } |
| 467 | |
| 468 | QMessageBox::StandardButton button = ::GetStandardButton(message.actions[message.default_action].type); |
| 469 | if (show_message_box) { |
| 470 | QMessageBox alert; |
| 471 | alert.setWindowTitle(message.title.c_str()); |
| 472 | alert.setText(message.description.c_str()); |
| 473 | if (!message.informative.empty()) { |
| 474 | alert.setInformativeText(message.informative.c_str()); |
| 475 | } |
| 476 | alert.setIcon(::GetIcon(message.severity)); |
| 477 | alert.setCheckBox(new QCheckBox("Do not show again.")); |
| 478 | |
| 479 | alert.setStandardButtons(message.GetStandardButtons()); |
| 480 | alert.setDefaultButton(button); |
| 481 | button = static_cast<QMessageBox::StandardButton>(alert.exec()); |
| 482 | |
| 483 | if (alert.checkBox()->isChecked()) { |
| 484 | if (it != ignored_messages.end()) { |
| 485 | ignored_messages[message.key] = message.version; |
| 486 | } else { |
| 487 | ignored_messages.insert(std::make_pair(message.key, message.version)); |
| 488 | } |
| 489 | } |
| 490 | } |
| 491 | |
| 492 | message.Apply(data_set, button); |
| 493 | |
| 494 | break; |
| 495 | } |
| 496 | } |
no test coverage detected