Bug 58749 - marking only the filename in a rename operation
Summary: marking only the filename in a rename operation
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Applications
Component: file icon view (show other bugs)
Version: unspecified
Platform: Debian testing Linux
: NOR wishlist
Target Milestone: ---
Assignee: Konqueror Developers
URL:
Keywords:
: 87410 98118 132401 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-05-21 11:34 UTC by Heine Salte
Modified: 2007-12-12 10:52 UTC (History)
9 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Current behavior (51.56 KB, image/jpeg)
2004-02-08 19:23 UTC, Mario Tanev
Details
( Hopefully ) future behavior (51.61 KB, image/jpeg)
2004-02-08 19:24 UTC, Mario Tanev
Details
Proposed patch (1.05 KB, patch)
2004-07-23 19:52 UTC, Paul Sprakes
Details
Possible beginning for iconview support (3.02 KB, patch)
2005-01-01 13:41 UTC, Michael Pyne
Details
Example screenshot (30.02 KB, image/jpeg)
2005-01-10 07:25 UTC, Sean Lynch
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Heine Salte 2003-05-21 11:34:22 UTC
Version:            (using KDE KDE 3.1.2)
Installed from:    Debian testing/unstable Packages
Compiler:          gcc3.2 
OS:          Linux

I just checked out the new Gnome 2, and the file manager there has a really useful feature. when you choose to rename the file, it automatically pre-select the filename, leaving out the extension, so all you have to do, is press F2, type the new name, and (i.e.) .png is kept at the back. of course, if you should feel the need to change the ezxtension, all you have to do then, is mark the remainder or press delete a couple of times. I found this feature immensely useful, saving lots of mousemovement and time, as I do a lot of renameing, for instance renaming ogg files to my preferred format :)
Comment 1 Mario Tanev 2004-02-08 19:23:59 UTC
Created attachment 4580 [details]
Current behavior
Comment 2 Mario Tanev 2004-02-08 19:24:59 UTC
Created attachment 4581 [details]
( Hopefully ) future behavior
Comment 3 Heine Salte 2004-02-09 14:11:33 UTC
exactly! that's how it should act.
Comment 4 Christoph Wiesen 2004-06-28 19:24:22 UTC
Very intelligent idea the GNOMEers had there... should be done in Konqueror too!
Comment 5 mail 2004-06-29 11:27:09 UTC
Don't know if Nautilus does it, but double extensions like .tar.bz2 should also be left out. This feature is very handy, I wonder why this has not been invented years before. Other systems warn before changing the extension, but simply not marking it seems to be a real innovation(TM).
Comment 6 Paul Sprakes 2004-07-23 19:52:40 UTC
Created attachment 6808 [details]
Proposed patch

This patch works well. Unfortunately it only works on the lists views. The icon
views need a little more work.
Comment 7 Michael Jahn 2004-09-15 23:26:42 UTC
*** Bug 87410 has been marked as a duplicate of this bug. ***
Comment 8 Christoph Wiesen 2004-12-21 20:52:22 UTC
Did work on this patch continue? Maybe it can make it in KDE 3.4 then?
Comment 9 Stephan Binner 2004-12-25 22:41:52 UTC
I have listed this wish in the KDE 3.4 feature plan so every working patch can enter until February. Read, an icon view patch is still welcome. :-)
Comment 10 Stephan Binner 2004-12-25 23:36:34 UTC
Committed listview patch.
Comment 11 Michael Pyne 2005-01-01 13:41:45 UTC
Created attachment 8877 [details]
Possible beginning for iconview support

I've attached a patch that someone could probably use as a starting point for
getting this working for the iconview as well.	The problem being that
QIconView and QIconViewItem very much handle renaming by themselves, giving the
application programmer no input as to how that happens.

I've tried redoing the rename() implementation based on the source code of
QIconViewItem::rename().  It sort of works as long as you hit enter to save the
results instead of clicking outside of the text box, which doesn't work.

Other things that don't work:

1) The file doesn't actually get renamed.  This shouldn't be hard to do
however.
2) The width and height don't adjust as you type at this point since the nifty
QTextEdit::document() call is apparently internal to the library.  It could
probably be worked around with one of the various Qt calls to pack text into a
rectangle.
3) The code style needs to be merged to match the surrounding code.

I probably won't have time to work more on this so I wanted to put it up so it
can be picked up by someone else.
Comment 12 Paul Sprakes 2005-01-01 14:29:11 UTC
Thanks for that. I'll see what I can do.
Comment 13 Sean Lynch 2005-01-10 07:25:21 UTC
Created attachment 9013 [details]
Example screenshot

Seems the logic to select the filename is to grab everything from the first
'period' on the left to the beginning of the word.  Would be better to grab the
first 'period' from the right and select to the beginning of the word...

example:
this.is.a.test.html current will select 'this', would be best to select
this.is.a.test

Some file extensions are more than 1 period.. such as .tar.gz/bz, would be nice
to at least check for these common cases along with the above suggestion.
Comment 14 Stephan Binner 2005-01-14 17:16:33 UTC
Honestly, how common are such complete.stupid.filenames?
Comment 15 mail 2005-01-14 17:44:57 UTC
There is something like:
.ps.gz
.tar.bz2
Picture-14.1.2004.jpg as germans write the date, not really stupid.

So on the one hand double extensions are not only .jpg.exe and on the other hand there are sensible ways of using the dot in filenames. 
My suggestion: Check from right to left and use whitelists of known extensions.
Comment 16 Stephan Binner 2005-01-15 11:47:56 UTC
Just noticed that it bites with archive-version.numbers files. Do you have a patch? :-)
Comment 17 mail 2005-01-15 12:23:45 UTC
Let me make my suggestion clearer:

- The last extension will never be marked.
- Every known extension before the last will not be marked, scanning from right to left until we find an unknown extension
- We get known extensions from KDE, so everyone can add his own extensions that will be recognized from then on.

In all exceptional cases: bad luck, but still better than in KDE 3.3.

Did I oversee something?
BTW: What does nautilus do in these complicated cases?
Comment 18 Max Lemieux 2005-01-21 04:01:31 UTC
I noticed today that renaming files in icon view by clicking the name (should be default behavior IMO, it's expected from all other platforms) selects a lot of whitespace to the left and right of the actual file name.

It would be nice to select only the text that exists (along with the above modifications). Not sure if this is systemic (I'm using KDE 3.3.1)
Comment 19 Tommi Tervo 2005-02-04 12:21:53 UTC
*** Bug 98118 has been marked as a duplicate of this bug. ***
Comment 20 Stephan Binner 2005-02-20 12:59:35 UTC
CVS commit by binner: 

Enhance renaming preselection: use mime type database, else search from right
CCBUG: 58749


  M +12 -4     konq_listview.cc   1.223


--- kdebase/konqueror/listview/konq_listview.cc  #1.222:1.223
@@ -34,4 +34,5 @@
 #include <kprotocolinfo.h>
 #include <klineedit.h>
+#include <kmimetype.h>
 
 #include <qapplication.h>
@@ -164,8 +165,15 @@ void ListViewBrowserExtension::rename()
   KLineEdit* le = m_listView->listViewWidget()->renameLineEdit();
   if ( le ) {
-     QString txt = le->text();
-     int firstDot = txt.find('.');
-     if( firstDot > 0 )
-        le->setSelection(0, firstDot);
+     const QString txt = le->text();
+     QString pattern;
+     KMimeType::diagnoseFileName( txt, pattern );
+     if (!pattern.isEmpty() && pattern.at(0)=='*' && pattern.find('*',1)==-1)
+         le->setSelection(0, txt.length()-pattern.stripWhiteSpace().length()+1);
+     else
+     {
+         int lastDot = txt.findRev('.');
+         if (lastDot > 0)
+             le->setSelection(0, lastDot);
+     }
   }
 }


Comment 21 Ivan Todoroski 2005-05-17 07:28:03 UTC
Was this included in KDE 3.4 final? It doesn't seem to be present in KDE 3.4.0.

I distinctly remember seeing it working once, maybe it was in one of the 3.4 release candidates, but now it's gone. :(
Comment 22 Ivan Todoroski 2005-05-17 07:42:51 UTC
Ah, I see that it works fine in List View, which is probably what I remember seeing. Would be nice if it worked in Icon View too.
Comment 23 Tommi Tervo 2006-08-14 18:00:31 UTC
*** Bug 132401 has been marked as a duplicate of this bug. ***
Comment 24 Martin Fitzpatrick 2007-01-07 17:16:29 UTC
Confirmed KDE 3.5.5 / Kubuntu 6.10.

File extension is included when renaming under: MultiColumn, Icon.
File extension is not included under: Tree, Info List, Detailed List.
Comment 25 FACORAT Fabrice 2007-02-25 18:37:46 UTC
just a ping to remind about this feature which will make konqueror acting in a consistant way in all view
Comment 26 Fri13 2007-05-01 17:49:42 UTC
This would be nice feature if would work on all view styles. And if this could get work with http://www.kde-look.org/content/show.php/Selection+Eyecandy?content=52738 idea it could be awsome.

Comment 27 Tommi Tervo 2007-12-12 10:52:12 UTC
Fixed in KDE 4.