Add filter input above SQL help tree. Fixes issue #1718. New code mostly from SuperNiFF.

This commit is contained in:
Ansgar Becker
2010-02-24 22:22:22 +00:00
parent b730230b09
commit 19fa02b4c6
2 changed files with 63 additions and 15 deletions

View File

@ -15,7 +15,6 @@ type
Splitter1: TSplitter;
treeTopics: TTreeView;
pnlRight: TPanel;
lblTopics: TLabel;
pnlRightTop: TPanel;
lblKeyword: TLabel;
lblDescription: TLabel;
@ -29,6 +28,7 @@ type
URIOpenerDescription: TSynURIOpener;
URIHighlighter: TSynURISyn;
URIOpenerExample: TSynURIOpener;
editFilter: TButtonedEdit;
procedure FormCreate(Sender: TObject);
procedure treeTopicsExpanding(Sender: TObject; Node: TTreeNode;
var AllowExpansion: Boolean);
@ -41,6 +41,7 @@ type
function ShowHelpItem: Boolean;
procedure fillTreeLevel( ParentNode: TTreeNode );
procedure findKeywordInTree;
procedure editFilterChange(Sender: TObject);
private
{ Private declarations }
@ -328,4 +329,44 @@ begin
end;
procedure TfrmSQLhelp.editFilterChange(Sender: TObject);
var
tnode: TTreeNode;
Results: TMySQLQuery;
topic: String;
begin
// Apply filter text
if Trim(editFilter.Text) = '' then begin
fillTreeLevel(nil);
Exit;
end;
Keyword := editFilter.Text;
treeTopics.Items.Clear;
topic := Keyword;
try
Screen.Cursor := crHourglass;
Results := Mainform.Connection.GetResults('HELP "%'+topic+'%"');
while not Results.Eof do begin
tnode := treeTopics.Items.AddChild(nil, Results.Col('name'));
if Results.ColExists('is_it_category') and (Results.Col('is_it_category') = 'Y') then begin
tnode.ImageIndex := ICONINDEX_CATEGORY_CLOSED;
tnode.SelectedIndex := ICONINDEX_CATEGORY_OPENED;
// Add a dummy item to show the plus-button so the user sees that there this
// is a category. When the plus-button is clicked, fetch the content of the category
treeTopics.Items.AddChild(tnode, DUMMY_NODE_TEXT);
end else begin
tnode.ImageIndex := ICONINDEX_HELPITEM;
tnode.SelectedIndex := tnode.ImageIndex;
end;
Results.Next;
end;
finally
FreeAndNil(Results);
Screen.Cursor := crDefault;
end;
editFilter.SetFocus;
end;
end.