forked from qt-creator/qt-creator
Valgrind: Simplify callgrind context menu creation
Change-Id: I5ea4bdf2dc6f4d3867e6abbc8d4cd6a1149a17b2 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -150,7 +150,6 @@ public slots:
|
|||||||
void updateCostFormat();
|
void updateCostFormat();
|
||||||
|
|
||||||
void handleFilterProjectCosts();
|
void handleFilterProjectCosts();
|
||||||
void handleShowCostsAction();
|
|
||||||
void handleShowCostsOfFunction();
|
void handleShowCostsOfFunction();
|
||||||
|
|
||||||
void slotGoToOverview();
|
void slotGoToOverview();
|
||||||
@@ -882,33 +881,15 @@ void CallgrindToolPrivate::editorOpened(IEditor *editor)
|
|||||||
|
|
||||||
void CallgrindToolPrivate::requestContextMenu(TextEditorWidget *widget, int line, QMenu *menu)
|
void CallgrindToolPrivate::requestContextMenu(TextEditorWidget *widget, int line, QMenu *menu)
|
||||||
{
|
{
|
||||||
// find callgrind text mark that corresponds to this editor's file and line number
|
// Find callgrind text mark that corresponds to this editor's file and line number
|
||||||
const Function *func = 0;
|
|
||||||
foreach (CallgrindTextMark *textMark, m_textMarks) {
|
foreach (CallgrindTextMark *textMark, m_textMarks) {
|
||||||
if (textMark->fileName() == widget->textDocument()->filePath().toString() && textMark->lineNumber() == line) {
|
if (textMark->fileName() == widget->textDocument()->filePath().toString() && textMark->lineNumber() == line) {
|
||||||
func = textMark->function();
|
const Function *func = textMark->function();
|
||||||
|
QAction *action = menu->addAction(tr("Select this Function in the Analyzer Output"));
|
||||||
|
connect(action, &QAction::triggered, this, [this, func] { selectFunction(func); });
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!func)
|
|
||||||
return; // no callgrind text mark under cursor, return
|
|
||||||
|
|
||||||
// add our action to the context menu
|
|
||||||
QAction *action = new QAction(tr("Select this Function in the Analyzer Output"), menu);
|
|
||||||
connect(action, &QAction::triggered, this, &CallgrindToolPrivate::handleShowCostsAction);
|
|
||||||
action->setData(QVariant::fromValue<const Function *>(func));
|
|
||||||
menu->addAction(action);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CallgrindToolPrivate::handleShowCostsAction()
|
|
||||||
{
|
|
||||||
const QAction *action = qobject_cast<QAction *>(sender());
|
|
||||||
QTC_ASSERT(action, return);
|
|
||||||
|
|
||||||
const Function *func = action->data().value<const Function *>();
|
|
||||||
QTC_ASSERT(func, return);
|
|
||||||
|
|
||||||
selectFunction(func);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CallgrindToolPrivate::handleShowCostsOfFunction()
|
void CallgrindToolPrivate::handleShowCostsOfFunction()
|
||||||
|
Reference in New Issue
Block a user