Valgrind: Restructure plugin setup

Bring it more in line with the standard pattern.

Plus some cosmetics.

Change-Id: I2297c4e72892db386c50ece7dc64bdc89f0d9010
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2019-03-20 17:49:26 +01:00
parent 90e828b890
commit 741950a3aa
10 changed files with 286 additions and 261 deletions

View File

@@ -106,13 +106,13 @@ const char CallgrindLocalActionId[] = "Callgrind.Local.Action";
const char CallgrindRemoteActionId[] = "Callgrind.Remote.Action";
const char CALLGRIND_RUN_MODE[] = "CallgrindTool.CallgrindRunMode";
class CallgrindTool : public QObject
class CallgrindToolPrivate : public QObject
{
Q_OBJECT
public:
CallgrindTool();
~CallgrindTool() override;
CallgrindToolPrivate();
~CallgrindToolPrivate() override;
void setupRunner(CallgrindToolRunner *runner);
@@ -218,10 +218,10 @@ public:
QString m_toggleCollectFunction;
bool m_toolBusy = false;
Perspective m_perspective{"Callgrind.Perspective", tr("Callgrind")};
Perspective m_perspective{"Callgrind.Perspective", CallgrindTool::tr("Callgrind")};
};
CallgrindTool::CallgrindTool()
CallgrindToolPrivate::CallgrindToolPrivate()
{
setObjectName("CallgrindTool");
@@ -235,22 +235,22 @@ CallgrindTool::CallgrindTool()
m_proxyModel.setFilterCaseSensitivity(Qt::CaseInsensitive);
connect(&m_stackBrowser, &StackBrowser::currentChanged,
this, &CallgrindTool::stackBrowserChanged);
this, &CallgrindToolPrivate::stackBrowserChanged);
connect(&m_updateTimer, &QTimer::timeout,
this, &CallgrindTool::updateFilterString);
this, &CallgrindToolPrivate::updateFilterString);
connect(EditorManager::instance(), &EditorManager::editorOpened,
this, &CallgrindTool::editorOpened);
this, &CallgrindToolPrivate::editorOpened);
m_startAction = Debugger::createStartAction();
m_stopAction = Debugger::createStopAction();
ActionContainer *menu = ActionManager::actionContainer(Debugger::Constants::M_DEBUG_ANALYZER);
QString toolTip = tr("Valgrind Function Profiler uses the "
QString toolTip = CallgrindTool::tr("Valgrind Function Profiler uses the "
"Callgrind tool to record function calls when a program runs.");
if (!Utils::HostOsInfo::isWindowsHost()) {
auto action = new QAction(tr("Valgrind Function Profiler"), this);
auto action = new QAction(CallgrindTool::tr("Valgrind Function Profiler"), this);
action->setToolTip(toolTip);
menu->addAction(ActionManager::registerAction(action, CallgrindLocalActionId),
Debugger::Constants::G_ANALYZER_TOOLS);
@@ -266,7 +266,7 @@ CallgrindTool::CallgrindTool()
});
}
auto action = new QAction(tr("Valgrind Function Profiler (External Application)"), this);
auto action = new QAction(CallgrindTool::tr("Valgrind Function Profiler (External Application)"), this);
action->setToolTip(toolTip);
menu->addAction(ActionManager::registerAction(action, CallgrindRemoteActionId),
Debugger::Constants::G_ANALYZER_REMOTE_TOOLS);
@@ -295,10 +295,10 @@ CallgrindTool::CallgrindTool()
Context analyzerContext = Context(Debugger::Constants::C_DEBUGMODE);
editorContextMenu->addSeparator(analyzerContext);
auto action = new QAction(tr("Profile Costs of This Function and Its Callees"), this);
auto action = new QAction(CallgrindTool::tr("Profile Costs of This Function and Its Callees"), this);
action->setIcon(ProjectExplorer::Icons::ANALYZER_START_SMALL.icon());
connect(action, &QAction::triggered, this,
&CallgrindTool::handleShowCostsOfFunction);
&CallgrindToolPrivate::handleShowCostsOfFunction);
Command *cmd = ActionManager::registerAction(action, "Analyzer.Callgrind.ShowCostsOfFunction",
analyzerContext);
editorContextMenu->addAction(cmd);
@@ -314,14 +314,14 @@ CallgrindTool::CallgrindTool()
m_visualization = new Visualization;
m_visualization->setFrameStyle(QFrame::NoFrame);
m_visualization->setObjectName("Valgrind.CallgrindTool.Visualisation");
m_visualization->setWindowTitle(tr("Visualization"));
m_visualization->setWindowTitle(CallgrindTool::tr("Visualization"));
m_visualization->setModel(&m_dataModel);
connect(m_visualization, &Visualization::functionActivated,
this, &CallgrindTool::visualisationFunctionSelected);
this, &CallgrindToolPrivate::visualisationFunctionSelected);
m_callersView = new CostView;
m_callersView->setObjectName("Valgrind.CallgrindTool.CallersView");
m_callersView->setWindowTitle(tr("Callers"));
m_callersView->setWindowTitle(CallgrindTool::tr("Callers"));
m_callersView->setSettings(coreSettings, "Valgrind.CallgrindTool.CallersView");
m_callersView->sortByColumn(CallModel::CostColumn, Qt::DescendingOrder);
m_callersView->setFrameStyle(QFrame::NoFrame);
@@ -330,11 +330,11 @@ CallgrindTool::CallgrindTool()
m_callersView->setModel(&m_callersProxy);
m_callersView->hideColumn(CallModel::CalleeColumn);
connect(m_callersView, &QAbstractItemView::activated,
this, &CallgrindTool::callerFunctionSelected);
this, &CallgrindToolPrivate::callerFunctionSelected);
m_calleesView = new CostView;
m_calleesView->setObjectName("Valgrind.CallgrindTool.CalleesView");
m_calleesView->setWindowTitle(tr("Callees"));
m_calleesView->setWindowTitle(CallgrindTool::tr("Callees"));
m_calleesView->setSettings(coreSettings, "Valgrind.CallgrindTool.CalleesView");
m_calleesView->sortByColumn(CallModel::CostColumn, Qt::DescendingOrder);
m_calleesView->setFrameStyle(QFrame::NoFrame);
@@ -343,22 +343,22 @@ CallgrindTool::CallgrindTool()
m_calleesView->setModel(&m_calleesProxy);
m_calleesView->hideColumn(CallModel::CallerColumn);
connect(m_calleesView, &QAbstractItemView::activated,
this, &CallgrindTool::calleeFunctionSelected);
this, &CallgrindToolPrivate::calleeFunctionSelected);
m_flatView = new CostView;
m_flatView->setObjectName("Valgrind.CallgrindTool.FlatView");
m_flatView->setWindowTitle(tr("Functions"));
m_flatView->setWindowTitle(CallgrindTool::tr("Functions"));
m_flatView->setSettings(coreSettings, "Valgrind.CallgrindTool.FlatView");
m_flatView->sortByColumn(DataModel::SelfCostColumn, Qt::DescendingOrder);
m_flatView->setFrameStyle(QFrame::NoFrame);
m_flatView->setAttribute(Qt::WA_MacShowFocusRect, false);
m_flatView->setModel(&m_proxyModel);
connect(m_flatView, &QAbstractItemView::activated,
this, &CallgrindTool::dataFunctionSelected);
this, &CallgrindToolPrivate::dataFunctionSelected);
updateCostFormat();
ValgrindGlobalSettings *settings = ValgrindPlugin::globalSettings();
ValgrindGlobalSettings *settings = ValgrindGlobalSettings::instance();
//
// Control Widget
@@ -367,15 +367,15 @@ CallgrindTool::CallgrindTool()
// load external log file
action = m_loadExternalLogFile = new QAction(this);
action->setIcon(Utils::Icons::OPENFILE_TOOLBAR.icon());
action->setToolTip(tr("Load External Log File"));
connect(action, &QAction::triggered, this, &CallgrindTool::loadExternalLogFile);
action->setToolTip(CallgrindTool::tr("Load External Log File"));
connect(action, &QAction::triggered, this, &CallgrindToolPrivate::loadExternalLogFile);
action = m_startKCachegrind = new QAction(this);
action->setEnabled(false);
const Utils::Icon kCachegrindIcon({{":/valgrind/images/kcachegrind.png",
Theme::IconsBaseColor}});
action->setIcon(kCachegrindIcon.icon());
action->setToolTip(tr("Open results in KCachegrind."));
action->setToolTip(CallgrindTool::tr("Open results in KCachegrind."));
connect(action, &QAction::triggered, this, [this, settings] {
QProcess::startDetached(settings->kcachegrindExecutable(), { m_lastFileName });
});
@@ -384,30 +384,30 @@ CallgrindTool::CallgrindTool()
m_dumpAction = action = new QAction(this);
action->setDisabled(true);
action->setIcon(Utils::Icons::REDO.icon());
//action->setText(tr("Dump"));
action->setToolTip(tr("Request the dumping of profile information. This will update the Callgrind visualization."));
connect(action, &QAction::triggered, this, &CallgrindTool::slotRequestDump);
//action->setText(CallgrindTool::tr("Dump"));
action->setToolTip(CallgrindTool::tr("Request the dumping of profile information. This will update the Callgrind visualization."));
connect(action, &QAction::triggered, this, &CallgrindToolPrivate::slotRequestDump);
// reset action
m_resetAction = action = new QAction(this);
action->setDisabled(true);
action->setIcon(Utils::Icons::RELOAD.icon());
//action->setText(tr("Reset"));
action->setToolTip(tr("Reset all event counters."));
connect(action, &QAction::triggered, this, &CallgrindTool::resetRequested);
//action->setText(CallgrindTool::tr("Reset"));
action->setToolTip(CallgrindTool::tr("Reset all event counters."));
connect(action, &QAction::triggered, this, &CallgrindToolPrivate::resetRequested);
// pause action
m_pauseAction = action = new QAction(this);
action->setCheckable(true);
action->setIcon(Utils::Icons::INTERRUPT_SMALL_TOOLBAR.icon());
//action->setText(tr("Ignore"));
action->setToolTip(tr("Pause event logging. No events are counted which will speed up program execution during profiling."));
connect(action, &QAction::toggled, this, &CallgrindTool::pauseToggled);
//action->setText(CallgrindTool::tr("Ignore"));
action->setToolTip(CallgrindTool::tr("Pause event logging. No events are counted which will speed up program execution during profiling."));
connect(action, &QAction::toggled, this, &CallgrindToolPrivate::pauseToggled);
// discard data action
m_discardAction = action = new QAction(this);
action->setIcon(Utils::Icons::CLEAN_TOOLBAR.icon());
action->setToolTip(tr("Discard Data"));
action->setToolTip(CallgrindTool::tr("Discard Data"));
connect(action, &QAction::triggered, this, [this](bool) {
clearTextMarks();
doClear(true);
@@ -418,21 +418,21 @@ CallgrindTool::CallgrindTool()
m_goBack = action = new QAction(this);
action->setDisabled(true);
action->setIcon(Utils::Icons::PREV_TOOLBAR.icon());
action->setToolTip(tr("Go back one step in history. This will select the previously selected item."));
action->setToolTip(CallgrindTool::tr("Go back one step in history. This will select the previously selected item."));
connect(action, &QAction::triggered, &m_stackBrowser, &StackBrowser::goBack);
// go forward
m_goNext = action = new QAction(this);
action->setDisabled(true);
action->setIcon(Utils::Icons::NEXT_TOOLBAR.icon());
action->setToolTip(tr("Go forward one step in history."));
action->setToolTip(CallgrindTool::tr("Go forward one step in history."));
connect(action, &QAction::triggered, &m_stackBrowser, &StackBrowser::goNext);
// event selection
m_eventCombo = new QComboBox;
m_eventCombo->setToolTip(tr("Selects which events from the profiling data are shown and visualized."));
m_eventCombo->setToolTip(CallgrindTool::tr("Selects which events from the profiling data are shown and visualized."));
connect(m_eventCombo, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &CallgrindTool::setCostEvent);
this, &CallgrindToolPrivate::setCostEvent);
updateEventCombo();
m_perspective.addToolBarAction(m_startAction);
@@ -453,61 +453,61 @@ CallgrindTool::CallgrindTool()
auto group = new QActionGroup(this);
// Show costs as absolute numbers
m_costAbsolute = new QAction(tr("Absolute Costs"), this);
m_costAbsolute->setToolTip(tr("Show costs as absolute numbers."));
m_costAbsolute = new QAction(CallgrindTool::tr("Absolute Costs"), this);
m_costAbsolute->setToolTip(CallgrindTool::tr("Show costs as absolute numbers."));
m_costAbsolute->setCheckable(true);
m_costAbsolute->setChecked(true);
connect(m_costAbsolute, &QAction::toggled, this, &CallgrindTool::updateCostFormat);
connect(m_costAbsolute, &QAction::toggled, this, &CallgrindToolPrivate::updateCostFormat);
group->addAction(m_costAbsolute);
// Show costs in percentages
m_costRelative = new QAction(tr("Relative Costs"), this);
m_costRelative->setToolTip(tr("Show costs relative to total inclusive cost."));
m_costRelative = new QAction(CallgrindTool::tr("Relative Costs"), this);
m_costRelative->setToolTip(CallgrindTool::tr("Show costs relative to total inclusive cost."));
m_costRelative->setCheckable(true);
connect(m_costRelative, &QAction::toggled, this, &CallgrindTool::updateCostFormat);
connect(m_costRelative, &QAction::toggled, this, &CallgrindToolPrivate::updateCostFormat);
group->addAction(m_costRelative);
// Show costs relative to parent
m_costRelativeToParent = new QAction(tr("Relative Costs to Parent"), this);
m_costRelativeToParent->setToolTip(tr("Show costs relative to parent function's inclusive cost."));
m_costRelativeToParent = new QAction(CallgrindTool::tr("Relative Costs to Parent"), this);
m_costRelativeToParent->setToolTip(CallgrindTool::tr("Show costs relative to parent function's inclusive cost."));
m_costRelativeToParent->setCheckable(true);
connect(m_costRelativeToParent, &QAction::toggled, this, &CallgrindTool::updateCostFormat);
connect(m_costRelativeToParent, &QAction::toggled, this, &CallgrindToolPrivate::updateCostFormat);
group->addAction(m_costRelativeToParent);
auto button = new QToolButton;
button->addActions(group->actions());
button->setPopupMode(QToolButton::InstantPopup);
button->setText("$");
button->setToolTip(tr("Cost Format"));
button->setToolTip(CallgrindTool::tr("Cost Format"));
m_perspective.addToolBarWidget(button);
}
// Cycle detection
//action = new QAction("Cycle Detection", this); ///FIXME: icon
action = m_cycleDetection = new QAction("O", this); ///FIXME: icon
action->setToolTip(tr("Enable cycle detection to properly handle recursive or circular function calls."));
action->setToolTip(CallgrindTool::tr("Enable cycle detection to properly handle recursive or circular function calls."));
action->setCheckable(true);
connect(action, &QAction::toggled, &m_dataModel, &DataModel::enableCycleDetection);
connect(action, &QAction::toggled, settings, &ValgrindGlobalSettings::setDetectCycles);
// Shorter template signature
action = m_shortenTemplates = new QAction("<>", this);
action->setToolTip(tr("Remove template parameter lists when displaying function names."));
action->setToolTip(CallgrindTool::tr("Remove template parameter lists when displaying function names."));
action->setCheckable(true);
connect(action, &QAction::toggled, &m_dataModel, &DataModel::setShortenTemplates);
connect(action, &QAction::toggled, settings, &ValgrindGlobalSettings::setShortenTemplates);
// Filtering
action = m_filterProjectCosts = new QAction(tr("Show Project Costs Only"), this);
action = m_filterProjectCosts = new QAction(CallgrindTool::tr("Show Project Costs Only"), this);
action->setIcon(Utils::Icons::FILTER.icon());
action->setToolTip(tr("Show only profiling info that originated from this project source."));
action->setToolTip(CallgrindTool::tr("Show only profiling info that originated from this project source."));
action->setCheckable(true);
connect(action, &QAction::toggled, this, &CallgrindTool::handleFilterProjectCosts);
connect(action, &QAction::toggled, this, &CallgrindToolPrivate::handleFilterProjectCosts);
// Filter
///FIXME: find workaround for https://bugreports.qt.io/browse/QTCREATORBUG-3247
m_searchFilter = new QLineEdit;
m_searchFilter->setPlaceholderText(tr("Filter..."));
m_searchFilter->setPlaceholderText(CallgrindTool::tr("Filter..."));
connect(m_searchFilter, &QLineEdit::textChanged,
&m_updateTimer, static_cast<void(QTimer::*)()>(&QTimer::start));
@@ -526,10 +526,10 @@ CallgrindTool::CallgrindTool()
false, Qt::RightDockWidgetArea);
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions,
this, &CallgrindTool::updateRunActions);
this, &CallgrindToolPrivate::updateRunActions);
}
CallgrindTool::~CallgrindTool()
CallgrindToolPrivate::~CallgrindToolPrivate()
{
qDeleteAll(m_textMarks);
delete m_flatView;
@@ -538,7 +538,7 @@ CallgrindTool::~CallgrindTool()
delete m_visualization;
}
void CallgrindTool::doClear(bool clearParseData)
void CallgrindToolPrivate::doClear(bool clearParseData)
{
if (clearParseData) // Crashed when done from destructor.
setParseData(nullptr);
@@ -552,7 +552,7 @@ void CallgrindTool::doClear(bool clearParseData)
m_proxyModel.setFilterFixedString(QString());
}
void CallgrindTool::setBusyCursor(bool busy)
void CallgrindToolPrivate::setBusyCursor(bool busy)
{
QCursor cursor(busy ? Qt::BusyCursor : Qt::ArrowCursor);
m_flatView->setCursor(cursor);
@@ -561,7 +561,7 @@ void CallgrindTool::setBusyCursor(bool busy)
m_visualization->setCursor(cursor);
}
void CallgrindTool::selectFunction(const Function *func)
void CallgrindToolPrivate::selectFunction(const Function *func)
{
if (!func) {
m_flatView->clearSelection();
@@ -594,7 +594,7 @@ void CallgrindTool::selectFunction(const Function *func)
}
}
void CallgrindTool::stackBrowserChanged()
void CallgrindToolPrivate::stackBrowserChanged()
{
m_goBack->setEnabled(m_stackBrowser.hasPrevious());
m_goNext->setEnabled(m_stackBrowser.hasNext());
@@ -602,12 +602,12 @@ void CallgrindTool::stackBrowserChanged()
selectFunction(item);
}
void CallgrindTool::updateFilterString()
void CallgrindToolPrivate::updateFilterString()
{
m_proxyModel.setFilterFixedString(m_searchFilter->text());
}
void CallgrindTool::setCostFormat(CostDelegate::CostFormat format)
void CallgrindToolPrivate::setCostFormat(CostDelegate::CostFormat format)
{
switch (format) {
case CostDelegate::FormatAbsolute:
@@ -622,7 +622,7 @@ void CallgrindTool::setCostFormat(CostDelegate::CostFormat format)
}
}
void CallgrindTool::setCostEvent(int index)
void CallgrindToolPrivate::setCostEvent(int index)
{
// prevent assert in model, don't try to set event to -1
// happens when we clear the eventcombo
@@ -634,19 +634,19 @@ void CallgrindTool::setCostEvent(int index)
m_callersModel.setCostEvent(index);
}
void CallgrindTool::enableCycleDetection(bool enabled)
void CallgrindToolPrivate::enableCycleDetection(bool enabled)
{
m_cycleDetection->setChecked(enabled);
}
void CallgrindTool::shortenTemplates(bool enabled)
void CallgrindToolPrivate::shortenTemplates(bool enabled)
{
m_shortenTemplates->setChecked(enabled);
}
// Following functions can be called with actions=0 or widgets=0
// depending on initialization sequence (whether callgrind was current).
CostDelegate::CostFormat CallgrindTool::costFormat() const
CostDelegate::CostFormat CallgrindToolPrivate::costFormat() const
{
if (m_costRelativeToParent && m_costRelativeToParent->isChecked())
return CostDelegate::FormatRelativeToParent;
@@ -655,7 +655,7 @@ CostDelegate::CostFormat CallgrindTool::costFormat() const
return CostDelegate::FormatAbsolute;
}
void CallgrindTool::updateCostFormat()
void CallgrindToolPrivate::updateCostFormat()
{
const CostDelegate::CostFormat format = costFormat();
if (m_flatView)
@@ -664,11 +664,11 @@ void CallgrindTool::updateCostFormat()
m_calleesView->setCostFormat(format);
m_callersView->setCostFormat(format);
}
if (ValgrindGlobalSettings *settings = ValgrindPlugin::globalSettings())
if (ValgrindGlobalSettings *settings = ValgrindGlobalSettings::instance())
settings->setCostFormat(format);
}
void CallgrindTool::handleFilterProjectCosts()
void CallgrindToolPrivate::handleFilterProjectCosts()
{
Project *pro = ProjectTree::currentProject();
@@ -680,7 +680,7 @@ void CallgrindTool::handleFilterProjectCosts()
}
}
void CallgrindTool::dataFunctionSelected(const QModelIndex &index)
void CallgrindToolPrivate::dataFunctionSelected(const QModelIndex &index)
{
auto func = index.data(DataModel::FunctionRole).value<const Function *>();
QTC_ASSERT(func, return);
@@ -688,7 +688,7 @@ void CallgrindTool::dataFunctionSelected(const QModelIndex &index)
selectFunction(func);
}
void CallgrindTool::calleeFunctionSelected(const QModelIndex &index)
void CallgrindToolPrivate::calleeFunctionSelected(const QModelIndex &index)
{
auto call = index.data(CallModel::FunctionCallRole).value<const FunctionCall *>();
QTC_ASSERT(call, return);
@@ -696,7 +696,7 @@ void CallgrindTool::calleeFunctionSelected(const QModelIndex &index)
selectFunction(call->callee());
}
void CallgrindTool::callerFunctionSelected(const QModelIndex &index)
void CallgrindToolPrivate::callerFunctionSelected(const QModelIndex &index)
{
auto call = index.data(CallModel::FunctionCallRole).value<const FunctionCall *>();
QTC_ASSERT(call, return);
@@ -704,7 +704,7 @@ void CallgrindTool::callerFunctionSelected(const QModelIndex &index)
selectFunction(call->caller());
}
void CallgrindTool::visualisationFunctionSelected(const Function *function)
void CallgrindToolPrivate::visualisationFunctionSelected(const Function *function)
{
if (function && function == m_visualization->function())
// up-navigation when the initial function was activated
@@ -713,7 +713,7 @@ void CallgrindTool::visualisationFunctionSelected(const Function *function)
selectFunction(function);
}
void CallgrindTool::setParseData(ParseData *data)
void CallgrindToolPrivate::setParseData(ParseData *data)
{
// we have new parse data, invalidate filters in the proxy model
m_visualization->setFunction(nullptr);
@@ -741,7 +741,7 @@ void CallgrindTool::setParseData(ParseData *data)
//setBusy(false);
}
void CallgrindTool::updateEventCombo()
void CallgrindToolPrivate::updateEventCombo()
{
QTC_ASSERT(m_eventCombo, return);
@@ -758,16 +758,16 @@ void CallgrindTool::updateEventCombo()
m_eventCombo->addItem(ParseData::prettyStringForEvent(event));
}
void CallgrindTool::setupRunner(CallgrindToolRunner *toolRunner)
void CallgrindToolPrivate::setupRunner(CallgrindToolRunner *toolRunner)
{
RunControl *runControl = toolRunner->runControl();
connect(toolRunner, &CallgrindToolRunner::parserDataReady, this, &CallgrindTool::takeParserDataFromRunControl);
connect(runControl, &RunControl::stopped, this, &CallgrindTool::engineFinished);
connect(toolRunner, &CallgrindToolRunner::parserDataReady, this, &CallgrindToolPrivate::takeParserDataFromRunControl);
connect(runControl, &RunControl::stopped, this, &CallgrindToolPrivate::engineFinished);
connect(this, &CallgrindTool::dumpRequested, toolRunner, &CallgrindToolRunner::dump);
connect(this, &CallgrindTool::resetRequested, toolRunner, &CallgrindToolRunner::reset);
connect(this, &CallgrindTool::pauseToggled, toolRunner, &CallgrindToolRunner::setPaused);
connect(this, &CallgrindToolPrivate::dumpRequested, toolRunner, &CallgrindToolRunner::dump);
connect(this, &CallgrindToolPrivate::resetRequested, toolRunner, &CallgrindToolRunner::reset);
connect(this, &CallgrindToolPrivate::pauseToggled, toolRunner, &CallgrindToolRunner::setPaused);
connect(m_stopAction, &QAction::triggered, toolRunner, [runControl] { runControl->initiateStop(); });
@@ -800,28 +800,28 @@ void CallgrindTool::setupRunner(CallgrindToolRunner *toolRunner)
doClear(true);
}
void CallgrindTool::updateRunActions()
void CallgrindToolPrivate::updateRunActions()
{
if (m_toolBusy) {
m_startAction->setEnabled(false);
m_startKCachegrind->setEnabled(false);
m_startAction->setToolTip(tr("A Valgrind Callgrind analysis is still in progress."));
m_startAction->setToolTip(CallgrindTool::tr("A Valgrind Callgrind analysis is still in progress."));
m_stopAction->setEnabled(true);
} else {
QString whyNot = tr("Start a Valgrind Callgrind analysis.");
QString whyNot = CallgrindTool::tr("Start a Valgrind Callgrind analysis.");
bool canRun = ProjectExplorerPlugin::canRunStartupProject(CALLGRIND_RUN_MODE, &whyNot);
m_startAction->setToolTip(whyNot);
m_startAction->setEnabled(canRun);
m_stopAction->setEnabled(false);
}
}
void CallgrindTool::clearTextMarks()
void CallgrindToolPrivate::clearTextMarks()
{
qDeleteAll(m_textMarks);
m_textMarks.clear();
}
void CallgrindTool::engineFinished()
void CallgrindToolPrivate::engineFinished()
{
m_toolBusy = false;
updateRunActions();
@@ -835,51 +835,51 @@ void CallgrindTool::engineFinished()
if (data)
showParserResults(data);
else
Debugger::showPermanentStatusMessage(tr("Profiling aborted."));
Debugger::showPermanentStatusMessage(CallgrindTool::tr("Profiling aborted."));
setBusyCursor(false);
}
void CallgrindTool::showParserResults(const ParseData *data)
void CallgrindToolPrivate::showParserResults(const ParseData *data)
{
QString msg;
if (data) {
// be careful, the list of events might be empty
if (data->events().isEmpty()) {
msg = tr("Parsing finished, no data.");
msg = CallgrindTool::tr("Parsing finished, no data.");
} else {
const QString costStr = QString::fromLatin1("%1 %2")
.arg(QString::number(data->totalCost(0)), data->events().constFirst());
msg = tr("Parsing finished, total cost of %1 reported.").arg(costStr);
msg = CallgrindTool::tr("Parsing finished, total cost of %1 reported.").arg(costStr);
}
} else {
msg = tr("Parsing failed.");
msg = CallgrindTool::tr("Parsing failed.");
}
Debugger::showPermanentStatusMessage(msg);
}
void CallgrindTool::editorOpened(IEditor *editor)
void CallgrindToolPrivate::editorOpened(IEditor *editor)
{
if (auto widget = qobject_cast<TextEditorWidget *>(editor->widget())) {
connect(widget, &TextEditorWidget::markContextMenuRequested,
this, &CallgrindTool::requestContextMenu);
this, &CallgrindToolPrivate::requestContextMenu);
}
}
void CallgrindTool::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
foreach (CallgrindTextMark *textMark, m_textMarks) {
if (textMark->fileName() == widget->textDocument()->filePath() && textMark->lineNumber() == line) {
const Function *func = textMark->function();
QAction *action = menu->addAction(tr("Select This Function in the Analyzer Output"));
QAction *action = menu->addAction(CallgrindTool::tr("Select This Function in the Analyzer Output"));
connect(action, &QAction::triggered, this, [this, func] { selectFunction(func); });
break;
}
}
}
void CallgrindTool::handleShowCostsOfFunction()
void CallgrindToolPrivate::handleShowCostsOfFunction()
{
CPlusPlus::Symbol *symbol = AnalyzerUtils::findSymbolUnderCursor();
if (!symbol)
@@ -895,32 +895,32 @@ void CallgrindTool::handleShowCostsOfFunction()
m_startAction->trigger();
}
void CallgrindTool::slotRequestDump()
void CallgrindToolPrivate::slotRequestDump()
{
//setBusy(true);
m_visualization->setText(tr("Populating..."));
m_visualization->setText(CallgrindTool::tr("Populating..."));
emit dumpRequested();
}
void CallgrindTool::loadExternalLogFile()
void CallgrindToolPrivate::loadExternalLogFile()
{
const QString filePath = QFileDialog::getOpenFileName(
ICore::mainWindow(),
tr("Open Callgrind Log File"),
CallgrindTool::tr("Open Callgrind Log File"),
QString(),
tr("Callgrind Output (callgrind.out*);;All Files (*)"));
CallgrindTool::tr("Callgrind Output (callgrind.out*);;All Files (*)"));
if (filePath.isEmpty())
return;
QFile logFile(filePath);
if (!logFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
QString msg = tr("Callgrind: Failed to open file for reading: %1").arg(filePath);
QString msg = CallgrindTool::tr("Callgrind: Failed to open file for reading: %1").arg(filePath);
TaskHub::addTask(Task::Error, msg, Debugger::Constants::ANALYZERTASK_ID);
TaskHub::requestPopup();
return;
}
Debugger::showPermanentStatusMessage(tr("Parsing Profile Data..."));
Debugger::showPermanentStatusMessage(CallgrindTool::tr("Parsing Profile Data..."));
QCoreApplication::processEvents();
Parser parser;
@@ -928,12 +928,12 @@ void CallgrindTool::loadExternalLogFile()
takeParserData(parser.takeData());
}
void CallgrindTool::takeParserDataFromRunControl(CallgrindToolRunner *rc)
void CallgrindToolPrivate::takeParserDataFromRunControl(CallgrindToolRunner *rc)
{
takeParserData(rc->takeParserData());
}
void CallgrindTool::takeParserData(ParseData *data)
void CallgrindToolPrivate::takeParserData(ParseData *data)
{
showParserResults(data);
@@ -945,14 +945,14 @@ void CallgrindTool::takeParserData(ParseData *data)
doClear(true);
setParseData(data);
const QString kcachegrindExecutable = ValgrindPlugin::globalSettings()->kcachegrindExecutable();
const QString kcachegrindExecutable = ValgrindGlobalSettings::instance()->kcachegrindExecutable();
const bool kcachegrindExists = !Utils::Environment::systemEnvironment().searchInPath(
kcachegrindExecutable).isEmpty();
m_startKCachegrind->setEnabled(kcachegrindExists && !m_lastFileName.isEmpty());
createTextMarks();
}
void CallgrindTool::createTextMarks()
void CallgrindToolPrivate::createTextMarks()
{
QList<QString> locations;
for (int row = 0; row < m_dataModel.rowCount(); ++row) {
@@ -987,24 +987,24 @@ void CallgrindTool::createTextMarks()
}
static CallgrindTool *theCallgrindTool;
// CallgrindTool
static CallgrindToolPrivate *dd = nullptr;
void setupCallgrindRunner(CallgrindToolRunner *toolRunner)
{
theCallgrindTool->setupRunner(toolRunner);
dd->setupRunner(toolRunner);
}
void initCallgrindTool()
CallgrindTool::CallgrindTool()
{
theCallgrindTool = new CallgrindTool;
dd = new CallgrindToolPrivate;
RunControl::registerWorker<CallgrindToolRunner>(CALLGRIND_RUN_MODE, {});
}
void destroyCallgrindTool()
CallgrindTool::~CallgrindTool()
{
delete theCallgrindTool;
theCallgrindTool = nullptr;
delete dd;
}
} // namespace Internal