2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-05-10 18:30:09 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2010-05-10 18:30:09 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-05-10 18:30:09 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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.
|
2010-05-10 18:30:09 +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.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2010-05-10 18:30:09 +02:00
|
|
|
|
|
|
|
|
#include "completionsettings.h"
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QSettings>
|
2010-05-10 18:30:09 +02:00
|
|
|
|
2011-05-10 15:19:38 +02:00
|
|
|
static const char groupPostfix[] = "Completion";
|
|
|
|
|
static const char caseSensitivityKey[] = "CaseSensitivity";
|
|
|
|
|
static const char completionTriggerKey[] = "CompletionTrigger";
|
2014-12-05 09:59:15 +01:00
|
|
|
static const char automaticProposalTimeoutKey[] = "AutomaticProposalTimeout";
|
2011-05-10 15:19:38 +02:00
|
|
|
static const char autoInsertBracesKey[] = "AutoInsertBraces";
|
2011-09-14 12:14:15 +02:00
|
|
|
static const char surroundingAutoBracketsKey[] = "SurroundingAutoBrackets";
|
2016-04-14 09:00:05 +02:00
|
|
|
static const char autoInsertQuotesKey[] = "AutoInsertQuotes";
|
|
|
|
|
static const char surroundingAutoQuotesKey[] = "SurroundingAutoQuotes";
|
2011-05-10 15:19:38 +02:00
|
|
|
static const char partiallyCompleteKey[] = "PartiallyComplete";
|
|
|
|
|
static const char spaceAfterFunctionNameKey[] = "SpaceAfterFunctionName";
|
2014-09-29 18:19:38 +02:00
|
|
|
static const char autoSplitStringsKey[] = "AutoSplitStrings";
|
2010-05-10 18:30:09 +02:00
|
|
|
|
|
|
|
|
using namespace TextEditor;
|
|
|
|
|
|
|
|
|
|
CompletionSettings::CompletionSettings()
|
2010-05-27 14:12:28 +02:00
|
|
|
: m_caseSensitivity(CaseInsensitive)
|
2010-07-15 16:05:43 +02:00
|
|
|
, m_completionTrigger(AutomaticCompletion)
|
2014-12-05 09:59:15 +01:00
|
|
|
, m_automaticProposalTimeoutInMs(400)
|
2010-05-10 18:30:09 +02:00
|
|
|
, m_autoInsertBrackets(true)
|
2011-09-14 12:14:15 +02:00
|
|
|
, m_surroundingAutoBrackets(true)
|
2016-04-14 09:00:05 +02:00
|
|
|
, m_autoInsertQuotes(true)
|
|
|
|
|
, m_surroundingAutoQuotes(true)
|
2010-05-10 18:30:09 +02:00
|
|
|
, m_partiallyComplete(true)
|
|
|
|
|
, m_spaceAfterFunctionName(false)
|
2014-09-29 18:19:38 +02:00
|
|
|
, m_autoSplitStrings(true)
|
2010-05-10 18:30:09 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CompletionSettings::toSettings(const QString &category, QSettings *s) const
|
|
|
|
|
{
|
|
|
|
|
QString group = QLatin1String(groupPostfix);
|
|
|
|
|
if (!category.isEmpty())
|
|
|
|
|
group.insert(0, category);
|
|
|
|
|
|
|
|
|
|
s->beginGroup(group);
|
|
|
|
|
s->setValue(QLatin1String(caseSensitivityKey), (int) m_caseSensitivity);
|
2010-07-15 16:05:43 +02:00
|
|
|
s->setValue(QLatin1String(completionTriggerKey), (int) m_completionTrigger);
|
2014-12-05 09:59:15 +01:00
|
|
|
s->setValue(QLatin1String(automaticProposalTimeoutKey), m_automaticProposalTimeoutInMs);
|
2010-05-10 18:30:09 +02:00
|
|
|
s->setValue(QLatin1String(autoInsertBracesKey), m_autoInsertBrackets);
|
2011-09-14 12:14:15 +02:00
|
|
|
s->setValue(QLatin1String(surroundingAutoBracketsKey), m_surroundingAutoBrackets);
|
2016-04-14 09:00:05 +02:00
|
|
|
s->setValue(QLatin1String(autoInsertQuotesKey), m_autoInsertQuotes);
|
|
|
|
|
s->setValue(QLatin1String(surroundingAutoQuotesKey), m_surroundingAutoQuotes);
|
2010-05-10 18:30:09 +02:00
|
|
|
s->setValue(QLatin1String(partiallyCompleteKey), m_partiallyComplete);
|
|
|
|
|
s->setValue(QLatin1String(spaceAfterFunctionNameKey), m_spaceAfterFunctionName);
|
2014-09-29 18:19:38 +02:00
|
|
|
s->setValue(QLatin1String(autoSplitStringsKey), m_autoSplitStrings);
|
2010-05-10 18:30:09 +02:00
|
|
|
s->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CompletionSettings::fromSettings(const QString &category, const QSettings *s)
|
|
|
|
|
{
|
|
|
|
|
QString group = QLatin1String(groupPostfix);
|
|
|
|
|
if (!category.isEmpty())
|
|
|
|
|
group.insert(0, category);
|
|
|
|
|
group += QLatin1Char('/');
|
|
|
|
|
|
|
|
|
|
*this = CompletionSettings(); // Assign defaults
|
|
|
|
|
|
|
|
|
|
m_caseSensitivity = (CaseSensitivity) s->value(group + QLatin1String(caseSensitivityKey), m_caseSensitivity).toInt();
|
2010-07-15 16:05:43 +02:00
|
|
|
m_completionTrigger = (CompletionTrigger) s->value(group + QLatin1String(completionTriggerKey), m_completionTrigger).toInt();
|
2014-12-05 09:59:15 +01:00
|
|
|
m_automaticProposalTimeoutInMs = s->value(group + QLatin1String(automaticProposalTimeoutKey), m_automaticProposalTimeoutInMs).toInt();
|
2010-05-10 18:30:09 +02:00
|
|
|
m_autoInsertBrackets = s->value(group + QLatin1String(autoInsertBracesKey), m_autoInsertBrackets).toBool();
|
2011-09-14 12:14:15 +02:00
|
|
|
m_surroundingAutoBrackets = s->value(group + QLatin1String(surroundingAutoBracketsKey), m_surroundingAutoBrackets).toBool();
|
2016-04-14 09:00:05 +02:00
|
|
|
m_autoInsertQuotes = s->value(group + QLatin1String(autoInsertQuotesKey), m_autoInsertQuotes).toBool();
|
|
|
|
|
m_surroundingAutoQuotes = s->value(group + QLatin1String(surroundingAutoQuotesKey), m_surroundingAutoQuotes).toBool();
|
2010-05-10 18:30:09 +02:00
|
|
|
m_partiallyComplete = s->value(group + QLatin1String(partiallyCompleteKey), m_partiallyComplete).toBool();
|
|
|
|
|
m_spaceAfterFunctionName = s->value(group + QLatin1String(spaceAfterFunctionNameKey), m_spaceAfterFunctionName).toBool();
|
2014-09-29 18:19:38 +02:00
|
|
|
m_autoSplitStrings = s->value(group + QLatin1String(autoSplitStringsKey), m_autoSplitStrings).toBool();
|
2010-05-10 18:30:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CompletionSettings::equals(const CompletionSettings &cs) const
|
|
|
|
|
{
|
|
|
|
|
return m_caseSensitivity == cs.m_caseSensitivity
|
2010-07-15 16:05:43 +02:00
|
|
|
&& m_completionTrigger == cs.m_completionTrigger
|
2014-12-05 09:59:15 +01:00
|
|
|
&& m_automaticProposalTimeoutInMs == cs.m_automaticProposalTimeoutInMs
|
2010-05-10 18:30:09 +02:00
|
|
|
&& m_autoInsertBrackets == cs.m_autoInsertBrackets
|
2011-09-14 12:14:15 +02:00
|
|
|
&& m_surroundingAutoBrackets == cs.m_surroundingAutoBrackets
|
2016-04-14 09:00:05 +02:00
|
|
|
&& m_autoInsertQuotes == cs.m_autoInsertQuotes
|
|
|
|
|
&& m_surroundingAutoQuotes == cs.m_surroundingAutoQuotes
|
2010-05-10 18:30:09 +02:00
|
|
|
&& m_partiallyComplete == cs.m_partiallyComplete
|
|
|
|
|
&& m_spaceAfterFunctionName == cs.m_spaceAfterFunctionName
|
2014-09-29 18:19:38 +02:00
|
|
|
&& m_autoSplitStrings == cs.m_autoSplitStrings
|
2010-05-10 18:30:09 +02:00
|
|
|
;
|
|
|
|
|
}
|