2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
|
|
|
|
** Please review the following information to ensure the GNU Lesser General
|
|
|
|
|
** Public License version 2.1 requirements will be met:
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "editorconfiguration.h"
|
2011-02-01 14:13:54 +01:00
|
|
|
#include "session.h"
|
|
|
|
|
#include "projectexplorer.h"
|
|
|
|
|
#include "project.h"
|
2010-11-02 16:14:00 +01:00
|
|
|
|
2011-02-01 14:13:54 +01:00
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
|
|
|
|
|
|
|
|
|
#include <texteditor/itexteditor.h>
|
|
|
|
|
#include <texteditor/basetexteditor.h>
|
|
|
|
|
#include <texteditor/texteditorsettings.h>
|
|
|
|
|
#include <texteditor/tabsettings.h>
|
2011-08-16 10:45:23 +02:00
|
|
|
#include <texteditor/simplecodestylepreferences.h>
|
|
|
|
|
#include <texteditor/typingsettings.h>
|
2011-02-01 14:13:54 +01:00
|
|
|
#include <texteditor/storagesettings.h>
|
|
|
|
|
#include <texteditor/behaviorsettings.h>
|
|
|
|
|
#include <texteditor/extraencodingsettings.h>
|
2011-08-16 10:45:23 +02:00
|
|
|
#include <texteditor/icodestylepreferences.h>
|
2011-02-03 15:48:14 +01:00
|
|
|
#include <texteditor/icodestylepreferencesfactory.h>
|
2011-02-01 14:13:54 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QLatin1String>
|
|
|
|
|
#include <QByteArray>
|
|
|
|
|
#include <QTextCodec>
|
|
|
|
|
#include <QDebug>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-02-01 14:13:54 +01:00
|
|
|
static const QLatin1String kPrefix("EditorConfiguration.");
|
|
|
|
|
static const QLatin1String kUseGlobal("EditorConfiguration.UseGlobal");
|
|
|
|
|
static const QLatin1String kCodec("EditorConfiguration.Codec");
|
2011-02-03 15:48:14 +01:00
|
|
|
static const QLatin1String kCodeStylePrefix("EditorConfiguration.CodeStyle.");
|
|
|
|
|
static const QLatin1String kCodeStyleCount("EditorConfiguration.CodeStyle.Count");
|
|
|
|
|
static const QLatin1String kId("Project");
|
2011-02-01 14:13:54 +01:00
|
|
|
|
|
|
|
|
using namespace TextEditor;
|
|
|
|
|
|
|
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
|
|
|
|
|
struct EditorConfigurationPrivate
|
|
|
|
|
{
|
|
|
|
|
EditorConfigurationPrivate()
|
|
|
|
|
: m_useGlobal(true)
|
2011-08-16 10:45:23 +02:00
|
|
|
, m_typingSettings(TextEditorSettings::instance()->typingSettings())
|
2011-02-01 14:13:54 +01:00
|
|
|
, m_storageSettings(TextEditorSettings::instance()->storageSettings())
|
|
|
|
|
, m_behaviorSettings(TextEditorSettings::instance()->behaviorSettings())
|
|
|
|
|
, m_extraEncodingSettings(TextEditorSettings::instance()->extraEncodingSettings())
|
|
|
|
|
, m_textCodec(Core::EditorManager::instance()->defaultTextCodec())
|
2011-02-03 15:48:14 +01:00
|
|
|
{
|
|
|
|
|
}
|
2011-02-01 14:13:54 +01:00
|
|
|
|
|
|
|
|
bool m_useGlobal;
|
2011-08-16 10:45:23 +02:00
|
|
|
ICodeStylePreferences *m_defaultCodeStyle;
|
|
|
|
|
TypingSettings m_typingSettings;
|
2011-02-01 14:13:54 +01:00
|
|
|
StorageSettings m_storageSettings;
|
|
|
|
|
BehaviorSettings m_behaviorSettings;
|
|
|
|
|
ExtraEncodingSettings m_extraEncodingSettings;
|
|
|
|
|
QTextCodec *m_textCodec;
|
2011-02-03 15:48:14 +01:00
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
QMap<QString, ICodeStylePreferences *> m_languageCodeStylePreferences;
|
2011-02-01 14:13:54 +01:00
|
|
|
};
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-09-16 13:10:06 +02:00
|
|
|
EditorConfiguration::EditorConfiguration() : d(new EditorConfigurationPrivate)
|
2011-02-01 14:13:54 +01:00
|
|
|
{
|
2011-08-16 10:45:23 +02:00
|
|
|
TextEditorSettings *textEditorSettings = TextEditorSettings::instance();
|
2011-02-03 15:48:14 +01:00
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
const QMap<QString, ICodeStylePreferences *> languageCodeStylePreferences = textEditorSettings->codeStyles();
|
|
|
|
|
QMapIterator<QString, ICodeStylePreferences *> itCodeStyle(languageCodeStylePreferences);
|
2011-02-03 15:48:14 +01:00
|
|
|
while (itCodeStyle.hasNext()) {
|
|
|
|
|
itCodeStyle.next();
|
|
|
|
|
const QString languageId = itCodeStyle.key();
|
2011-08-16 10:45:23 +02:00
|
|
|
ICodeStylePreferences *originalPreferences = itCodeStyle.value();
|
|
|
|
|
ICodeStylePreferencesFactory *factory = textEditorSettings->codeStyleFactory(languageId);
|
|
|
|
|
ICodeStylePreferences *preferences = factory->createCodeStyle();
|
|
|
|
|
preferences->setDelegatingPool(textEditorSettings->codeStylePool(languageId));
|
2011-02-03 15:48:14 +01:00
|
|
|
preferences->setId(languageId + QLatin1String("Project"));
|
2011-06-08 10:45:26 +02:00
|
|
|
preferences->setDisplayName(tr("Project %1", "Settings, %1 is a language (C++ or QML)").arg(factory->displayName()));
|
2011-08-16 10:45:23 +02:00
|
|
|
preferences->setCurrentDelegate(originalPreferences);
|
2011-09-16 13:10:06 +02:00
|
|
|
d->m_languageCodeStylePreferences.insert(languageId, preferences);
|
2011-02-03 15:48:14 +01:00
|
|
|
}
|
2011-08-16 10:45:23 +02:00
|
|
|
|
|
|
|
|
d->m_defaultCodeStyle = new SimpleCodeStylePreferences(this);
|
|
|
|
|
d->m_defaultCodeStyle->setDelegatingPool(textEditorSettings->codeStylePool());
|
|
|
|
|
d->m_defaultCodeStyle->setDisplayName(tr("Project", "Settings"));
|
|
|
|
|
d->m_defaultCodeStyle->setId(kId);
|
2011-11-28 11:08:15 +01:00
|
|
|
d->m_defaultCodeStyle->setCurrentDelegate(d->m_useGlobal
|
|
|
|
|
? TextEditorSettings::instance()->codeStyle() : 0);
|
2010-01-14 16:24:21 +01:00
|
|
|
}
|
|
|
|
|
|
2011-02-01 14:13:54 +01:00
|
|
|
EditorConfiguration::~EditorConfiguration()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2011-09-16 13:10:06 +02:00
|
|
|
qDeleteAll(d->m_languageCodeStylePreferences.values());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2011-02-01 14:13:54 +01:00
|
|
|
bool EditorConfiguration::useGlobalSettings() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2011-09-16 13:10:06 +02:00
|
|
|
return d->m_useGlobal;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2011-02-01 14:13:54 +01:00
|
|
|
void EditorConfiguration::cloneGlobalSettings()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2011-08-16 10:45:23 +02:00
|
|
|
TextEditorSettings *textEditorSettings = TextEditorSettings::instance();
|
|
|
|
|
|
|
|
|
|
d->m_defaultCodeStyle->setTabSettings(textEditorSettings->codeStyle()->tabSettings());
|
|
|
|
|
setTypingSettings(textEditorSettings->typingSettings());
|
|
|
|
|
setStorageSettings(textEditorSettings->storageSettings());
|
|
|
|
|
setBehaviorSettings(textEditorSettings->behaviorSettings());
|
|
|
|
|
setExtraEncodingSettings(textEditorSettings->extraEncodingSettings());
|
2011-09-16 13:10:06 +02:00
|
|
|
d->m_textCodec = Core::EditorManager::instance()->defaultTextCodec();
|
2011-02-01 14:13:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QTextCodec *EditorConfiguration::textCodec() const
|
|
|
|
|
{
|
2011-09-16 13:10:06 +02:00
|
|
|
return d->m_textCodec;
|
2011-02-01 14:13:54 +01:00
|
|
|
}
|
|
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
const TypingSettings &EditorConfiguration::typingSettings() const
|
2011-02-01 14:13:54 +01:00
|
|
|
{
|
2011-08-16 10:45:23 +02:00
|
|
|
return d->m_typingSettings;
|
2011-02-01 14:13:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const StorageSettings &EditorConfiguration::storageSettings() const
|
|
|
|
|
{
|
2011-09-16 13:10:06 +02:00
|
|
|
return d->m_storageSettings;
|
2011-02-01 14:13:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const BehaviorSettings &EditorConfiguration::behaviorSettings() const
|
|
|
|
|
{
|
2011-09-16 13:10:06 +02:00
|
|
|
return d->m_behaviorSettings;
|
2011-02-01 14:13:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ExtraEncodingSettings &EditorConfiguration::extraEncodingSettings() const
|
|
|
|
|
{
|
2011-09-16 13:10:06 +02:00
|
|
|
return d->m_extraEncodingSettings;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
ICodeStylePreferences *EditorConfiguration::codeStyle() const
|
2011-02-03 15:48:14 +01:00
|
|
|
{
|
2011-08-16 10:45:23 +02:00
|
|
|
return d->m_defaultCodeStyle;
|
2011-02-03 15:48:14 +01:00
|
|
|
}
|
|
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
ICodeStylePreferences *EditorConfiguration::codeStyle(const QString &languageId) const
|
2011-02-03 15:48:14 +01:00
|
|
|
{
|
2011-08-16 10:45:23 +02:00
|
|
|
return d->m_languageCodeStylePreferences.value(languageId, codeStyle());
|
2011-02-03 15:48:14 +01:00
|
|
|
}
|
|
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
QMap<QString, ICodeStylePreferences *> EditorConfiguration::codeStyles() const
|
2011-02-03 15:48:14 +01:00
|
|
|
{
|
2011-09-16 13:10:06 +02:00
|
|
|
return d->m_languageCodeStylePreferences;
|
2011-02-03 15:48:14 +01:00
|
|
|
}
|
|
|
|
|
|
2010-01-14 16:24:21 +01:00
|
|
|
QVariantMap EditorConfiguration::toMap() const
|
|
|
|
|
{
|
|
|
|
|
QVariantMap map;
|
2011-09-16 13:10:06 +02:00
|
|
|
map.insert(kUseGlobal, d->m_useGlobal);
|
|
|
|
|
map.insert(kCodec, d->m_textCodec->name());
|
2011-02-03 15:48:14 +01:00
|
|
|
|
2011-09-16 13:10:06 +02:00
|
|
|
map.insert(kCodeStyleCount, d->m_languageCodeStylePreferences.count());
|
2011-08-16 10:45:23 +02:00
|
|
|
QMapIterator<QString, ICodeStylePreferences *> itCodeStyle(d->m_languageCodeStylePreferences);
|
|
|
|
|
int i = 0;
|
2011-02-03 15:48:14 +01:00
|
|
|
while (itCodeStyle.hasNext()) {
|
|
|
|
|
itCodeStyle.next();
|
|
|
|
|
QVariantMap settingsIdMap;
|
|
|
|
|
settingsIdMap.insert(QLatin1String("language"), itCodeStyle.key());
|
|
|
|
|
QVariantMap value;
|
|
|
|
|
itCodeStyle.value()->toMap(QString(), &value);
|
|
|
|
|
settingsIdMap.insert(QLatin1String("value"), value);
|
|
|
|
|
map.insert(kCodeStylePrefix + QString::number(i), settingsIdMap);
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
d->m_defaultCodeStyle->tabSettings().toMap(kPrefix, &map);
|
|
|
|
|
d->m_typingSettings.toMap(kPrefix, &map);
|
2011-09-16 13:10:06 +02:00
|
|
|
d->m_storageSettings.toMap(kPrefix, &map);
|
|
|
|
|
d->m_behaviorSettings.toMap(kPrefix, &map);
|
|
|
|
|
d->m_extraEncodingSettings.toMap(kPrefix, &map);
|
2011-02-01 14:13:54 +01:00
|
|
|
|
2010-01-14 16:24:21 +01:00
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-06 11:54:09 +02:00
|
|
|
void EditorConfiguration::fromMap(const QVariantMap &map)
|
2010-01-14 16:24:21 +01:00
|
|
|
{
|
2011-09-16 13:10:06 +02:00
|
|
|
d->m_useGlobal = map.value(kUseGlobal, d->m_useGlobal).toBool();
|
2011-02-01 14:13:54 +01:00
|
|
|
|
2011-09-16 13:10:06 +02:00
|
|
|
const QByteArray &codecName = map.value(kCodec, d->m_textCodec->name()).toByteArray();
|
|
|
|
|
d->m_textCodec = QTextCodec::codecForName(codecName);
|
|
|
|
|
if (!d->m_textCodec)
|
|
|
|
|
d->m_textCodec = Core::EditorManager::instance()->defaultTextCodec();
|
2011-02-01 14:13:54 +01:00
|
|
|
|
2011-02-03 15:48:14 +01:00
|
|
|
const int codeStyleCount = map.value(kCodeStyleCount, 0).toInt();
|
|
|
|
|
for (int i = 0; i < codeStyleCount; ++i) {
|
|
|
|
|
QVariantMap settingsIdMap = map.value(kCodeStylePrefix + QString::number(i)).toMap();
|
|
|
|
|
if (settingsIdMap.isEmpty()) {
|
|
|
|
|
qWarning() << "No data for code style settings list" << i << "found!";
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
QString languageId = settingsIdMap.value(QLatin1String("language")).toString();
|
|
|
|
|
QVariantMap value = settingsIdMap.value(QLatin1String("value")).toMap();
|
2011-08-16 10:45:23 +02:00
|
|
|
ICodeStylePreferences *preferences = d->m_languageCodeStylePreferences.value(languageId);
|
2011-02-03 15:48:14 +01:00
|
|
|
if (preferences) {
|
|
|
|
|
preferences->fromMap(QString(), value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
d->m_defaultCodeStyle->fromMap(kPrefix, map);
|
|
|
|
|
d->m_typingSettings.fromMap(kPrefix, map);
|
2011-09-16 13:10:06 +02:00
|
|
|
d->m_storageSettings.fromMap(kPrefix, map);
|
|
|
|
|
d->m_behaviorSettings.fromMap(kPrefix, map);
|
|
|
|
|
d->m_extraEncodingSettings.fromMap(kPrefix, map);
|
2011-02-01 14:13:54 +01:00
|
|
|
}
|
|
|
|
|
|
2011-02-03 15:48:14 +01:00
|
|
|
void EditorConfiguration::configureEditor(ITextEditor *textEditor) const
|
2011-02-01 14:13:54 +01:00
|
|
|
{
|
2011-02-03 15:48:14 +01:00
|
|
|
BaseTextEditorWidget *baseTextEditor = qobject_cast<BaseTextEditorWidget *>(textEditor->widget());
|
2011-08-16 10:45:23 +02:00
|
|
|
baseTextEditor->setCodeStyle(codeStyle(baseTextEditor->languageSettingsId()));
|
2011-09-16 13:10:06 +02:00
|
|
|
if (!d->m_useGlobal) {
|
|
|
|
|
textEditor->setTextCodec(d->m_textCodec, ITextEditor::TextCodecFromProjectSetting);
|
2011-02-03 15:48:14 +01:00
|
|
|
if (baseTextEditor)
|
2011-02-01 14:13:54 +01:00
|
|
|
switchSettings(baseTextEditor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EditorConfiguration::setUseGlobalSettings(bool use)
|
|
|
|
|
{
|
2011-09-16 13:10:06 +02:00
|
|
|
d->m_useGlobal = use;
|
2011-08-16 10:45:23 +02:00
|
|
|
d->m_defaultCodeStyle->setCurrentDelegate(d->m_useGlobal
|
|
|
|
|
? TextEditorSettings::instance()->codeStyle() : 0);
|
2011-02-01 14:13:54 +01:00
|
|
|
const SessionManager *session = ProjectExplorerPlugin::instance()->session();
|
|
|
|
|
QList<Core::IEditor *> opened = Core::EditorManager::instance()->openedEditors();
|
|
|
|
|
foreach (Core::IEditor *editor, opened) {
|
2011-02-21 16:02:26 +01:00
|
|
|
if (BaseTextEditorWidget *baseTextEditor = qobject_cast<BaseTextEditorWidget *>(editor->widget())) {
|
2012-02-14 16:43:51 +01:00
|
|
|
Project *project = session->projectForFile(editor->document()->fileName());
|
2011-02-01 14:13:54 +01:00
|
|
|
if (project && project->editorConfiguration() == this)
|
|
|
|
|
switchSettings(baseTextEditor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-21 16:02:26 +01:00
|
|
|
void EditorConfiguration::switchSettings(BaseTextEditorWidget *baseTextEditor) const
|
2011-02-01 14:13:54 +01:00
|
|
|
{
|
2011-09-16 13:10:06 +02:00
|
|
|
if (d->m_useGlobal)
|
2011-02-01 14:13:54 +01:00
|
|
|
switchSettings_helper(TextEditorSettings::instance(), this, baseTextEditor);
|
|
|
|
|
else
|
|
|
|
|
switchSettings_helper(this, TextEditorSettings::instance(), baseTextEditor);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <class NewSenderT, class OldSenderT>
|
|
|
|
|
void EditorConfiguration::switchSettings_helper(const NewSenderT *newSender,
|
|
|
|
|
const OldSenderT *oldSender,
|
2011-02-21 16:02:26 +01:00
|
|
|
BaseTextEditorWidget *baseTextEditor) const
|
2011-02-01 14:13:54 +01:00
|
|
|
{
|
2011-08-16 10:45:23 +02:00
|
|
|
baseTextEditor->setTypingSettings(newSender->typingSettings());
|
2011-02-01 14:13:54 +01:00
|
|
|
baseTextEditor->setStorageSettings(newSender->storageSettings());
|
|
|
|
|
baseTextEditor->setBehaviorSettings(newSender->behaviorSettings());
|
|
|
|
|
baseTextEditor->setExtraEncodingSettings(newSender->extraEncodingSettings());
|
|
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
disconnect(oldSender, SIGNAL(typingSettingsChanged(TextEditor::TypingSettings)),
|
|
|
|
|
baseTextEditor, SLOT(setTypingSettings(TextEditor::TypingSettings)));
|
2011-02-01 14:13:54 +01:00
|
|
|
disconnect(oldSender, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings)),
|
|
|
|
|
baseTextEditor, SLOT(setStorageSettings(TextEditor::StorageSettings)));
|
|
|
|
|
disconnect(oldSender, SIGNAL(behaviorSettingsChanged(TextEditor::BehaviorSettings)),
|
|
|
|
|
baseTextEditor, SLOT(setBehaviorSettings(TextEditor::BehaviorSettings)));
|
|
|
|
|
disconnect(oldSender, SIGNAL(extraEncodingSettingsChanged(TextEditor::ExtraEncodingSettings)),
|
|
|
|
|
baseTextEditor, SLOT(setExtraEncodingSettings(TextEditor::ExtraEncodingSettings)));
|
|
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
connect(newSender, SIGNAL(typingSettingsChanged(TextEditor::TypingSettings)),
|
|
|
|
|
baseTextEditor, SLOT(setTypingSettings(TextEditor::TypingSettings)));
|
2011-02-01 14:13:54 +01:00
|
|
|
connect(newSender, SIGNAL(storageSettingsChanged(TextEditor::StorageSettings)),
|
|
|
|
|
baseTextEditor, SLOT(setStorageSettings(TextEditor::StorageSettings)));
|
|
|
|
|
connect(newSender, SIGNAL(behaviorSettingsChanged(TextEditor::BehaviorSettings)),
|
|
|
|
|
baseTextEditor, SLOT(setBehaviorSettings(TextEditor::BehaviorSettings)));
|
|
|
|
|
connect(newSender, SIGNAL(extraEncodingSettingsChanged(TextEditor::ExtraEncodingSettings)),
|
|
|
|
|
baseTextEditor, SLOT(setExtraEncodingSettings(TextEditor::ExtraEncodingSettings)));
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-16 10:45:23 +02:00
|
|
|
void EditorConfiguration::setTypingSettings(const TextEditor::TypingSettings &settings)
|
|
|
|
|
{
|
|
|
|
|
d->m_typingSettings = settings;
|
|
|
|
|
emit typingSettingsChanged(d->m_typingSettings);
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-03 15:48:14 +01:00
|
|
|
void EditorConfiguration::setStorageSettings(const TextEditor::StorageSettings &settings)
|
2011-02-01 14:13:54 +01:00
|
|
|
{
|
2011-09-16 13:10:06 +02:00
|
|
|
d->m_storageSettings = settings;
|
|
|
|
|
emit storageSettingsChanged(d->m_storageSettings);
|
2011-02-01 14:13:54 +01:00
|
|
|
}
|
|
|
|
|
|
2011-02-03 15:48:14 +01:00
|
|
|
void EditorConfiguration::setBehaviorSettings(const TextEditor::BehaviorSettings &settings)
|
2011-02-01 14:13:54 +01:00
|
|
|
{
|
2011-09-16 13:10:06 +02:00
|
|
|
d->m_behaviorSettings = settings;
|
|
|
|
|
emit behaviorSettingsChanged(d->m_behaviorSettings);
|
2011-02-01 14:13:54 +01:00
|
|
|
}
|
|
|
|
|
|
2011-02-03 15:48:14 +01:00
|
|
|
void EditorConfiguration::setExtraEncodingSettings(const TextEditor::ExtraEncodingSettings &settings)
|
2011-02-01 14:13:54 +01:00
|
|
|
{
|
2011-09-16 13:10:06 +02:00
|
|
|
d->m_extraEncodingSettings = settings;
|
|
|
|
|
emit extraEncodingSettingsChanged(d->m_extraEncodingSettings);
|
2011-02-01 14:13:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void EditorConfiguration::setTextCodec(QTextCodec *textCodec)
|
|
|
|
|
{
|
2011-09-16 13:10:06 +02:00
|
|
|
d->m_textCodec = textCodec;
|
2011-02-01 14:13:54 +01:00
|
|
|
}
|
|
|
|
|
|
2011-02-03 15:48:14 +01:00
|
|
|
TabSettings actualTabSettings(const QString &fileName,
|
|
|
|
|
const BaseTextEditorWidget *baseTextEditor)
|
2011-02-01 14:13:54 +01:00
|
|
|
{
|
|
|
|
|
if (baseTextEditor) {
|
|
|
|
|
return baseTextEditor->tabSettings();
|
|
|
|
|
} else {
|
|
|
|
|
const SessionManager *session = ProjectExplorerPlugin::instance()->session();
|
|
|
|
|
if (Project *project = session->projectForFile(fileName))
|
2011-08-16 10:45:23 +02:00
|
|
|
return project->editorConfiguration()->codeStyle()->tabSettings();
|
2011-02-01 14:13:54 +01:00
|
|
|
else
|
2011-08-16 10:45:23 +02:00
|
|
|
return TextEditorSettings::instance()->codeStyle()->tabSettings();
|
2011-02-01 14:13:54 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // ProjectExplorer
|