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
|
|
|
|
2016-05-02 09:10:39 +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";
|
2016-05-02 09:10:39 +02:00
|
|
|
static const char autoInsertBracesKey[] = "AutoInsertBraces";
|
|
|
|
|
static const char surroundingAutoBracketsKey[] = "SurroundingAutoBrackets";
|
|
|
|
|
static const char autoInsertQuotesKey[] = "AutoInsertQuotes";
|
|
|
|
|
static const char surroundingAutoQuotesKey[] = "SurroundingAutoQuotes";
|
|
|
|
|
static const char partiallyCompleteKey[] = "PartiallyComplete";
|
|
|
|
|
static const char spaceAfterFunctionNameKey[] = "SpaceAfterFunctionName";
|
|
|
|
|
static const char autoSplitStringsKey[] = "AutoSplitStrings";
|
2010-05-10 18:30:09 +02:00
|
|
|
|
|
|
|
|
using namespace TextEditor;
|
|
|
|
|
|
|
|
|
|
void CompletionSettings::toSettings(const QString &category, QSettings *s) const
|
|
|
|
|
{
|
2016-05-02 09:10:39 +02:00
|
|
|
QString group(groupPostfix);
|
2010-05-10 18:30:09 +02:00
|
|
|
if (!category.isEmpty())
|
|
|
|
|
group.insert(0, category);
|
|
|
|
|
|
|
|
|
|
s->beginGroup(group);
|
2016-05-02 09:10:39 +02:00
|
|
|
s->setValue(caseSensitivityKey, (int) m_caseSensitivity);
|
|
|
|
|
s->setValue(completionTriggerKey, (int) m_completionTrigger);
|
|
|
|
|
s->setValue(automaticProposalTimeoutKey, m_automaticProposalTimeoutInMs);
|
|
|
|
|
s->setValue(autoInsertBracesKey, m_autoInsertBrackets);
|
|
|
|
|
s->setValue(surroundingAutoBracketsKey, m_surroundingAutoBrackets);
|
|
|
|
|
s->setValue(autoInsertQuotesKey, m_autoInsertQuotes);
|
|
|
|
|
s->setValue(surroundingAutoQuotesKey, m_surroundingAutoQuotes);
|
|
|
|
|
s->setValue(partiallyCompleteKey, m_partiallyComplete);
|
|
|
|
|
s->setValue(spaceAfterFunctionNameKey, m_spaceAfterFunctionName);
|
|
|
|
|
s->setValue(autoSplitStringsKey, m_autoSplitStrings);
|
2010-05-10 18:30:09 +02:00
|
|
|
s->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CompletionSettings::fromSettings(const QString &category, const QSettings *s)
|
|
|
|
|
{
|
2016-05-02 09:10:39 +02:00
|
|
|
QString group(groupPostfix);
|
2010-05-10 18:30:09 +02:00
|
|
|
if (!category.isEmpty())
|
|
|
|
|
group.insert(0, category);
|
2016-05-02 09:10:39 +02:00
|
|
|
group += '/';
|
2010-05-10 18:30:09 +02:00
|
|
|
|
|
|
|
|
*this = CompletionSettings(); // Assign defaults
|
|
|
|
|
|
2016-05-02 09:10:39 +02:00
|
|
|
m_caseSensitivity = (CaseSensitivity)
|
|
|
|
|
s->value(group + caseSensitivityKey, m_caseSensitivity).toInt();
|
|
|
|
|
m_completionTrigger = (CompletionTrigger)
|
|
|
|
|
s->value(group + completionTriggerKey, m_completionTrigger).toInt();
|
|
|
|
|
m_automaticProposalTimeoutInMs =
|
|
|
|
|
s->value(group + automaticProposalTimeoutKey, m_automaticProposalTimeoutInMs).toInt();
|
|
|
|
|
m_autoInsertBrackets =
|
|
|
|
|
s->value(group + autoInsertBracesKey, m_autoInsertBrackets).toBool();
|
|
|
|
|
m_surroundingAutoBrackets =
|
|
|
|
|
s->value(group + surroundingAutoBracketsKey, m_surroundingAutoBrackets).toBool();
|
|
|
|
|
m_autoInsertQuotes =
|
|
|
|
|
s->value(group + autoInsertQuotesKey, m_autoInsertQuotes).toBool();
|
|
|
|
|
m_surroundingAutoQuotes =
|
|
|
|
|
s->value(group + surroundingAutoQuotesKey, m_surroundingAutoQuotes).toBool();
|
|
|
|
|
m_partiallyComplete =
|
|
|
|
|
s->value(group + partiallyCompleteKey, m_partiallyComplete).toBool();
|
|
|
|
|
m_spaceAfterFunctionName =
|
|
|
|
|
s->value(group + spaceAfterFunctionNameKey, m_spaceAfterFunctionName).toBool();
|
|
|
|
|
m_autoSplitStrings =
|
|
|
|
|
s->value(group + autoSplitStringsKey, m_autoSplitStrings).toBool();
|
2010-05-10 18:30:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CompletionSettings::equals(const CompletionSettings &cs) const
|
|
|
|
|
{
|
2016-05-02 09:10:39 +02:00
|
|
|
return m_caseSensitivity == cs.m_caseSensitivity
|
|
|
|
|
&& m_completionTrigger == cs.m_completionTrigger
|
|
|
|
|
&& m_automaticProposalTimeoutInMs == cs.m_automaticProposalTimeoutInMs
|
|
|
|
|
&& m_autoInsertBrackets == cs.m_autoInsertBrackets
|
|
|
|
|
&& m_surroundingAutoBrackets == cs.m_surroundingAutoBrackets
|
|
|
|
|
&& m_autoInsertQuotes == cs.m_autoInsertQuotes
|
|
|
|
|
&& m_surroundingAutoQuotes == cs.m_surroundingAutoQuotes
|
|
|
|
|
&& m_partiallyComplete == cs.m_partiallyComplete
|
|
|
|
|
&& m_spaceAfterFunctionName == cs.m_spaceAfterFunctionName
|
|
|
|
|
&& m_autoSplitStrings == cs.m_autoSplitStrings
|
2010-05-10 18:30:09 +02:00
|
|
|
;
|
|
|
|
|
}
|