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:
@@ -52,16 +52,10 @@ AndroidSettingsPage::AndroidSettingsPage(QObject *parent)
|
||||
setCategoryIcon(QLatin1String(Constants::ANDROID_SETTINGS_CATEGORY_ICON));
|
||||
}
|
||||
|
||||
bool AndroidSettingsPage::matches(const QString &searchKeyWord) const
|
||||
QWidget *AndroidSettingsPage::widget()
|
||||
{
|
||||
return m_keywords.contains(searchKeyWord, Qt::CaseInsensitive);
|
||||
}
|
||||
|
||||
QWidget *AndroidSettingsPage::createPage(QWidget *parent)
|
||||
{
|
||||
m_widget = new AndroidSettingsWidget(parent);
|
||||
if (m_keywords.isEmpty())
|
||||
m_keywords = m_widget->searchKeywords();
|
||||
if (!m_widget)
|
||||
m_widget = new AndroidSettingsWidget;
|
||||
return m_widget;
|
||||
}
|
||||
|
||||
@@ -97,6 +91,7 @@ void AndroidSettingsPage::apply()
|
||||
|
||||
void AndroidSettingsPage::finish()
|
||||
{
|
||||
delete m_widget;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
namespace Android {
|
||||
namespace Internal {
|
||||
|
||||
@@ -44,14 +46,12 @@ class AndroidSettingsPage : public Core::IOptionsPage
|
||||
public:
|
||||
explicit AndroidSettingsPage(QObject *parent = 0);
|
||||
|
||||
bool matches(const QString &searchKeyWord) const;
|
||||
QWidget *createPage(QWidget *parent);
|
||||
QWidget *widget();
|
||||
void apply();
|
||||
void finish();
|
||||
|
||||
private:
|
||||
QString m_keywords;
|
||||
AndroidSettingsWidget *m_widget;
|
||||
QPointer<AndroidSettingsWidget> m_widget;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -129,24 +129,6 @@ AndroidSettingsWidget::~AndroidSettingsWidget()
|
||||
delete m_ui;
|
||||
}
|
||||
|
||||
QString AndroidSettingsWidget::searchKeywords() const
|
||||
{
|
||||
QString rc;
|
||||
QTextStream(&rc) << m_ui->SDKLocationLabel->text()
|
||||
<< ' ' << m_ui->SDKLocationLineEdit->text()
|
||||
<< ' ' << m_ui->NDKLocationLabel->text()
|
||||
<< ' ' << m_ui->NDKLocationLineEdit->text()
|
||||
<< ' ' << m_ui->AntLocationLabel->text()
|
||||
<< ' ' << m_ui->AntLocationLineEdit->text()
|
||||
<< ' ' << m_ui->OpenJDKLocationLabel->text()
|
||||
<< ' ' << m_ui->OpenJDKLocationLineEdit->text()
|
||||
<< ' ' << m_ui->AVDManagerLabel->text()
|
||||
<< ' ' << m_ui->DataPartitionSizeLable->text()
|
||||
<< ' ' << m_ui->DataPartitionSizeSpinBox->text();
|
||||
rc.remove(QLatin1Char('&'));
|
||||
return rc;
|
||||
}
|
||||
|
||||
void AndroidSettingsWidget::initGui()
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
|
||||
@@ -66,11 +66,10 @@ class AndroidSettingsWidget : public QWidget
|
||||
Q_OBJECT
|
||||
public:
|
||||
// Todo: This would be so much simpler if it just used Utils::PathChooser!!!
|
||||
AndroidSettingsWidget(QWidget *parent);
|
||||
AndroidSettingsWidget(QWidget *parent = 0);
|
||||
~AndroidSettingsWidget();
|
||||
|
||||
void saveSettings(bool saveNow = false);
|
||||
QString searchKeywords() const;
|
||||
|
||||
private slots:
|
||||
void sdkLocationEditingFinished();
|
||||
|
||||
Reference in New Issue
Block a user