forked from qt-creator/qt-creator
Analyzer: Use toolId instead of AnalyzerAction when sufficient
Less code. Change-Id: I62ef8f9a87e57d109673bd7ae0ca945440961e78 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -151,8 +151,8 @@ public:
|
|||||||
void selectAction(AnalyzerAction *action);
|
void selectAction(AnalyzerAction *action);
|
||||||
void handleToolStarted();
|
void handleToolStarted();
|
||||||
void handleToolFinished();
|
void handleToolFinished();
|
||||||
void saveToolSettings(AnalyzerAction *action);
|
void saveToolSettings(Id toolId);
|
||||||
void loadToolSettings(AnalyzerAction *action);
|
void loadToolSettings(Id toolId);
|
||||||
|
|
||||||
// Convenience.
|
// Convenience.
|
||||||
bool isActionRunnable(AnalyzerAction *action) const;
|
bool isActionRunnable(AnalyzerAction *action) const;
|
||||||
@@ -496,7 +496,7 @@ void AnalyzerManagerPrivate::selectAction(AnalyzerAction *action)
|
|||||||
|
|
||||||
// Clean up old tool.
|
// Clean up old tool.
|
||||||
if (m_currentAction) {
|
if (m_currentAction) {
|
||||||
saveToolSettings(m_currentAction);
|
saveToolSettings(m_currentAction->toolId());
|
||||||
foreach (QDockWidget *widget, m_toolWidgets.value(m_currentAction->toolId()))
|
foreach (QDockWidget *widget, m_toolWidgets.value(m_currentAction->toolId()))
|
||||||
deactivateDock(widget);
|
deactivateDock(widget);
|
||||||
}
|
}
|
||||||
@@ -516,7 +516,7 @@ void AnalyzerManagerPrivate::selectAction(AnalyzerAction *action)
|
|||||||
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);
|
||||||
|
|
||||||
loadToolSettings(action);
|
loadToolSettings(action->toolId());
|
||||||
|
|
||||||
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));
|
||||||
@@ -556,29 +556,28 @@ void AnalyzerManagerPrivate::handleToolFinished()
|
|||||||
updateRunActions();
|
updateRunActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnalyzerManagerPrivate::loadToolSettings(AnalyzerAction *action)
|
void AnalyzerManagerPrivate::loadToolSettings(Id toolId)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_mainWindow, return);
|
QTC_ASSERT(m_mainWindow, return);
|
||||||
QSettings *settings = ICore::settings();
|
QSettings *settings = ICore::settings();
|
||||||
settings->beginGroup(QLatin1String("AnalyzerViewSettings_") + action->toolId().toString());
|
settings->beginGroup(QLatin1String("AnalyzerViewSettings_") + toolId.toString());
|
||||||
if (settings->value(QLatin1String("ToolSettingsSaved"), false).toBool())
|
if (settings->value(QLatin1String("ToolSettingsSaved"), false).toBool())
|
||||||
m_mainWindow->restoreSettings(settings);
|
m_mainWindow->restoreSettings(settings);
|
||||||
else
|
else
|
||||||
m_mainWindow->restoreSettings(m_defaultSettings.value(action->toolId()));
|
m_mainWindow->restoreSettings(m_defaultSettings.value(toolId));
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnalyzerManagerPrivate::saveToolSettings(AnalyzerAction *action)
|
void AnalyzerManagerPrivate::saveToolSettings(Id toolId)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(action, return);
|
|
||||||
QTC_ASSERT(m_mainWindow, return);
|
QTC_ASSERT(m_mainWindow, return);
|
||||||
|
|
||||||
QSettings *settings = ICore::settings();
|
QSettings *settings = ICore::settings();
|
||||||
settings->beginGroup(QLatin1String("AnalyzerViewSettings_") + action->toolId().toString());
|
settings->beginGroup(QLatin1String("AnalyzerViewSettings_") + toolId.toString());
|
||||||
m_mainWindow->saveSettings(settings);
|
m_mainWindow->saveSettings(settings);
|
||||||
settings->setValue(QLatin1String("ToolSettingsSaved"), true);
|
settings->setValue(QLatin1String("ToolSettingsSaved"), true);
|
||||||
settings->endGroup();
|
settings->endGroup();
|
||||||
settings->setValue(QLatin1String(LAST_ACTIVE_TOOL), action->toolId().toString());
|
settings->setValue(QLatin1String(LAST_ACTIVE_TOOL), toolId.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnalyzerManagerPrivate::updateRunActions()
|
void AnalyzerManagerPrivate::updateRunActions()
|
||||||
@@ -625,7 +624,7 @@ AnalyzerManager::~AnalyzerManager()
|
|||||||
void AnalyzerManager::shutdown()
|
void AnalyzerManager::shutdown()
|
||||||
{
|
{
|
||||||
if (d->m_currentAction)
|
if (d->m_currentAction)
|
||||||
d->saveToolSettings(d->m_currentAction);
|
d->saveToolSettings(d->m_currentAction->toolId());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnalyzerManager::addAction(AnalyzerAction *action)
|
void AnalyzerManager::addAction(AnalyzerAction *action)
|
||||||
|
Reference in New Issue
Block a user