| 649 | } |
| 650 | |
| 651 | void TaskWindow::updateCategoriesMenu() |
| 652 | { |
| 653 | typedef QMap<QString, QString>::ConstIterator NameToIdsConstIt; |
| 654 | |
| 655 | d->categoriesMenu->clear(); |
| 656 | |
| 657 | const QList<QString> filteredCategories = d->filter->filteredCategories(); |
| 658 | |
| 659 | QMap<QString, QString> nameToIds; |
| 660 | foreach (QString categoryId, d->taskModel->categoryIds()) |
| 661 | nameToIds.insert(d->taskModel->categoryDisplayName(categoryId), categoryId); |
| 662 | |
| 663 | const NameToIdsConstIt cend = nameToIds.constEnd(); |
| 664 | for (NameToIdsConstIt it = nameToIds.constBegin(); it != cend; ++it) { |
| 665 | const QString &displayName = it.key(); |
| 666 | const QString categoryId = it.value(); |
| 667 | QAction *action = new QAction(d->categoriesMenu); |
| 668 | action->setCheckable(true); |
| 669 | action->setText(displayName); |
| 670 | action->setChecked(!filteredCategories.contains(categoryId)); |
| 671 | connect(action, &QAction::triggered, this, [this, action, categoryId] { |
| 672 | setCategoryVisibility(categoryId, action->isChecked()); |
| 673 | }); |
| 674 | d->categoriesMenu->addAction(action); |
| 675 | } |
| 676 | } |
| 677 | |
| 678 | ///// |
| 679 | // Delegate |
nothing calls this directly
no test coverage detected