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:
		@@ -428,44 +428,6 @@ void CppCodeStylePreferencesWidget::slotCurrentPreferencesChanged(TextEditor::IC
 | 
			
		||||
        updatePreview();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QString CppCodeStylePreferencesWidget::searchKeywords() const
 | 
			
		||||
{
 | 
			
		||||
    QString rc;
 | 
			
		||||
    QLatin1Char sep(' ');
 | 
			
		||||
    QTextStream(&rc)
 | 
			
		||||
       << sep << m_ui->tabSettingsWidget->searchKeywords()
 | 
			
		||||
       << sep << m_ui->indentBlockBraces->text()
 | 
			
		||||
       << sep << m_ui->indentBlockBody->text()
 | 
			
		||||
       << sep << m_ui->indentClassBraces->text()
 | 
			
		||||
       << sep << m_ui->indentEnumBraces->text()
 | 
			
		||||
       << sep << m_ui->indentNamespaceBraces->text()
 | 
			
		||||
       << sep << m_ui->indentNamespaceBody->text()
 | 
			
		||||
       << sep << m_ui->indentAccessSpecifiers->text()
 | 
			
		||||
       << sep << m_ui->indentDeclarationsRelativeToAccessSpecifiers->text()
 | 
			
		||||
       << sep << m_ui->indentFunctionBody->text()
 | 
			
		||||
       << sep << m_ui->indentFunctionBraces->text()
 | 
			
		||||
       << sep << m_ui->indentSwitchLabels->text()
 | 
			
		||||
       << sep << m_ui->indentCaseStatements->text()
 | 
			
		||||
       << sep << m_ui->indentCaseBlocks->text()
 | 
			
		||||
       << sep << m_ui->indentCaseBreak->text()
 | 
			
		||||
       << sep << m_ui->bindStarToIdentifier->text()
 | 
			
		||||
       << sep << m_ui->bindStarToTypeName->text()
 | 
			
		||||
       << sep << m_ui->bindStarToLeftSpecifier->text()
 | 
			
		||||
       << sep << m_ui->bindStarToRightSpecifier->text()
 | 
			
		||||
       << sep << m_ui->contentGroupBox->title()
 | 
			
		||||
       << sep << m_ui->bracesGroupBox->title()
 | 
			
		||||
       << sep << m_ui->switchGroupBox->title()
 | 
			
		||||
       << sep << m_ui->alignmentGroupBox->title()
 | 
			
		||||
       << sep << m_ui->pointerReferencesGroupBox->title()
 | 
			
		||||
       << sep << m_ui->extraPaddingConditions->text()
 | 
			
		||||
       << sep << m_ui->alignAssignments->text()
 | 
			
		||||
          ;
 | 
			
		||||
    for (int i = 0; i < m_ui->categoryTab->count(); i++)
 | 
			
		||||
        QTextStream(&rc) << sep << m_ui->categoryTab->tabText(i);
 | 
			
		||||
    rc.remove(QLatin1Char('&'));
 | 
			
		||||
    return rc;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CppCodeStylePreferencesWidget::slotCodeStyleSettingsChanged()
 | 
			
		||||
{
 | 
			
		||||
    if (m_blockUpdates)
 | 
			
		||||
@@ -564,19 +526,20 @@ CppCodeStyleSettingsPage::CppCodeStyleSettingsPage(QWidget *parent) :
 | 
			
		||||
    setCategoryIcon(QLatin1String(Constants::SETTINGS_CATEGORY_CPP_ICON));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
QWidget *CppCodeStyleSettingsPage::createPage(QWidget *parent)
 | 
			
		||||
QWidget *CppCodeStyleSettingsPage::widget()
 | 
			
		||||
{
 | 
			
		||||
    CppCodeStylePreferences *originalCodeStylePreferences
 | 
			
		||||
            = CppToolsSettings::instance()->cppCodeStyle();
 | 
			
		||||
    m_pageCppCodeStylePreferences = new CppCodeStylePreferences(m_widget);
 | 
			
		||||
    m_pageCppCodeStylePreferences->setDelegatingPool(originalCodeStylePreferences->delegatingPool());
 | 
			
		||||
    m_pageCppCodeStylePreferences->setCodeStyleSettings(originalCodeStylePreferences->codeStyleSettings());
 | 
			
		||||
    m_pageCppCodeStylePreferences->setCurrentDelegate(originalCodeStylePreferences->currentDelegate());
 | 
			
		||||
    // we set id so that it won't be possible to set delegate to the original prefs
 | 
			
		||||
    m_pageCppCodeStylePreferences->setId(originalCodeStylePreferences->id());
 | 
			
		||||
    m_widget = new CodeStyleEditor(TextEditorSettings::codeStyleFactory(CppTools::Constants::CPP_SETTINGS_ID),
 | 
			
		||||
                                   m_pageCppCodeStylePreferences, parent);
 | 
			
		||||
 | 
			
		||||
    if (!m_widget) {
 | 
			
		||||
        CppCodeStylePreferences *originalCodeStylePreferences
 | 
			
		||||
                = CppToolsSettings::instance()->cppCodeStyle();
 | 
			
		||||
        m_pageCppCodeStylePreferences = new CppCodeStylePreferences(m_widget);
 | 
			
		||||
        m_pageCppCodeStylePreferences->setDelegatingPool(originalCodeStylePreferences->delegatingPool());
 | 
			
		||||
        m_pageCppCodeStylePreferences->setCodeStyleSettings(originalCodeStylePreferences->codeStyleSettings());
 | 
			
		||||
        m_pageCppCodeStylePreferences->setCurrentDelegate(originalCodeStylePreferences->currentDelegate());
 | 
			
		||||
        // we set id so that it won't be possible to set delegate to the original prefs
 | 
			
		||||
        m_pageCppCodeStylePreferences->setId(originalCodeStylePreferences->id());
 | 
			
		||||
        m_widget = new CodeStyleEditor(TextEditorSettings::codeStyleFactory(CppTools::Constants::CPP_SETTINGS_ID),
 | 
			
		||||
                                       m_pageCppCodeStylePreferences);
 | 
			
		||||
    }
 | 
			
		||||
    return m_widget;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -601,9 +564,9 @@ void CppCodeStyleSettingsPage::apply()
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool CppCodeStyleSettingsPage::matches(const QString &s) const
 | 
			
		||||
void CppCodeStyleSettingsPage::finish()
 | 
			
		||||
{
 | 
			
		||||
    return m_searchKeywords.contains(s, Qt::CaseInsensitive);
 | 
			
		||||
    delete m_widget;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
} // namespace Internal
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user