diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2023-11-17 13:14:13 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2023-11-20 14:38:51 +0000 |
commit | ac952955a4e6a0471feba28079f38d84b9438a12 (patch) | |
tree | 7420897fdb82bb7a49e4c2aecb17b3da773d3c0e /src/plugins/texteditor/refactoringchanges.h | |
parent | cf74409bac2dbc58204ef85d1ba13916f76a7093 (diff) |
TextEditor: Clean up RefactoringFile interface
Change-Id: I1e415b6b51065d16bc49a25118931723b600c00b
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/plugins/texteditor/refactoringchanges.h')
-rw-r--r-- | src/plugins/texteditor/refactoringchanges.h | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/plugins/texteditor/refactoringchanges.h b/src/plugins/texteditor/refactoringchanges.h index 5d270b2f65..20de8dad87 100644 --- a/src/plugins/texteditor/refactoringchanges.h +++ b/src/plugins/texteditor/refactoringchanges.h @@ -31,6 +31,7 @@ class TextEditorWidget; class TEXTEDITOR_EXPORT RefactoringFile { Q_DISABLE_COPY(RefactoringFile) + friend class PlainRefactoringFileFactory; // access to constructor public: using Range = Utils::ChangeSet::Range; @@ -39,8 +40,7 @@ public: bool isValid() const; const QTextDocument *document() const; - // mustn't use the cursor to change the document - const QTextCursor cursor() const; + const QTextCursor cursor() const; // mustn't use the cursor to change the document Utils::FilePath filePath() const; TextEditorWidget *editor() const; @@ -69,10 +69,16 @@ protected: RefactoringFile(TextEditorWidget *editor); RefactoringFile(const Utils::FilePath &filePath); - QTextDocument *mutableDocument() const; + void invalidate() { m_filePath.clear(); } + void setFilePath(const Utils::FilePath &filePath) { m_filePath = filePath; } // FIXME: Really necessary? + void enableFormatting() { m_formattingEnabled = true; } - // derived classes may want to clear language specific extra data - virtual void fileChanged() {} +private: + virtual void fileChanged() {} // derived classes may want to clear language specific extra data + virtual void indentSelection(const QTextCursor &selection, + const TextDocument *textDocument) const; + virtual void reindentSelection(const QTextCursor &selection, + const TextDocument *textDocument) const; enum IndentType {Indent, Reindent}; void indentOrReindent(const RefactoringSelections &ranges, IndentType indent); @@ -84,10 +90,7 @@ protected: static RefactoringSelections rangesToSelections(QTextDocument *document, const QList<Range> &ranges); - virtual void indentSelection(const QTextCursor &selection, - const TextDocument *textDocument) const; - virtual void reindentSelection(const QTextCursor &selection, - const TextDocument *textDocument) const; + QTextDocument *mutableDocument() const; Utils::FilePath m_filePath; mutable Utils::TextFileFormat m_textFileFormat; @@ -102,8 +105,6 @@ protected: int m_editorCursorPosition = -1; bool m_appliedOnce = false; bool m_formattingEnabled = false; - - friend class PlainRefactoringFileFactory; // access to constructor }; class TEXTEDITOR_EXPORT RefactoringFileFactory |