Fix drag'n'drop behavior within the Target area
ClosedPublic

Authored by sdepiets on Jul 17 2018, 6:14 AM.

Details

Summary

Fix the drag'n'drop behavior within the Target area

The behavior of Drag and drop within the Target area is currently very buggy.
The reason is that when you move some text from the middle of the sentence to a different place, the cursor loses the information of the selection (the cursor info becomes the end location of the selection and there is no storage of what the selection was).

To reproduce this move something in the middle of the sentence to the end of the sentence, you will see that actually your selection is just copied right after the selection.

In order to fix this behavior and make it move the text instead of just copying, this patch stores the original location of the selection, correctly updates the location of the cursor to the destination and deletes the text at the original location (except if you do Ctrl+Dragndrop).

https://bugs.kde.org/show_bug.cgi?id=346784

Diff Detail

Repository
R456 Lokalize
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
sdepiets requested review of this revision.Jul 17 2018, 6:14 AM
sdepiets created this revision.
sdepiets edited the summary of this revision. (Show Details)Jul 17 2018, 6:15 AM
sdepiets added a project: Localization.

I'll push this next week if there is no additional comments

aacid added a comment.Jul 29 2018, 9:36 PM

I would feel more safe if you initialized m_cursorSelectionStart and m_cursorSelectionEnd to 0 in the constructor

Also do you know why we need this custom implementation of the drag and drop of text? I mean in a regular TextEdit the drag and drop "just works" so why do we need this stuff by ourselves? Would removing code instead of adding be possible?

sdepiets updated this revision to Diff 38887.Aug 1 2018, 5:52 AM

Initialize variables

I've initiated the values.

The custom copy/paste is to allow for some meta-data to be transferred. There is a function to avoid duplicating the inline tags.
I'm not exactly sure how it works but I'm not comfortable removing it for the moment.

This revision was not accepted when it landed; it landed in state Needs Review.Aug 8 2018, 2:55 AM
This revision was automatically updated to reflect the committed changes.