Commit 18ac68ad authored by Erik Verbruggen's avatar Erik Verbruggen

C++: add header chooser to codemodel settings page.

Change-Id: I2da9c4b382afcad2faad1817af266381a2f02b2a
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@digia.com>
parent 5cf0fabb
...@@ -34,6 +34,9 @@ ...@@ -34,6 +34,9 @@
using namespace CppTools; using namespace CppTools;
using namespace CppTools::Internal; using namespace CppTools::Internal;
static QLatin1String cppHeaderMimeType(Constants::CPP_HEADER_MIMETYPE);
static QLatin1String cHeaderMimeType(Constants::C_HEADER_MIMETYPE);
void CppCodeModelSettings::fromSettings(QSettings *s) void CppCodeModelSettings::fromSettings(QSettings *s)
{ {
s->beginGroup(QLatin1String(Constants::CPPTOOLS_SETTINGSGROUP)); s->beginGroup(QLatin1String(Constants::CPPTOOLS_SETTINGSGROUP));
...@@ -42,6 +45,7 @@ void CppCodeModelSettings::fromSettings(QSettings *s) ...@@ -42,6 +45,7 @@ void CppCodeModelSettings::fromSettings(QSettings *s)
setIdForMimeType(supporters, QLatin1String(Constants::CPP_SOURCE_MIMETYPE)); setIdForMimeType(supporters, QLatin1String(Constants::CPP_SOURCE_MIMETYPE));
setIdForMimeType(supporters, QLatin1String(Constants::OBJECTIVE_C_SOURCE_MIMETYPE)); setIdForMimeType(supporters, QLatin1String(Constants::OBJECTIVE_C_SOURCE_MIMETYPE));
setIdForMimeType(supporters, QLatin1String(Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE)); setIdForMimeType(supporters, QLatin1String(Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE));
setIdForMimeType(supporters, QLatin1String(Constants::CPP_HEADER_MIMETYPE));
QVariant v = s->value(QLatin1String(Constants::CPPTOOLS_MODEL_MANAGER_PCH_USAGE), PchUse_None); QVariant v = s->value(QLatin1String(Constants::CPPTOOLS_MODEL_MANAGER_PCH_USAGE), PchUse_None);
setPCHUsage(static_cast<PCHUsage>(v.toInt())); setPCHUsage(static_cast<PCHUsage>(v.toInt()));
s->endGroup(); s->endGroup();
...@@ -65,6 +69,23 @@ void CppCodeModelSettings::setModelManagerSupports(const QList<ModelManagerSuppo ...@@ -65,6 +69,23 @@ void CppCodeModelSettings::setModelManagerSupports(const QList<ModelManagerSuppo
m_availableModelManagerSupportersByName[supporter->displayName()] = supporter->id(); m_availableModelManagerSupportersByName[supporter->displayName()] = supporter->id();
} }
QString CppCodeModelSettings::modelManagerSupportId(const QString &mimeType) const
{
if (mimeType == cHeaderMimeType)
return m_modelManagerSupportByMimeType.value(cppHeaderMimeType);
else
return m_modelManagerSupportByMimeType.value(mimeType);
}
void CppCodeModelSettings::setModelManagerSupportId(const QString &mimeType,
const QString &supporter)
{
if (mimeType == cHeaderMimeType)
m_modelManagerSupportByMimeType.insert(cppHeaderMimeType, supporter);
else
m_modelManagerSupportByMimeType.insert(mimeType, supporter);
}
void CppCodeModelSettings::setIdForMimeType(const QVariant &var, const QString &mimeType) void CppCodeModelSettings::setIdForMimeType(const QVariant &var, const QString &mimeType)
{ {
QHash<QString, QVariant> mimeToId = var.toHash(); QHash<QString, QVariant> mimeToId = var.toHash();
......
...@@ -57,8 +57,8 @@ public: ...@@ -57,8 +57,8 @@ public:
void setModelManagerSupports(const QList<ModelManagerSupport *> &supporters); void setModelManagerSupports(const QList<ModelManagerSupport *> &supporters);
QString &modelManagerSupportId(const QString &mimeType) QString modelManagerSupportId(const QString &mimeType) const;
{ return m_modelManagerSupportByMimeType[mimeType]; } void setModelManagerSupportId(const QString &mimeType, const QString &supporter);
const QHash<QString, QString> &availableModelManagerSupportersByName() const const QHash<QString, QString> &availableModelManagerSupportersByName() const
{ return m_availableModelManagerSupportersByName; } { return m_availableModelManagerSupportersByName; }
......
...@@ -60,6 +60,7 @@ void CppCodeModelSettingsWidget::setSettings(const QSharedPointer<CppCodeModelSe ...@@ -60,6 +60,7 @@ void CppCodeModelSettingsWidget::setSettings(const QSharedPointer<CppCodeModelSe
applyToWidget(m_ui->cppChooser, QLatin1String(Constants::CPP_SOURCE_MIMETYPE)); applyToWidget(m_ui->cppChooser, QLatin1String(Constants::CPP_SOURCE_MIMETYPE));
applyToWidget(m_ui->objcChooser, QLatin1String(Constants::OBJECTIVE_C_SOURCE_MIMETYPE)); applyToWidget(m_ui->objcChooser, QLatin1String(Constants::OBJECTIVE_C_SOURCE_MIMETYPE));
applyToWidget(m_ui->objcppChooser, QLatin1String(Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE)); applyToWidget(m_ui->objcppChooser, QLatin1String(Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE));
applyToWidget(m_ui->hChooser, QLatin1String(Constants::C_HEADER_MIMETYPE));
m_ui->ignorePCHCheckBox->setChecked(s->pchUsage() == CppCodeModelSettings::PchUse_None); m_ui->ignorePCHCheckBox->setChecked(s->pchUsage() == CppCodeModelSettings::PchUse_None);
} }
...@@ -88,6 +89,8 @@ void CppCodeModelSettingsWidget::applyToSettings() const ...@@ -88,6 +89,8 @@ void CppCodeModelSettingsWidget::applyToSettings() const
QLatin1String(Constants::OBJECTIVE_C_SOURCE_MIMETYPE)); QLatin1String(Constants::OBJECTIVE_C_SOURCE_MIMETYPE));
changed |= applyToSettings(m_ui->objcppChooser, changed |= applyToSettings(m_ui->objcppChooser,
QLatin1String(Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE)); QLatin1String(Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE));
changed |= applyToSettings(m_ui->hChooser,
QLatin1String(Constants::C_HEADER_MIMETYPE));
if (m_ui->ignorePCHCheckBox->isChecked() != if (m_ui->ignorePCHCheckBox->isChecked() !=
(m_settings->pchUsage() == CppCodeModelSettings::PchUse_None)) { (m_settings->pchUsage() == CppCodeModelSettings::PchUse_None)) {
...@@ -104,11 +107,11 @@ void CppCodeModelSettingsWidget::applyToSettings() const ...@@ -104,11 +107,11 @@ void CppCodeModelSettingsWidget::applyToSettings() const
bool CppCodeModelSettingsWidget::applyToSettings(QComboBox *chooser, const QString &mimeType) const bool CppCodeModelSettingsWidget::applyToSettings(QComboBox *chooser, const QString &mimeType) const
{ {
QString newId = chooser->itemData(chooser->currentIndex()).toString(); QString newId = chooser->itemData(chooser->currentIndex()).toString();
QString &currentId = m_settings->modelManagerSupportId(mimeType); QString currentId = m_settings->modelManagerSupportId(mimeType);
if (newId == currentId) if (newId == currentId)
return false; return false;
currentId = newId; m_settings->setModelManagerSupportId(mimeType, newId);
return true; return true;
} }
......
...@@ -74,6 +74,16 @@ ...@@ -74,6 +74,16 @@
<item row="3" column="1"> <item row="3" column="1">
<widget class="QComboBox" name="objcppChooser"/> <widget class="QComboBox" name="objcppChooser"/>
</item> </item>
<item row="4" column="0">
<widget class="QLabel" name="hLabel">
<property name="text">
<string>Headers</string>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="hChooser"/>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
......
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