This makes possible to change the View Input Mode using KTextEditor::View:setInputMode(InputMode).
This is useful for when using *KTextEditor* as an external library in an another project. The developer should be able to change the input mode programmatically.
Details
Diff Detail
- Repository
- R39 KTextEditor
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
I think having API for this is good, but it must be done without a virtual function, that is not BC.
See e.g. setScrollPosition for how to do that.
One could add a KF6 TODO to make it virtual.
Thanks @cullmann for your review.
Just one question: what do you mean about BE. I'm not a native so I'm not sure what it mean.
I tried to do that without virtual function like setScrollPosition() but there is a linking issue when trying to compile an external application with the generated libKF5KTextEditor.so:
undefined reference to KTextEditor::View::setInputMode(KTextEditor::View::InputMode)
git diff:
diff --git a/src/include/ktexteditor/view.h b/src/include/ktexteditor/view.h index 80d3c37..60b7981 100644 --- a/src/include/ktexteditor/view.h +++ b/src/include/ktexteditor/view.h @@ -250,7 +250,7 @@ public: * \param inputMode new InputMode value * \see viewInputMode() */ - virtual void setInputMode(InputMode inputMode) = 0; + void setInputMode(InputMode inputMode); /** * Get the view's current input mode. diff --git a/src/utils/ktexteditor.cpp b/src/utils/ktexteditor.cpp index c498267..558c6d5 100644 --- a/src/utils/ktexteditor.cpp +++ b/src/utils/ktexteditor.cpp @@ -346,6 +346,11 @@ void Command::processText(KTextEditor::View *, const QString &) { } +void View::setInputMode(KTextEditor::View::InputMode mode) +{ + d->setInputMode(mode); +} + void View::setScrollPosition(KTextEditor::Cursor &cursor) { d->setScrollPositionInternal(cursor); diff --git a/src/view/kateview.h b/src/view/kateview.h index faa88d3..4ca1993 100644 --- a/src/view/kateview.h +++ b/src/view/kateview.h @@ -122,7 +122,7 @@ public: InputMode viewInputMode() const override; QString viewInputModeHuman() const override; - void setInputMode(InputMode mode) override; + void setInputMode(InputMode mode); // // KTextEditor::ClipboardInterface
Ah, sorry, BC meant "binary compatible", see e.g. https://community.kde.org/Policies/Binary_Compatibility_Issues_With_C%2B%2B
For the linking, on first glance, the change looks ok and should link.
Looks good.
Unfortunately the context is missing: Does it nake sense to have a // TODO KF6: make virtual? Or is that the old way?
Hmm, actually, not sure if we need to make it virtual, on the other side, it avoids to maintain the redirection.
I can add a KF6 todo and push it.