Keep renamed file(s) in view
ClosedPublic

Authored by emateli on Jun 21 2017, 12:41 PM.

Details

Summary

When renaming a file, it's new name causes it to scroll out of view Dolphin will not scroll to the location of the new file. This patch aims to address that. This affects all view modes.

BUG: 354330

Test Plan
  1. Have many files in a directory (or several files, just zoom in a lot)
  2. Rename a file so that it will move out of view

Diff Detail

Repository
R318 Dolphin
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
emateli created this revision.Jun 21 2017, 12:41 PM
Restricted Application added a subscriber: Konqueror. · View Herald TranscriptJun 21 2017, 12:41 PM
dfaure added a subscriber: dfaure.Jun 22 2017, 7:39 AM
dfaure added inline comments.
src/views/dolphinview.cpp
1754

is this called even if the renaming is canceled?

1766

you should add a newline after '}' (most editors do that automatically)

src/views/dolphinview.h
771

missing "&" after const QList<QUrl> (no need to copy)

emateli added inline comments.Jun 22 2017, 10:06 AM
src/views/dolphinview.cpp
1766

This is called only when the user clicks the Rename button and items were actually renamed.

emateli updated this revision to Diff 15733.Jun 22 2017, 10:07 AM

Minor fixes + renamed signal and slot methods

emateli updated this revision to Diff 15734.Jun 22 2017, 10:08 AM

Coding style fix

+1 from me, Dolphin devs should have final say.

emateli retitled this revision from Keep renamed file(s) in view to Keep renamed file(s) in view; BUG: 354330.Jun 22 2017, 10:18 PM

Please remove BUG: .... from the summary line, and replace the line

Relevant bug report: https://bugs.kde.org/show_bug.cgi?id=354330

with

BUG: 354330

emateli retitled this revision from Keep renamed file(s) in view; BUG: 354330 to Keep renamed file(s) in view.Jun 22 2017, 10:29 PM
emateli edited the summary of this revision. (Show Details)
elvisangelaccio requested changes to this revision.Aug 30 2017, 3:21 PM
elvisangelaccio added a subscriber: elvisangelaccio.
elvisangelaccio added inline comments.
src/views/dolphinview.cpp
1762

The old code did not have this assignment. Is it really necessary?

src/views/dolphinview.h
315

I'd just call it slotRenamingFinished(). Also, no need to have it public, make it a private slot.

src/views/renamedialog.cpp
42

Not really necessary, default QList ctor is automatically called.

246

Unrelated whitespace change.

This revision now requires changes to proceed.Aug 30 2017, 3:21 PM
src/views/dolphinview.h
771

Maybe forceUrlsSelection() would be more clear

emateli added inline comments.Sep 3 2017, 6:49 PM
src/views/dolphinview.cpp
1762

As far as I remember until I added that statement when mass renaming the new selection after the rename would include some (seemingly random) items in the directory but I cannot reproduce it reliably.

ngraham added a subscriber: ngraham.Sep 4 2017, 4:57 AM

-1

FWIW, I don't approve of this patch from a usability perspective. It's not at all clear that changing the view is what the user expects in this case. Especially if you're renaming multiple files in such a manner that they will be re-sorted elsewhere, the view will change after each rename operation and you will need to manually scroll back over and over again, making the multiple-file-rename operation an infuriating experience. macOS finder behaved this way for many years and Apple got a lot of complaints about it, eventually reverting the behavior to match what Dolphin does today.

-1

FWIW, I don't approve of this patch from a usability perspective. It's not at all clear that changing the view is what the user expects in this case. Especially if you're renaming multiple files in such a manner that they will be re-sorted elsewhere, the view will change after each rename operation and you will need to manually scroll back over and over again, making the multiple-file-rename operation an infuriating experience. macOS finder behaved this way for many years and Apple got a lot of complaints about it, eventually reverting the behavior to match what Dolphin does today.

You could argue the same with pasting. If you paste or drop a file, the Dolphin view will scroll to it.
This patch just fixes a regression/inconsistency, as the feature was already there.

Renaming a single file is probably a more common use case, so I think is safe if Dolphin privileges it over multiple successive renames. The latter use case could be fixed in other ways (for example, using the new stash:/ ioslave).

Fair enough, I withdraw my objection.

emateli updated this revision to Diff 19536.Sep 14 2017, 5:29 PM
emateli edited edge metadata.
emateli marked 2 inline comments as done.
emateli added inline comments.Sep 14 2017, 5:35 PM
src/views/dolphinview.cpp
1754

No, it will be called only when there are successful rename operations finished.

elvisangelaccio added a subscriber: emmanuelp.

Looks good to me now.
@emmanuelp can you have another look? :)

src/views/renamedialog.cpp
254

Unrelated whitespace change.

ngraham accepted this revision.Sep 15 2017, 2:58 AM

Looks good to me too.

emateli updated this revision to Diff 19574.Sep 15 2017, 6:05 PM
emateli marked an inline comment as not done.
emmanuelp accepted this revision.Sep 15 2017, 6:26 PM
This revision is now accepted and ready to land.Sep 15 2017, 6:26 PM
aacid set the repository for this revision to R318 Dolphin.Sep 16 2017, 7:50 PM
aacid added a subscriber: aacid.Sep 16 2017, 7:53 PM

@elvisangelaccio @emmanuelp since @emateli doesn't have commit access should I commit?

To which branch?

In D6312#146391, @aacid wrote:

@elvisangelaccio @emmanuelp since @emateli doesn't have commit access should I commit?

To which branch?

I think it should go to the stable branch. I'll take care of it, I need to push another patch anyway :)

This revision was automatically updated to reflect the committed changes.

Sure, I can take a look.

emateli added a comment.EditedSep 18 2017, 7:42 PM

@elvisangelaccio: So I was thinking of using KIO::FileUndoManager::undoJobFinished but it unfortunately provides no details as to what job was undone.
A possible option would be to keep the last job recorded so we have the name that the undo-ed item will have after reverting, but this is just hacky and doesn't support more than 1 action. I think best would be if job information was passed from KIO::FileUndoManager and then Dolphin could leverage it. I also tried to use selectionManager but to no avail.

elvisangelaccio added a comment.EditedSep 18 2017, 9:30 PM

@elvisangelaccio: So I was thinking of using KIO::FileUndoManager::undoJobFinished but it unfortunately provides no details as to what job was undone.
A possible option would be to keep the last job recorded so we have the name that the undo-ed item will have after reverting, but this is just hacky and doesn't support more than 1 action. I think best would be if job information was passed from KIO::FileUndoManager and then Dolphin could leverage it. I also tried to use selectionManager but to no avail.

Yeah, looks like we need a new signal in KIO::FileUndoManager that tells us which job was undone...