MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / openContextMenu

Method openContextMenu

pcsx2-qt/Debugger/Memory/SavedAddressesView.cpp:56–117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56void SavedAddressesView::openContextMenu(QPoint pos)
57{
58 QMenu* menu = new QMenu(this);
59 menu->setAttribute(Qt::WA_DeleteOnClose);
60
61 QAction* new_action = menu->addAction(tr("New"));
62 connect(new_action, &QAction::triggered, this, &SavedAddressesView::contextNew);
63
64 const QModelIndex index_at_pos = m_ui.savedAddressesList->indexAt(pos);
65 const bool is_index_valid = index_at_pos.isValid();
66 bool is_cpu_alive = cpu().isAlive();
67
68 std::vector<QAction*> go_to_actions = createEventActions<DebuggerEvents::GoToAddress>(
69 menu, [this, index_at_pos]() {
70 const QModelIndex rowAddressIndex = m_model->index(index_at_pos.row(), 0, QModelIndex());
71
72 DebuggerEvents::GoToAddress event;
73 event.address = m_model->data(rowAddressIndex, Qt::UserRole).toUInt();
74 return std::optional(event);
75 });
76
77 for (QAction* go_to_action : go_to_actions)
78 go_to_action->setEnabled(is_index_valid);
79
80 QAction* copy_action = menu->addAction(index_at_pos.column() == 0 ? tr("Copy Address") : tr("Copy Text"));
81 copy_action->setEnabled(is_index_valid);
82 connect(copy_action, &QAction::triggered, [this, index_at_pos]() {
83 QGuiApplication::clipboard()->setText(
84 m_model->data(index_at_pos, Qt::DisplayRole).toString());
85 });
86
87 if (m_model->rowCount() > 0)
88 {
89 QAction* copy_all_as_csv_action = menu->addAction(tr("Copy all as CSV"));
90 connect(copy_all_as_csv_action, &QAction::triggered, [this]() {
91 QGuiApplication::clipboard()->setText(
92 QtUtils::AbstractItemModelToCSV(m_ui.savedAddressesList->model(), Qt::DisplayRole, true));
93 });
94 }
95
96 QAction* paste_from_csv_action = menu->addAction(tr("Paste from CSV"));
97 connect(paste_from_csv_action, &QAction::triggered, this, &SavedAddressesView::contextPasteCSV);
98
99 QAction* load_action = menu->addAction(tr("Load from Settings"));
100 load_action->setEnabled(is_cpu_alive);
101 connect(load_action, &QAction::triggered, [this]() {
102 m_model->clear();
103 DebuggerSettingsManager::loadGameSettings(m_model);
104 });
105
106 QAction* save_action = menu->addAction(tr("Save to Settings"));
107 save_action->setEnabled(is_cpu_alive);
108 connect(save_action, &QAction::triggered, this, &SavedAddressesView::saveToDebuggerSettings);
109
110 QAction* delete_action = menu->addAction(tr("Delete"));
111 connect(delete_action, &QAction::triggered, this, [this, index_at_pos]() {
112 m_model->removeRows(index_at_pos.row(), 1);
113 });

Callers

nothing calls this directly

Calls 9

AbstractItemModelToCSVFunction · 0.85
isValidMethod · 0.80
isAliveMethod · 0.80
indexMethod · 0.45
dataMethod · 0.45
toStringMethod · 0.45
rowCountMethod · 0.45
clearMethod · 0.45
removeRowsMethod · 0.45

Tested by

no test coverage detected