MCPcopy Create free account
hub / github.com/KDAB/GammaRay / messageContextMenu

Method messageContextMenu

ui/tools/messagehandler/messagehandlerwidget.cpp:166–202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164}
165
166void MessageHandlerWidget::messageContextMenu(const QPoint &pos)
167{
168 auto index = ui->messageView->indexAt(pos);
169 if (!index.isValid())
170 return;
171 index = index.sibling(index.row(), MessageModelColumn::File);
172 if (!index.isValid())
173 return;
174
175 const auto fileName = index.data(MessageModelRole::File).toString();
176 if (fileName.isEmpty())
177 return;
178 const auto line = index.data(MessageModelRole::Line).toInt();
179
180 QMenu contextMenu;
181 ContextMenuExtension cme;
182 cme.setLocation(ContextMenuExtension::ShowSource, SourceLocation::fromOneBased(QUrl(fileName), line));
183 cme.populateMenu(&contextMenu);
184
185 MessageHandlerInterface *handler = ObjectBroker::object<MessageHandlerInterface *>();
186 auto copyAction = contextMenu.addAction(QIcon::fromTheme(QStringLiteral("edit-copy")), tr("Copy Backtrace"));
187 copyAction->setVisible(handler->stackTraceAvailable());
188 connect(handler, &MessageHandlerInterface::stackTraceAvailableChanged, copyAction, &QAction::setVisible);
189
190 connect(copyAction, &QAction::triggered, this, [this, handler] {
191 delete m_backtraceFetchContext;
192 m_backtraceFetchContext = new QObject(handler);
193
194 connect(handler, &MessageHandlerInterface::fullTraceChanged, m_backtraceFetchContext, [handler] {
195 qApp->clipboard()->setText(handler->fullTrace().join(QStringLiteral("\n")));
196 });
197
198 handler->generateFullTrace();
199 });
200
201 contextMenu.exec(ui->messageView->viewport()->mapToGlobal(pos));
202}
203
204void MessageHandlerWidget::stackTraceContextMenu(QPoint pos)
205{

Callers

nothing calls this directly

Calls 11

rowMethod · 0.80
setLocationMethod · 0.80
populateMenuMethod · 0.80
stackTraceAvailableMethod · 0.80
QUrlClass · 0.50
isValidMethod · 0.45
dataMethod · 0.45
isEmptyMethod · 0.45
setTextMethod · 0.45
fullTraceMethod · 0.45
generateFullTraceMethod · 0.45

Tested by

no test coverage detected