From deb43b4c8a261855252aeee09fd6df283576932e Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 3 Dec 2013 14:17:03 +0100 Subject: 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 --- src/plugins/cpptools/cppfilesettingspage.cpp | 29 +++++++--------------------- 1 file changed, 7 insertions(+), 22 deletions(-) (limited to 'src/plugins/cpptools/cppfilesettingspage.cpp') diff --git a/src/plugins/cpptools/cppfilesettingspage.cpp b/src/plugins/cpptools/cppfilesettingspage.cpp index 1571e7ac22..48235be2d5 100644 --- a/src/plugins/cpptools/cppfilesettingspage.cpp +++ b/src/plugins/cpptools/cppfilesettingspage.cpp @@ -293,21 +293,6 @@ CppFileSettings CppFileSettingsWidget::settings() const return rc; } -QString CppFileSettingsWidget::searchKeywords() const -{ - QString rc; - QTextStream(&rc) << m_ui->headersGroupBox->title() - << ' ' << m_ui->headerSuffixLabel->text() - << ' ' << m_ui->headerSearchPathsLabel->text() - << ' ' << m_ui->sourcesGroupBox->title() - << ' ' << m_ui->sourceSuffixLabel->text() - << ' ' << m_ui->sourceSearchPathsLabel->text() - << ' ' << m_ui->lowerCaseFileNamesCheckBox->text() - << ' ' << m_ui->licenseTemplateLabel->text(); - rc.remove(QLatin1Char('&')); - return rc; -} - static inline void setComboText(QComboBox *cb, const QString &text, int defaultIndex = 0) { const int index = cb->findText(text); @@ -355,13 +340,13 @@ CppFileSettingsPage::CppFileSettingsPage(QSharedPointer &settin setCategoryIcon(QLatin1String(Constants::SETTINGS_CATEGORY_CPP_ICON)); } -QWidget *CppFileSettingsPage::createPage(QWidget *parent) +QWidget *CppFileSettingsPage::widget() { - m_widget = new CppFileSettingsWidget(parent); - m_widget->setSettings(*m_settings); - if (m_searchKeywords.isEmpty()) - m_searchKeywords = m_widget->searchKeywords(); + if (!m_widget) { + m_widget = new CppFileSettingsWidget; + m_widget->setSettings(*m_settings); + } return m_widget; } @@ -378,9 +363,9 @@ void CppFileSettingsPage::apply() } } -bool CppFileSettingsPage::matches(const QString &s) const +void CppFileSettingsPage::finish() { - return m_searchKeywords.contains(s, Qt::CaseInsensitive); + delete m_widget; } } // namespace Internal -- cgit v1.2.1