Commit c9f5a14b authored by Erik Verbruggen's avatar Erik Verbruggen

C++: add code-model settings to choose one by mime-type.

The model-manager now supports multiple code models for semantic
highlighting and code completion, and will choose one based on the
mime-type of the editor.

The settings page is currently disabled. It will get enabled when a
second plug-in lands that has a ModelManagerSupport class.

Change-Id: I10023f52322ed6860397da15dba1c231e80e6517
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent f33d145e
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** 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
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "cppcodemodelsettings.h"
#include "cppmodelmanagersupport.h"
#include "cpptoolsconstants.h"
using namespace CppTools;
using namespace CppTools::Internal;
void CppCodeModelSettings::fromSettings(QSettings *s)
{
s->beginGroup(QLatin1String(Constants::CPPTOOLS_SETTINGSGROUP));
QVariant supporters = s->value(QLatin1String(Constants::CPPTOOLS_MODEL_MANAGER_SUPPORTERS_KEY));
setIdForMimeType(supporters, QLatin1String(Constants::C_SOURCE_MIMETYPE));
setIdForMimeType(supporters, QLatin1String(Constants::CPP_SOURCE_MIMETYPE));
setIdForMimeType(supporters, QLatin1String(Constants::OBJECTIVE_C_SOURCE_MIMETYPE));
setIdForMimeType(supporters, QLatin1String(Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE));
s->endGroup();
}
void CppCodeModelSettings::toSettings(QSettings *s)
{
s->beginGroup(QLatin1String(Constants::CPPTOOLS_SETTINGSGROUP));
QHash<QString, QVariant> var;
foreach (const QString &mimeType, m_modelManagerSupportByMimeType.keys())
var[mimeType] = m_modelManagerSupportByMimeType[mimeType];
s->setValue(QLatin1String(Constants::CPPTOOLS_MODEL_MANAGER_SUPPORTERS_KEY), QVariant(var));
s->endGroup();
}
void CppCodeModelSettings::setModelManagerSupports(const QList<ModelManagerSupport *> &supporters)
{
m_availableModelManagerSupportersByName.clear();
foreach (ModelManagerSupport *supporter, supporters)
m_availableModelManagerSupportersByName[supporter->displayName()] = supporter->id();
}
void CppCodeModelSettings::setIdForMimeType(const QVariant &var, const QString &mimeType)
{
QHash<QString, QVariant> mimeToId = var.toHash();
m_modelManagerSupportByMimeType[mimeType] = mimeToId.value(mimeType, defaultId()).toString();
}
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** 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
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef CPPTOOLS_INTERNAL_CPPCODEMODELSETTINGS_H
#define CPPTOOLS_INTERNAL_CPPCODEMODELSETTINGS_H
#include <QHash>
#include <QList>
#include <QSettings>
#include <QString>
namespace CppTools {
class ModelManagerSupport;
namespace Internal {
class CppCodeModelSettings
{
QHash<QString, QString> m_modelManagerSupportByMimeType;
QHash<QString, QString> m_availableModelManagerSupportersByName;
QString m_defaultId;
public:
void fromSettings(QSettings *s);
void toSettings(QSettings *s);
void setModelManagerSupports(const QList<ModelManagerSupport *> &supporters);
QString &modelManagerSupportId(const QString &mimeType)
{ return m_modelManagerSupportByMimeType[mimeType]; }
const QHash<QString, QString> &availableModelManagerSupportersByName() const
{ return m_availableModelManagerSupportersByName; }
QString defaultId() const
{ return m_defaultId; }
void setDefaultId(const QString &defaultId)
{ m_defaultId = defaultId; }
private:
void setIdForMimeType(const QVariant &var, const QString &mimeType);
};
} // namespace Internal
} // namespace CppTools
#endif // CPPTOOLS_INTERNAL_CPPCODEMODELSETTINGS_H
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** 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
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "cppcodemodelsettingspage.h"
#include "cpptoolsconstants.h"
#include "ui_cppcodemodelsettingspage.h"
#include <coreplugin/icore.h>
#include <QTextStream>
using namespace CppTools;
using namespace CppTools::Internal;
CppCodeModelSettingsWidget::CppCodeModelSettingsWidget(QWidget *parent)
: QWidget(parent)
, m_ui(new Ui::CppCodeModelSettingsPage)
{
m_ui->setupUi(this);
}
CppCodeModelSettingsWidget::~CppCodeModelSettingsWidget()
{
delete m_ui;
}
void CppCodeModelSettingsWidget::setSettings(const QSharedPointer<CppCodeModelSettings> &s)
{
m_settings = s;
applyToWidget(m_ui->cChooser, QLatin1String(Constants::C_SOURCE_MIMETYPE));
applyToWidget(m_ui->cppChooser, QLatin1String(Constants::CPP_SOURCE_MIMETYPE));
applyToWidget(m_ui->objcChooser, QLatin1String(Constants::OBJECTIVE_C_SOURCE_MIMETYPE));
applyToWidget(m_ui->objcppChooser, QLatin1String(Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE));
}
void CppCodeModelSettingsWidget::applyToWidget(QComboBox *chooser, const QString &mimeType) const
{
chooser->clear();
QStringList names = m_settings->availableModelManagerSupportersByName().keys();
qSort(names);
foreach (const QString &name, names) {
const QString &id = m_settings->availableModelManagerSupportersByName()[name];
chooser->addItem(name, id);
if (id == m_settings->modelManagerSupportId(mimeType))
chooser->setCurrentIndex(chooser->count() - 1);
}
chooser->setEnabled(names.size() > 1);
}
void CppCodeModelSettingsWidget::applyToSettings() const
{
bool changed = false;
changed |= applyToSettings(m_ui->cChooser, QLatin1String(Constants::C_SOURCE_MIMETYPE));
changed |= applyToSettings(m_ui->cppChooser, QLatin1String(Constants::CPP_SOURCE_MIMETYPE));
changed |= applyToSettings(m_ui->objcChooser,
QLatin1String(Constants::OBJECTIVE_C_SOURCE_MIMETYPE));
changed |= applyToSettings(m_ui->objcppChooser,
QLatin1String(Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE));
if (changed)
m_settings->toSettings(Core::ICore::settings());
}
QString CppCodeModelSettingsWidget::searchKeywords() const
{
QString rc;
QTextStream ts(&rc);
ts << m_ui->theGroupBox->title()
<< ' ' << m_ui->cLabel->text()
<< ' ' << m_ui->cppLabel->text()
<< ' ' << m_ui->objcLabel->text()
<< ' ' << m_ui->objcppLabel->text();
foreach (const QString &mmsNames, m_settings->availableModelManagerSupportersByName().keys())
ts << ' ' << mmsNames;
rc.remove(QLatin1Char('&'));
return rc;
}
bool CppCodeModelSettingsWidget::applyToSettings(QComboBox *chooser, const QString &mimeType) const
{
QString newId = chooser->itemData(chooser->currentIndex()).toString();
QString &currentId = m_settings->modelManagerSupportId(mimeType);
if (newId == currentId)
return false;
currentId = newId;
return true;
}
CppCodeModelSettingsPage::CppCodeModelSettingsPage(QSharedPointer<CppCodeModelSettings> &settings,
QObject *parent)
: Core::IOptionsPage(parent)
, m_settings(settings)
{
setId(Constants::CPP_CODE_MODEL_SETTINGS_ID);
setDisplayName(QCoreApplication::translate("CppTools",Constants::CPP_CODE_MODEL_SETTINGS_NAME));
setCategory(Constants::CPP_SETTINGS_CATEGORY);
setDisplayCategory(QCoreApplication::translate("CppTools",Constants::CPP_SETTINGS_TR_CATEGORY));
setCategoryIcon(QLatin1String(Constants::SETTINGS_CATEGORY_CPP_ICON));
}
QWidget *CppCodeModelSettingsPage::createPage(QWidget *parent)
{
m_widget = new CppCodeModelSettingsWidget(parent);
m_widget->setSettings(m_settings);
if (m_searchKeywords.isEmpty())
m_searchKeywords = m_widget->searchKeywords();
return m_widget;
}
void CppCodeModelSettingsPage::apply()
{
if (m_widget)
m_widget->applyToSettings();
}
bool CppCodeModelSettingsPage::matches(const QString &s) const
{
return m_searchKeywords.contains(s, Qt::CaseInsensitive);
}
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** 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
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef CPPTOOLS_INTERNAL_CPPCODEMODELSETTINGSPAGE_H
#define CPPTOOLS_INTERNAL_CPPCODEMODELSETTINGSPAGE_H
#include "cppcodemodelsettings.h"
#include <coreplugin/dialogs/ioptionspage.h>
#include <QPointer>
#include <QWidget>
QT_FORWARD_DECLARE_CLASS(QComboBox)
QT_FORWARD_DECLARE_CLASS(QSettings)
namespace CppTools {
namespace Internal {
namespace Ui { class CppCodeModelSettingsPage; }
class CppCodeModelSettingsWidget: public QWidget
{
Q_OBJECT
public:
explicit CppCodeModelSettingsWidget(QWidget *parent = 0);
~CppCodeModelSettingsWidget();
void setSettings(const QSharedPointer<CppCodeModelSettings> &s);
void applyToSettings() const;
QString searchKeywords() const;
private:
bool applyToSettings(QComboBox *chooser, const QString &mimeType) const;
void applyToWidget(QComboBox *chooser, const QString &mimeType) const;
private:
Ui::CppCodeModelSettingsPage *m_ui;
QSharedPointer<CppCodeModelSettings> m_settings;
};
class CppCodeModelSettingsPage: public Core::IOptionsPage
{
public:
explicit CppCodeModelSettingsPage(QSharedPointer<CppCodeModelSettings> &settings,
QObject *parent = 0);
QWidget *createPage(QWidget *parent);
void apply();
void finish() { }
bool matches(const QString &s) const;
private:
const QSharedPointer<CppCodeModelSettings> m_settings;
QPointer<CppCodeModelSettingsWidget> m_widget;
QString m_searchKeywords;
};
} // Internal namespace
} // CppTools namespace
#endif // CPPTOOLS_INTERNAL_CPPCODEMODELSETTINGSPAGE_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CppTools::Internal::CppCodeModelSettingsPage</class>
<widget class="QWidget" name="CppTools::Internal::CppCodeModelSettingsPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>629</width>
<height>374</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="theGroupBox">
<property name="title">
<string>Code Completion and Semantic Highlighting</string>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="cLabel">
<property name="text">
<string>C</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="cChooser">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="cppLabel">
<property name="text">
<string>C++</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="cppChooser">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="objcLabel">
<property name="text">
<string>Objective C</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="objcChooser"/>
</item>
<item row="3" column="0">
<widget class="QLabel" name="objcppLabel">
<property name="text">
<string>Objective C++</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="objcppChooser"/>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>151</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
......@@ -31,6 +31,7 @@
#include "abstracteditorsupport.h"
#include "builtinindexingsupport.h"
#include "cppcodemodelsettings.h"
#include "cppfindreferences.h"
#include "cpphighlightingsupport.h"
#include "cppindexingsupport.h"
......@@ -38,6 +39,7 @@
#include "cpppreprocessor.h"
#include "cpptoolsconstants.h"
#include "cpptoolseditorsupport.h"
#include "cpptoolsplugin.h"
#include <coreplugin/icore.h>
#include <coreplugin/progressmanager/progressmanager.h>
......@@ -257,6 +259,8 @@ CppModelManager::CppModelManager(QObject *parent)
qRegisterMetaType<CPlusPlus::Document::Ptr>("CPlusPlus::Document::Ptr");
m_modelManagerSupportFallback.reset(new ModelManagerSupportInternal);
CppToolsPlugin::instance()->codeModelSettings()->setDefaultId(
m_modelManagerSupportFallback->id());
addModelManagerSupport(m_modelManagerSupportFallback.data());
m_internalIndexingSupport = new BuiltinIndexingSupport;
......@@ -908,13 +912,17 @@ void CppModelManager::finishedRefreshingSourceFiles(const QStringList &files)
void CppModelManager::addModelManagerSupport(ModelManagerSupport *modelManagerSupport)
{
if (!m_codeModelSupporters.contains(modelManagerSupport))
m_codeModelSupporters.append(modelManagerSupport);
Q_ASSERT(modelManagerSupport);
m_idTocodeModelSupporter[modelManagerSupport->id()] = modelManagerSupport;
QSharedPointer<CppCodeModelSettings> cms = CppToolsPlugin::instance()->codeModelSettings();
cms->setModelManagerSupports(m_idTocodeModelSupporter.values());
}
ModelManagerSupport *CppModelManager::modelManagerSupportForMimeType(const QString &mimeType) const
{
return m_mimeTypeToCodeModelSupport.value(mimeType, m_modelManagerSupportFallback.data());
QSharedPointer<CppCodeModelSettings> cms = CppToolsPlugin::instance()->codeModelSettings();
const QString &id = cms->modelManagerSupportId(mimeType);
return m_idTocodeModelSupporter.value(id, m_modelManagerSupportFallback.data());
}
CppCompletionAssistProvider *CppModelManager::completionAssistProvider(Core::IEditor *editor) const
......
......@@ -105,7 +105,7 @@ public:
void finishedRefreshingSourceFiles(const QStringList &files);
virtual void addModelManagerSupport(ModelManagerSupport *codeModelSupport);
virtual void addModelManagerSupport(ModelManagerSupport *modelManagerSupport);
virtual ModelManagerSupport *modelManagerSupportForMimeType(const QString &mimeType) const;
virtual CppCompletionAssistProvider *completionAssistProvider(Core::IEditor *editor) const;
virtual CppHighlightingSupport *highlightingSupport(Core::IEditor *editor) const;
......@@ -202,9 +202,8 @@ private:
QSet<AbstractEditorSupport *> m_extraEditorSupports;
// Completion & highlighting
QList<ModelManagerSupport *> m_codeModelSupporters;
QHash<QString, ModelManagerSupport *> m_idTocodeModelSupporter;
QScopedPointer<ModelManagerSupport> m_modelManagerSupportFallback;
QHash<QString, ModelManagerSupport *> m_mimeTypeToCodeModelSupport;
// Indexing
CppIndexingSupport *m_indexingSupporter;
......
......@@ -47,7 +47,9 @@ HEADERS += completionsettingspage.h \
cpppreprocessor.h \
includeutils.h \
cpplocatordata.h \
cppmodelmanagersupportinternal.h
cppmodelmanagersupportinternal.h \
cppcodemodelsettings.h \
cppcodemodelsettingspage.h
SOURCES += completionsettingspage.cpp \
cppclassesfilter.cpp \
......@@ -93,11 +95,14 @@ SOURCES += completionsettingspage.cpp \
cpppreprocessor.cpp \
includeutils.cpp \
cpplocatordata.cpp \
cppmodelmanagersupportinternal.cpp
cppmodelmanagersupportinternal.cpp \
cppcodemodelsettings.cpp \
cppcodemodelsettingspage.cpp
FORMS += completionsettingspage.ui \
cppfilesettingspage.ui \
cppcodestylesettingspage.ui
cppcodestylesettingspage.ui \
cppcodemodelsettingspage.ui
equals(TEST, 1) {
SOURCES += \
......
......@@ -110,7 +110,12 @@ QtcPlugin {
"cpppreprocessor.cpp",
"cpppreprocessor.h",
"includeutils.cpp",
"includeutils.h"
"includeutils.h",
"cppcodemodelsettings.cpp",
"cppcodemodelsettings.h",
"cppcodemodelsettingspage.cpp",
"cppcodemodelsettingspage.h",
"cppcodemodelsettingspage.ui"
]
Group {
......
......@@ -51,11 +51,14 @@ const char CPP_HEADER_MIMETYPE[] = "text/x-c++hdr";
const char CPPTOOLS_SETTINGSGROUP[] = "CppTools";
const char LOWERCASE_CPPFILES_KEY[] = "LowerCaseFiles";
enum { lowerCaseFilesDefault = 1 };
const char CPPTOOLS_MODEL_MANAGER_SUPPORTERS_KEY[] = "ModelManagerSupporters";
const char CPP_CODE_STYLE_SETTINGS_ID[] = "A.Code Style";
const char CPP_CODE_STYLE_SETTINGS_NAME[] = QT_TRANSLATE_NOOP("CppTools", "Code Style");
const char CPP_FILE_SETTINGS_ID[] = "B.File Naming";
const char CPP_FILE_SETTINGS_NAME[] = QT_TRANSLATE_NOOP("CppTools", "File Naming");
const char CPP_CODE_MODEL_SETTINGS_ID[] = "C.Code Model";
const char CPP_CODE_MODEL_SETTINGS_NAME[] = QT_TRANSLATE_NOOP("CppTools", "Code Model");
const char CPP_SETTINGS_CATEGORY[] = "I.C++";
const char CPP_SETTINGS_TR_CATEGORY[] = QT_TRANSLATE_NOOP("CppTools", "C++");
const char SETTINGS_CATEGORY_CPP_ICON[] = ":/core/images/category_cpp.png";
......
......@@ -30,6 +30,7 @@
#include "cpptoolsconstants.h"
#include "cpptoolsplugin.h"
#include "cppfilesettingspage.h"
#include "cppcodemodelsettingspage.h"
#include "cppcodestylesettingspage.h"
#include "cppclassesfilter.h"
#include "cppfunctionsfilter.h"
......@@ -74,8 +75,9 @@ enum { debug = 0 };
static CppToolsPlugin *m_instance = 0;
static QHash<QString, QString> m_headerSourceMapping;
CppToolsPlugin::CppToolsPlugin() :
m_fileSettings(new CppFileSettings)
CppToolsPlugin::CppToolsPlugin()
: m_fileSettings(new CppFileSettings)
, m_codeModelSettings(new CppCodeModelSettings)
{
m_instance = this;
}
......@@ -127,6 +129,7 @@ bool CppToolsPlugin::initialize(const QStringList &arguments, QString *error)
addAutoReleasedObject(new CppFunctionsFilter(locatorData));
addAutoReleasedObject(new CppCurrentDocumentFilter(modelManager));
addAutoReleasedObject(new CppFileSettingsPage(m_fileSettings));
// addAutoReleasedObject(new CppCodeModelSettingsPage(m_codeModelSettings));
addAutoReleasedObject(new SymbolsFindFilter(modelManager));
addAutoReleasedObject(new CppCodeStyleSettingsPage);
......@@ -165,6 +168,7 @@ void CppToolsPlugin::extensionsInitialized()
m_fileSettings->fromSettings(ICore::settings());
if (!m_fileSettings->applySuffixesToMimeDB())
qWarning("Unable to apply cpp suffixes to mime database (cpp mime types not found).\n");
m_codeModelSettings->fromSettings(ICore::settings());
}
ExtensionSystem::IPlugin::ShutdownFlag CppToolsPlugin::aboutToShutdown()
......@@ -172,6 +176,11 @@ ExtensionSystem::IPlugin::ShutdownFlag CppToolsPlugin::aboutToShutdown()
return SynchronousShutdown;
}
QSharedPointer<CppCodeModelSettings> CppToolsPlugin::codeModelSettings() const
{
return m_codeModelSettings;
}
void CppToolsPlugin::switchHeaderSource()
{
QString otherFile = correspondingHeaderOrSource(
......
......@@ -49,6 +49,7 @@ namespace Internal {
class CppModelManager;
struct CppFileSettings;
class CppCodeModelSettings;
class CPPTOOLS_EXPORT CppToolsPlugin : public ExtensionSystem::IPlugin
{
......@@ -68,6 +69,8 @@ public:
void extensionsInitialized();
ShutdownFlag aboutToShutdown();
QSharedPointer<CppCodeModelSettings> codeModelSettings() const;
public slots:
void switchHeaderSource();
void switchHeaderSourceInNextSplit();
......@@ -225,6 +228,7 @@ private:
private:
QSharedPointer<CppFileSettings> m_fileSettings;
QSharedPointer<CppCodeModelSettings> m_codeModelSettings;
CppToolsSettings *m_settings;
};
......
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