diff options
author | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2010-05-10 18:30:09 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com> | 2010-05-11 15:11:12 +0200 |
commit | e53b5bc9a106f961a79e2a9c94b5dd10f05845d4 (patch) | |
tree | 9cf0387ee6007cdf2b6147dbcb68c073cfdc80ad /src/plugins/cpptools/cppcodecompletion.cpp | |
parent | b8f7d44753dc70838ac74e2262b606b5f0b363a7 (diff) | |
download | qt-creator-e53b5bc9a106f961a79e2a9c94b5dd10f05845d4.tar.gz |
Fixed completion settings to also apply to the QML code completion
By moving the completion settings into the TextEditor plugin, so that
both the CppTools and the QmlJSEditor plugins can access the settings.
The user-interface to edit the settings is still in the CppTools plugin,
since we're in string freeze at the moment. It should be moved to the
TextEditor plugin later.
For now the QML completion only supports the case-sensitivity and
partial completion options, since there is no automatic insertion of
brackets.
Task-number: QTCREATORBUG-1327
Reviewed-by: Daniel Molkentin <daniel.molkentin@nokia.com>
Diffstat (limited to 'src/plugins/cpptools/cppcodecompletion.cpp')
-rw-r--r-- | src/plugins/cpptools/cppcodecompletion.cpp | 57 |
1 files changed, 8 insertions, 49 deletions
diff --git a/src/plugins/cpptools/cppcodecompletion.cpp b/src/plugins/cpptools/cppcodecompletion.cpp index a01e63b18d..19e8e94cdf 100644 --- a/src/plugins/cpptools/cppcodecompletion.cpp +++ b/src/plugins/cpptools/cppcodecompletion.cpp @@ -56,6 +56,7 @@ #include <coreplugin/icore.h> #include <coreplugin/mimedatabase.h> #include <coreplugin/editormanager/editormanager.h> +#include <texteditor/completionsettings.h> #include <texteditor/itexteditor.h> #include <texteditor/itexteditable.h> #include <texteditor/basetexteditor.h> @@ -435,10 +436,6 @@ CppCodeCompletion::CppCodeCompletion(CppModelManager *manager) m_manager(manager), m_editor(0), m_startPosition(-1), - m_caseSensitivity(FirstLetterCaseSensitive), - m_autoInsertBrackets(true), - m_partialCompletionEnabled(true), - m_spaceAfterFunctionName(false), m_forcedCompletion(false), m_completionOperator(T_EOF_SYMBOL), m_objcEnabled(true) @@ -450,46 +447,6 @@ QIcon CppCodeCompletion::iconForSymbol(Symbol *symbol) const return m_icons.iconForSymbol(symbol); } -CppCodeCompletion::CaseSensitivity CppCodeCompletion::caseSensitivity() const -{ - return m_caseSensitivity; -} - -void CppCodeCompletion::setCaseSensitivity(CaseSensitivity caseSensitivity) -{ - m_caseSensitivity = caseSensitivity; -} - -bool CppCodeCompletion::autoInsertBrackets() const -{ - return m_autoInsertBrackets; -} - -void CppCodeCompletion::setAutoInsertBrackets(bool autoInsertBrackets) -{ - m_autoInsertBrackets = autoInsertBrackets; -} - -bool CppCodeCompletion::isPartialCompletionEnabled() const -{ - return m_partialCompletionEnabled; -} - -void CppCodeCompletion::setPartialCompletionEnabled(bool partialCompletionEnabled) -{ - m_partialCompletionEnabled = partialCompletionEnabled; -} - -bool CppCodeCompletion::isSpaceAfterFunctionName() const -{ - return m_spaceAfterFunctionName; -} - -void CppCodeCompletion::setSpaceAfterFunctionName(bool spaceAfterFunctionName) -{ - m_spaceAfterFunctionName = spaceAfterFunctionName; -} - /* Searches backwards for an access operator. */ @@ -1459,7 +1416,7 @@ void CppCodeCompletion::completions(QList<TextEditor::CompletionItem> *completio return; if (m_completionOperator != T_LPAREN) { - filter(m_completions, completions, key, m_caseSensitivity); + filter(m_completions, completions, key); } else if (m_completionOperator == T_LPAREN || m_completionOperator == T_SIGNAL || @@ -1537,7 +1494,9 @@ void CppCodeCompletion::complete(const TextEditor::CompletionItem &item) //qDebug() << "current symbol:" << overview.prettyName(symbol->name()) //<< overview.prettyType(symbol->type()); - if (m_autoInsertBrackets && symbol && symbol->type()) { + const bool autoInsertBrackets = completionSettings().m_autoInsertBrackets; + + if (autoInsertBrackets && symbol && symbol->type()) { if (Function *function = symbol->type()->asFunctionType()) { // If the member is a function, automatically place the opening parenthesis, // except when it might take template parameters. @@ -1550,7 +1509,7 @@ void CppCodeCompletion::complete(const TextEditor::CompletionItem &item) extraChars += QLatin1Char('<'); } } else if (! function->isAmbiguous()) { - if (m_spaceAfterFunctionName) + if (completionSettings().m_spaceAfterFunctionName) extraChars += QLatin1Char(' '); extraChars += QLatin1Char('('); @@ -1578,7 +1537,7 @@ void CppCodeCompletion::complete(const TextEditor::CompletionItem &item) } } - if (m_autoInsertBrackets && item.data.canConvert<CompleteFunctionDeclaration>()) { + if (autoInsertBrackets && item.data.canConvert<CompleteFunctionDeclaration>()) { // everything from the closing parenthesis on are extra chars, to // make sure an auto-inserted ")" gets replaced by ") const" if necessary int closingParen = toInsert.lastIndexOf(QLatin1Char(')')); @@ -1614,7 +1573,7 @@ bool CppCodeCompletion::partiallyComplete(const QList<TextEditor::CompletionItem } else if (completionItems.count() == 1) { complete(completionItems.first()); return true; - } else if (m_partialCompletionEnabled && m_completionOperator != T_LPAREN) { + } else if (m_completionOperator != T_LPAREN) { return TextEditor::ICompletionCollector::partiallyComplete(completionItems); } |