substring completion in KLineEdit

View: New views
10 Messages — Rating Filter:   Alert me  

substring completion in KLineEdit

by Oszkar Ambrus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Is it possible to enable KLineEdit to use substringCompletion() to
retrieve its completion elements?

I want to perform non-prefix completion on KLineEdit. Is it possible
without subclassing it?

Thanks!


--
Oszkár Ambrus

"Whoever believes in the Son [Jesus Christ] has eternal life"
(John 3:36)

Masters Student, Digital Enterprise Research Institute, NUIG
[http://www.deri.ie]

 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

Re: substring completion in KLineEdit

by Aleix Pol-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Why don't you use QCompleter?

On Fri, Oct 23, 2009 at 5:36 PM, Oszkar Ambrus <oszkar.ambrus@...> wrote:
Hi,

Is it possible to enable KLineEdit to use substringCompletion() to
retrieve its completion elements?

I want to perform non-prefix completion on KLineEdit. Is it possible
without subclassing it?

Thanks!


--
Oszkár Ambrus

"Whoever believes in the Son [Jesus Christ] has eternal life"
(John 3:36)

Masters Student, Digital Enterprise Research Institute, NUIG
[http://www.deri.ie]


>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

Re: substring completion in KLineEdit

by Oszkar Ambrus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 23/10/09 18:48, Aleix Pol wrote:
> Why don't you use QCompleter?
It is even less flexible.
It doesn't even have a substringCompletion function.
I guess I have to do this by hand...


--
Oszkár Ambrus

"Whoever believes in the Son [Jesus Christ] has eternal life"
(John 3:36)

Masters Student, Digital Enterprise Research Institute, NUIG
[http://www.deri.ie]


 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

Re: substring completion in KLineEdit

by Aleix Pol-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Oct 23, 2009 at 8:37 PM, Oszkar Ambrus <oszkar.ambrus@...> wrote:
On 23/10/09 18:48, Aleix Pol wrote:
> Why don't you use QCompleter?
It is even less flexible.
It doesn't even have a substringCompletion function.
I guess I have to do this by hand...


--
Oszkár Ambrus

"Whoever believes in the Son [Jesus Christ] has eternal life"
(John 3:36)

Masters Student, Digital Enterprise Research Institute, NUIG
[http://www.deri.ie]



>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

You can do quite a lot of things with QCompleter, you can check the ExpressionEdit class in KAlgebra (trunk/kdeedu/kalgebra/src/expressionedit.cpp). I'm not sure about what you mean by substringCompletion, but i think you can check in that code and you will find it.

Enjoy,
Aleix

 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

Re: substring completion in KLineEdit

by Oszkar Ambrus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 23/10/09 20:14, Aleix Pol wrote:
> You can do quite a lot of things with QCompleter, you can check the
> ExpressionEdit class in KAlgebra
> (trunk/kdeedu/kalgebra/src/expressionedit.cpp). I'm not sure about what
> you mean by substringCompletion, but i think you can check in that code
> and you will find it.
Thanks for the example. But it uses QCompleter, and it only does prefix
completion.

KCompletion::substringCompletion() returns the completion list based on
sub-string checking. That means it doesn't just do prefix checking.

It's just what Firefox does: when you type something into the address
bar, it lists everything that has that expression in it.





>
> Enjoy,
> Aleix
>
>
> ------------------------------------------------------------------------
>
>  
>>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


--
Oszkár Ambrus

"Whoever believes in the Son [Jesus Christ] has eternal life"
(John 3:36)

Masters Student, Digital Enterprise Research Institute, NUIG
[http://www.deri.ie]

 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

Re: substring completion in KLineEdit

by Eduardo Robles Elvira :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, Oct 23, 2009 at 9:32 PM, Oszkar Ambrus <oszkar.ambrus@...> wrote:
> On 23/10/09 20:14, Aleix Pol wrote:
>> You can do quite a lot of things with QCompleter, you can check the
>> ExpressionEdit class in KAlgebra
>> (trunk/kdeedu/kalgebra/src/expressionedit.cpp). I'm not sure about what
>> you mean by substringCompletion, but i think you can check in that code
>> and you will find it.
> Thanks for the example. But it uses QCompleter, and it only does prefix
> completion.

Hi,

With QCompleter, you can set a QAbstractItemModel as the source for
the completion, and then you can do the substringcompletion within
that model. Before I knew about QCompleter, I went all the way to
rewrite KLineEdit to support just that for my GSoC. You can see the
code in https://github.com/edulix/gsoc/tree

Regards,
   Eduardo Robles Elvira.
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

Re: substring completion in KLineEdit

by Oszkar Ambrus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 23/10/09 23:33, Eduardo Robles Elvira wrote:
> With QCompleter, you can set a QAbstractItemModel as the source for
> the completion, and then you can do the substringcompletion within
> that model. Before I knew about QCompleter, I went all the way to
> rewrite KLineEdit to support just that for my GSoC. You can see the
> code in https://github.com/edulix/gsoc/tree

I still don't see how I can get the LineEdit to perform substring
completion and show the appropriate list.

I can only see workarounds, like subclassing it, and tackling with the
KeyPressed function, or grabbing the textChanged signal, filtering the
list manually, and feeding it to the popup of the completer.


--
Oszkár Ambrus

"Whoever believes in the Son [Jesus Christ] has eternal life"
(John 3:36)

Masters Student, Digital Enterprise Research Institute, NUIG
[http://www.deri.ie]

 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

Re: substring completion in KLineEdit

by Bugzilla from zorglub_olsen@hotmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Friday 23 October 2009 21:32, Oszkar Ambrus wrote:

> On 23/10/09 20:14, Aleix Pol wrote:
>> You can do quite a lot of things with QCompleter, you can check the
>> ExpressionEdit class in KAlgebra
>> (trunk/kdeedu/kalgebra/src/expressionedit.cpp). I'm not sure about what
>> you mean by substringCompletion, but i think you can check in that code
>> and you will find it.
> Thanks for the example. But it uses QCompleter, and it only does prefix
> completion.
>
> KCompletion::substringCompletion() returns the completion list based on
> sub-string checking. That means it doesn't just do prefix checking.
>
> It's just what Firefox does: when you type something into the address
> bar, it lists everything that has that expression in it.
[snip rest]

Just FYI, I personally find the Firefox substring thing confusing. The
current (KDE3) Konqueror location bar allows me to select between several
completion methods, and that's very cool. You could add substring
completion to such a list, so that I could disable it. I always use
the "Dropdown list & Automatic" option whereever possible.

//Niels

 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

Re: substring completion in KLineEdit

by Oszkar Ambrus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 24/10/09 09:34, Niels wrote:
  > Just FYI, I personally find the Firefox substring thing confusing. The
> current (KDE3) Konqueror location bar allows me to select between several
> completion methods, and that's very cool. You could add substring
> completion to such a list, so that I could disable it. I always use
> the "Dropdown list & Automatic" option whereever possible.

I personally consider the FF method very good, but regardless of this,
in my application I need that kind of method. I'm completing on RDF
data, like "foaf:Person" or "<http://xmlns.com/foaf/0.1/Person>", and I
need to show an item, if it contains the substring.



--
Oszkár Ambrus

"Whoever believes in the Son [Jesus Christ] has eternal life"
(John 3:36)

Masters Student, Digital Enterprise Research Institute, NUIG
[http://www.deri.ie]

 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

Re: substring completion in KLineEdit [SOLVED]

by Oszkar Ambrus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> I still don't see how I can get the LineEdit to perform substring
> completion and show the appropriate list.
>
> I can only see workarounds, like subclassing it, and tackling with the
> KeyPressed function, or grabbing the textChanged signal, filtering the
> list manually, and feeding it to the popup of the completer.

The solution was fairly simple: subclassing KLineEdit and reimplementing
the makeCompletion() slot.
It only works for my particular case though (using CompletionPopupAuto).




--
Oszkár Ambrus

"Whoever believes in the Son [Jesus Christ] has eternal life"
(John 3:36)

Masters Student, Digital Enterprise Research Institute, NUIG
[http://www.deri.ie]

 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<