diff options
| author | David Schulz <[email protected]> | 2016-08-25 13:25:45 +0200 |
|---|---|---|
| committer | David Schulz <[email protected]> | 2016-08-31 05:33:56 +0000 |
| commit | 89ff2c1db5ee2068cf763ff1789b17b7f2afa118 (patch) | |
| tree | e09226f489917c0263745f3e54858be6abaa8868 /src/plugins/cpptools/cppqtstyleindenter.cpp | |
| parent | b97bc4016f90435fe9e82c3c2855804a34ca97de (diff) | |
Editor: Collect indentation for a list of text blocks
Allows the indenter to reuse code formatter structures.
Task-number: QTCREATORBUG-16420
Change-Id: Ie906d7fdcb50798da02ef5b750fb03ae752aadc1
Reviewed-by: Nikolai Kosjar <[email protected]>
Diffstat (limited to 'src/plugins/cpptools/cppqtstyleindenter.cpp')
| -rw-r--r-- | src/plugins/cpptools/cppqtstyleindenter.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/plugins/cpptools/cppqtstyleindenter.cpp b/src/plugins/cpptools/cppqtstyleindenter.cpp index e1596c60c69..8877d5b49c9 100644 --- a/src/plugins/cpptools/cppqtstyleindenter.cpp +++ b/src/plugins/cpptools/cppqtstyleindenter.cpp @@ -186,3 +186,21 @@ CppCodeStyleSettings CppQtStyleIndenter::codeStyleSettings() const return m_cppCodeStylePreferences->currentCodeStyleSettings(); return CppCodeStyleSettings(); } + +TextEditor::IndentationForBlock +CppQtStyleIndenter::indentationForBlocks(const QVector<QTextBlock> &blocks, + const TextEditor::TabSettings &tabSettings) +{ + QtStyleCodeFormatter codeFormatter(tabSettings, codeStyleSettings()); + + codeFormatter.updateStateUntil(blocks.last()); + + TextEditor::IndentationForBlock ret; + foreach (QTextBlock block, blocks) { + int indent; + int padding; + codeFormatter.indentFor(block, &indent, &padding); + ret.insert(block.blockNumber(), indent); + } + return ret; +} |
