2013-09-06 13:14:15 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2013-09-06 13:14:15 +02:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2013-09-06 13:14:15 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2013-09-06 13:14:15 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "cppcodemodelsettings.h"
|
|
|
|
|
#include "cpptoolsconstants.h"
|
|
|
|
|
|
2015-11-11 10:47:27 +01:00
|
|
|
#include <QSettings>
|
|
|
|
|
|
2013-09-06 13:14:15 +02:00
|
|
|
using namespace CppTools;
|
|
|
|
|
|
2013-12-10 14:32:09 +01:00
|
|
|
static QLatin1String cppHeaderMimeType(Constants::CPP_HEADER_MIMETYPE);
|
|
|
|
|
static QLatin1String cHeaderMimeType(Constants::C_HEADER_MIMETYPE);
|
2015-11-10 16:54:53 +01:00
|
|
|
static QLatin1String clangExtraOptionsKey(Constants::CPPTOOLS_EXTRA_CLANG_OPTIONS);
|
2013-12-10 14:32:09 +01:00
|
|
|
|
2013-09-06 13:14:15 +02:00
|
|
|
void CppCodeModelSettings::fromSettings(QSettings *s)
|
|
|
|
|
{
|
|
|
|
|
s->beginGroup(QLatin1String(Constants::CPPTOOLS_SETTINGSGROUP));
|
2015-06-02 17:25:41 +02:00
|
|
|
|
2015-11-10 16:54:53 +01:00
|
|
|
setExtraClangOptions(s->value(clangExtraOptionsKey, defaultExtraClangOptions()).toStringList());
|
|
|
|
|
|
2013-09-30 13:36:01 +02:00
|
|
|
QVariant v = s->value(QLatin1String(Constants::CPPTOOLS_MODEL_MANAGER_PCH_USAGE), PchUse_None);
|
|
|
|
|
setPCHUsage(static_cast<PCHUsage>(v.toInt()));
|
2013-09-06 13:14:15 +02:00
|
|
|
s->endGroup();
|
2015-05-08 15:48:17 +02:00
|
|
|
|
|
|
|
|
emit changed();
|
2013-09-06 13:14:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CppCodeModelSettings::toSettings(QSettings *s)
|
|
|
|
|
{
|
|
|
|
|
s->beginGroup(QLatin1String(Constants::CPPTOOLS_SETTINGSGROUP));
|
2015-11-11 10:47:27 +01:00
|
|
|
|
2015-11-10 16:54:53 +01:00
|
|
|
s->setValue(clangExtraOptionsKey, extraClangOptions());
|
2013-09-30 13:36:01 +02:00
|
|
|
s->setValue(QLatin1String(Constants::CPPTOOLS_MODEL_MANAGER_PCH_USAGE), pchUsage());
|
2013-09-06 13:14:15 +02:00
|
|
|
|
2015-11-11 10:47:27 +01:00
|
|
|
s->endGroup();
|
2015-06-02 17:25:41 +02:00
|
|
|
|
2015-05-08 15:48:17 +02:00
|
|
|
emit changed();
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-10 16:54:53 +01:00
|
|
|
QStringList CppCodeModelSettings::defaultExtraClangOptions()
|
|
|
|
|
{
|
|
|
|
|
return {
|
|
|
|
|
QStringLiteral("-Weverything"),
|
|
|
|
|
QStringLiteral("-Wno-c++98-compat"),
|
|
|
|
|
QStringLiteral("-Wno-c++98-compat-pedantic"),
|
|
|
|
|
QStringLiteral("-Wno-unused-macros"),
|
|
|
|
|
QStringLiteral("-Wno-newline-eof"),
|
|
|
|
|
QStringLiteral("-Wno-exit-time-destructors"),
|
|
|
|
|
QStringLiteral("-Wno-global-constructors"),
|
|
|
|
|
QStringLiteral("-Wno-gnu-zero-variadic-macro-arguments"),
|
|
|
|
|
QStringLiteral("-Wno-documentation"),
|
|
|
|
|
QStringLiteral("-Wno-shadow"),
|
|
|
|
|
QStringLiteral("-Wno-missing-prototypes"), // Not optimal for C projects.
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QStringList CppCodeModelSettings::extraClangOptions() const
|
|
|
|
|
{
|
|
|
|
|
return m_extraClangOptions;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CppCodeModelSettings::setExtraClangOptions(const QStringList &extraClangOptions)
|
|
|
|
|
{
|
|
|
|
|
m_extraClangOptions = extraClangOptions;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-11 10:47:27 +01:00
|
|
|
CppCodeModelSettings::PCHUsage CppCodeModelSettings::pchUsage() const
|
2013-09-06 13:14:15 +02:00
|
|
|
{
|
2015-11-11 10:47:27 +01:00
|
|
|
return m_pchUsage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CppCodeModelSettings::setPCHUsage(CppCodeModelSettings::PCHUsage pchUsage)
|
|
|
|
|
{
|
|
|
|
|
m_pchUsage = pchUsage;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CppCodeModelSettings::emitChanged()
|
|
|
|
|
{
|
|
|
|
|
emit changed();
|
2013-09-06 13:14:15 +02:00
|
|
|
}
|