Simple find in big lists (Shortcuts/commands, Toolbar etc.)
Posted: Fri Jan 24, 2014 10:16 am
The program has and will have more big lists of items (ok, some of them are trees). Some examples: The big list from Settings | Shortcuts (how do I find a certain command to assign a shortcut?), the big list from Settings | Toolbar (how do I find a certain button?), Auto Correct (in the future), Bookmarks manager (in the future) aso. Having the lists sorted really isn't enough.
Of course, we can implement for all of them the Auto Complete engine but I think that it could be rather complicated. If Pierre thinks that it is simple to do it, then it will be the best thing.
But if it is not, then we can live with a simple search view like this one:
...which will do a simple case INsensitive(!!!) search on the grids, line by line till it will found something.
The untested, unoptimized pseudo-code will be something like:
Of course, for Find First the call will be with aFromRow = 0 and for FindNext will be with CurrentRow+1.
This could be very easy a shared code and view among many lists in our program: list of Toolbar buttons, list of the Shortcuts, Auto-Correct list aso.
Of course, we can implement for all of them the Auto Complete engine but I think that it could be rather complicated. If Pierre thinks that it is simple to do it, then it will be the best thing.
But if it is not, then we can live with a simple search view like this one:
...which will do a simple case INsensitive(!!!) search on the grids, line by line till it will found something.
The untested, unoptimized pseudo-code will be something like:
Code: Select all
function DoSearch(aFromRow: integer; myText: string; myGrid: TGrid): boolean;
begin
Result:=False;
for y:=aFromRow to myGrid.RowCount-1 do
begin
for x:=0 to myGrid.ColCount-1 do
if Pos(UpperCase(myText), UpperCase(myGrid.Cells[x,y]))>0 then //found!!
begin
Result:=True;
Break; //out from cycle!
end;
if Result then
begin
myGrid.Cells[x,y].Selected:=True;
Break; //out from y cycle also!
end;
end;
if not Result then
ShowMessage('Text not found!');
end;
This could be very easy a shared code and view among many lists in our program: list of Toolbar buttons, list of the Shortcuts, Auto-Correct list aso.