MCPcopy Create free account
hub / github.com/OneMoreGres/ScreenTranslator / showModelContextMenu

Method showModelContextMenu

src/service/updates.cpp:915–943  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

913}
914
915void 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
945int Updater::findDownload(const QUrl &url) const
946{

Callers

nothing calls this directly

Calls 3

toStringFunction · 0.85
selectAllUpdatesMethod · 0.80
tryActionMethod · 0.80

Tested by

no test coverage detected