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

@@ -50,27 +50,26 @@ DocSettingsPage::DocSettingsPage()
setCategoryIcon(QLatin1String(Help::Constants::HELP_CATEGORY_ICON));
}
QWidget *DocSettingsPage::createPage(QWidget *parent)
QWidget *DocSettingsPage::widget()
{
QWidget *widget = new QWidget(parent);
m_ui.setupUi(widget);
if (!m_widget) {
m_widget = new QWidget;
m_ui.setupUi(m_widget);
connect(m_ui.addButton, SIGNAL(clicked()), this, SLOT(addDocumentation()));
connect(m_ui.removeButton, SIGNAL(clicked()), this, SLOT(removeDocumentation()));
connect(m_ui.addButton, SIGNAL(clicked()), this, SLOT(addDocumentation()));
connect(m_ui.removeButton, SIGNAL(clicked()), this, SLOT(removeDocumentation()));
m_ui.docsListWidget->installEventFilter(this);
m_ui.docsListWidget->installEventFilter(this);
const QStringList nameSpaces = HelpManager::registeredNamespaces();
foreach (const QString &nameSpace, nameSpaces) {
addItem(nameSpace, HelpManager::fileFromNamespace(nameSpace));
m_filesToRegister.insert(nameSpace, HelpManager::fileFromNamespace(nameSpace));
const QStringList nameSpaces = HelpManager::registeredNamespaces();
foreach (const QString &nameSpace, nameSpaces) {
addItem(nameSpace, HelpManager::fileFromNamespace(nameSpace));
m_filesToRegister.insert(nameSpace, HelpManager::fileFromNamespace(nameSpace));
}
m_filesToUnregister.clear();
}
m_filesToUnregister.clear();
if (m_searchKeywords.isEmpty())
m_searchKeywords = m_ui.groupBox->title();
return widget;
return m_widget;
}
void DocSettingsPage::addDocumentation()
@@ -155,9 +154,9 @@ void DocSettingsPage::apply()
m_filesToUnregister.clear();
}
bool DocSettingsPage::matches(const QString &s) const
void DocSettingsPage::finish()
{
return m_searchKeywords.contains(s, Qt::CaseInsensitive);
delete m_widget;
}
bool DocSettingsPage::eventFilter(QObject *object, QEvent *event)