On Wednesday 01 December 2004 12:49, Robert Ewald wrote: > Hi, > > I made a patch implementing my idea of efficient link navigation in an html > view. > > It works as follows: > > In an HTML view you hit 'd' and a tooltips over each visible link is > displayed. The tooltip contains a keysequence to access that link. Entering > the keysequence focusses the link and upon hitting enter the link is > followed (although that does not work reliably yet). > > Implementation details: > > Upon hitting 'D' displayLinkNavTooltips() is called. Each Element in the > HTMLTree is traversed and tested for HREF. If this Element is also visible, > it is added to the list linkNavElements. > > To fill the tooltips the 26 characters in the alphabet are seen as a > number, with a=0 and z=26. Converting the position of the element in the > list to base26 yields a keysequence, which is displayed in the tooltip. > > linkNavActivated is set to true and on further keypresses, > dispatchKeyEventHelper fills a search string, which is converted to a > decimal position in the element list. This Element is then focussed. > > Thats what I think I have implemented. At the moment the element is only > focussed. I would rather have, that the keypresses are enough so no enter > is needed. Therefore I have to determine the number of characters needed in > the tooltips. For this task i would need to include "math.h" (or anything > implementing a log or ln function). I am reluctant to add a dependency, > thats why I would like some advice. > i think you can simply check for the different cases: int k = 0; int c = visibleRects.count(); if ( c <= 26 ) { k = 1; } else if ( c <= 26*26 ) { k = 2; } else if ( c <= 26*26*26 ) { k = 3; } so no need for a log here. perhaps this is even faster then calculating the logs. > Thanks > > Robert Ewald Holger >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<