Fix two bugs when renaming multiple files

Review Request #110223 - Created April 27, 2013 and submitted

Frank Reininghaus
When renaming multiple files, the user can provide a pattern for the new name, which contains one or more '#' that will be replaced by digits. The "Rename" button is only enabled if the pattern contains exactly one sequence of '#'.

Currently, there are two small problems:

(a) The button is not enabled if the pattern contains just a '#' and nothing else.
(b) The button is enabled if there is no '#' at all in the pattern.

The code that determines if the button should be enabled is obviously incorrect, and also needlessly complex. I think we can just check if the distance between the first and last '#' in the pattern is 1 less than the total number of '#'. That is the case if and only if there is exactly one sequence of '#'.

In the special case that the count is zero, both QString::indexOf() and QString::lastIndexOf() return -1, and the check fails, so it's not necessary to add a special case for that in the code.
Works for me.
Emmanuel Pescosta
Commit Hook
Frank Reininghaus
Review request changed

Status: Closed (submitted)