[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kfm-devel
Subject:    Re: Patch: window menu keyboard shortcuts
From:       David Faure <david () mandrakesoft ! com>
Date:       2000-11-14 21:34:48
[Download RAW message or body]

On Tuesday 14 November 2000 19:58, Keunwoo Lee wrote:
> On Tue, 14 Nov 2000, David Faure wrote:
> 
> > There's a little bug in the code though: if the smart thing didn't
> > manage to put a '&' (it can happen, in a very crowded menu, "found"
> > will still be false), then activating the item won't work (if it can't
> > find '&', it returns at once).
> 
> I don't follow.  In slotProfileActivated(), we only go ampersand hunting
> when we fail to find a profile's unmodified name in the map.  If there's
> no ampersand, we jump directly to loading the view profile.
Ooops, I missed that part indeed. Ok.

> > In fact, if we populate the menu using an iterator over the QMap, we
> > don't have to use the menu text to find the item when we know that
> > item 5 has been activated. All we need to do is to iterate again the
> > QMap, to find the 5th item. This way, slotProfileActivated can be
> > rewritten much more cleanly.
> 
> Oops.  Yes, of course.  I was just doing a quick & dirty fixup of what was
> there previously.

I know, but thinking about it, and seeing how it complexifies the search
when there are ampersands in the middle, I'd advise the iterator method instead.

> More or less what I was thinking of.  I guess the proper place, once it
> was done, would be kdeui, since it's a general menu-related facility.
Yes.

> Right now I think it should be a template function that takes an iterator
> returning a string, and populates a QStringList (or arbitrary collection?)
> with a menu-ized version:
> 
> template <class Iter, class Deref>
> void generateMenuShortcuts(Iter begin, Iter end, QStringList& target,
>                            Deref deref) {
>     for( ; begin != end; ++begin) {
>         QString str = deref(begin);
>         // do stuff
>     }
> }
> 
> We could provide Deref classes (QMapIterDeref, QStrListIterDeref), use
> template specialization with default arguments, and then overload it on
> the collections directly, to make it maximally convenient.

Hmm, this sounds quite complex to me. I think I prefer the QStringList method
for the sake of "keeping it simple". Or we can say there will always be "something"
bundled with the menu item (as our profile names are), and base the function
on QMap and QMapIterators, where the "data" of the qmap can be anything
(-> template). It forces to use QMap, but it makes the thing much easier to
use IMHO.

-- 
David FAURE, david@mandrakesoft.com, faure@kde.org
http://www.mandrakesoft.com/~david/, http://www.konqueror.org/
KDE, Making The Future of Computing Available Today
See http://www.kde.org/kde1-and-kde2.html for how to set up KDE 2

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic