Text editor: Introduce per project settings

With some refactorings to make the code look better.

Reviewed-by: con
This commit is contained in:
Leandro Melo
2011-02-01 14:13:54 +01:00
parent cbafc50acc
commit ea313f3ec8
46 changed files with 1955 additions and 912 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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: