[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-devel
Subject: Re: Extend AutoCompletion to provide mid-string matches also?
From: Thomas Baumgart <ipwizard () users ! sourceforge ! net>
Date: 2006-11-29 18:51:22
Message-ID: 200611291951.22373 () net-bembel ! de
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
Hi all,
on Wednesday 29 November 2006 19:32, Carsten Pfeiffer wrote:
> On Monday 27 November 2006 17:52, Achim Spangler wrote:
>
> Hi,
>
> > the normal KComboBox - AutoCompletion does only deliver matches where
> > the entered text matches to the beginning of an entry.
> > e.g.
> > entered text: "F" - proposed completion: "Foo"
> >
> > I'd like to get a completion as follows:
> > entered text: "oo" - proposed completion: "Foo"
>
> yes, that's what you get when you press Ctrl-T (unless another shortcut
> overrides this). The shortcut is configurable in kcontrol, if necessary.
In KMyMoney we emulate a Ctrl-T with every character typed by the user by
overriding keyPressEvent in the following manner:
void kMyMoneyPayee::keyPressEvent( QKeyEvent * ev)
{
KLineEdit::keyPressEvent(ev);
if(ev->isAccepted()) {
// if the key was accepted by KLineEdit, we fake a substring completion
// which we set previously to Ctrl+T.
QKeyEvent evc(QEvent::KeyPress, Qt::Key_T, 0, Qt::ControlButton);
KLineEdit::keyPressEvent(&evc);
}
}
As mentioned here in the comment, we set the shortcut to ctrl-t no matter
what in the constructor of the widget with
// set the standard value for substring completion, as we
// fake that with every key entered. see also
// code in keyPressEvent()
setKeyBinding(SubstringCompletion, KShortcut("Ctrl+T"));
Hope that helps even though this is based on a KLineEdit widget. Should
work the same for a KComboBox. Just replace the KComboBox lineedit widget
with
combobox->setLineEdit(new yourOwnLineEditWidget(this), "combo edit"));
--
Regards
Thomas Baumgart
thb@net-bembel.de Check the KMyMoney open source
http://www.net-bembel.de/ project at http://kmymoney2.sf.net/
GPG-FP: E55E D592 F45F 116B 8429 4F99 9C59 DB40 B75D D3BA
-------------------------------------------------------------
Embedded Linux: because you can't do control-alt-delete on a pacemaker.
-------------------------------------------------------------
[Attachment #5 (application/pgp-signature)]
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic