Preferences: Add default implementation for filtering

The default "matches" method now takes the widget and looks for all
child labels, checkboxes, push buttons and group boxes.
Because of that, the former "createWidget" method
can be called multiple times without creating a new widget
(-->widget()), and the "finished" method must ensure that the created
widget gets deleted, since not all widgets that were created are added
to the UI anymore.

Change-Id: Ia231c7c78dd8819146668e6447d36d22e7836904
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
Eike Ziller
2013-12-03 14:17:03 +01:00
parent ea1a92484a
commit deb43b4c8a
118 changed files with 1093 additions and 1731 deletions

View File

@@ -101,23 +101,6 @@ void CppCodeModelSettingsWidget::applyToSettings() const
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()
<< ' ' << m_ui->anotherGroupBox->title()
<< ' ' << m_ui->ignorePCHCheckBox->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();
@@ -141,12 +124,12 @@ CppCodeModelSettingsPage::CppCodeModelSettingsPage(QSharedPointer<CppCodeModelSe
setCategoryIcon(QLatin1String(Constants::SETTINGS_CATEGORY_CPP_ICON));
}
QWidget *CppCodeModelSettingsPage::createPage(QWidget *parent)
QWidget *CppCodeModelSettingsPage::widget()
{
m_widget = new CppCodeModelSettingsWidget(parent);
m_widget->setSettings(m_settings);
if (m_searchKeywords.isEmpty())
m_searchKeywords = m_widget->searchKeywords();
if (!m_widget) {
m_widget = new CppCodeModelSettingsWidget;
m_widget->setSettings(m_settings);
}
return m_widget;
}
@@ -156,7 +139,7 @@ void CppCodeModelSettingsPage::apply()
m_widget->applyToSettings();
}
bool CppCodeModelSettingsPage::matches(const QString &s) const
void CppCodeModelSettingsPage::finish()
{
return m_searchKeywords.contains(s, Qt::CaseInsensitive);
delete m_widget;
}