If you read my previous post, you know that there is a Dolphin forum at forum.kde.org.

Thanks to a couple of very active forum members who are doing a really amazing job, many user questions are answered quite quickly. This is why I didn’t get involved in many topics so far: Every time I look at the forum, most new questions have been answered already, and the others are often about problems that I unfortunately can’t help with.

Today I’m going to tell you how the forum made me find and fix a bug in Dolphin. The other day, a new user asked some questions, one of which was about selecting a file by typing the first few letters of its name. Let me first give you some background information.

Let’s assume that we want to jump to a particular file in the current folder as quickly as possible. I will tell you about two ways to do this in Dolphin in a minute. As an example, I will consider the folder dolphin/src/views/ in Dolphin’s source code, which contains the files (I have “folders first” enabled, which is why tooltips and versioncontrol are first in the view):

tooltips

versioncontrol

additionalinfoaccessor.cpp

additionalinfoaccessor.h

dolphindirlister.cpp

dolphindirlister.h

many more dolphin* files…

draganddrophelper.cpp

draganddrophelper.h

renamedialog.cpp

renamedialog.h

viewmodecontroller.cpp

viewmodecontroller.h

viewproperties.cpp

viewproperties.h

zoomlevelinfo.cpp

zoomlevelinfo.h

Let’s assume that the file we are interested in is draganddrophelper.cpp.

Filter Bar

If you press Control+I, or select “Show Filter Bar” from the “Tools” menu, the filter bar is shown at the bottom of the view. Just enter any text there, and the view will only show files whose name contains this text. In our example, entering “dr” will hide all files except draganddrophelper.cpp and draganddrophelper.h

Keyboard Search

If you don’t want to use the filter bar, you can enter the first few letters of a file’s name to jump to this file. Pressing “d” will focus the first file whose name starts with the letter “d”, i.e., dolphindirlister.cpp. Now we expect that pressing “r” will take us to draganddrophelper.cpp. However, we will probably get to renamedialog.cpp instead – it seems that Dolphin forgot that we first entered a “d”! We will achieve the desired result only if we type very fast.

Digging into the code

In Dolphin 1.x, keyboard search was taken care of by QAbstractItemView. In Dolphin’s new view engine, the key event handling code is organized in a different way, but the behaviour is mostly the same. The idea is the following: All letters entered by the user are put together to a search string, and then the next file whose name starts with that string is focused. However, if a pause longer than some timeout value occurs between two key presses, it is assumed that the user wants to start a new search, and the previous search string is forgotten.

The problem is that this timeout is QApplication::keyboardInputInterval() in KDE <= 4.8.1 (and probably still today in QAbstractItemView). At first sight, the name of this function suggests that it does indeed have something to do with keyboard input, but the API docs tell us that it’s not quite what we need here, and that the default value is just 0.4 seconds. This is why we have to type so quickly to do a multi-letter keyboard search in Dolphin.

After a quick discussion on the kfm-devel list, we decided to increase the timeout to 5 seconds.

Some readers will probably note that Nautilus provides visual feedback about the search string during a keyboard search. If you read the mailing list thread, you will see that we would like to provide something similar in Dolphin as well. However, we can’t promise to implement this in the near future because our TODO-lists are quite long already :-(. A quick note to potential new contributors, just to prevent misunderstandings: Implementing such a feature requires thorough knowledge of Dolphin’s code base. People who would like to help out should therefore start with something easier first.

More bug fixes

Here is the complete list of Dolphin bug fixes in KDE 4.8.2, most of which were done by Peter, from the KDE 4.8.2 changelog:

Select files which have been pasted or dropped. Fixes bug 295389. See Git commit 210e5e3.

Prevent flickering of icons or previews when downloading files. See Git commit ef2ef83.

Fix sorting-issue when “Sort folders first” is disabled. Fixes bug 296437. See Git commit 7120e01.

Bypass crash in combination with the Polyester-style. Fixes bug 296453. See Git commit 010699e.

Fix alternate background issue in the Details mode. See Git commit f3e6298.

Fix translation-issue in the context-menu. Fixes bug 290620. See Git commit 44482f8.

Prevent endless scrolling when dragging items. Fixes bug 295584. See Git commit 6bf5f88.

Details view: Allow to turn off expandable folders like in Dolphin 1.7. Fixes bug 289090. See Git commit e04cb14.

Allow custom ordering of columns from the Details view. Fixes bug 164696. See Git commit b62c74e.

Increase the timeout for keyboard searches (typing the first few letters of a file name) to 5 seconds. See Git commit 02eab49.