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-19 12:25:16 +02:00
|
|
|
static const char settingsGroup[] = "CppTools/Completion";
|
2016-05-02 09:10:39 +02:00
|
|
|
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";
|
2016-04-28 12:51:34 +02:00
|
|
|
static const char animateAutoCompleteKey[] = "AnimateAutoComplete";
|
2016-06-01 10:19:59 +02:00
|
|
|
static const char highlightAutoCompleteKey[] = "HighlightAutoComplete";
|
2016-06-10 15:13:38 +02:00
|
|
|
static const char skipAutoCompleteKey[] = "SkipAutoComplete";
|
2016-06-14 08:00:32 +02:00
|
|
|
static const char autoRemoveKey[] = "AutoRemove";
|
2010-05-10 18:30:09 +02:00
|
|
|
|
|
|
|
|
using namespace TextEditor;
|
|
|
|
|
|
2016-05-19 12:25:16 +02:00
|
|
|
void CompletionSettings::toSettings(QSettings *s) const
|
2010-05-10 18:30:09 +02:00
|
|
|
{
|
2016-05-19 12:25:16 +02:00
|
|
|
s->beginGroup(settingsGroup);
|
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);
|
2016-04-28 12:51:34 +02:00
|
|
|
s->setValue(animateAutoCompleteKey, m_animateAutoComplete);
|
2016-06-01 10:19:59 +02:00
|
|
|
s->setValue(highlightAutoCompleteKey, m_highlightAutoComplete);
|
2016-06-10 15:13:38 +02:00
|
|
|
s->setValue(skipAutoCompleteKey, m_skipAutoCompletedText);
|
2016-06-14 08:00:32 +02:00
|
|
|
s->setValue(autoRemoveKey, m_autoRemove);
|
2010-05-10 18:30:09 +02:00
|
|
|
s->endGroup();
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-19 12:25:16 +02:00
|
|
|
void CompletionSettings::fromSettings(QSettings *s)
|
2010-05-10 18:30:09 +02:00
|
|
|
{
|
|
|
|
|
*this = CompletionSettings(); // Assign defaults
|
|
|
|
|
|
2016-05-19 12:25:16 +02:00
|
|
|
s->beginGroup(settingsGroup);
|
2016-05-02 09:10:39 +02:00
|
|
|
m_caseSensitivity = (CaseSensitivity)
|
2016-05-19 12:25:16 +02:00
|
|
|
s->value(caseSensitivityKey, m_caseSensitivity).toInt();
|
2016-05-02 09:10:39 +02:00
|
|
|
m_completionTrigger = (CompletionTrigger)
|
2016-05-19 12:25:16 +02:00
|
|
|
s->value(completionTriggerKey, m_completionTrigger).toInt();
|
2016-05-02 09:10:39 +02:00
|
|
|
m_automaticProposalTimeoutInMs =
|
2016-05-19 12:25:16 +02:00
|
|
|
s->value(automaticProposalTimeoutKey, m_automaticProposalTimeoutInMs).toInt();
|
2016-05-02 09:10:39 +02:00
|
|
|
m_autoInsertBrackets =
|
2016-05-19 12:25:16 +02:00
|
|
|
s->value(autoInsertBracesKey, m_autoInsertBrackets).toBool();
|
2016-05-02 09:10:39 +02:00
|
|
|
m_surroundingAutoBrackets =
|
2016-05-19 12:25:16 +02:00
|
|
|
s->value(surroundingAutoBracketsKey, m_surroundingAutoBrackets).toBool();
|
2016-05-02 09:10:39 +02:00
|
|
|
m_autoInsertQuotes =
|
2016-05-19 12:25:16 +02:00
|
|
|
s->value(autoInsertQuotesKey, m_autoInsertQuotes).toBool();
|
2016-05-02 09:10:39 +02:00
|
|
|
m_surroundingAutoQuotes =
|
2016-05-19 12:25:16 +02:00
|
|
|
s->value(surroundingAutoQuotesKey, m_surroundingAutoQuotes).toBool();
|
2016-05-02 09:10:39 +02:00
|
|
|
m_partiallyComplete =
|
2016-05-19 12:25:16 +02:00
|
|
|
s->value(partiallyCompleteKey, m_partiallyComplete).toBool();
|
2016-05-02 09:10:39 +02:00
|
|
|
m_spaceAfterFunctionName =
|
2016-05-19 12:25:16 +02:00
|
|
|
s->value(spaceAfterFunctionNameKey, m_spaceAfterFunctionName).toBool();
|
2016-05-02 09:10:39 +02:00
|
|
|
m_autoSplitStrings =
|
2016-05-19 12:25:16 +02:00
|
|
|
s->value(autoSplitStringsKey, m_autoSplitStrings).toBool();
|
2016-04-28 12:51:34 +02:00
|
|
|
m_animateAutoComplete =
|
|
|
|
|
s->value(animateAutoCompleteKey, m_animateAutoComplete).toBool();
|
2016-06-01 10:19:59 +02:00
|
|
|
m_highlightAutoComplete =
|
|
|
|
|
s->value(highlightAutoCompleteKey, m_highlightAutoComplete).toBool();
|
2016-06-10 15:13:38 +02:00
|
|
|
m_skipAutoCompletedText =
|
|
|
|
|
s->value(skipAutoCompleteKey, m_skipAutoCompletedText).toBool();
|
2016-06-14 08:00:32 +02:00
|
|
|
m_autoRemove =
|
|
|
|
|
s->value(autoRemoveKey, m_autoRemove).toBool();
|
2016-05-19 12:25:16 +02:00
|
|
|
s->endGroup();
|
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
|
2016-04-28 12:51:34 +02:00
|
|
|
&& m_animateAutoComplete == cs.m_animateAutoComplete
|
2016-06-01 10:19:59 +02:00
|
|
|
&& m_highlightAutoComplete == cs.m_highlightAutoComplete
|
2016-06-10 15:13:38 +02:00
|
|
|
&& m_skipAutoCompletedText == cs.m_skipAutoCompletedText
|
2016-06-14 08:00:32 +02:00
|
|
|
&& m_autoRemove == cs.m_autoRemove
|
2010-05-10 18:30:09 +02:00
|
|
|
;
|
|
|
|
|
}
|