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: ...@@ -51,10 +51,10 @@ public:
virtual void indentSelection(const QTextCursor &selection, virtual void indentSelection(const QTextCursor &selection,
const QString &fileName, const QString &fileName,
const TextEditor::BaseTextEditorWidget *textEditor) const const TextEditor::BaseTextDocument *textDocument) const
{ {
const TextEditor::TabSettings &tabSettings = const TextEditor::TabSettings &tabSettings =
ProjectExplorer::actualTabSettings(fileName, textEditor); ProjectExplorer::actualTabSettings(fileName, textDocument);
CppQtStyleIndenter indenter; CppQtStyleIndenter indenter;
indenter.indent(selection.document(), selection, QChar::Null, tabSettings); indenter.indent(selection.document(), selection, QChar::Null, tabSettings);
...@@ -62,10 +62,10 @@ public: ...@@ -62,10 +62,10 @@ public:
virtual void reindentSelection(const QTextCursor &selection, virtual void reindentSelection(const QTextCursor &selection,
const QString &fileName, const QString &fileName,
const TextEditor::BaseTextEditorWidget *textEditor) const const TextEditor::BaseTextDocument *textDocument) const
{ {
const TextEditor::TabSettings &tabSettings = const TextEditor::TabSettings &tabSettings =
ProjectExplorer::actualTabSettings(fileName, textEditor); ProjectExplorer::actualTabSettings(fileName, textDocument);
CppQtStyleIndenter indenter; CppQtStyleIndenter indenter;
indenter.reindent(selection.document(), selection, tabSettings); indenter.reindent(selection.document(), selection, tabSettings);
......
...@@ -401,10 +401,10 @@ void EditorConfiguration::slotAboutToRemoveProject(ProjectExplorer::Project *pro ...@@ -401,10 +401,10 @@ void EditorConfiguration::slotAboutToRemoveProject(ProjectExplorer::Project *pro
} }
TabSettings actualTabSettings(const QString &fileName, TabSettings actualTabSettings(const QString &fileName,
const BaseTextEditorWidget *baseTextEditor) const BaseTextDocument *baseTextdocument)
{ {
if (baseTextEditor) if (baseTextdocument)
return baseTextEditor->tabSettings(); return baseTextdocument->tabSettings();
if (Project *project = SessionManager::projectForFile(fileName)) if (Project *project = SessionManager::projectForFile(fileName))
return project->editorConfiguration()->codeStyle()->tabSettings(); return project->editorConfiguration()->codeStyle()->tabSettings();
return TextEditorSettings::codeStyle()->tabSettings(); return TextEditorSettings::codeStyle()->tabSettings();
......
...@@ -40,6 +40,7 @@ namespace Core { class Id; } ...@@ -40,6 +40,7 @@ namespace Core { class Id; }
namespace TextEditor { namespace TextEditor {
class ITextEditor; class ITextEditor;
class BaseTextEditorWidget; class BaseTextEditorWidget;
class BaseTextDocument;
class TabSettings; class TabSettings;
class ICodeStylePreferences; class ICodeStylePreferences;
class TypingSettings; class TypingSettings;
...@@ -116,7 +117,7 @@ private: ...@@ -116,7 +117,7 @@ private:
// the file belongs to and return the project settings. If the file doesn't belong to any // the file belongs to and return the project settings. If the file doesn't belong to any
// project return the global settings. // project return the global settings.
PROJECTEXPLORER_EXPORT TextEditor::TabSettings actualTabSettings( PROJECTEXPLORER_EXPORT TextEditor::TabSettings actualTabSettings(
const QString &fileName, const TextEditor::BaseTextEditorWidget *baseTextEditor); const QString &fileName, const TextEditor::BaseTextDocument *baseTextDocument);
} // ProjectExplorer } // ProjectExplorer
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "qmljsindenter.h" #include "qmljsindenter.h"
#include <qmljs/parser/qmljsast_p.h> #include <qmljs/parser/qmljsast_p.h>
#include <texteditor/basetextdocument.h>
#include <texteditor/tabsettings.h> #include <texteditor/tabsettings.h>
#include <projectexplorer/editorconfiguration.h> #include <projectexplorer/editorconfiguration.h>
...@@ -50,7 +51,7 @@ public: ...@@ -50,7 +51,7 @@ public:
virtual void indentSelection(const QTextCursor &selection, virtual void indentSelection(const QTextCursor &selection,
const QString &fileName, const QString &fileName,
const TextEditor::BaseTextEditorWidget *textEditor) const const TextEditor::BaseTextDocument *textDocument) const
{ {
// ### shares code with QmlJSTextEditor::indent // ### shares code with QmlJSTextEditor::indent
QTextDocument *doc = selection.document(); QTextDocument *doc = selection.document();
...@@ -59,7 +60,7 @@ public: ...@@ -59,7 +60,7 @@ public:
const QTextBlock end = doc->findBlock(selection.selectionEnd()).next(); const QTextBlock end = doc->findBlock(selection.selectionEnd()).next();
const TextEditor::TabSettings &tabSettings = const TextEditor::TabSettings &tabSettings =
ProjectExplorer::actualTabSettings(fileName, textEditor); ProjectExplorer::actualTabSettings(fileName, textDocument);
CreatorCodeFormatter codeFormatter(tabSettings); CreatorCodeFormatter codeFormatter(tabSettings);
codeFormatter.updateStateUntil(block); codeFormatter.updateStateUntil(block);
...@@ -74,10 +75,10 @@ public: ...@@ -74,10 +75,10 @@ public:
virtual void reindentSelection(const QTextCursor &selection, virtual void reindentSelection(const QTextCursor &selection,
const QString &fileName, const QString &fileName,
const TextEditor::BaseTextEditorWidget *textEditor) const const TextEditor::BaseTextDocument *textDocument) const
{ {
const TextEditor::TabSettings &tabSettings = const TextEditor::TabSettings &tabSettings =
ProjectExplorer::actualTabSettings(fileName, textEditor); ProjectExplorer::actualTabSettings(fileName, textDocument);
QmlJSEditor::Internal::Indenter indenter; QmlJSEditor::Internal::Indenter indenter;
indenter.reindent(selection.document(), selection, tabSettings); indenter.reindent(selection.document(), selection, tabSettings);
......
...@@ -384,7 +384,7 @@ void RefactoringFile::apply() ...@@ -384,7 +384,7 @@ void RefactoringFile::apply()
void RefactoringFile::indentOrReindent(void (RefactoringChangesData::*mf)(const QTextCursor &, void RefactoringFile::indentOrReindent(void (RefactoringChangesData::*mf)(const QTextCursor &,
const QString &, const QString &,
const BaseTextEditorWidget *) const, const BaseTextDocument *) const,
const QList<QPair<QTextCursor, QTextCursor> > &ranges) const QList<QPair<QTextCursor, QTextCursor> > &ranges)
{ {
typedef QPair<QTextCursor, QTextCursor> CursorPair; typedef QPair<QTextCursor, QTextCursor> CursorPair;
...@@ -393,7 +393,7 @@ void RefactoringFile::indentOrReindent(void (RefactoringChangesData::*mf)(const ...@@ -393,7 +393,7 @@ void RefactoringFile::indentOrReindent(void (RefactoringChangesData::*mf)(const
QTextCursor selection(p.first.document()); QTextCursor selection(p.first.document());
selection.setPosition(p.first.position()); selection.setPosition(p.first.position());
selection.setPosition(p.second.position(), QTextCursor::KeepAnchor); 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() ...@@ -406,12 +406,12 @@ void RefactoringFile::fileChanged()
RefactoringChangesData::~RefactoringChangesData() 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"; 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"; qWarning() << Q_FUNC_INFO << "not implemented";
} }
......
...@@ -44,6 +44,7 @@ class QTextDocument; ...@@ -44,6 +44,7 @@ class QTextDocument;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace TextEditor { namespace TextEditor {
class BaseTextDocument;
class BaseTextEditorWidget; class BaseTextEditorWidget;
class RefactoringChanges; class RefactoringChanges;
class RefactoringFile; class RefactoringFile;
...@@ -97,7 +98,7 @@ protected: ...@@ -97,7 +98,7 @@ protected:
void indentOrReindent(void (RefactoringChangesData::*mf)(const QTextCursor &, void indentOrReindent(void (RefactoringChangesData::*mf)(const QTextCursor &,
const QString &, const QString &,
const BaseTextEditorWidget *) const, const BaseTextDocument *) const,
const QList<QPair<QTextCursor, QTextCursor> > &ranges); const QList<QPair<QTextCursor, QTextCursor> > &ranges);
protected: protected:
...@@ -159,10 +160,10 @@ public: ...@@ -159,10 +160,10 @@ public:
virtual void indentSelection(const QTextCursor &selection, virtual void indentSelection(const QTextCursor &selection,
const QString &fileName, const QString &fileName,
const BaseTextEditorWidget *textEditor) const; const BaseTextDocument *textEditor) const;
virtual void reindentSelection(const QTextCursor &selection, virtual void reindentSelection(const QTextCursor &selection,
const QString &fileName, const QString &fileName,
const BaseTextEditorWidget *textEditor) const; const BaseTextDocument *textEditor) const;
virtual void fileChanged(const QString &fileName); 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