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
m_settings = s;
setupClangCodeModelWidgets();
m_ui->ignorePCHCheckBox->setChecked(s->pchUsage() == CppCodeModelSettings::PchUse_None);
setupPchCheckBox();
}
void CppCodeModelSettingsWidget::applyToSettings() const
{
bool changed = false;
if (applyClangCodeModelWidgetsToSettings())
changed = true;
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;
}
changed |= applyClangCodeModelWidgetsToSettings();
changed |= applyPchCheckBoxToSettings();
if (changed)
m_settings->toSettings(Core::ICore::settings());
......@@ -101,6 +93,12 @@ void CppCodeModelSettingsWidget::setupClangCodeModelWidgets() const
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 settingsChanged = false;
......@@ -124,6 +122,23 @@ bool CppCodeModelSettingsWidget::applyClangCodeModelWidgetsToSettings() const
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,
QObject *parent)
: Core::IOptionsPage(parent)
......
......@@ -59,7 +59,10 @@ public:
private:
void setupClangCodeModelWidgets() const;
void setupPchCheckBox() const;
bool applyClangCodeModelWidgetsToSettings() const;
bool applyPchCheckBoxToSettings() const;
private:
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