Commit 439db76f authored by Nikolai Kosjar's avatar Nikolai Kosjar

CppTools: Clean up CppCodeModelSettingsWidget

Change-Id: Iee93d2d656a8a5c991b292d3e591cedd3e86f9e3
Reviewed-by: default avatarMarco Bubke <marco.bubke@theqtcompany.com>
parent 48952084
...@@ -64,23 +64,15 @@ void CppCodeModelSettingsWidget::setSettings(const QSharedPointer<CppCodeModelSe ...@@ -64,23 +64,15 @@ void CppCodeModelSettingsWidget::setSettings(const QSharedPointer<CppCodeModelSe
m_settings = s; m_settings = s;
setupClangCodeModelWidgets(); setupClangCodeModelWidgets();
m_ui->ignorePCHCheckBox->setChecked(s->pchUsage() == CppCodeModelSettings::PchUse_None); setupPchCheckBox();
} }
void CppCodeModelSettingsWidget::applyToSettings() const void CppCodeModelSettingsWidget::applyToSettings() const
{ {
bool changed = false; bool changed = false;
if (applyClangCodeModelWidgetsToSettings()) changed |= applyClangCodeModelWidgetsToSettings();
changed = true; changed |= applyPchCheckBoxToSettings();
if (m_ui->ignorePCHCheckBox->isChecked() !=
(m_settings->pchUsage() == CppCodeModelSettings::PchUse_None)) {
m_settings->setPCHUsage(
m_ui->ignorePCHCheckBox->isChecked() ? CppCodeModelSettings::PchUse_None
: CppCodeModelSettings::PchUse_BuildSystem);
changed = true;
}
if (changed) if (changed)
m_settings->toSettings(Core::ICore::settings()); m_settings->toSettings(Core::ICore::settings());
...@@ -101,6 +93,12 @@ void CppCodeModelSettingsWidget::setupClangCodeModelWidgets() const ...@@ -101,6 +93,12 @@ void CppCodeModelSettingsWidget::setupClangCodeModelWidgets() const
m_ui->clangOptionsToAppendTextEdit->document()->setPlainText(extraClangOptions); m_ui->clangOptionsToAppendTextEdit->document()->setPlainText(extraClangOptions);
} }
void CppCodeModelSettingsWidget::setupPchCheckBox() const
{
const bool ignorePch = m_settings->pchUsage() == CppCodeModelSettings::PchUse_None;
m_ui->ignorePCHCheckBox->setChecked(ignorePch);
}
bool CppCodeModelSettingsWidget::applyClangCodeModelWidgetsToSettings() const bool CppCodeModelSettingsWidget::applyClangCodeModelWidgetsToSettings() const
{ {
bool settingsChanged = false; bool settingsChanged = false;
...@@ -124,6 +122,23 @@ bool CppCodeModelSettingsWidget::applyClangCodeModelWidgetsToSettings() const ...@@ -124,6 +122,23 @@ bool CppCodeModelSettingsWidget::applyClangCodeModelWidgetsToSettings() const
return settingsChanged; return settingsChanged;
} }
bool CppCodeModelSettingsWidget::applyPchCheckBoxToSettings() const
{
const bool newIgnorePch = m_ui->ignorePCHCheckBox->isChecked();
const bool previousIgnorePch = m_settings->pchUsage() == CppCodeModelSettings::PchUse_None;
if (newIgnorePch != previousIgnorePch) {
const CppCodeModelSettings::PCHUsage pchUsage = m_ui->ignorePCHCheckBox->isChecked()
? CppCodeModelSettings::PchUse_None
: CppCodeModelSettings::PchUse_BuildSystem;
m_settings->setPCHUsage(pchUsage);
return true;
}
return false;
}
CppCodeModelSettingsPage::CppCodeModelSettingsPage(QSharedPointer<CppCodeModelSettings> &settings, CppCodeModelSettingsPage::CppCodeModelSettingsPage(QSharedPointer<CppCodeModelSettings> &settings,
QObject *parent) QObject *parent)
: Core::IOptionsPage(parent) : Core::IOptionsPage(parent)
......
...@@ -59,7 +59,10 @@ public: ...@@ -59,7 +59,10 @@ public:
private: private:
void setupClangCodeModelWidgets() const; void setupClangCodeModelWidgets() const;
void setupPchCheckBox() const;
bool applyClangCodeModelWidgetsToSettings() const; bool applyClangCodeModelWidgetsToSettings() const;
bool applyPchCheckBoxToSettings() const;
private: private:
Ui::CppCodeModelSettingsPage *m_ui; Ui::CppCodeModelSettingsPage *m_ui;
......
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