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:
@@ -48,16 +48,10 @@ IosSettingsPage::IosSettingsPage(QObject *parent)
|
||||
setCategoryIcon(QLatin1String(Constants::IOS_SETTINGS_CATEGORY_ICON));
|
||||
}
|
||||
|
||||
bool IosSettingsPage::matches(const QString &searchKeyWord) const
|
||||
QWidget *IosSettingsPage::widget()
|
||||
{
|
||||
return m_keywords.contains(searchKeyWord, Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
QWidget *IosSettingsPage::createPage(QWidget *parent)
|
||||
{
|
||||
m_widget = new IosSettingsWidget(parent);
|
||||
if (m_keywords.isEmpty())
|
||||
m_keywords = m_widget->searchKeywords();
|
||||
if (!m_widget)
|
||||
m_widget = new IosSettingsWidget;
|
||||
return m_widget;
|
||||
}
|
||||
|
||||
@@ -69,6 +63,7 @@ void IosSettingsPage::apply()
|
||||
|
||||
void IosSettingsPage::finish()
|
||||
{
|
||||
delete m_widget;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
namespace Ios {
|
||||
namespace Internal {
|
||||
|
||||
@@ -43,14 +45,12 @@ class IosSettingsPage : public Core::IOptionsPage
|
||||
public:
|
||||
explicit IosSettingsPage(QObject *parent = 0);
|
||||
|
||||
bool matches(const QString &searchKeyWord) const;
|
||||
QWidget *createPage(QWidget *parent);
|
||||
QWidget *widget();
|
||||
void apply();
|
||||
void finish();
|
||||
|
||||
private:
|
||||
QString m_keywords;
|
||||
IosSettingsWidget *m_widget;
|
||||
QPointer<IosSettingsWidget> m_widget;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -65,14 +65,6 @@ IosSettingsWidget::~IosSettingsWidget()
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
QString IosSettingsWidget::searchKeywords() const
|
||||
{
|
||||
QString rc;
|
||||
QTextStream(&rc) << m_ui->deviceAskCheckBox->text();
|
||||
rc.remove(QLatin1Char('&'));
|
||||
return rc;
|
||||
}
|
||||
|
||||
void IosSettingsWidget::initGui()
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
@@ -48,11 +48,10 @@ class IosSettingsWidget : public QWidget
|
||||
Q_OBJECT
|
||||
public:
|
||||
// Todo: This would be so much simpler if it just used Utils::PathChooser!!!
|
||||
IosSettingsWidget(QWidget *parent);
|
||||
IosSettingsWidget(QWidget *parent = 0);
|
||||
~IosSettingsWidget();
|
||||
|
||||
void saveSettings();
|
||||
QString searchKeywords() const;
|
||||
|
||||
private slots:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user