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

@ -32,31 +32,38 @@ object frmSQLhelp: TfrmSQLhelp
Align = alLeft
BevelOuter = bvNone
TabOrder = 0
object lblTopics: TLabel
object treeTopics: TTreeView
AlignWithMargins = True
Left = 3
Top = 8
Top = 27
Width = 147
Height = 13
Align = alBottom
Caption = 'Topics:'
end
object treeTopics: TTreeView
Left = 0
Top = 24
Width = 153
Height = 312
Align = alBottom
Anchors = [akLeft, akTop, akRight, akBottom]
Height = 309
Margins.Bottom = 0
Align = alClient
ChangeDelay = 50
Images = MainForm.ImageListMain
Indent = 19
ReadOnly = True
ShowLines = False
TabOrder = 0
TabOrder = 1
OnChange = treeTopicsChange
OnExpanding = treeTopicsExpanding
end
object editFilter: TButtonedEdit
AlignWithMargins = True
Left = 3
Top = 3
Width = 147
Height = 21
Margins.Bottom = 0
Align = alTop
Images = MainForm.ImageListMain
LeftButton.Hint = 'Search'
LeftButton.ImageIndex = 53
LeftButton.Visible = True
TabOrder = 0
OnChange = editFilterChange
end
end
object StatusBar1: TStatusBar
Left = 0

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.