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:
@@ -95,17 +95,6 @@ void QmlJSCodeStylePreferencesWidget::setPreferences(TextEditor::ICodeStylePrefe
|
||||
}
|
||||
|
||||
|
||||
QString QmlJSCodeStylePreferencesWidget::searchKeywords() const
|
||||
{
|
||||
QString rc;
|
||||
QLatin1Char sep(' ');
|
||||
QTextStream(&rc)
|
||||
<< sep << m_ui->tabPreferencesWidget->searchKeywords()
|
||||
;
|
||||
rc.remove(QLatin1Char('&'));
|
||||
return rc;
|
||||
}
|
||||
|
||||
void QmlJSCodeStylePreferencesWidget::decorateEditor(const TextEditor::FontSettings &fontSettings)
|
||||
{
|
||||
const ISnippetProvider *provider = 0;
|
||||
@@ -171,18 +160,19 @@ QmlJSCodeStyleSettingsPage::QmlJSCodeStyleSettingsPage(/*QSharedPointer<CppFileS
|
||||
setCategoryIcon(QLatin1String(QmlDesigner::Constants::SETTINGS_CATEGORY_QML_ICON));
|
||||
}
|
||||
|
||||
QWidget *QmlJSCodeStyleSettingsPage::createPage(QWidget *parent)
|
||||
QWidget *QmlJSCodeStyleSettingsPage::widget()
|
||||
{
|
||||
TextEditor::SimpleCodeStylePreferences *originalTabPreferences
|
||||
= QmlJSToolsSettings::globalCodeStyle();
|
||||
m_pageTabPreferences = new TextEditor::SimpleCodeStylePreferences(m_widget);
|
||||
m_pageTabPreferences->setDelegatingPool(originalTabPreferences->delegatingPool());
|
||||
m_pageTabPreferences->setTabSettings(originalTabPreferences->tabSettings());
|
||||
m_pageTabPreferences->setCurrentDelegate(originalTabPreferences->currentDelegate());
|
||||
m_pageTabPreferences->setId(originalTabPreferences->id());
|
||||
m_widget = new CodeStyleEditor(TextEditorSettings::codeStyleFactory(QmlJSTools::Constants::QML_JS_SETTINGS_ID),
|
||||
m_pageTabPreferences, parent);
|
||||
|
||||
if (!m_widget) {
|
||||
TextEditor::SimpleCodeStylePreferences *originalTabPreferences
|
||||
= QmlJSToolsSettings::globalCodeStyle();
|
||||
m_pageTabPreferences = new TextEditor::SimpleCodeStylePreferences(m_widget);
|
||||
m_pageTabPreferences->setDelegatingPool(originalTabPreferences->delegatingPool());
|
||||
m_pageTabPreferences->setTabSettings(originalTabPreferences->tabSettings());
|
||||
m_pageTabPreferences->setCurrentDelegate(originalTabPreferences->currentDelegate());
|
||||
m_pageTabPreferences->setId(originalTabPreferences->id());
|
||||
m_widget = new CodeStyleEditor(TextEditorSettings::codeStyleFactory(QmlJSTools::Constants::QML_JS_SETTINGS_ID),
|
||||
m_pageTabPreferences);
|
||||
}
|
||||
return m_widget;
|
||||
}
|
||||
|
||||
@@ -203,9 +193,9 @@ void QmlJSCodeStyleSettingsPage::apply()
|
||||
}
|
||||
}
|
||||
|
||||
bool QmlJSCodeStyleSettingsPage::matches(const QString &s) const
|
||||
void QmlJSCodeStyleSettingsPage::finish()
|
||||
{
|
||||
return m_searchKeywords.contains(s, Qt::CaseInsensitive);
|
||||
delete m_widget;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user