forked from qt-creator/qt-creator
Text editor: Introduce per project settings
With some refactorings to make the code look better. Reviewed-by: con
This commit is contained in:
@@ -214,7 +214,7 @@ QString CppFileSettings::licenseTemplate(const QString &fileName, const QString
|
||||
return QString();
|
||||
}
|
||||
|
||||
QTextCodec *codec = Core::EditorManager::instance()->defaultTextEncoding();
|
||||
QTextCodec *codec = Core::EditorManager::instance()->defaultTextCodec();
|
||||
QTextStream licenseStream(&file);
|
||||
licenseStream.setCodec(codec);
|
||||
licenseStream.setAutoDetectUnicode(true);
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#include <cpptools/cppmodelmanager.h>
|
||||
#include <texteditor/texteditorsettings.h>
|
||||
#include <texteditor/tabsettings.h>
|
||||
#include <projectexplorer/editorconfiguration.h>
|
||||
|
||||
#include <QtGui/QTextBlock>
|
||||
|
||||
@@ -64,7 +65,9 @@ CppRefactoringFile CppRefactoringChanges::file(const QString &fileName)
|
||||
return CppRefactoringFile(fileName, this);
|
||||
}
|
||||
|
||||
void CppRefactoringChanges::indentSelection(const QTextCursor &selection) const
|
||||
void CppRefactoringChanges::indentSelection(const QTextCursor &selection,
|
||||
const QString &fileName,
|
||||
const TextEditor::BaseTextEditor *textEditor) const
|
||||
{
|
||||
// ### shares code with CPPEditor::indent()
|
||||
QTextDocument *doc = selection.document();
|
||||
@@ -72,7 +75,8 @@ void CppRefactoringChanges::indentSelection(const QTextCursor &selection) const
|
||||
QTextBlock block = doc->findBlock(selection.selectionStart());
|
||||
const QTextBlock end = doc->findBlock(selection.selectionEnd()).next();
|
||||
|
||||
const TextEditor::TabSettings &tabSettings(TextEditor::TextEditorSettings::instance()->tabSettings());
|
||||
const TextEditor::TabSettings &tabSettings =
|
||||
ProjectExplorer::actualTabSettings(fileName, textEditor);
|
||||
CppTools::QtStyleCodeFormatter codeFormatter(tabSettings);
|
||||
codeFormatter.updateStateUntil(block);
|
||||
|
||||
|
||||
@@ -92,7 +92,9 @@ public:
|
||||
CppRefactoringFile file(const QString &fileName);
|
||||
|
||||
private:
|
||||
virtual void indentSelection(const QTextCursor &selection) const;
|
||||
virtual void indentSelection(const QTextCursor &selection,
|
||||
const QString &fileName,
|
||||
const TextEditor::BaseTextEditor *textEditor) const;
|
||||
virtual void fileChanged(const QString &fileName);
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user