Analyzer: Have one status label per tool.

It does not make sense for all the analyzers to share a single status
label, as they are unrelated to each other.

Change-Id: I9cf885263853251f841ef96836860455905677ac
Reviewed-by: hjk <hjk@theqtcompany.com>
This commit is contained in:
Christian Kandeler
2015-07-01 12:31:27 +02:00
parent 7706a35b4a
commit 19253ded5e
5 changed files with 25 additions and 16 deletions

View File

@@ -173,10 +173,11 @@ public:
ActionContainer *m_menu; ActionContainer *m_menu;
QComboBox *m_toolBox; QComboBox *m_toolBox;
QStackedWidget *m_controlsStackWidget; QStackedWidget *m_controlsStackWidget;
StatusLabel *m_statusLabel; QStackedWidget *m_statusLabelsStackWidget;
typedef QMap<Id, FancyMainWindowSettings> MainWindowSettingsMap; typedef QMap<Id, FancyMainWindowSettings> MainWindowSettingsMap;
QHash<Id, QList<QDockWidget *> > m_toolWidgets; QHash<Id, QList<QDockWidget *> > m_toolWidgets;
QHash<Id, QWidget *> m_controlsWidgetFromTool; QHash<Id, QWidget *> m_controlsWidgetFromTool;
QHash<Id, StatusLabel *> m_statusLabelsPerTool;
MainWindowSettingsMap m_defaultSettings; MainWindowSettingsMap m_defaultSettings;
// list of dock widgets to prevent memory leak // list of dock widgets to prevent memory leak
@@ -198,7 +199,7 @@ AnalyzerManagerPrivate::AnalyzerManagerPrivate(AnalyzerManager *qq):
m_menu(0), m_menu(0),
m_toolBox(new QComboBox), m_toolBox(new QComboBox),
m_controlsStackWidget(new QStackedWidget), m_controlsStackWidget(new QStackedWidget),
m_statusLabel(new StatusLabel) m_statusLabelsStackWidget(new QStackedWidget)
{ {
m_toolBox->setObjectName(QLatin1String("AnalyzerManagerToolBox")); m_toolBox->setObjectName(QLatin1String("AnalyzerManagerToolBox"));
connect(m_toolBox, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::activated), connect(m_toolBox, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::activated),
@@ -352,7 +353,7 @@ void AnalyzerManagerPrivate::createModeMainWindow()
analyzeToolBarLayout->addWidget(new StyledSeparator); analyzeToolBarLayout->addWidget(new StyledSeparator);
analyzeToolBarLayout->addWidget(m_toolBox); analyzeToolBarLayout->addWidget(m_toolBox);
analyzeToolBarLayout->addWidget(m_controlsStackWidget); analyzeToolBarLayout->addWidget(m_controlsStackWidget);
analyzeToolBarLayout->addWidget(m_statusLabel); analyzeToolBarLayout->addWidget(m_statusLabelsStackWidget);
analyzeToolBarLayout->addStretch(); analyzeToolBarLayout->addStretch();
auto dock = new QDockWidget(tr("Analyzer Toolbar")); auto dock = new QDockWidget(tr("Analyzer Toolbar"));
@@ -493,6 +494,9 @@ void AnalyzerManagerPrivate::selectAction(AnalyzerAction *action)
QTC_CHECK(!m_controlsWidgetFromTool.contains(toolId)); QTC_CHECK(!m_controlsWidgetFromTool.contains(toolId));
m_controlsWidgetFromTool[toolId] = widget; m_controlsWidgetFromTool[toolId] = widget;
m_controlsStackWidget->addWidget(widget); m_controlsStackWidget->addWidget(widget);
StatusLabel * const toolStatusLabel = new StatusLabel;
m_statusLabelsPerTool[toolId] = toolStatusLabel;
m_statusLabelsStackWidget->addWidget(toolStatusLabel);
} }
foreach (QDockWidget *widget, m_toolWidgets.value(toolId)) foreach (QDockWidget *widget, m_toolWidgets.value(toolId))
activateDock(Qt::DockWidgetArea(widget->property(INITIAL_DOCK_AREA).toInt()), widget); activateDock(Qt::DockWidgetArea(widget->property(INITIAL_DOCK_AREA).toInt()), widget);
@@ -501,6 +505,7 @@ void AnalyzerManagerPrivate::selectAction(AnalyzerAction *action)
QTC_CHECK(m_controlsWidgetFromTool.contains(toolId)); QTC_CHECK(m_controlsWidgetFromTool.contains(toolId));
m_controlsStackWidget->setCurrentWidget(m_controlsWidgetFromTool.value(toolId)); m_controlsStackWidget->setCurrentWidget(m_controlsWidgetFromTool.value(toolId));
m_statusLabelsStackWidget->setCurrentWidget(m_statusLabelsPerTool.value(toolId));
m_toolBox->setCurrentIndex(toolboxIndex); m_toolBox->setCurrentIndex(toolboxIndex);
updateRunActions(); updateRunActions();
@@ -669,14 +674,16 @@ void AnalyzerManagerPrivate::resetLayout()
m_mainWindow->restoreSettings(m_defaultSettings.value(m_currentAction->toolId())); m_mainWindow->restoreSettings(m_defaultSettings.value(m_currentAction->toolId()));
} }
void AnalyzerManager::showStatusMessage(const QString &message, int timeoutMS) void AnalyzerManager::showStatusMessage(Id toolId, const QString &message, int timeoutMS)
{ {
d->m_statusLabel->showStatusMessage(message, timeoutMS); StatusLabel * const statusLabel = d->m_statusLabelsPerTool.value(toolId);
QTC_ASSERT(statusLabel, return);
statusLabel->showStatusMessage(message, timeoutMS);
} }
void AnalyzerManager::showPermanentStatusMessage(const QString &message) void AnalyzerManager::showPermanentStatusMessage(Id toolId, const QString &message)
{ {
showStatusMessage(message, -1); showStatusMessage(toolId, message, -1);
} }
void AnalyzerManager::showMode() void AnalyzerManager::showMode()

View File

@@ -78,8 +78,8 @@ public:
static void stopTool(); static void stopTool();
// Convenience functions. // Convenience functions.
static void showStatusMessage(const QString &message, int timeoutMS = 10000); static void showStatusMessage(Core::Id toolId, const QString &message, int timeoutMS = 10000);
static void showPermanentStatusMessage(const QString &message); static void showPermanentStatusMessage(Core::Id toolId, const QString &message);
static void handleToolStarted(); static void handleToolStarted();
static void handleToolFinished(); static void handleToolFinished();

View File

@@ -30,6 +30,7 @@
#include "callgrindengine.h" #include "callgrindengine.h"
#include "callgrindtool.h"
#include "valgrindsettings.h" #include "valgrindsettings.h"
#include <valgrind/callgrind/callgrindcontroller.h> #include <valgrind/callgrind/callgrindcontroller.h>
@@ -58,7 +59,7 @@ CallgrindRunControl::CallgrindRunControl(const AnalyzerStartParameters &sp,
void CallgrindRunControl::showStatusMessage(const QString &msg) void CallgrindRunControl::showStatusMessage(const QString &msg)
{ {
AnalyzerManager::showStatusMessage(msg); AnalyzerManager::showStatusMessage(CallgrindToolId, msg);
} }
QStringList CallgrindRunControl::toolArguments() const QStringList CallgrindRunControl::toolArguments() const

View File

@@ -834,7 +834,7 @@ void CallgrindToolPrivate::engineFinished()
if (data) if (data)
showParserResults(data); showParserResults(data);
else else
AnalyzerManager::showStatusMessage(tr("Profiling aborted.")); AnalyzerManager::showStatusMessage(CallgrindToolId, tr("Profiling aborted."));
setBusyCursor(false); setBusyCursor(false);
} }
@@ -853,7 +853,7 @@ void CallgrindToolPrivate::showParserResults(const ParseData *data)
} else { } else {
msg = tr("Parsing failed."); msg = tr("Parsing failed.");
} }
AnalyzerManager::showStatusMessage(msg); AnalyzerManager::showStatusMessage(CallgrindToolId, msg);
} }
void CallgrindToolPrivate::editorOpened(IEditor *editor) void CallgrindToolPrivate::editorOpened(IEditor *editor)
@@ -918,7 +918,7 @@ void CallgrindToolPrivate::loadExternalLogFile()
return; return;
} }
AnalyzerManager::showStatusMessage(tr("Parsing Profile Data...")); AnalyzerManager::showStatusMessage(CallgrindToolId, tr("Parsing Profile Data..."));
QCoreApplication::processEvents(); QCoreApplication::processEvents();
Parser parser; Parser parser;

View File

@@ -94,6 +94,7 @@ using namespace Valgrind::XmlProtocol;
namespace Valgrind { namespace Valgrind {
namespace Internal { namespace Internal {
const Core::Id MemcheckToolId = "Memcheck";
// ---------------------------- MemcheckErrorFilterProxyModel // ---------------------------- MemcheckErrorFilterProxyModel
MemcheckErrorFilterProxyModel::MemcheckErrorFilterProxyModel(QObject *parent) MemcheckErrorFilterProxyModel::MemcheckErrorFilterProxyModel(QObject *parent)
@@ -355,7 +356,7 @@ QWidget *MemcheckTool::createWidgets()
m_errorView->setObjectName(QLatin1String("Valgrind.MemcheckTool.ErrorView")); m_errorView->setObjectName(QLatin1String("Valgrind.MemcheckTool.ErrorView"));
m_errorView->setWindowTitle(tr("Memory Issues")); m_errorView->setWindowTitle(tr("Memory Issues"));
QDockWidget *errorDock = AnalyzerManager::createDockWidget("Memcheck", m_errorView); QDockWidget *errorDock = AnalyzerManager::createDockWidget(MemcheckToolId, m_errorView);
errorDock->show(); errorDock->show();
mw->splitDockWidget(mw->toolBarDockWidget(), errorDock, Qt::Vertical); mw->splitDockWidget(mw->toolBarDockWidget(), errorDock, Qt::Vertical);
@@ -575,7 +576,7 @@ MemcheckRunControl *MemcheckTool::createMemcheckRunControl(const AnalyzerStartPa
void MemcheckTool::engineFinished() void MemcheckTool::engineFinished()
{ {
const int issuesFound = updateUiAfterFinishedHelper(); const int issuesFound = updateUiAfterFinishedHelper();
AnalyzerManager::showStatusMessage(issuesFound > 0 AnalyzerManager::showStatusMessage(MemcheckToolId, issuesFound > 0
? AnalyzerManager::tr("Memory Analyzer Tool finished, %n issues were found.", 0, issuesFound) ? AnalyzerManager::tr("Memory Analyzer Tool finished, %n issues were found.", 0, issuesFound)
: AnalyzerManager::tr("Memory Analyzer Tool finished, no issues were found.")); : AnalyzerManager::tr("Memory Analyzer Tool finished, no issues were found."));
} }
@@ -583,7 +584,7 @@ void MemcheckTool::engineFinished()
void MemcheckTool::loadingExternalXmlLogFileFinished() void MemcheckTool::loadingExternalXmlLogFileFinished()
{ {
const int issuesFound = updateUiAfterFinishedHelper(); const int issuesFound = updateUiAfterFinishedHelper();
AnalyzerManager::showStatusMessage(issuesFound > 0 AnalyzerManager::showStatusMessage(MemcheckToolId, issuesFound > 0
? AnalyzerManager::tr("Log file processed, %n issues were found.", 0, issuesFound) ? AnalyzerManager::tr("Log file processed, %n issues were found.", 0, issuesFound)
: AnalyzerManager::tr("Log file processed, no issues were found.")); : AnalyzerManager::tr("Log file processed, no issues were found."));
} }