Re: Review Request: make KFileWidget keep current extension if possible

2011-12-08 Thread David Faure

---
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/102986/#review8808
---


Thx, looks better. Just one comment for code readability, feel free to commit 
after adjusting.


kfile/kfilewidget.cpp
http://git.reviewboard.kde.org/r/102986/#comment7376

clear()ing just to get into the next if() makes this a bit hard to read.

Wouldn't it be simpler to say

if (!currentExtension.isEmpty()  extensionList.contains(...)) {
  extension = '.' + currentExtension;
} else {
  extension = defaultExtension;
}

If there are really just two cases, there is no need for 3 ifs.



- David Faure


On Nov. 17, 2011, 6:53 p.m., Martin Koller wrote:
 
 ---
 This is an automatically generated e-mail. To reply, visit:
 http://git.reviewboard.kde.org/r/102986/
 ---
 
 (Updated Nov. 17, 2011, 6:53 p.m.)
 
 
 Review request for kdelibs.
 
 
 Description
 ---
 
 In trying to fix mentioned bug, I found out the original problem lies in 
 KFileWidget:
 If I'm editing a JPEG file which has the non-mainExtension .jpg and 
 KFileWidget was told to auto-select an extension,
 then it did not check if the already given extension is one which is also 
 allowed and simply removed
 .jpg and added .jpeg, which is not what a user would expect.
 
 This patch now checks the current extension against all allowed extensions 
 and if there's a match, it
 keeps the current extension. Only otherwise will it add the default extension.
 
 
 This addresses bug 229547.
 http://bugs.kde.org/show_bug.cgi?id=229547
 
 
 Diffs
 -
 
   kfile/kfilewidget.cpp 09b86d4 
 
 Diff: http://git.reviewboard.kde.org/r/102986/diff/diff
 
 
 Testing
 ---
 
 Used kolourpaint with name.jpg, name.jpeg, name., name, name.tif, 
 name.tiff
 
 
 Thanks,
 
 Martin Koller
 




Re: Review Request: make KFileWidget keep current extension if possible

2011-11-17 Thread Martin Koller

---
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/102986/
---

(Updated Nov. 17, 2011, 6:53 p.m.)


Review request for kdelibs.


Changes
---

I'm now using KMimeType::extractKnownExtension as the set filter is not 
necessarily a MimeType filter (can be also just *.cpp etc.)
And if the KFileWidget is used with an uncommon filter which is not a known 
MimeType, I fall back to get the last part of the filename after
the dot as with my first patch.


Description
---

In trying to fix mentioned bug, I found out the original problem lies in 
KFileWidget:
If I'm editing a JPEG file which has the non-mainExtension .jpg and 
KFileWidget was told to auto-select an extension,
then it did not check if the already given extension is one which is also 
allowed and simply removed
.jpg and added .jpeg, which is not what a user would expect.

This patch now checks the current extension against all allowed extensions and 
if there's a match, it
keeps the current extension. Only otherwise will it add the default extension.


This addresses bug 229547.
http://bugs.kde.org/show_bug.cgi?id=229547


Diffs (updated)
-

  kfile/kfilewidget.cpp 09b86d4 

Diff: http://git.reviewboard.kde.org/r/102986/diff/diff


Testing
---

Used kolourpaint with name.jpg, name.jpeg, name., name, name.tif, 
name.tiff


Thanks,

Martin Koller