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:
@@ -53,9 +53,10 @@ MacroOptionsPage::MacroOptionsPage(QObject *parent)
|
||||
TextEditor::Constants::TEXT_EDITOR_SETTINGS_TR_CATEGORY));
|
||||
}
|
||||
|
||||
QWidget *MacroOptionsPage::createPage(QWidget *parent)
|
||||
QWidget *MacroOptionsPage::widget()
|
||||
{
|
||||
m_widget = new MacroOptionsWidget(parent);
|
||||
if (!m_widget)
|
||||
m_widget = new MacroOptionsWidget;
|
||||
return m_widget;
|
||||
}
|
||||
|
||||
@@ -67,5 +68,5 @@ void MacroOptionsPage::apply()
|
||||
|
||||
void MacroOptionsPage::finish()
|
||||
{
|
||||
// Nothing to do
|
||||
delete m_widget;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
namespace Macros {
|
||||
namespace Internal {
|
||||
|
||||
@@ -45,12 +47,12 @@ public:
|
||||
MacroOptionsPage(QObject *parent = 0);
|
||||
|
||||
// IOptionsPage implementation
|
||||
QWidget *createPage(QWidget *parent);
|
||||
QWidget *widget();
|
||||
void apply();
|
||||
void finish();
|
||||
|
||||
private:
|
||||
Internal::MacroOptionsWidget *m_widget;
|
||||
QPointer<MacroOptionsWidget> m_widget;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user