Commit dcba4a27 authored by Eike Ziller's avatar Eike Ziller
Browse files

Use document instead of widget in TextEditor::RefactoringChangesData



Change-Id: I938041c9774fbebd1edc6dc29ccfa569bae94f70
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
parent 7be1f106
......@@ -51,10 +51,10 @@ public:
virtual void indentSelection(const QTextCursor &selection,
const QString &fileName,
const TextEditor::BaseTextEditorWidget *textEditor) const
const TextEditor::BaseTextDocument *textDocument) const
{
const TextEditor::TabSettings &tabSettings =
ProjectExplorer::actualTabSettings(fileName, textEditor);
ProjectExplorer::actualTabSettings(fileName, textDocument);
CppQtStyleIndenter indenter;
indenter.indent(selection.document(), selection, QChar::Null, tabSettings);
......@@ -62,10 +62,10 @@ public:
virtual void reindentSelection(const QTextCursor &selection,
const QString &fileName,
const TextEditor::BaseTextEditorWidget *textEditor) const
const TextEditor::BaseTextDocument *textDocument) const
{
const TextEditor::TabSettings &tabSettings =
ProjectExplorer::actualTabSettings(fileName, textEditor);
ProjectExplorer::actualTabSettings(fileName, textDocument);
CppQtStyleIndenter indenter;
indenter.reindent(selection.document(), selection, tabSettings);
......
......@@ -401,10 +401,10 @@ void EditorConfiguration::slotAboutToRemoveProject(ProjectExplorer::Project *pro
}
TabSettings actualTabSettings(const QString &fileName,
const BaseTextEditorWidget *baseTextEditor)
const BaseTextDocument *baseTextdocument)
{
if (baseTextEditor)
return baseTextEditor->tabSettings();
if (baseTextdocument)
return baseTextdocument->tabSettings();
if (Project *project = SessionManager::projectForFile(fileName))
return project->editorConfiguration()->codeStyle()->tabSettings();
return TextEditorSettings::codeStyle()->tabSettings();
......
......@@ -40,6 +40,7 @@ namespace Core { class Id; }
namespace TextEditor {
class ITextEditor;
class BaseTextEditorWidget;
class BaseTextDocument;
class TabSettings;
class ICodeStylePreferences;
class TypingSettings;
......@@ -116,7 +117,7 @@ private:
// the file belongs to and return the project settings. If the file doesn't belong to any
// project return the global settings.
PROJECTEXPLORER_EXPORT TextEditor::TabSettings actualTabSettings(
const QString &fileName, const TextEditor::BaseTextEditorWidget *baseTextEditor);
const QString &fileName, const TextEditor::BaseTextDocument *baseTextDocument);
} // ProjectExplorer
......
......@@ -33,6 +33,7 @@
#include "qmljsindenter.h"
#include <qmljs/parser/qmljsast_p.h>
#include <texteditor/basetextdocument.h>
#include <texteditor/tabsettings.h>
#include <projectexplorer/editorconfiguration.h>
......@@ -50,7 +51,7 @@ public:
virtual void indentSelection(const QTextCursor &selection,
const QString &fileName,
const TextEditor::BaseTextEditorWidget *textEditor) const
const TextEditor::BaseTextDocument *textDocument) const
{
// ### shares code with QmlJSTextEditor::indent
QTextDocument *doc = selection.document();
......@@ -59,7 +60,7 @@ public:
const QTextBlock end = doc->findBlock(selection.selectionEnd()).next();
const TextEditor::TabSettings &tabSettings =
ProjectExplorer::actualTabSettings(fileName, textEditor);
ProjectExplorer::actualTabSettings(fileName, textDocument);
CreatorCodeFormatter codeFormatter(tabSettings);
codeFormatter.updateStateUntil(block);
......@@ -74,10 +75,10 @@ public:
virtual void reindentSelection(const QTextCursor &selection,
const QString &fileName,
const TextEditor::BaseTextEditorWidget *textEditor) const
const TextEditor::BaseTextDocument *textDocument) const
{
const TextEditor::TabSettings &tabSettings =
ProjectExplorer::actualTabSettings(fileName, textEditor);
ProjectExplorer::actualTabSettings(fileName, textDocument);
QmlJSEditor::Internal::Indenter indenter;
indenter.reindent(selection.document(), selection, tabSettings);
......
......@@ -384,7 +384,7 @@ void RefactoringFile::apply()
void RefactoringFile::indentOrReindent(void (RefactoringChangesData::*mf)(const QTextCursor &,
const QString &,
const BaseTextEditorWidget *) const,
const BaseTextDocument *) const,
const QList<QPair<QTextCursor, QTextCursor> > &ranges)
{
typedef QPair<QTextCursor, QTextCursor> CursorPair;
......@@ -393,7 +393,7 @@ void RefactoringFile::indentOrReindent(void (RefactoringChangesData::*mf)(const
QTextCursor selection(p.first.document());
selection.setPosition(p.first.position());
selection.setPosition(p.second.position(), QTextCursor::KeepAnchor);
((*m_data).*(mf))(selection, m_fileName, m_editor);
((*m_data).*(mf))(selection, m_fileName, m_editor->baseTextDocument());
}
}
......@@ -406,12 +406,12 @@ void RefactoringFile::fileChanged()
RefactoringChangesData::~RefactoringChangesData()
{}
void RefactoringChangesData::indentSelection(const QTextCursor &, const QString &, const BaseTextEditorWidget *) const
void RefactoringChangesData::indentSelection(const QTextCursor &, const QString &, const BaseTextDocument *) const
{
qWarning() << Q_FUNC_INFO << "not implemented";
}
void RefactoringChangesData::reindentSelection(const QTextCursor &, const QString &, const BaseTextEditorWidget *) const
void RefactoringChangesData::reindentSelection(const QTextCursor &, const QString &, const BaseTextDocument *) const
{
qWarning() << Q_FUNC_INFO << "not implemented";
}
......
......@@ -44,6 +44,7 @@ class QTextDocument;
QT_END_NAMESPACE
namespace TextEditor {
class BaseTextDocument;
class BaseTextEditorWidget;
class RefactoringChanges;
class RefactoringFile;
......@@ -97,7 +98,7 @@ protected:
void indentOrReindent(void (RefactoringChangesData::*mf)(const QTextCursor &,
const QString &,
const BaseTextEditorWidget *) const,
const BaseTextDocument *) const,
const QList<QPair<QTextCursor, QTextCursor> > &ranges);
protected:
......@@ -159,10 +160,10 @@ public:
virtual void indentSelection(const QTextCursor &selection,
const QString &fileName,
const BaseTextEditorWidget *textEditor) const;
const BaseTextDocument *textEditor) const;
virtual void reindentSelection(const QTextCursor &selection,
const QString &fileName,
const BaseTextEditorWidget *textEditor) const;
const BaseTextDocument *textEditor) const;
virtual void fileChanged(const QString &fileName);
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment