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:
@@ -68,37 +68,17 @@ void OptionsPageWidget::setSettings(const MercurialSettings &s)
|
||||
m_ui.timeout->setValue(s.intValue(MercurialSettings::timeoutKey));
|
||||
}
|
||||
|
||||
QString OptionsPageWidget::searchKeywords() const
|
||||
{
|
||||
QString rc;
|
||||
QLatin1Char sep(' ');
|
||||
QTextStream(&rc)
|
||||
<< sep << m_ui.configGroupBox->title()
|
||||
<< sep << m_ui.mercurialCommandLabel->text()
|
||||
<< sep << m_ui.userGroupBox->title()
|
||||
<< sep << m_ui.defaultUsernameLabel->text()
|
||||
<< sep << m_ui.defaultEmailLabel->text()
|
||||
<< sep << m_ui.miscGroupBox->title()
|
||||
<< sep << m_ui.showLogEntriesLabel->text()
|
||||
<< sep << m_ui.timeoutSecondsLabel->text()
|
||||
;
|
||||
rc.remove(QLatin1Char('&'));
|
||||
return rc;
|
||||
}
|
||||
|
||||
OptionsPage::OptionsPage()
|
||||
{
|
||||
setId(VcsBase::Constants::VCS_ID_MERCURIAL);
|
||||
setDisplayName(tr("Mercurial"));
|
||||
}
|
||||
|
||||
QWidget *OptionsPage::createPage(QWidget *parent)
|
||||
QWidget *OptionsPage::widget()
|
||||
{
|
||||
if (!optionsPageWidget)
|
||||
optionsPageWidget = new OptionsPageWidget(parent);
|
||||
optionsPageWidget = new OptionsPageWidget;
|
||||
optionsPageWidget->setSettings(MercurialPlugin::settings());
|
||||
if (m_searchKeywords.isEmpty())
|
||||
m_searchKeywords = optionsPageWidget->searchKeywords();
|
||||
return optionsPageWidget;
|
||||
}
|
||||
|
||||
@@ -115,7 +95,7 @@ void OptionsPage::apply()
|
||||
}
|
||||
}
|
||||
|
||||
bool OptionsPage::matches(const QString &s) const
|
||||
void OptionsPage::finish()
|
||||
{
|
||||
return m_searchKeywords.contains(s, Qt::CaseInsensitive);
|
||||
delete optionsPageWidget;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user