Expose KTextEditor::ViewPrivate:setInputMode(InputMode) to KTextEditor::View
ClosedPublic

Authored by cullmann on Oct 21 2018, 9:23 AM.

Details

Summary

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.

Diff Detail

Repository
R39 KTextEditor
Lint
Lint Skipped
Unit
Unit Tests Skipped
demsking created this revision.Oct 21 2018, 9:23 AM
Restricted Application added projects: Kate, Frameworks. · View Herald TranscriptOct 21 2018, 9:23 AM
Restricted Application added subscribers: kde-frameworks-devel, kwrite-devel. · View Herald Transcript
demsking requested review of this revision.Oct 21 2018, 9:23 AM

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.

cullmann requested changes to this revision.Oct 21 2018, 9:47 AM
This revision now requires changes to proceed.Oct 21 2018, 9:47 AM
demsking added a comment.EditedOct 21 2018, 4:38 PM

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.

kossebau resigned from this revision.Oct 28 2018, 1:05 PM

Not my domain, so resigning as reviewer :)

cullmann commandeered this revision.Dec 11 2018, 8:33 PM
cullmann updated this revision to Diff 47389.
cullmann edited reviewers, added: demsking; removed: cullmann.

My change is BC and should have right naming, Dominik, ok?

dhaumann accepted this revision.Dec 12 2018, 12:04 AM

Looks good.

Unfortunately the context is missing: Does it nake sense to have a // TODO KF6: make virtual? Or is that the old way?

This revision is now accepted and ready to land.Dec 12 2018, 12:04 AM

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.

This revision was automatically updated to reflect the committed changes.