| 913 | } |
| 914 | |
| 915 | void Updater::showModelContextMenu() |
| 916 | { |
| 917 | QMenu menu; |
| 918 | auto install = menu.addAction(toString(Action::Install)); |
| 919 | menu.addAction(toString(Action::Remove)); |
| 920 | menu.addSeparator(); |
| 921 | auto updateAll = menu.addAction(tr("Update all")); |
| 922 | |
| 923 | const auto choice = menu.exec(QCursor::pos()); |
| 924 | if (!choice) |
| 925 | return; |
| 926 | |
| 927 | if (choice == updateAll) { |
| 928 | model_->selectAllUpdates(); |
| 929 | return; |
| 930 | } |
| 931 | |
| 932 | auto view = qobject_cast<QAbstractItemView *>(sender()); |
| 933 | SOFT_ASSERT(view, return ); |
| 934 | |
| 935 | const auto selection = view->selectionModel(); |
| 936 | SOFT_ASSERT(selection, return ); |
| 937 | const auto indexes = selection->selectedRows(int(Model::Column::Name)); |
| 938 | if (indexes.isEmpty()) |
| 939 | return; |
| 940 | |
| 941 | const auto action = choice == install ? Action::Install : Action::Remove; |
| 942 | for (const auto &index : indexes) model_->tryAction(action, fromProxy(index)); |
| 943 | } |
| 944 | |
| 945 | int Updater::findDownload(const QUrl &url) const |
| 946 | { |
nothing calls this directly
no test coverage detected