forked from qt-creator/qt-creator
Since we also license under GPL-3.0 WITH Qt-GPL-exception-1.0,
this applies only to a hypothetical newer version of GPL, that doesn't
exist yet. If such a version emerges, we can still decide to relicense...
While at it, replace (deprecated) GPL-3.0 with more explicit GPL-3.0-only
Change was done by running
find . -type f -exec perl -pi -e "s/LicenseRef-Qt-Commercial OR GPL-3.0\+ OR GPL-3.0 WITH Qt-GPL-exception-1.0/LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0/g" {} \;
Change-Id: I5097e6ce8d10233993ee30d7e25120e2659eb10b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
89 lines
2.2 KiB
C++
89 lines
2.2 KiB
C++
// Copyright (C) 2016 The Qt Company Ltd.
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
|
|
#include "qmljscodestylepreferences.h"
|
|
|
|
namespace QmlJSTools {
|
|
|
|
QmlJSCodeStylePreferences::QmlJSCodeStylePreferences(QObject *parent) :
|
|
ICodeStylePreferences(parent)
|
|
{
|
|
setSettingsSuffix("CodeStyleSettings");
|
|
|
|
connect(this, &QmlJSCodeStylePreferences::currentValueChanged,
|
|
this, &QmlJSCodeStylePreferences::slotCurrentValueChanged);
|
|
}
|
|
|
|
QVariant QmlJSCodeStylePreferences::value() const
|
|
{
|
|
QVariant v;
|
|
v.setValue(codeStyleSettings());
|
|
return v;
|
|
}
|
|
|
|
void QmlJSCodeStylePreferences::setValue(const QVariant &data)
|
|
{
|
|
if (!data.canConvert<QmlJSCodeStyleSettings>())
|
|
return;
|
|
|
|
setCodeStyleSettings(data.value<QmlJSCodeStyleSettings>());
|
|
}
|
|
|
|
QmlJSCodeStyleSettings QmlJSCodeStylePreferences::codeStyleSettings() const
|
|
{
|
|
return m_data;
|
|
}
|
|
|
|
void QmlJSCodeStylePreferences::setCodeStyleSettings(const QmlJSCodeStyleSettings &data)
|
|
{
|
|
if (m_data == data)
|
|
return;
|
|
|
|
m_data = data;
|
|
|
|
QVariant v;
|
|
v.setValue(data);
|
|
emit valueChanged(v);
|
|
emit codeStyleSettingsChanged(m_data);
|
|
if (!currentDelegate())
|
|
emit currentValueChanged(v);
|
|
}
|
|
|
|
QmlJSCodeStyleSettings QmlJSCodeStylePreferences::currentCodeStyleSettings() const
|
|
{
|
|
QVariant v = currentValue();
|
|
if (!v.canConvert<QmlJSCodeStyleSettings>()) {
|
|
// warning
|
|
return {};
|
|
}
|
|
return v.value<QmlJSCodeStyleSettings>();
|
|
}
|
|
|
|
void QmlJSCodeStylePreferences::slotCurrentValueChanged(const QVariant &value)
|
|
{
|
|
if (!value.canConvert<QmlJSCodeStyleSettings>())
|
|
return;
|
|
|
|
emit currentCodeStyleSettingsChanged(value.value<QmlJSCodeStyleSettings>());
|
|
}
|
|
|
|
QVariantMap QmlJSCodeStylePreferences::toMap() const
|
|
{
|
|
QVariantMap map = ICodeStylePreferences::toMap();
|
|
if (!currentDelegate()) {
|
|
const QVariantMap dataMap = m_data.toMap();
|
|
for (auto it = dataMap.begin(), end = dataMap.end(); it != end; ++it)
|
|
map.insert(it.key(), it.value());
|
|
}
|
|
return map;
|
|
}
|
|
|
|
void QmlJSCodeStylePreferences::fromMap(const QVariantMap &map)
|
|
{
|
|
ICodeStylePreferences::fromMap(map);
|
|
if (!currentDelegate())
|
|
m_data.fromMap(map);
|
|
}
|
|
|
|
} // namespace QmlJSTools
|