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:
@@ -101,16 +101,6 @@ void QuickToolBarSettingsPageWidget::setSettings(const QuickToolBarSettings &s)
|
||||
m_ui.textEditHelperCheckBoxPin->setChecked(s.pinContextPane);
|
||||
}
|
||||
|
||||
QString QuickToolBarSettingsPageWidget::searchKeywords() const
|
||||
{
|
||||
QString rc;
|
||||
QTextStream(&rc)
|
||||
<< ' ' << m_ui.textEditHelperCheckBox->text()
|
||||
<< ' ' << m_ui.textEditHelperCheckBoxPin->text();
|
||||
rc.remove(QLatin1Char('&'));
|
||||
return rc;
|
||||
}
|
||||
|
||||
QuickToolBarSettings QuickToolBarSettings::get()
|
||||
{
|
||||
QuickToolBarSettings settings;
|
||||
@@ -129,12 +119,12 @@ QuickToolBarSettingsPage::QuickToolBarSettingsPage() :
|
||||
setCategoryIcon(QLatin1String(QmlDesigner::Constants::SETTINGS_CATEGORY_QML_ICON));
|
||||
}
|
||||
|
||||
QWidget *QuickToolBarSettingsPage::createPage(QWidget *parent)
|
||||
QWidget *QuickToolBarSettingsPage::widget()
|
||||
{
|
||||
m_widget = new QuickToolBarSettingsPageWidget(parent);
|
||||
m_widget->setSettings(QuickToolBarSettings::get());
|
||||
if (m_searchKeywords.isEmpty())
|
||||
m_searchKeywords = m_widget->searchKeywords();
|
||||
if (!m_widget) {
|
||||
m_widget = new QuickToolBarSettingsPageWidget;
|
||||
m_widget->setSettings(QuickToolBarSettings::get());
|
||||
}
|
||||
return m_widget;
|
||||
}
|
||||
|
||||
@@ -145,7 +135,7 @@ void QuickToolBarSettingsPage::apply()
|
||||
m_widget->settings().set();
|
||||
}
|
||||
|
||||
bool QuickToolBarSettingsPage::matches(const QString &s) const
|
||||
void QuickToolBarSettingsPage::finish()
|
||||
{
|
||||
return m_searchKeywords.contains(s, Qt::CaseInsensitive);
|
||||
delete m_widget;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
|
||||
#include "ui_quicktoolbarsettingspage.h"
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
#include <QPointer>
|
||||
#include <QWidget>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@@ -76,7 +77,6 @@ public:
|
||||
QuickToolBarSettings settings() const;
|
||||
void setSettings(const QuickToolBarSettings &);
|
||||
|
||||
QString searchKeywords() const;
|
||||
static QuickToolBarSettings get();
|
||||
|
||||
private:
|
||||
@@ -91,14 +91,12 @@ class QuickToolBarSettingsPage : public Core::IOptionsPage
|
||||
public:
|
||||
QuickToolBarSettingsPage();
|
||||
|
||||
QWidget *createPage(QWidget *parent);
|
||||
QWidget *widget();
|
||||
void apply();
|
||||
void finish() { }
|
||||
bool matches(const QString &) const;
|
||||
void finish();
|
||||
|
||||
private:
|
||||
QString m_searchKeywords;
|
||||
QuickToolBarSettingsPageWidget* m_widget;
|
||||
QPointer<QuickToolBarSettingsPageWidget> m_widget;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user