Auto Complete Engine

Ideas for improvements and requests for new features in XnView MP

Moderators: helmut, XnTriq, xnview

User avatar
m.Th.
XnThusiast
Posts: 1676
Joined: Wed Aug 16, 2006 6:31 am

Auto Complete Engine

Post by m.Th. »

Now it is quite difficult to find a category / keyword in the Category Tree because we don't have a proper search engine for this.

Usually the tree of categories can reach to 500 - 1500 keywords or even more which is way to big in order to be searched by "hand" (there are generational dimensions like 'People', 'Events', 'Animals', 'Flowers', 'Places' etc.).

The classical approach to this is to have an Auto Complete / Auto Fill Engine with Partial Match Anywhere like this one:

Image

The mockup in our GUI:
AutoComplete.png
Implementation considerations:

1. Use in a background thread (perhaps delayed at 400ms like in Windows Explorer) a simple...

Code: Select all

Select TagID, Label from Tags where Label Like '%foo%' order by Label collate nocase limit 50;
...in order to fetch the items in the drop-down list. Be sure that the Label field is indexed with COLLATE NOCASE.

This should work near real-time till 50-60-70k rows (or even more), much more than our needs.

Take care - we'll use this elsewhere for paths. There we'll need to 'escape' the % and _ because these characters can appear in a path. More on this, later.

See here for more details:
http://stackoverflow.com/questions/8196 ... d-lag?rq=1

If one needs help or anything, please drop a line.

2. Be sure to implement this engine abstract. We'll need it in other areas. (eg. in the soon-to-be presented Catalog pane ;) ) So, the table name and the two fields must be arguments / properties / fields etc.

3. If the User presses Enter or the ">" button then the first item from the drop-down list is selected and assigned to the selection of photos. If nothing is in the list then a message appears "Do you want to add 'blah' as a new Category?" {yes} {no}. Also, perhaps is better for this to add a button called 'Add...' and a shortcut in the drop down keyboard handler (usually Ctrl+Enter). Beware, as I said, the main Auto Complete Engine should be abstract, hence this part perhaps could be implemented as a delegate / event.

Any comments?
You do not have the required permissions to view the files attached to this post.
m. Th.

- Dark Themed XnViewMP 1.7.1 64bit on Win11 x64 -
User avatar
oops66
XnThusiast
Posts: 2005
Joined: Tue Jul 17, 2007 1:17 am
Location: France

Re: Auto Complete Engine

Post by oops66 »

+1 I support, an "auto Complete Engine" is usually always user friendly ;-)
XnViewMP Linux X64 - Debian - X64
User avatar
m.Th.
XnThusiast
Posts: 1676
Joined: Wed Aug 16, 2006 6:31 am

Re: Auto Complete Engine

Post by m.Th. »

oops66 wrote:+1 I support, an "auto Complete Engine" is usually always user friendly ;-)
Yes, and much faster... :) ...Ooops! I forgot! We need to add a shortcut to it. I propose Ctrl+K. (from Keywords, Kategories...)
m. Th.

- Dark Themed XnViewMP 1.7.1 64bit on Win11 x64 -
User avatar
oops66
XnThusiast
Posts: 2005
Joined: Tue Jul 17, 2007 1:17 am
Location: France

Re: Auto Complete Engine

Post by oops66 »

m.Th. wrote:
oops66 wrote:+1 I support, an "auto Complete Engine" is usually always user friendly ;-)
Yes, and much faster... :) ...Ooops! I forgot! We need to add a shortcut to it. I propose Ctrl+K. (from Keywords, Kategories...)
...Or better, a la google ... I have just taped xnv ... and "iew" is grayed out ;-) ... and the 4 remaining possibilities are "clickable"
Image
XnViewMP Linux X64 - Debian - X64
User avatar
m.Th.
XnThusiast
Posts: 1676
Joined: Wed Aug 16, 2006 6:31 am

Re: Auto Complete Engine

Post by m.Th. »

...Or better, a la google
Sure - ...if he can do it. :) Usually the first letters (XNV in your example) are selected and the last ones unselected.

More important IMHO is to have a proper state management. We distinguish two states:
  • IN search - when the edit area contains some letters, drop down list is opened and contains the items from Select Label from Tags where Label like '%xnv%'. Clicking on one of the items will trigger the OnChoseItem(aItem) event/delegate
  • Idle - when the edit area is empty, drop down list is closed and contains the last "MAX_HIST" (let's say MAX_HIST = 20) items. IOW it contains the History of the Recent Searches. Of course, the user can open the list manually and click one of the items which will trigger (again) the OnChoseItem(aItem) event.
In our case here (there will be, I hope, at least another case, when we'll implement the Catalog pane) the OnChoseItem(aItem) will have (IIRC) the following steps:
  1. Assign the keyword aItem to the selection
  2. Add the aItem in front of the History list & check if the History is >MAX_HIST. If yes, trim it. (The History list can be saved in a simple text file, together with the other future keyword sets).
  3. Clear the edit area from DDComboBox.
  4. Clear the items from DDComboBox and replace them with the History list.
m. Th.

- Dark Themed XnViewMP 1.7.1 64bit on Win11 x64 -
User avatar
m.Th.
XnThusiast
Posts: 1676
Joined: Wed Aug 16, 2006 6:31 am

Re: Auto Complete Engine

Post by m.Th. »

...and to add another very important thing:

If the Category / Keyword which is sought isn't found, the engine should create it by pressing Enter.

And the Enter key is pressed, the category Properties window should be shown in order to allow us to set up / change additional properties like Parent Category, Shortcut etc.

Of course, the Properties window should have two buttons 'Apply' and 'Cancel'. If the user presses 'Apply' then the category is created (or updated if it already exists).
m. Th.

- Dark Themed XnViewMP 1.7.1 64bit on Win11 x64 -
User avatar
xnview
Author of XnView
Posts: 45859
Joined: Mon Oct 13, 2003 7:31 am
Location: France

Re: Auto Complete Engine

Post by xnview »

Why use the DB, i have all keywords in memory...??
Pierre.
User avatar
m.Th.
XnThusiast
Posts: 1676
Joined: Wed Aug 16, 2006 6:31 am

Re: Auto Complete Engine

Post by m.Th. »

xnview wrote:Why use the DB, i have all keywords in memory...??
Ahaaa!! That's good. Very good. :)

Build an abstract auto complete engine against a list (for our concrete case, since the Categories are in a tree, perhaps you can display in the drop-down list also the entire path? - eg. 'People \ Programmers \ Pierre') because this Auto Complete will be useful in other areas as well.

One area in which this Auto Complete Engine will be very useful when we'll use it against the list from Settings | Interface | Shortcuts. You know, it will be very nice for the newcomers to have a search box like in Windows 7:

Image

This would be very good for the ones which aren't already familiarized with the menus and such. But not only for them...
m. Th.

- Dark Themed XnViewMP 1.7.1 64bit on Win11 x64 -