analyzer: merge dockwidget and toolbar creation.

Now that dock and control widgets are always created as late as
possible and both are needed immediately afterward it makes sense
to merge there construction. This also reduces the chance to create
a partial tool gui in an inconsitent state.

Change-Id: Ic7f405d65b2b8f0b4ee3ff0ef991d6e4746bac0a
Reviewed-on: http://codereview.qt.nokia.com/1249
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
hjk
2011-07-06 16:52:14 +02:00
committed by hjk
parent 4823487b59
commit 868613b5ed
8 changed files with 91 additions and 116 deletions
+2 -4
View File
@@ -637,12 +637,10 @@ void AnalyzerManagerPrivate::selectTool(IAnalyzerTool *tool, StartMode mode)
m_currentMode = mode;
if (!m_defaultSettings.contains(tool)) {
// First time the tool is used.
tool->initializeDockWidgets();
QWidget *widget = tool->createWidgets();
QTC_ASSERT(widget, /**/);
m_defaultSettings.insert(tool, m_mainWindow->saveSettings());
QTC_ASSERT(!m_controlsWidgetFromTool.contains(tool), /**/);
QWidget *widget = tool->createControlWidget();
m_controlsWidgetFromTool[tool] = widget;
m_controlsStackWidget->addWidget(widget);
}
+2 -7
View File
@@ -109,15 +109,10 @@ public:
/// This gets called after all analyzation tools where initialized.
virtual void extensionsInitialized() = 0;
/**
* This is called to add all dock widgets if tool becomes active first time.
* \sa AnalzyerManager::createDockWidget
*/
virtual void initializeDockWidgets() {}
/// Creates all widgets used by the tool.
/// Returns a control widget which will be shown in the status bar when
/// this tool is selected. Must be non-zero.
virtual QWidget *createControlWidget() = 0;
virtual QWidget *createWidgets() = 0;
/// Returns a new engine for the given start parameters.
/// Called each time the tool is launched.
+16 -21
View File
@@ -225,15 +225,23 @@ IAnalyzerEngine *QmlProfilerTool::createEngine(const AnalyzerStartParameters &sp
return engine;
}
void QmlProfilerTool::initializeDockWidgets()
void QmlProfilerTool::toolSelected()
{
ensureWidgets();
updateAttachAction(true);
}
void QmlProfilerTool::ensureWidgets()
void QmlProfilerTool::toolDeselected()
{
if (d->m_traceWindow)
return;
updateAttachAction(false);
}
QWidget *QmlProfilerTool::createWidgets()
{
QTC_ASSERT(!d->m_traceWindow, return 0);
//
// DockWidgets
//
Utils::FancyMainWindow *mw = AnalyzerManager::mainWindow();
@@ -291,23 +299,10 @@ void QmlProfilerTool::ensureWidgets()
mw->tabifyDockWidget(eventsDock, timelineDock);
mw->tabifyDockWidget(timelineDock, calleeDock);
mw->tabifyDockWidget(calleeDock, callerDock);
}
void QmlProfilerTool::toolSelected()
{
updateAttachAction(true);
}
void QmlProfilerTool::toolDeselected()
{
updateAttachAction(false);
}
QWidget *QmlProfilerTool::createControlWidget()
{
ensureWidgets();
// custom toolbar (TODO)
//
// Toolbar
//
QWidget *toolbarWidget = new QWidget;
toolbarWidget->setObjectName(QLatin1String("QmlProfilerToolBarWidget"));
+1 -2
View File
@@ -53,14 +53,13 @@ public:
ToolMode toolMode() const;
void extensionsInitialized() {}
void initializeDockWidgets();
void toolSelected();
void toolDeselected();
Analyzer::IAnalyzerEngine *createEngine(const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration = 0);
QWidget *createControlWidget();
QWidget *createWidgets();
void startTool(Analyzer::StartMode mode);
public slots:
+61 -62
View File
@@ -115,8 +115,7 @@ public:
void setParseData(ParseData *data);
CostDelegate::CostFormat costFormat() const;
QWidget *createControlWidget();
void initializeDockWidgets();
QWidget *createWidgets();
void doClear(bool clearParseData);
void updateEventCombo();
@@ -566,13 +565,67 @@ void CallgrindTool::extensionsInitialized()
}
}
void CallgrindTool::initializeDockWidgets()
IAnalyzerEngine *CallgrindTool::createEngine(const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration)
{
d->initializeDockWidgets();
return d->createEngine(sp, runConfiguration);
}
void CallgrindToolPrivate::initializeDockWidgets()
IAnalyzerEngine *CallgrindToolPrivate::createEngine(const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration)
{
CallgrindEngine *engine = new CallgrindEngine(q, sp, runConfiguration);
connect(engine, SIGNAL(parserDataReady(CallgrindEngine *)),
SLOT(takeParserData(CallgrindEngine *)));
connect(engine, SIGNAL(starting(const Analyzer::IAnalyzerEngine*)),
SLOT(engineStarting(const Analyzer::IAnalyzerEngine*)));
connect(engine, SIGNAL(finished()),
SLOT(engineFinished()));
connect(this, SIGNAL(dumpRequested()), engine, SLOT(dump()));
connect(this, SIGNAL(resetRequested()), engine, SLOT(reset()));
connect(this, SIGNAL(pauseToggled(bool)), engine, SLOT(setPaused(bool)));
// initialize engine
engine->setPaused(m_pauseAction->isChecked());
// we may want to toggle collect for one function only in this run
engine->setToggleCollectFunction(m_toggleCollectFunction);
m_toggleCollectFunction.clear();
AnalyzerManager::showStatusMessage(AnalyzerManager::msgToolStarted(q->displayName()));
// apply project settings
AnalyzerProjectSettings *analyzerSettings = runConfiguration->extraAspect<AnalyzerProjectSettings>();
CallgrindProjectSettings *settings = analyzerSettings->subConfig<CallgrindProjectSettings>();
QTC_ASSERT(settings, return engine)
QTC_ASSERT(m_visualisation, return engine);
m_visualisation->setMinimumInclusiveCostRatio(settings->visualisationMinimumInclusiveCostRatio() / 100.0);
m_proxyModel->setMinimumInclusiveCostRatio(settings->minimumInclusiveCostRatio() / 100.0);
m_dataModel->setVerboseToolTipsEnabled(settings->enableEventToolTips());
return engine;
}
void CallgrindTool::startTool(StartMode mode)
{
ValgrindPlugin::startValgrindTool(this, mode);
}
QWidget *CallgrindTool::createWidgets()
{
return d->createWidgets();
}
QWidget *CallgrindToolPrivate::createWidgets()
{
QTC_ASSERT(!m_visualisation, return 0);
//
// DockWidgets
//
Utils::FancyMainWindow *mw = AnalyzerManager::mainWindow();
m_visualisation = new Visualisation(mw);
m_visualisation->setFrameStyle(QFrame::NoFrame);
@@ -636,64 +689,10 @@ void CallgrindToolPrivate::initializeDockWidgets()
mw->splitDockWidget(mw->toolBarDockWidget(), flatDock, Qt::Vertical);
mw->splitDockWidget(mw->toolBarDockWidget(), calleesDock, Qt::Vertical);
mw->splitDockWidget(calleesDock, callersDock, Qt::Horizontal);
}
IAnalyzerEngine *CallgrindTool::createEngine(const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration)
{
return d->createEngine(sp, runConfiguration);
}
IAnalyzerEngine *CallgrindToolPrivate::createEngine(const AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration)
{
CallgrindEngine *engine = new CallgrindEngine(q, sp, runConfiguration);
connect(engine, SIGNAL(parserDataReady(CallgrindEngine *)),
SLOT(takeParserData(CallgrindEngine *)));
connect(engine, SIGNAL(starting(const Analyzer::IAnalyzerEngine*)),
SLOT(engineStarting(const Analyzer::IAnalyzerEngine*)));
connect(engine, SIGNAL(finished()),
SLOT(engineFinished()));
connect(this, SIGNAL(dumpRequested()), engine, SLOT(dump()));
connect(this, SIGNAL(resetRequested()), engine, SLOT(reset()));
connect(this, SIGNAL(pauseToggled(bool)), engine, SLOT(setPaused(bool)));
// initialize engine
engine->setPaused(m_pauseAction->isChecked());
// we may want to toggle collect for one function only in this run
engine->setToggleCollectFunction(m_toggleCollectFunction);
m_toggleCollectFunction.clear();
AnalyzerManager::showStatusMessage(AnalyzerManager::msgToolStarted(q->displayName()));
// apply project settings
AnalyzerProjectSettings *analyzerSettings = runConfiguration->extraAspect<AnalyzerProjectSettings>();
CallgrindProjectSettings *settings = analyzerSettings->subConfig<CallgrindProjectSettings>();
QTC_ASSERT(settings, return engine)
QTC_ASSERT(m_visualisation, return engine);
m_visualisation->setMinimumInclusiveCostRatio(settings->visualisationMinimumInclusiveCostRatio() / 100.0);
m_proxyModel->setMinimumInclusiveCostRatio(settings->minimumInclusiveCostRatio() / 100.0);
m_dataModel->setVerboseToolTipsEnabled(settings->enableEventToolTips());
return engine;
}
void CallgrindTool::startTool(StartMode mode)
{
ValgrindPlugin::startValgrindTool(this, mode);
}
QWidget *CallgrindTool::createControlWidget()
{
return d->createControlWidget();
}
QWidget *CallgrindToolPrivate::createControlWidget()
{
//
// Control Widget
//
QAction *action = 0;
QWidget *widget = new QWidget;
QHBoxLayout *layout = new QHBoxLayout;
+1 -1
View File
@@ -58,7 +58,7 @@ public:
Analyzer::IAnalyzerEngine *createEngine(const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration = 0);
QWidget *createControlWidget();
QWidget *createWidgets();
void startTool(Analyzer::StartMode mode);
+7 -16
View File
@@ -232,8 +232,6 @@ void MemcheckTool::settingsDestroyed(QObject *settings)
void MemcheckTool::maybeActiveRunConfigurationChanged()
{
ensureWidgets();
AnalyzerSettings *settings = 0;
ProjectExplorer::ProjectExplorerPlugin *pe = ProjectExplorer::ProjectExplorerPlugin::instance();
if (ProjectExplorer::Project *project = pe->startupProject()) {
@@ -355,15 +353,10 @@ private:
QStringList m_projectFiles;
};
void MemcheckTool::initializeDockWidgets()
{
ensureWidgets();
}
void MemcheckTool::ensureWidgets()
QWidget *MemcheckTool::createWidgets()
{
if (m_errorView)
return;
QTC_ASSERT(!m_errorView, return 0);
Utils::FancyMainWindow *mw = AnalyzerManager::mainWindow();
@@ -391,12 +384,10 @@ void MemcheckTool::ensureWidgets()
connect(ProjectExplorer::ProjectExplorerPlugin::instance(),
SIGNAL(updateRunActions()), SLOT(maybeActiveRunConfigurationChanged()));
}
QWidget *MemcheckTool::createControlWidget()
{
ensureWidgets();
//
// The Control Widget.
//
QAction *action = 0;
QHBoxLayout *layout = new QHBoxLayout;
QToolButton *button = 0;
@@ -519,7 +510,7 @@ void MemcheckTool::internalParserError(const QString &errorString)
void MemcheckTool::clearErrorView()
{
ensureWidgets();
QTC_ASSERT(m_errorView, return);
m_errorModel->clear();
qDeleteAll(m_suppressionActions);
@@ -529,7 +520,7 @@ void MemcheckTool::clearErrorView()
void MemcheckTool::updateErrorFilter()
{
ensureWidgets();
QTC_ASSERT(m_errorView, return);
QTC_ASSERT(m_settings, return);
AbstractMemcheckSettings *memcheckSettings = m_settings->subConfig<AbstractMemcheckSettings>();
+1 -3
View File
@@ -111,10 +111,8 @@ private slots:
private:
ToolMode toolMode() const;
void ensureWidgets();
void initializeDockWidgets();
void extensionsInitialized() {}
QWidget *createControlWidget();
QWidget *createWidgets();
Analyzer::IAnalyzerEngine *createEngine(const Analyzer::AnalyzerStartParameters &sp,
ProjectExplorer::RunConfiguration *runConfiguration = 0);