D18915: Fix batchrename changing extension to lower case

cfoster noreply at phabricator.kde.org
Mon Feb 11 08:14:09 GMT 2019


cfoster added inline comments.

INLINE COMMENTS

> abalaji wrote in batchrenamejob.cpp:62
> You can just `QString dot = "."`, but you should use a single character instead of a string, since it's just a single character

Without the fromStdString() I get the following compilation error.

src/core/batchrenamejob.cpp:64:15: error: 'QString::QString(const char*)' is private within this context

  QString dot= ".";

I must admit I don't fully understand the compilation error however adding fromStdString seemed the most reasonable way to fix it.

> abalaji wrote in batchrenamejob.cpp:64
> I wonder if just getting rid of `.toLower()` fixes this bug

I tested just removing the .toLower() however this didn't fix it. It seems that QMimeDatabase::suffixForFileName() converts it to lower case unless I overlooked something. See the code snippet below.

I tested this with the following lines in a standalone program:
QMimeDatabase db;
QUrl url = (QString) "foo.TXT";
const QString extension = db.suffixForFileName(url.toDisplayString());
qDebug(qUtf8Printable(extension)); //Outputs "txt"

> abalaji wrote in batchrenamejob.cpp:68
> Rather than using `contains` here, you can just use `lastIndexOf`, check if it's not `-1`, and go from there. Just simply `urlStr.lastIndexOf('.')`.

Fair point will do.

REPOSITORY
  R241 KIO

REVISION DETAIL
  https://phabricator.kde.org/D18915

To: cfoster, #dolphin, #frameworks, abalaji
Cc: chinmoyr, kde-frameworks-devel, michaelh, ngraham, bruns
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20190211/96661798/attachment.htm>


More information about the kfm-devel mailing list