2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-05-10 18:30:09 +02:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
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
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
2014-10-01 13:21:18 +02:00
|
|
|
** conditions see http://www.qt.io/licensing. For further information
|
|
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2010-05-10 18:30:09 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
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";
|
|
|
|
|
static const char autoInsertBracesKey[] = "AutoInsertBraces";
|
2011-09-14 12:14:15 +02:00
|
|
|
static const char surroundingAutoBracketsKey[] = "SurroundingAutoBrackets";
|
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)
|
2010-05-10 18:30:09 +02:00
|
|
|
, m_autoInsertBrackets(true)
|
2011-09-14 12:14:15 +02:00
|
|
|
, m_surroundingAutoBrackets(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);
|
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);
|
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();
|
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();
|
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
|
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
|
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
|
|
|
;
|
|
|
|
|
}
|