2011-03-04 12:15:18 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator Instrumentation Tools
|
|
|
|
|
**
|
|
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
|
|
**
|
|
|
|
|
** Author: Milian Wolff, KDAB (milian.wolff@kdab.com)
|
|
|
|
|
**
|
|
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
|
|
|
**
|
|
|
|
|
** No Commercial Usage
|
|
|
|
|
**
|
|
|
|
|
** This file contains pre-release code and may not be distributed.
|
|
|
|
|
** You may use this file in accordance with the terms and conditions
|
|
|
|
|
** contained in the Technology Preview License Agreement accompanying
|
|
|
|
|
** this package.
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
|
|
|
|
** If you have questions regarding the use of this file, please contact
|
|
|
|
|
** Nokia at qt-info@nokia.com.
|
|
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "analyzersettings.h"
|
|
|
|
|
|
|
|
|
|
#include "analyzermanager.h"
|
|
|
|
|
#include "ianalyzertool.h"
|
|
|
|
|
#include "analyzerplugin.h"
|
|
|
|
|
#include "analyzeroptionspage.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <valgrind/xmlprotocol/error.h>
|
|
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
2011-03-08 13:56:52 +01:00
|
|
|
#include <QtCore/QSettings>
|
2011-03-04 12:15:18 +01:00
|
|
|
|
|
|
|
|
using namespace Analyzer;
|
|
|
|
|
using namespace Analyzer::Internal;
|
|
|
|
|
|
|
|
|
|
static const QLatin1String groupC("Analyzer");
|
|
|
|
|
|
|
|
|
|
AnalyzerGlobalSettings *AnalyzerGlobalSettings::m_instance = 0;
|
|
|
|
|
|
2011-03-04 16:00:01 +01:00
|
|
|
AbstractAnalyzerSubConfig::AbstractAnalyzerSubConfig(QObject *parent)
|
|
|
|
|
: QObject(parent)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AbstractAnalyzerSubConfig::~AbstractAnalyzerSubConfig()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-04 16:00:01 +01:00
|
|
|
AnalyzerSettings::AnalyzerSettings(QObject *parent)
|
|
|
|
|
: QObject(parent)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AnalyzerSettings::~AnalyzerSettings()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AnalyzerSettings::fromMap(const QVariantMap &map)
|
|
|
|
|
{
|
|
|
|
|
bool ret = true;
|
2011-03-04 16:00:01 +01:00
|
|
|
foreach(AbstractAnalyzerSubConfig *config, subConfigs()) {
|
2011-03-04 12:15:18 +01:00
|
|
|
ret = ret && config->fromMap(map);
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap AnalyzerSettings::defaults() const
|
|
|
|
|
{
|
|
|
|
|
QVariantMap map;
|
2011-03-04 16:00:01 +01:00
|
|
|
foreach(AbstractAnalyzerSubConfig *config, subConfigs()) {
|
2011-03-04 12:15:18 +01:00
|
|
|
map.unite(config->defaults());
|
|
|
|
|
}
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap AnalyzerSettings::toMap() const
|
|
|
|
|
{
|
|
|
|
|
QVariantMap map;
|
2011-03-04 16:00:01 +01:00
|
|
|
foreach(AbstractAnalyzerSubConfig *config, subConfigs()) {
|
2011-03-04 12:15:18 +01:00
|
|
|
map.unite(config->toMap());
|
|
|
|
|
}
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-04 16:00:01 +01:00
|
|
|
AnalyzerGlobalSettings::AnalyzerGlobalSettings(QObject *parent)
|
|
|
|
|
: AnalyzerSettings(parent)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
|
|
|
|
QTC_ASSERT(!m_instance, return);
|
|
|
|
|
m_instance = this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AnalyzerGlobalSettings *AnalyzerGlobalSettings::instance()
|
|
|
|
|
{
|
|
|
|
|
if (!m_instance)
|
2011-03-04 16:00:01 +01:00
|
|
|
m_instance = new AnalyzerGlobalSettings(AnalyzerPlugin::instance());
|
|
|
|
|
|
2011-03-04 12:15:18 +01:00
|
|
|
return m_instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AnalyzerGlobalSettings::~AnalyzerGlobalSettings()
|
|
|
|
|
{
|
|
|
|
|
qDeleteAll(m_subConfigFactories);
|
|
|
|
|
m_instance = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AnalyzerGlobalSettings::readSettings()
|
|
|
|
|
{
|
|
|
|
|
QSettings *settings = Core::ICore::instance()->settings();
|
|
|
|
|
|
|
|
|
|
QVariantMap map;
|
|
|
|
|
|
|
|
|
|
settings->beginGroup(groupC);
|
|
|
|
|
// read the values from config, using the keys from the defaults value map
|
|
|
|
|
const QVariantMap def = defaults();
|
|
|
|
|
for (QVariantMap::ConstIterator it = def.constBegin(); it != def.constEnd(); ++it)
|
|
|
|
|
map.insert(it.key(), settings->value(it.key(), it.value()));
|
|
|
|
|
settings->endGroup();
|
|
|
|
|
|
|
|
|
|
// apply the values to our member variables
|
|
|
|
|
fromMap(map);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AnalyzerGlobalSettings::writeSettings() const
|
|
|
|
|
{
|
|
|
|
|
QSettings *settings = Core::ICore::instance()->settings();
|
|
|
|
|
settings->beginGroup(groupC);
|
|
|
|
|
const QVariantMap map = toMap();
|
|
|
|
|
for (QVariantMap::ConstIterator it = map.begin(); it != map.end(); ++it)
|
|
|
|
|
settings->setValue(it.key(), it.value());
|
|
|
|
|
settings->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AnalyzerGlobalSettings::registerSubConfigFactory(AbstractAnalyzerSubConfigFactory *factory)
|
|
|
|
|
{
|
|
|
|
|
m_subConfigFactories << factory;
|
|
|
|
|
|
2011-03-04 16:00:01 +01:00
|
|
|
AbstractAnalyzerSubConfig *config = factory->createGlobalSubConfig(this);
|
2011-03-04 12:15:18 +01:00
|
|
|
addSubConfig(config);
|
|
|
|
|
AnalyzerPlugin::instance()->addAutoReleasedObject(new AnalyzerOptionsPage(config));
|
|
|
|
|
|
|
|
|
|
readSettings();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<AbstractAnalyzerSubConfigFactory *> AnalyzerGlobalSettings::subConfigFactories() const
|
|
|
|
|
{
|
|
|
|
|
return m_subConfigFactories;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-04 16:00:01 +01:00
|
|
|
AnalyzerProjectSettings::AnalyzerProjectSettings(QObject *parent)
|
|
|
|
|
: AnalyzerSettings(parent)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
|
|
|
|
// add sub configs
|
|
|
|
|
foreach(AbstractAnalyzerSubConfigFactory *factory, AnalyzerGlobalSettings::instance()->subConfigFactories()) {
|
2011-03-04 16:00:01 +01:00
|
|
|
addSubConfig(factory->createProjectSubConfig(parent));
|
2011-03-04 12:15:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// take defaults from global settings
|
|
|
|
|
AnalyzerGlobalSettings *gs = AnalyzerGlobalSettings::instance();
|
|
|
|
|
fromMap(gs->toMap());
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-04 16:00:01 +01:00
|
|
|
AnalyzerProjectSettings::~AnalyzerProjectSettings()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-04 12:15:18 +01:00
|
|
|
QString AnalyzerProjectSettings::displayName() const
|
|
|
|
|
{
|
|
|
|
|
return tr("Analyzer Settings");
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-04 16:00:01 +01:00
|
|
|
bool AnalyzerProjectSettings::fromMap(const QVariantMap &map)
|
2011-03-04 12:15:18 +01:00
|
|
|
{
|
|
|
|
|
return AnalyzerSettings::fromMap(map);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QVariantMap AnalyzerProjectSettings::toMap() const
|
|
|
|
|
{
|
|
|
|
|
return AnalyzerSettings::toMap();
|
|
|
|
|
}
|