forked from qt-creator/qt-creator
		
	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:
		@@ -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<CppFileSettings> &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
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user