diff options
author | Eike Ziller <[email protected]> | 2025-05-06 13:49:40 +0200 |
---|---|---|
committer | Eike Ziller <[email protected]> | 2025-06-06 13:43:32 +0000 |
commit | a8a6f911cb1794b897aecdfd3006897e9424b9de (patch) | |
tree | 58756840281056a40ab3d4b7b5e620751a37aec5 | |
parent | f8c7837c3b2c0be0a411a05e80e58283c7880749 (diff) |
a18b33d5a1a16a8e22a3771e3c18ce3ca735eba5 got rid of a cast from
TextEditorWidget to PlainTextEdit.
Using TextEditorWidget directly gets rid of another cast that casts that
PlainTextEdit back to TextEditorWidget.
Change-Id: Ib287c19188e7f86be8d0a7f6b630e4473d7d906e
Reviewed-by: David Schulz <[email protected]>
3 files changed, 40 insertions, 32 deletions
diff --git a/src/plugins/qmldesigner/components/integration/designdocument.cpp b/src/plugins/qmldesigner/components/integration/designdocument.cpp index 2331f4971a7..52633745915 100644 --- a/src/plugins/qmldesigner/components/integration/designdocument.cpp +++ b/src/plugins/qmldesigner/components/integration/designdocument.cpp @@ -14,28 +14,29 @@ #include <model/modelresourcemanagement.h> #include <nodeinstanceview.h> #include <nodelistproperty.h> +#include <qmldesignerplugin.h> +#include <qmlobjectnode.h> #include <rewritingexception.h> +#include <svgpasteaction.h> +#include <timelineactions.h> #include <utils3d.h> #include <variantproperty.h> #include <viewmanager.h> -#include <qmldesignerplugin.h> -#include <qmlobjectnode.h> +#include <coreplugin/editormanager/editormanager.h> +#include <coreplugin/icore.h> +#include <coreplugin/idocument.h> #include <projectexplorer/buildsystem.h> -#include <projectexplorer/projecttree.h> +#include <projectexplorer/kit.h> #include <projectexplorer/project.h> -#include <projectexplorer/target.h> #include <projectexplorer/projectmanager.h> -#include <projectexplorer/kit.h> +#include <projectexplorer/projecttree.h> +#include <projectexplorer/target.h> #include <qtsupport/qtkitaspect.h> #include <qtsupport/qtsupportconstants.h> #include <qtsupport/qtversionmanager.h> -#include <coreplugin/icore.h> -#include <coreplugin/idocument.h> -#include <coreplugin/editormanager/editormanager.h> +#include <texteditor/texteditorwidget.h> #include <utils/algorithm.h> -#include <timelineactions.h> -#include <svgpasteaction.h> #include <qmljs/qmljsmodelmanagerinterface.h> @@ -364,22 +365,25 @@ bool DesignDocument::isDocumentLoaded() const void DesignDocument::resetToDocumentModel() { - const Utils::PlainTextEdit *edit = plainTextEdit(); + const TextEditor::TextEditorWidget *edit = textEditorWidget(); if (edit) edit->document()->clearUndoRedoStacks(); m_inFileComponentModel.reset(); } -void DesignDocument::loadDocument(Utils::PlainTextEdit *edit) +void DesignDocument::loadDocument(TextEditor::TextEditorWidget *edit) { Q_CHECK_PTR(edit); - connect(edit, &Utils::PlainTextEdit::undoAvailable, this, &DesignDocument::undoAvailable); - connect(edit, &Utils::PlainTextEdit::redoAvailable, this, &DesignDocument::redoAvailable); - connect(edit, &Utils::PlainTextEdit::modificationChanged, this, &DesignDocument::dirtyStateChanged); + connect(edit, &TextEditor::TextEditorWidget::undoAvailable, this, &DesignDocument::undoAvailable); + connect(edit, &TextEditor::TextEditorWidget::redoAvailable, this, &DesignDocument::redoAvailable); + connect(edit, + &TextEditor::TextEditorWidget::modificationChanged, + this, + &DesignDocument::dirtyStateChanged); - m_documentTextModifier.reset(new BaseTextEditModifier(qobject_cast<TextEditor::TextEditorWidget *>(plainTextEdit()))); + m_documentTextModifier.reset(new BaseTextEditModifier(edit)); connect(m_documentTextModifier.get(), &TextModifier::textChanged, @@ -402,7 +406,7 @@ void DesignDocument::changeToDocumentModel() viewManager().detachRewriterView(); viewManager().detachViewsExceptRewriterAndComponetView(); - const Utils::PlainTextEdit *edit = plainTextEdit(); + const TextEditor::TextEditorWidget *edit = textEditorWidget(); if (edit) edit->document()->clearUndoRedoStacks(); @@ -449,7 +453,7 @@ void DesignDocument::changeToInFileComponentModel(ComponentTextModifier *textMod viewManager().detachRewriterView(); viewManager().detachViewsExceptRewriterAndComponetView(); - const Utils::PlainTextEdit *edit = plainTextEdit(); + const TextEditor::TextEditorWidget *edit = textEditorWidget(); if (edit) edit->document()->clearUndoRedoStacks(); @@ -516,23 +520,23 @@ void DesignDocument::attachRewriterToModel() bool DesignDocument::isUndoAvailable() const { - if (plainTextEdit()) - return plainTextEdit()->document()->isUndoAvailable(); + if (textEditorWidget()) + return textEditorWidget()->document()->isUndoAvailable(); return false; } bool DesignDocument::isRedoAvailable() const { - if (plainTextEdit()) - return plainTextEdit()->document()->isRedoAvailable(); + if (textEditorWidget()) + return textEditorWidget()->document()->isRedoAvailable(); return false; } void DesignDocument::clearUndoRedoStacks() const { - const Utils::PlainTextEdit *edit = plainTextEdit(); + const TextEditor::TextEditorWidget *edit = textEditorWidget(); if (edit) edit->document()->clearUndoRedoStacks(); } @@ -776,7 +780,7 @@ TextEditor::BaseTextEditor *DesignDocument::textEditor() const return qobject_cast<TextEditor::BaseTextEditor*>(editor()); } -Utils::PlainTextEdit *DesignDocument::plainTextEdit() const +TextEditor::TextEditorWidget *DesignDocument::textEditorWidget() const { if (TextEditor::BaseTextEditor *editor = textEditor()) return editor->editorWidget(); @@ -791,7 +795,7 @@ ModelNode DesignDocument::rootModelNode() const void DesignDocument::undo() { if (rewriterView() && !rewriterView()->modificationGroupActive()) { - plainTextEdit()->undo(); + textEditorWidget()->undo(); rewriterView()->forceAmend(); } @@ -801,7 +805,7 @@ void DesignDocument::undo() void DesignDocument::redo() { if (rewriterView() && !rewriterView()->modificationGroupActive()) { - plainTextEdit()->redo(); + textEditorWidget()->redo(); rewriterView()->forceAmend(); } diff --git a/src/plugins/qmldesigner/components/integration/designdocument.h b/src/plugins/qmldesigner/components/integration/designdocument.h index 160b6737e74..f621dbe113f 100644 --- a/src/plugins/qmldesigner/components/integration/designdocument.h +++ b/src/plugins/qmldesigner/components/integration/designdocument.h @@ -28,6 +28,10 @@ namespace ProjectExplorer { class Target; } +namespace TextEditor { +class TextEditorWidget; +} + namespace QmlDesigner { class ModelNode; @@ -50,7 +54,7 @@ public: QString displayName() const; QString simplfiedDisplayName() const; - void loadDocument(Utils::PlainTextEdit *edit); + void loadDocument(TextEditor::TextEditorWidget *edit); void attachRewriterToModel(); void close(); #ifndef QDS_USE_PROJECTSTORAGE @@ -77,7 +81,7 @@ public: Core::IEditor *editor() const; TextEditor::BaseTextEditor *textEditor() const; - Utils::PlainTextEdit *plainTextEdit() const; + TextEditor::TextEditorWidget *textEditorWidget() const; Utils::FilePath fileName() const; ProjectExplorer::Target *currentTarget() const; bool isDocumentLoaded() const; diff --git a/src/plugins/qmldesigner/qmldesignerplugin.cpp b/src/plugins/qmldesigner/qmldesignerplugin.cpp index e552748615f..7f368fb7b4d 100644 --- a/src/plugins/qmldesigner/qmldesignerplugin.cpp +++ b/src/plugins/qmldesigner/qmldesignerplugin.cpp @@ -553,8 +553,8 @@ void QmlDesignerPlugin::jumpTextCursorToSelectedModelNode() if (selectedNode.isValid()) { const int nodeOffset = rewriterView()->nodeOffset(selectedNode); if (nodeOffset > 0) { - const ModelNode currentSelectedNode = rewriterView()-> - nodeAtTextCursorPosition(currentDesignDocument()->plainTextEdit()->textCursor().position()); + const ModelNode currentSelectedNode = rewriterView()->nodeAtTextCursorPosition( + currentDesignDocument()->textEditorWidget()->textCursor().position()); if (currentSelectedNode != selectedNode) { int line, column; currentDesignDocument()->textEditor()->convertPosition(nodeOffset, &line, &column); @@ -567,7 +567,7 @@ void QmlDesignerPlugin::jumpTextCursorToSelectedModelNode() void QmlDesignerPlugin::selectModelNodeUnderTextCursor() { - const int cursorPosition = currentDesignDocument()->plainTextEdit()->textCursor().position(); + const int cursorPosition = currentDesignDocument()->textEditorWidget()->textCursor().position(); ModelNode modelNode = rewriterView()->nodeAtTextCursorPosition(cursorPosition); if (modelNode.isValid()) rewriterView()->setSelectedModelNode(modelNode); @@ -580,7 +580,7 @@ void QmlDesignerPlugin::activateAutoSynchronization() // text editor -> visual editor if (!currentDesignDocument()->isDocumentLoaded()) - currentDesignDocument()->loadDocument(currentDesignDocument()->plainTextEdit()); + currentDesignDocument()->loadDocument(currentDesignDocument()->textEditorWidget()); currentDesignDocument()->updateActiveTarget(); d->mainWidget.enableWidgets(); |