Commit 7fa69afa authored by Orgad Shaneh's avatar Orgad Shaneh Committed by hjk

Use Core::Id for language

Change-Id: I0077558e9e2cf5aa06ac921cb45224e29aa85c9b
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 7d36034f
......@@ -150,7 +150,7 @@ void CppPlugin::initializeEditor(CPPEditorWidget *editor)
{
m_actionHandler->setupActions(editor);
editor->setLanguageSettingsId(QLatin1String(CppTools::Constants::CPP_SETTINGS_ID));
editor->setLanguageSettingsId(CppTools::Constants::CPP_SETTINGS_ID);
TextEditor::TextEditorSettings::instance()->initializeEditor(editor);
// method combo box sorting
......
......@@ -91,7 +91,7 @@ CppCodeStylePreferencesFactory::CppCodeStylePreferencesFactory()
{
}
QString CppCodeStylePreferencesFactory::languageId()
Core::Id CppCodeStylePreferencesFactory::languageId()
{
return Constants::CPP_SETTINGS_ID;
}
......
......@@ -39,14 +39,14 @@ class CppCodeStylePreferencesFactory : public TextEditor::ICodeStylePreferencesF
public:
CppCodeStylePreferencesFactory();
virtual QString languageId();
virtual QString displayName();
virtual TextEditor::ICodeStylePreferences *createCodeStyle() const;
virtual QWidget *createEditor(TextEditor::ICodeStylePreferences *settings,
QWidget *parent) const;
virtual TextEditor::Indenter *createIndenter() const;
virtual TextEditor::ISnippetProvider *snippetProvider() const;
virtual QString previewText() const;
Core::Id languageId();
QString displayName();
TextEditor::ICodeStylePreferences *createCodeStyle() const;
QWidget *createEditor(TextEditor::ICodeStylePreferences *settings,
QWidget *parent) const;
TextEditor::Indenter *createIndenter() const;
TextEditor::ISnippetProvider *snippetProvider() const;
QString previewText() const;
};
} // namespace CppTools
......
......@@ -76,13 +76,13 @@ CodeStyleSettingsWidget::CodeStyleSettingsWidget(Project *project) : QWidget(),
const EditorConfiguration *config = m_project->editorConfiguration();
QMap<QString, ICodeStylePreferencesFactory *> factories
QMap<Core::Id, ICodeStylePreferencesFactory *> factories
= TextEditor::TextEditorSettings::instance()->codeStyleFactories();
QMapIterator<QString, ICodeStylePreferencesFactory *> it(factories);
QMapIterator<Core::Id, ICodeStylePreferencesFactory *> it(factories);
while (it.hasNext()) {
it.next();
ICodeStylePreferencesFactory *factory = it.value();
const QString languageId = factory->languageId();
Core::Id languageId = factory->languageId();
ICodeStylePreferences *codeStylePreferences = config->codeStyle(languageId);
CodeStyleEditor *preview = new CodeStyleEditor(factory, codeStylePreferences, m_ui.stackedWidget);
......
......@@ -82,23 +82,23 @@ struct EditorConfigurationPrivate
ExtraEncodingSettings m_extraEncodingSettings;
QTextCodec *m_textCodec;
QMap<QString, ICodeStylePreferences *> m_languageCodeStylePreferences;
QMap<Core::Id, ICodeStylePreferences *> m_languageCodeStylePreferences;
};
EditorConfiguration::EditorConfiguration() : d(new EditorConfigurationPrivate)
{
TextEditorSettings *textEditorSettings = TextEditorSettings::instance();
const QMap<QString, ICodeStylePreferences *> languageCodeStylePreferences = textEditorSettings->codeStyles();
QMapIterator<QString, ICodeStylePreferences *> itCodeStyle(languageCodeStylePreferences);
const QMap<Core::Id, ICodeStylePreferences *> languageCodeStylePreferences = textEditorSettings->codeStyles();
QMapIterator<Core::Id, ICodeStylePreferences *> itCodeStyle(languageCodeStylePreferences);
while (itCodeStyle.hasNext()) {
itCodeStyle.next();
const QString languageId = itCodeStyle.key();
Core::Id languageId = itCodeStyle.key();
ICodeStylePreferences *originalPreferences = itCodeStyle.value();
ICodeStylePreferencesFactory *factory = textEditorSettings->codeStyleFactory(languageId);
ICodeStylePreferences *preferences = factory->createCodeStyle();
preferences->setDelegatingPool(textEditorSettings->codeStylePool(languageId));
preferences->setId(languageId + QLatin1String("Project"));
preferences->setId(languageId.toString() + QLatin1String("Project"));
preferences->setDisplayName(tr("Project %1", "Settings, %1 is a language (C++ or QML)").arg(factory->displayName()));
preferences->setCurrentDelegate(originalPreferences);
d->m_languageCodeStylePreferences.insert(languageId, preferences);
......@@ -165,12 +165,12 @@ ICodeStylePreferences *EditorConfiguration::codeStyle() const
return d->m_defaultCodeStyle;
}
ICodeStylePreferences *EditorConfiguration::codeStyle(const QString &languageId) const
ICodeStylePreferences *EditorConfiguration::codeStyle(Core::Id languageId) const
{
return d->m_languageCodeStylePreferences.value(languageId, codeStyle());
}
QMap<QString, ICodeStylePreferences *> EditorConfiguration::codeStyles() const
QMap<Core::Id, ICodeStylePreferences *> EditorConfiguration::codeStyles() const
{
return d->m_languageCodeStylePreferences;
}
......@@ -182,12 +182,12 @@ QVariantMap EditorConfiguration::toMap() const
map.insert(kCodec, d->m_textCodec->name());
map.insert(kCodeStyleCount, d->m_languageCodeStylePreferences.count());
QMapIterator<QString, ICodeStylePreferences *> itCodeStyle(d->m_languageCodeStylePreferences);
QMapIterator<Core::Id, ICodeStylePreferences *> itCodeStyle(d->m_languageCodeStylePreferences);
int i = 0;
while (itCodeStyle.hasNext()) {
itCodeStyle.next();
QVariantMap settingsIdMap;
settingsIdMap.insert(QLatin1String("language"), itCodeStyle.key());
settingsIdMap.insert(QLatin1String("language"), itCodeStyle.key().name());
QVariantMap value;
itCodeStyle.value()->toMap(QString(), &value);
settingsIdMap.insert(QLatin1String("value"), value);
......@@ -220,7 +220,7 @@ void EditorConfiguration::fromMap(const QVariantMap &map)
qWarning() << "No data for code style settings list" << i << "found!";
continue;
}
QString languageId = settingsIdMap.value(QLatin1String("language")).toString();
Core::Id languageId(settingsIdMap.value(QLatin1String("language")).toByteArray());
QVariantMap value = settingsIdMap.value(QLatin1String("value")).toMap();
ICodeStylePreferences *preferences = d->m_languageCodeStylePreferences.value(languageId);
if (preferences) {
......
......@@ -32,6 +32,8 @@
#include "projectexplorer_export.h"
#include <coreplugin/id.h>
#include <QObject>
#include <QVariantMap>
......@@ -71,8 +73,8 @@ public:
const TextEditor::ExtraEncodingSettings &extraEncodingSettings() const;
TextEditor::ICodeStylePreferences *codeStyle() const;
TextEditor::ICodeStylePreferences *codeStyle(const QString &languageId) const;
QMap<QString, TextEditor::ICodeStylePreferences *> codeStyles() const;
TextEditor::ICodeStylePreferences *codeStyle(Core::Id languageId) const;
QMap<Core::Id, TextEditor::ICodeStylePreferences *> codeStyles() const;
void configureEditor(TextEditor::ITextEditor *textEditor) const;
......
......@@ -524,9 +524,9 @@ bool ProjectFileWizardExtension::processVersionControl(const QList<Core::Generat
return true;
}
static TextEditor::ICodeStylePreferences *codeStylePreferences(ProjectExplorer::Project *project, const QString &languageId)
static TextEditor::ICodeStylePreferences *codeStylePreferences(ProjectExplorer::Project *project, Core::Id languageId)
{
if (languageId.isEmpty())
if (!languageId.isValid())
return 0;
if (project)
......@@ -542,9 +542,9 @@ void ProjectFileWizardExtension::applyCodeStyle(Core::GeneratedFile *file) const
const Core::MimeDatabase *mdb = Core::ICore::mimeDatabase();
Core::MimeType mt = mdb->findByFile(QFileInfo(file->path()));
const QString languageId = TextEditor::TextEditorSettings::instance()->languageId(mt.type());
Core::Id languageId = TextEditor::TextEditorSettings::instance()->languageId(mt.type());
if (languageId.isEmpty())
if (!languageId.isValid())
return; // don't modify files like *.ui *.pro
ProjectNode *project = 0;
......
......@@ -62,14 +62,14 @@ QmlJSCodeStylePreferencesFactory::QmlJSCodeStylePreferencesFactory()
{
}
QString QmlJSCodeStylePreferencesFactory::languageId()
Core::Id QmlJSCodeStylePreferencesFactory::languageId()
{
return Constants::QML_JS_SETTINGS_ID;
}
QString QmlJSCodeStylePreferencesFactory::displayName()
{
return Constants::QML_JS_SETTINGS_NAME;
return QLatin1String(Constants::QML_JS_SETTINGS_NAME);
}
TextEditor::ICodeStylePreferences *QmlJSCodeStylePreferencesFactory::createCodeStyle() const
......
......@@ -39,13 +39,13 @@ class QmlJSCodeStylePreferencesFactory : public TextEditor::ICodeStylePreference
public:
QmlJSCodeStylePreferencesFactory();
virtual QString languageId();
virtual QString displayName();
virtual TextEditor::ICodeStylePreferences *createCodeStyle() const;
virtual QWidget *createEditor(TextEditor::ICodeStylePreferences *settings,
QWidget *parent) const;
virtual TextEditor::Indenter *createIndenter() const;
virtual TextEditor::ISnippetProvider *snippetProvider() const;
Core::Id languageId();
QString displayName();
TextEditor::ICodeStylePreferences *createCodeStyle() const;
QWidget *createEditor(TextEditor::ICodeStylePreferences *settings,
QWidget *parent) const;
TextEditor::Indenter *createIndenter() const;
TextEditor::ISnippetProvider *snippetProvider() const;
QString previewText() const;
};
......
......@@ -4555,12 +4555,12 @@ const TabSettings &BaseTextEditorWidget::tabSettings() const
return d->m_document->tabSettings();
}
void BaseTextEditorWidget::setLanguageSettingsId(const QString &settingsId)
void BaseTextEditorWidget::setLanguageSettingsId(Core::Id settingsId)
{
d->m_tabSettingsId = settingsId;
}
QString BaseTextEditorWidget::languageSettingsId() const
Core::Id BaseTextEditorWidget::languageSettingsId() const
{
return d->m_tabSettingsId;
}
......
......@@ -33,8 +33,9 @@
#include "itexteditor.h"
#include "codeassist/assistenums.h"
#include <find/ifindsupport.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/id.h>
#include <find/ifindsupport.h>
#include <QPlainTextEdit>
......@@ -389,8 +390,8 @@ public:
virtual void extraAreaMouseEvent(QMouseEvent *);
const TabSettings &tabSettings() const;
void setLanguageSettingsId(const QString &settingsId);
QString languageSettingsId() const;
void setLanguageSettingsId(Core::Id settingsId);
Core::Id languageSettingsId() const;
void setCodeStyle(ICodeStylePreferences *settings);
......
......@@ -36,6 +36,7 @@
#include "fontsettings.h"
#include "refactoroverlay.h"
#include <coreplugin/id.h>
#include <utils/changeset.h>
#include <QBasicTimer>
......@@ -202,7 +203,7 @@ public:
QWidget *m_extraArea;
QString m_tabSettingsId;
Core::Id m_tabSettingsId;
ICodeStylePreferences *m_codeStylePreferences;
DisplaySettings m_displaySettings;
FontSettings m_fontSettings;
......
......@@ -115,7 +115,7 @@ CodeStylePool::~CodeStylePool()
QString CodeStylePool::settingsDir() const
{
const QString suffix = d->m_factory ? d->m_factory->languageId() : QLatin1String("default");
const QString suffix = d->m_factory ? d->m_factory->languageId().toString() : QLatin1String("default");
return customCodeStylesPath().append(suffix);
}
......
......@@ -132,7 +132,7 @@ bool FontSettings::fromSettings(const QString &category,
// Load color scheme from ini file
foreach (const FormatDescription &desc, descriptions) {
const TextStyle id = desc.id();
const QString fmt = s->value(group + Constants::nameForStyle(id), QString()).toString();
const QString fmt = s->value(group + QLatin1String(Constants::nameForStyle(id)), QString()).toString();
Format format;
if (fmt.isEmpty()) {
format.setForeground(desc.foreground());
......
......@@ -32,6 +32,8 @@
#include "texteditor_global.h"
#include <coreplugin/id.h>
#include <QObject>
namespace TextEditor {
......@@ -47,7 +49,7 @@ class TEXTEDITOR_EXPORT ICodeStylePreferencesFactory : public QObject
public:
explicit ICodeStylePreferencesFactory(QObject *parent = 0);
virtual QString languageId() = 0;
virtual Core::Id languageId() = 0;
virtual QString displayName() = 0;
virtual ICodeStylePreferences *createCodeStyle() const = 0;
virtual QWidget *createEditor(ICodeStylePreferences *preferences, QWidget *parent) const = 0;
......
......@@ -69,11 +69,11 @@ public:
HighlighterSettingsPage *m_highlighterSettingsPage;
SnippetsSettingsPage *m_snippetsSettingsPage;
QMap<QString, ICodeStylePreferencesFactory *> m_languageToFactory;
QMap<Core::Id, ICodeStylePreferencesFactory *> m_languageToFactory;
QMap<QString, ICodeStylePreferences *> m_languageToCodeStyle;
QMap<QString, CodeStylePool *> m_languageToCodeStylePool;
QMap<QString, QString> m_mimeTypeToLanguage;
QMap<Core::Id, ICodeStylePreferences *> m_languageToCodeStyle;
QMap<Core::Id, CodeStylePool *> m_languageToCodeStylePool;
QMap<QString, Core::Id> m_mimeTypeToLanguage;
CompletionSettings m_completionSettings;
......@@ -411,12 +411,12 @@ void TextEditorSettings::registerCodeStyleFactory(ICodeStylePreferencesFactory *
m_d->m_languageToFactory.insert(factory->languageId(), factory);
}
QMap<QString, ICodeStylePreferencesFactory *> TextEditorSettings::codeStyleFactories() const
QMap<Core::Id, ICodeStylePreferencesFactory *> TextEditorSettings::codeStyleFactories() const
{
return m_d->m_languageToFactory;
}
ICodeStylePreferencesFactory *TextEditorSettings::codeStyleFactory(const QString &languageId) const
ICodeStylePreferencesFactory *TextEditorSettings::codeStyleFactory(Core::Id languageId) const
{
return m_d->m_languageToFactory.value(languageId);
}
......@@ -426,17 +426,17 @@ ICodeStylePreferences *TextEditorSettings::codeStyle() const
return m_d->m_behaviorSettingsPage->codeStyle();
}
ICodeStylePreferences *TextEditorSettings::codeStyle(const QString &languageId) const
ICodeStylePreferences *TextEditorSettings::codeStyle(Core::Id languageId) const
{
return m_d->m_languageToCodeStyle.value(languageId, codeStyle());
}
QMap<QString, ICodeStylePreferences *> TextEditorSettings::codeStyles() const
QMap<Core::Id, ICodeStylePreferences *> TextEditorSettings::codeStyles() const
{
return m_d->m_languageToCodeStyle;
}
void TextEditorSettings::registerCodeStyle(const QString &languageId, ICodeStylePreferences *prefs)
void TextEditorSettings::registerCodeStyle(Core::Id languageId, ICodeStylePreferences *prefs)
{
m_d->m_languageToCodeStyle.insert(languageId, prefs);
}
......@@ -446,22 +446,22 @@ CodeStylePool *TextEditorSettings::codeStylePool() const
return m_d->m_behaviorSettingsPage->codeStylePool();
}
CodeStylePool *TextEditorSettings::codeStylePool(const QString &languageId) const
CodeStylePool *TextEditorSettings::codeStylePool(Core::Id languageId) const
{
return m_d->m_languageToCodeStylePool.value(languageId);
}
void TextEditorSettings::registerCodeStylePool(const QString &languageId, CodeStylePool *pool)
void TextEditorSettings::registerCodeStylePool(Core::Id languageId, CodeStylePool *pool)
{
m_d->m_languageToCodeStylePool.insert(languageId, pool);
}
void TextEditorSettings::registerMimeTypeForLanguageId(const QString &mimeType, const QString &languageId)
void TextEditorSettings::registerMimeTypeForLanguageId(const QString &mimeType, Core::Id languageId)
{
m_d->m_mimeTypeToLanguage.insert(mimeType, languageId);
}
QString TextEditorSettings::languageId(const QString &mimeType) const
Core::Id TextEditorSettings::languageId(const QString &mimeType) const
{
return m_d->m_mimeTypeToLanguage.value(mimeType);
}
......
......@@ -32,6 +32,8 @@
#include "texteditor_global.h"
#include <coreplugin/id.h>
#include <QObject>
QT_BEGIN_NAMESPACE
......@@ -87,21 +89,21 @@ public:
void setCompletionSettings(const TextEditor::CompletionSettings &);
ICodeStylePreferencesFactory *codeStyleFactory(const QString &languageId) const;
QMap<QString, ICodeStylePreferencesFactory *> codeStyleFactories() const;
ICodeStylePreferencesFactory *codeStyleFactory(Core::Id languageId) const;
QMap<Core::Id, ICodeStylePreferencesFactory *> codeStyleFactories() const;
void registerCodeStyleFactory(ICodeStylePreferencesFactory *codeStyleFactory);
CodeStylePool *codeStylePool() const;
CodeStylePool *codeStylePool(const QString &languageId) const;
void registerCodeStylePool(const QString &languageId, CodeStylePool *pool);
CodeStylePool *codeStylePool(Core::Id languageId) const;
void registerCodeStylePool(Core::Id languageId, CodeStylePool *pool);
ICodeStylePreferences *codeStyle() const;
ICodeStylePreferences *codeStyle(const QString &languageId) const;
QMap<QString, ICodeStylePreferences *> codeStyles() const;
void registerCodeStyle(const QString &languageId, ICodeStylePreferences *prefs);
ICodeStylePreferences *codeStyle(Core::Id languageId) const;
QMap<Core::Id, ICodeStylePreferences *> codeStyles() const;
void registerCodeStyle(Core::Id languageId, ICodeStylePreferences *prefs);
void registerMimeTypeForLanguageId(const QString &mimeType, const QString &languageId);
QString languageId(const QString &mimeType) const;
void registerMimeTypeForLanguageId(const QString &mimeType, Core::Id languageId);
Core::Id languageId(const QString &mimeType) const;
signals:
void fontSettingsChanged(const TextEditor::FontSettings &);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment