Analyzer: Rework the dock widget layout generation

Decouple layout generation from widget generation and
separate analyzer action description from menu action creation.

Tool specific layouts are named "Perspective" now.

Change-Id: I774efe77a07640c4cc26e4e566662c8a673c8831
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
hjk
2016-02-26 14:14:49 +01:00
parent 04cbf8b818
commit 931ee3382c
32 changed files with 645 additions and 679 deletions

View File

@@ -53,7 +53,7 @@ CallgrindRunControl::CallgrindRunControl(ProjectExplorer::RunConfiguration *runC
void CallgrindRunControl::showStatusMessage(const QString &msg)
{
AnalyzerManager::showPermanentStatusMessage(CallgrindToolId, msg);
AnalyzerManager::showPermanentStatusMessage(CallgrindPerspective, msg);
}
QStringList CallgrindRunControl::toolArguments() const

View File

@@ -570,8 +570,7 @@ QWidget *CallgrindToolPrivate::createWidgets()
//
// DockWidgets
//
Utils::FancyMainWindow *mw = AnalyzerManager::mainWindow();
m_visualisation = new Visualisation(mw);
m_visualisation = new Visualisation;
m_visualisation->setFrameStyle(QFrame::NoFrame);
m_visualisation->setObjectName(QLatin1String("Valgrind.CallgrindTool.Visualisation"));
m_visualisation->setWindowTitle(tr("Visualization"));
@@ -579,7 +578,7 @@ QWidget *CallgrindToolPrivate::createWidgets()
connect(m_visualisation, &Visualisation::functionActivated,
this, &CallgrindToolPrivate::visualisationFunctionSelected);
m_callersView = new CostView(mw);
m_callersView = new CostView;
m_callersView->setObjectName(QLatin1String("Valgrind.CallgrindTool.CallersView"));
m_callersView->setWindowTitle(tr("Callers"));
m_callersView->setSettings(coreSettings, "Valgrind.CallgrindTool.CallersView");
@@ -593,7 +592,7 @@ QWidget *CallgrindToolPrivate::createWidgets()
connect(m_callersView, &QAbstractItemView::activated,
this, &CallgrindToolPrivate::callerFunctionSelected);
m_calleesView = new CostView(mw);
m_calleesView = new CostView;
m_calleesView->setObjectName(QLatin1String("Valgrind.CallgrindTool.CalleesView"));
m_calleesView->setWindowTitle(tr("Callees"));
m_calleesView->setSettings(coreSettings, "Valgrind.CallgrindTool.CalleesView");
@@ -607,7 +606,7 @@ QWidget *CallgrindToolPrivate::createWidgets()
connect(m_calleesView, &QAbstractItemView::activated,
this, &CallgrindToolPrivate::calleeFunctionSelected);
m_flatView = new CostView(mw);
m_flatView = new CostView;
m_flatView->setObjectName(QLatin1String("Valgrind.CallgrindTool.FlatView"));
m_flatView->setWindowTitle(tr("Functions"));
m_flatView->setSettings(coreSettings, "Valgrind.CallgrindTool.FlatView");
@@ -620,20 +619,18 @@ QWidget *CallgrindToolPrivate::createWidgets()
updateCostFormat();
QDockWidget *callersDock = AnalyzerManager::createDockWidget(CallgrindToolId, m_callersView);
QDockWidget *flatDock = AnalyzerManager::createDockWidget(CallgrindToolId, m_flatView);
QDockWidget *calleesDock = AnalyzerManager::createDockWidget(CallgrindToolId, m_calleesView);
QDockWidget *visualizationDock = AnalyzerManager::createDockWidget
(CallgrindToolId, m_visualisation, Qt::RightDockWidgetArea);
AnalyzerManager::createDockWidget(m_callersView, CallgrindCallersDock);
AnalyzerManager::createDockWidget(m_flatView, CallgrindFlatDock);
AnalyzerManager::createDockWidget(m_calleesView, CallgrindCalleesDock);
AnalyzerManager::createDockWidget(m_visualisation, CallgrindVisualizationDock);
callersDock->show();
calleesDock->show();
flatDock->show();
visualizationDock->hide();
mw->splitDockWidget(mw->toolBarDockWidget(), flatDock, Qt::Vertical);
mw->splitDockWidget(mw->toolBarDockWidget(), calleesDock, Qt::Vertical);
mw->splitDockWidget(calleesDock, callersDock, Qt::Horizontal);
Perspective perspective(CallgrindPerspective);
perspective.addDock(CallgrindFlatDock, Id(), Perspective::SplitVertical);
perspective.addDock(CallgrindCalleesDock, Id(), Perspective::SplitVertical);
perspective.addDock(CallgrindCallersDock, CallgrindCalleesDock, Perspective::SplitHorizontal);
perspective.addDock(CallgrindVisualizationDock, Id(), Perspective::SplitVertical,
false, Qt::RightDockWidgetArea);
AnalyzerManager::addPerspective(perspective);
//
// Control Widget
@@ -827,7 +824,7 @@ void CallgrindToolPrivate::engineFinished()
if (data)
showParserResults(data);
else
AnalyzerManager::showPermanentStatusMessage(CallgrindToolId, tr("Profiling aborted."));
AnalyzerManager::showPermanentStatusMessage(CallgrindPerspective, tr("Profiling aborted."));
setBusyCursor(false);
}
@@ -846,7 +843,7 @@ void CallgrindToolPrivate::showParserResults(const ParseData *data)
} else {
msg = tr("Parsing failed.");
}
AnalyzerManager::showPermanentStatusMessage(CallgrindToolId, msg);
AnalyzerManager::showPermanentStatusMessage(CallgrindPerspective, msg);
}
void CallgrindToolPrivate::editorOpened(IEditor *editor)
@@ -911,7 +908,7 @@ void CallgrindToolPrivate::loadExternalLogFile()
return;
}
AnalyzerManager::showPermanentStatusMessage(CallgrindToolId, tr("Parsing Profile Data..."));
AnalyzerManager::showPermanentStatusMessage(CallgrindPerspective, tr("Parsing Profile Data..."));
QCoreApplication::processEvents();
Parser parser;

View File

@@ -26,15 +26,22 @@
#ifndef CALLGRINDTOOL_H
#define CALLGRINDTOOL_H
#include <debugger/analyzer/ianalyzertool.h>
#include <QObject>
namespace ProjectExplorer { class RunConfiguration; }
namespace Valgrind {
namespace Internal {
const char CallgrindToolId[] = "Callgrind";
const char CallgrindPerspective[] = "CallgrindPerspective";
const char CallgrindLocalActionId[] = "Callgrind.Local";
const char CallgrindRemoteActionId[] = "Callgrind.Remote";
const char CallgrindCallersDock[] = "CallgrindCallersDock";
const char CallgrindCalleesDock[] = "CallgrindCalleesDock";
const char CallgrindFlatDock[] = "CallgrindFlatDock";
const char CallgrindVisualizationDock[] = "CallgrindVisualizationDock";
class ValgrindRunControl;
const char CALLGRIND_RUN_MODE[] = "CallgrindTool.CallgrindRunMode";

View File

@@ -89,7 +89,6 @@ using namespace Valgrind::XmlProtocol;
namespace Valgrind {
namespace Internal {
const Core::Id MemcheckToolId = "Memcheck";
// ---------------------------- MemcheckErrorFilterProxyModel
MemcheckErrorFilterProxyModel::MemcheckErrorFilterProxyModel(QObject *parent)
@@ -330,8 +329,6 @@ QWidget *MemcheckTool::createWidgets()
{
QTC_ASSERT(!m_errorView, return 0);
Utils::FancyMainWindow *mw = AnalyzerManager::mainWindow();
m_errorView = new MemcheckErrorView;
m_errorView->setObjectName(QLatin1String("MemcheckErrorView"));
m_errorView->setFrameStyle(QFrame::NoFrame);
@@ -351,9 +348,11 @@ QWidget *MemcheckTool::createWidgets()
m_errorView->setObjectName(QLatin1String("Valgrind.MemcheckTool.ErrorView"));
m_errorView->setWindowTitle(tr("Memory Issues"));
QDockWidget *errorDock = AnalyzerManager::createDockWidget(MemcheckToolId, m_errorView);
errorDock->show();
mw->splitDockWidget(mw->toolBarDockWidget(), errorDock, Qt::Vertical);
AnalyzerManager::createDockWidget(m_errorView, MemcheckDock);
Perspective perspective(MemcheckPerspective);
perspective.addDock(MemcheckDock, Core::Id(), Perspective::SplitVertical);
AnalyzerManager::addPerspective(perspective);
connect(ProjectExplorerPlugin::instance(), &ProjectExplorerPlugin::updateRunActions,
this, &MemcheckTool::maybeActiveRunConfigurationChanged);
@@ -558,7 +557,7 @@ int MemcheckTool::updateUiAfterFinishedHelper()
void MemcheckTool::engineFinished()
{
const int issuesFound = updateUiAfterFinishedHelper();
AnalyzerManager::showPermanentStatusMessage(MemcheckToolId, issuesFound > 0
AnalyzerManager::showPermanentStatusMessage(MemcheckPerspective, issuesFound > 0
? AnalyzerManager::tr("Memory Analyzer Tool finished, %n issues were found.", 0, issuesFound)
: AnalyzerManager::tr("Memory Analyzer Tool finished, no issues were found."));
}
@@ -566,7 +565,7 @@ void MemcheckTool::engineFinished()
void MemcheckTool::loadingExternalXmlLogFileFinished()
{
const int issuesFound = updateUiAfterFinishedHelper();
AnalyzerManager::showPermanentStatusMessage(MemcheckToolId, issuesFound > 0
AnalyzerManager::showPermanentStatusMessage(MemcheckPerspective, issuesFound > 0
? AnalyzerManager::tr("Log file processed, %n issues were found.", 0, issuesFound)
: AnalyzerManager::tr("Log file processed, no issues were found."));
}

View File

@@ -27,7 +27,7 @@
#ifndef MEMCHECKTOOL_H
#define MEMCHECKTOOL_H
#include <debugger/analyzer/ianalyzertool.h>
#include <coreplugin/id.h>
#include <QSortFilterProxyModel>
@@ -44,11 +44,16 @@ class Error;
}
}
namespace ProjectExplorer { class RunConfiguration; }
namespace Valgrind {
const char MEMCHECK_RUN_MODE[] = "MemcheckTool.MemcheckRunMode";
const char MEMCHECK_WITH_GDB_RUN_MODE[] = "MemcheckTool.MemcheckWithGdbRunMode";
const char MemcheckPerspective[] = "MemcheckPerspective";
const char MemcheckDock[] = "MemcheckDock";
namespace Internal {
class FrameFinder;

View File

@@ -54,6 +54,7 @@
#include <utils/hostosinfo.h>
#include <QtPlugin>
#include <QAction>
#include <QCoreApplication>
#include <QPointer>
@@ -119,7 +120,6 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *)
void ValgrindPlugin::extensionsInitialized()
{
using namespace std::placeholders;
AnalyzerAction *action = 0;
QString callgrindToolTip = tr("Valgrind Function Profile uses the "
"Callgrind tool to record function calls when a program runs.");
@@ -135,59 +135,59 @@ void ValgrindPlugin::extensionsInitialized()
return cgTool->createRunControl(runConfiguration);
};
ActionDescription desc;
if (!Utils::HostOsInfo::isWindowsHost()) {
action = new AnalyzerAction(this);
action->setActionId("Memcheck.Local");
action->setToolId("Memcheck");
action->setWidgetCreator(mcWidgetCreator);
action->setRunControlCreator([mcTool](RunConfiguration *runConfig, Id runMode) {
desc.setText(tr("Valgrind Memory Analyzer"));
desc.setToolTip(memcheckToolTip);
desc.setEnabled(false);
desc.setActionId("Memcheck.Local");
desc.setPerspectiveId(MemcheckPerspective);
desc.setWidgetCreator(mcWidgetCreator);
desc.setRunControlCreator([mcTool](RunConfiguration *runConfig, Id runMode) {
return mcTool->createRunControl(runConfig, runMode);
});
action->setToolMode(DebugMode);
action->setRunMode(MEMCHECK_RUN_MODE);
action->setText(tr("Valgrind Memory Analyzer"));
action->setToolTip(memcheckToolTip);
action->setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS);
action->setEnabled(false);
AnalyzerManager::addAction(action);
desc.setToolMode(DebugMode);
desc.setRunMode(MEMCHECK_RUN_MODE);
desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS);
AnalyzerManager::addAction(desc);
auto mcgTool = new MemcheckTool(this);
action = new AnalyzerAction(this);
action->setActionId("MemcheckWithGdb.Local");
action->setToolId("MemcheckWithGdb");
action->setWidgetCreator([mcgTool] { return mcgTool->createWidgets(); });
action->setRunControlCreator([mcgTool](RunConfiguration *runConfig, Id runMode) {
return mcgTool->createRunControl(runConfig, runMode);
});
action->setToolMode(DebugMode);
action->setRunMode(MEMCHECK_WITH_GDB_RUN_MODE);
action->setText(tr("Valgrind Memory Analyzer with GDB"));
action->setToolTip(tr("Valgrind Analyze Memory with GDB uses the "
desc.setText(tr("Valgrind Memory Analyzer with GDB"));
desc.setToolTip(tr("Valgrind Analyze Memory with GDB uses the "
"Memcheck tool to find memory leaks.\nWhen a problem is detected, "
"the application is interrupted and can be debugged."));
action->setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS);
action->setEnabled(false);
AnalyzerManager::addAction(action);
desc.setEnabled(false);
desc.setActionId("MemcheckWithGdb.Local");
desc.setPerspectiveId(MemcheckPerspective);
desc.setWidgetCreator([mcgTool] { return mcgTool->createWidgets(); });
desc.setRunControlCreator([mcgTool](RunConfiguration *runConfig, Id runMode) {
return mcgTool->createRunControl(runConfig, runMode);
});
desc.setToolMode(DebugMode);
desc.setRunMode(MEMCHECK_WITH_GDB_RUN_MODE);
desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS);
AnalyzerManager::addAction(desc);
action = new AnalyzerAction(this);
action->setActionId(CallgrindLocalActionId);
action->setToolId(CallgrindToolId);
action->setWidgetCreator(cgWidgetCreator);
action->setRunControlCreator(cgRunControlCreator);
action->setToolMode(OptimizedMode);
action->setRunMode(CALLGRIND_RUN_MODE);
action->setText(tr("Valgrind Function Profiler"));
action->setToolTip(callgrindToolTip);
action->setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS);
action->setEnabled(false);
AnalyzerManager::addAction(action);
desc.setText(tr("Valgrind Function Profiler"));
desc.setToolTip(callgrindToolTip);
desc.setEnabled(false);
desc.setActionId(CallgrindLocalActionId);
desc.setPerspectiveId(CallgrindPerspective);
desc.setWidgetCreator(cgWidgetCreator);
desc.setRunControlCreator(cgRunControlCreator);
desc.setToolMode(OptimizedMode);
desc.setRunMode(CALLGRIND_RUN_MODE);
desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_TOOLS);
AnalyzerManager::addAction(desc);
}
action = new AnalyzerAction(this);
action->setActionId("Memcheck.Remote");
action->setToolId("Memcheck");
action->setWidgetCreator(mcWidgetCreator);
action->setCustomToolStarter([mcTool](ProjectExplorer::RunConfiguration *runConfig) {
desc.setText(tr("Valgrind Memory Analyzer (External Remote Application)"));
desc.setToolTip(memcheckToolTip);
desc.setActionId("Memcheck.Remote");
desc.setPerspectiveId(MemcheckPerspective);
desc.setWidgetCreator(mcWidgetCreator);
desc.setCustomToolStarter([mcTool](ProjectExplorer::RunConfiguration *runConfig) {
StartRemoteDialog dlg;
if (dlg.exec() != QDialog::Accepted)
return;
@@ -201,16 +201,13 @@ void ValgrindPlugin::extensionsInitialized()
rc->setDisplayName(runnable.executable);
ProjectExplorerPlugin::startRunControl(rc, MEMCHECK_RUN_MODE);
});
action->setText(tr("Valgrind Memory Analyzer (External Remote Application)"));
action->setToolTip(memcheckToolTip);
action->setMenuGroup(Analyzer::Constants::G_ANALYZER_REMOTE_TOOLS);
AnalyzerManager::addAction(action);
desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_REMOTE_TOOLS);
AnalyzerManager::addAction(desc);
action = new AnalyzerAction(this);
action->setActionId(CallgrindRemoteActionId);
action->setToolId(CallgrindToolId);
action->setWidgetCreator(cgWidgetCreator);
action->setCustomToolStarter([cgTool](ProjectExplorer::RunConfiguration *runConfig) {
desc.setActionId(CallgrindRemoteActionId);
desc.setPerspectiveId(CallgrindPerspective);
desc.setWidgetCreator(cgWidgetCreator);
desc.setCustomToolStarter([cgTool](ProjectExplorer::RunConfiguration *runConfig) {
StartRemoteDialog dlg;
if (dlg.exec() != QDialog::Accepted)
return;
@@ -225,10 +222,10 @@ void ValgrindPlugin::extensionsInitialized()
ProjectExplorerPlugin::startRunControl(rc, CALLGRIND_RUN_MODE);
});
action->setText(tr("Valgrind Function Profiler (External Remote Application)"));
action->setToolTip(callgrindToolTip);
action->setMenuGroup(Analyzer::Constants::G_ANALYZER_REMOTE_TOOLS);
AnalyzerManager::addAction(action);
desc.setText(tr("Valgrind Function Profiler (External Remote Application)"));
desc.setToolTip(callgrindToolTip);
desc.setMenuGroup(Analyzer::Constants::G_ANALYZER_REMOTE_TOOLS);
AnalyzerManager::addAction(desc);
// If there is a CppEditor context menu add our own context menu actions.
if (ActionContainer *editorContextMenu =

View File

@@ -28,7 +28,6 @@
#define VALGRINDPLUGIN_H
#include <extensionsystem/iplugin.h>
#include <debugger/analyzer/ianalyzertool.h>
#include <projectexplorer/projectexplorer.h>
namespace Valgrind {

View File

@@ -31,7 +31,6 @@
#include "callgrindtool.h"
#include "memchecktool.h"
#include <debugger/analyzer/ianalyzertool.h>
#include <debugger/analyzer/analyzermanager.h>
#include <debugger/analyzer/analyzerrunconfigwidget.h>

View File

@@ -35,9 +35,6 @@
#include <QSettings>
#include <QDebug>
using namespace Analyzer;
const char numCallersC[] = "Analyzer.Valgrind.NumCallers";
const char leakCheckOnFinishC[] = "Analyzer.Valgrind.LeakCheckOnFinish";
const char showReachableC[] = "Analyzer.Valgrind.ShowReachable";